Ticket #1165: deluge-1165.01.patch

File deluge-1165.01.patch, 9.9 KB (added by Reidsy, 15 years ago)
  • deluge/core/core.py

    diff --git a/deluge/core/core.py b/deluge/core/core.py
    index 1eb80eb..73de401 100644
    a b def connect_peer(self, torrent_id, ip, port):  
    382382            log.warning("Error adding peer %s:%s to %s", ip, port, torrent_id)
    383383
    384384    @export
     385    def add_url_seed(self, torrent_id, url):
     386        log.debug("adding torrent url %s" % url)
     387        self.torrentmanager[torrent_id].add_url_seed(url)
     388
     389    @export
     390    def remove_url_seed(self, torrent_id, url):
     391        log.debug("removing torrent url %s" % url)
     392        self.torrentmanager[torrent_id].remove_url_seed(url)
     393
     394    @export
     395    def url_seeds(self, torrent_id):
     396        return self.torrrentmanager[torrent_id].url_seeds()
     397
     398    @export
    385399    def move_storage(self, torrent_ids, dest):
    386400        log.debug("Moving storage %s to %s", torrent_ids, dest)
    387401        for torrent_id in torrent_ids:
  • deluge/core/torrent.py

    diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py
    index 5e8c26e..9b8fee9 100644
    a b def connect_peer(self, ip, port):  
    829829            return False
    830830        return True
    831831
     832    def add_url_seed(self, url):
     833        """
     834        add manual webseed
     835        url is assumed correctly formatted and valid
     836       
     837        follows libtorrent bep 19
     838        http://www.rasterbar.com/products/libtorrent/manual.html#http-seeding
     839        """
     840        try:
     841            self.handle.add_url_seed(url)
     842        except:
     843            log.debug("Unable to add webseed")
     844
     845    def remove_url_seed(self, url):
     846        """
     847        remove a webseed if it exists
     848        url is assumed correct
     849       
     850        webseeds may automatically be removed by libtorrent if they are invalid or fail
     851        """
     852        self.handle.remove_url_seed(url)
     853
     854    def url_seeds(self):
     855        """
     856        returns a list of webseeds
     857        """
     858        return self.handle.url_seeds()
     859
    832860    def move_storage(self, dest):
    833861        """Move a torrent's storage location"""
    834862
  • deluge/ui/gtkui/glade/dgtkpopups.glade

    diff --git a/deluge/ui/gtkui/glade/dgtkpopups.glade b/deluge/ui/gtkui/glade/dgtkpopups.glade
    index 68f2c4b..8796b35 100644
    a b  
    260260      </widget>
    261261    </child>
    262262  </widget>
     263 
     264  <widget class="GtkDialog" id="add_webseed_dialog">
     265    <property name="border_width">5</property>
     266    <property name="title" translatable="yes">Add Webseed</property>
     267    <property name="window_position">GTK_WIN_POS_MOUSE</property>
     268    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
     269    <property name="skip_taskbar_hint">True</property>
     270    <property name="skip_pager_hint">True</property>
     271    <property name="decorated">False</property>
     272    <property name="has_separator">False</property>
     273    <child internal-child="vbox">
     274      <widget class="GtkVBox" id="dialog-vbox3">
     275        <property name="visible">True</property>
     276        <property name="spacing">2</property>
     277        <child>
     278          <widget class="GtkVBox" id="vbox1">
     279            <property name="visible">True</property>
     280            <property name="spacing">2</property>
     281            <child>
     282              <widget class="GtkHBox" id="hbox1">
     283                <property name="visible">True</property>
     284                <property name="spacing">5</property>
     285                <child>
     286                  <widget class="GtkImage" id="image1">
     287                    <property name="visible">True</property>
     288                    <property name="stock">gtk-add</property>
     289                  </widget>
     290                  <packing>
     291                    <property name="expand">False</property>
     292                    <property name="fill">False</property>
     293                  </packing>
     294                </child>
     295                <child>
     296                  <widget class="GtkLabel" id="label1">
     297                    <property name="visible">True</property>
     298                    <property name="xalign">0</property>
     299                    <property name="label" translatable="yes">&lt;b&gt;Add Webseed&lt;/b&gt;</property>
     300                    <property name="use_markup">True</property>
     301                  </widget>
     302                  <packing>
     303                    <property name="position">1</property>
     304                  </packing>
     305                </child>
     306              </widget>
     307            </child>
     308            <child>
     309              <widget class="GtkHSeparator" id="hseparator1">
     310                <property name="visible">True</property>
     311              </widget>
     312              <packing>
     313                <property name="expand">False</property>
     314                <property name="position">1</property>
     315              </packing>
     316            </child>
     317            <child>
     318              <widget class="GtkEntry" id="webseed_address">
     319                <property name="visible">True</property>
     320                <property name="can_focus">True</property>
     321                <property name="activates_default">True</property>
     322                <property name="width_chars">39</property>
     323                <property name="text" translatable="yes">http://</property>
     324              </widget>
     325              <packing>
     326                <property name="position">2</property>
     327              </packing>
     328            </child>
     329          </widget>
     330          <packing>
     331            <property name="expand">False</property>
     332            <property name="position">1</property>
     333          </packing>
     334        </child>
     335        <child internal-child="action_area">
     336          <widget class="GtkHButtonBox" id="dialog-action_area3">
     337            <property name="visible">True</property>
     338            <property name="layout_style">GTK_BUTTONBOX_END</property>
     339            <child>
     340              <widget class="GtkButton" id="button2">
     341                <property name="visible">True</property>
     342                <property name="can_focus">True</property>
     343                <property name="receives_default">True</property>
     344                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     345                <property name="label">gtk-cancel</property>
     346                <property name="use_stock">True</property>
     347                <property name="response_id">0</property>
     348              </widget>
     349            </child>
     350            <child>
     351              <widget class="GtkButton" id="button1">
     352                <property name="visible">True</property>
     353                <property name="can_focus">True</property>
     354                <property name="can_default">True</property>
     355                <property name="has_default">True</property>
     356                <property name="receives_default">True</property>
     357                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     358                <property name="label">gtk-ok</property>
     359                <property name="use_stock">True</property>
     360                <property name="response_id">1</property>
     361              </widget>
     362              <packing>
     363                <property name="position">1</property>
     364              </packing>
     365            </child>
     366          </widget>
     367          <packing>
     368            <property name="expand">False</property>
     369            <property name="pack_type">GTK_PACK_END</property>
     370          </packing>
     371        </child>
     372      </widget>
     373    </child>
     374  </widget>
     375 
    263376</glade-interface>
  • deluge/ui/gtkui/glade/main_window.glade

    diff --git a/deluge/ui/gtkui/glade/main_window.glade b/deluge/ui/gtkui/glade/main_window.glade
    index d575269..6b1baf4 100644
    a b  
    27162716        </child>
    27172717      </widget>
    27182718    </child>
     2719    <child>
     2720      <widget class="GtkImageMenuItem" id="menuitem4">
     2721        <property name="label" translatable="yes">_Add Webseed</property>
     2722        <property name="visible">True</property>
     2723        <property name="tooltip" translatable="yes">Add a webseed</property>
     2724        <property name="use_underline">True</property>
     2725        <property name="use_stock">False</property>
     2726        <signal name="activate" handler="on_menuitem_add_webseed_activate"/>
     2727        <child internal-child="image">
     2728          <widget class="GtkImage" id="image1">
     2729            <property name="visible">True</property>
     2730            <property name="stock">gtk-add</property>
     2731            <property name="icon-size">1</property>
     2732          </widget>
     2733        </child>
     2734      </widget>
     2735    </child>
    27192736  </widget>
    27202737</glade-interface>
  • deluge/ui/gtkui/peers_tab.py

    diff --git a/deluge/ui/gtkui/peers_tab.py b/deluge/ui/gtkui/peers_tab.py
    index bb2316f..27876f4 100644
    a b def __init__(self):  
    6767        self.peer_menu = glade.get_widget("menu_peer_tab")
    6868        glade.signal_autoconnect({
    6969            "on_menuitem_add_peer_activate": self._on_menuitem_add_peer_activate,
     70            "on_menuitem_add_webseed_activate": self._on_menuitem_add_webseed_activate,
    7071            })
    7172
    7273        self.listview = glade.get_widget("peers_listview")
    def _on_menuitem_add_peer_activate(self, menuitem):  
    399400                client.core.connect_peer(self.torrent_id, ip, port)
    400401        peer_dialog.destroy()
    401402        return True
     403
     404    def _on_menuitem_add_webseed_activate(self, menuitem):
     405        """This is a callback for manually adding a webseed"""
     406        log.debug("on_menuitem_add_webseed")
     407        dialog_glade = gtk.glade.XML(
     408            pkg_resources.resource_filename("deluge.ui.gtkui",
     409                "glade/dgtkpopups.glade"))
     410        add_webseed_dialog = dialog_glade.get_widget("add_webseed_dialog")
     411        address = dialog_glade.get_widget("webseed_address")
     412        response = add_webseed_dialog.run()
     413        if response:
     414            client.core.add_url_seed(self.torrent_id, address.get_text())
     415        #else the user clicked cancel
     416        add_webseed_dialog.destroy()
     417        return True