Ticket #237: torrent_peers.patch

File torrent_peers.patch, 3.0 KB (added by kevinlsk@gmail.com, 16 years ago)
  • plugins/TorrentPeers/__init__.py

    diff --git a/plugins/TorrentPeers/__init__.py b/plugins/TorrentPeers/__init__.py
    index ee7188a..64a1f67 100644
    a b class TorrentPeers:  
    8989       
    9090        self.tab_peers = PeersTabManager(tree_view, core)
    9191        self.tab_peers.build_peers_view()
     92        self.tab_peers.build_popup()
    9293       
    9394        self.config_updated()
    9495
  • plugins/TorrentPeers/tab_peers.py

    diff --git a/plugins/TorrentPeers/tab_peers.py b/plugins/TorrentPeers/tab_peers.py
    index d181aaa..38b9d65 100644
    a b class PeersTabManager(object):  
    5959                                        str, str, float, int, int)
    6060        # Stores IP -> gtk.TreeIter's iter mapping for quick look up
    6161        # in update_torrent_info_widget
    62         self.peer_store_dict = {}       
     62        self.peer_store_dict = {}
    6363        self._cached_flags = {}
    6464        self.show_flags = None
    6565        self.flag_size = ""
    class PeersTabManager(object):  
    9191        up = dgtk.add_func_column(self.peer_view, _("Up Speed"),
    9292                                  dgtk.cell_data_speed, 6, width=115)
    9393
     94    def build_popup(self):
     95        menu = gtk.Menu()
     96        menuItem = gtk.MenuItem("Block user for this session")
     97        menuItem.connect("button-release-event", self.cb_block_user)
     98        menu.append(menuItem)
     99        menu.show_all()
     100        self.menu = menu
     101        self.peer_view.connect("button-release-event", self.cb_view_popup)
     102
     103    def cb_block_user(self, widget, event):
     104        sel = self.peer_view.get_selection()
     105        (model, iter) = sel.get_selected()
     106        # FIXME
     107        # How to get the column by name?
     108        # It is possible that the user moved the IP Address column
     109        str_ip = model.get_value(iter, 2)
     110        self.manager.add_range_to_ip_filter(str_ip, str_ip)
     111        self.manager.set_ip_filter()
     112        print "Block IP: %s" % str_ip
     113
     114    def cb_view_popup(self, widget, event):
     115        if (event.button != 3):
     116            return
     117        self.menu.popup(None, None, None, event.button, event.time)
     118
    94119    def enable_flags(self):
    95120        self.show_flags = True
    96121
  • src/deluge_core.cpp

    diff --git a/src/deluge_core.cpp b/src/deluge_core.cpp
    index 64f79a1..bb20b1d 100644
    a b timeinfo = localtime(&rawtime);  
    20892089std::cout << asctime(timeinfo) << " torrent_add_range_to_IP_filter()" << std::endl;
    20902090#endif
    20912091    if (M_the_filter == NULL) {
    2092         RAISE_PTR(DelugeError, "No filter defined, use reset_IP_filter");
     2092        M_the_filter = new ip_filter();
    20932093    }
    20942094
    20952095    char *start, *end;
    timeinfo = localtime(&rawtime);  
    21132113std::cout << asctime(timeinfo) << " torrent_set_IP_filter()" << std::endl;
    21142114#endif
    21152115    if (M_the_filter == NULL) {
    2116         RAISE_PTR(DelugeError, "No filter defined, use reset_IP_filter");
     2116        M_the_filter = new ip_filter();
    21172117    }
     2118
    21182119    M_ses->set_ip_filter(*M_the_filter);
    21192120
    21202121    Py_INCREF(Py_None); return Py_None;