Skip to content

Commit

Permalink
[UI] Add and improve trackers tab
Browse files Browse the repository at this point in the history
First, added trackers tab to the WebUI.
Second, now we can view all the trackers and view each:
* status
* number of peers
* additional message
Third, information about DHT, PeX and LSD is also added.
Fourth, moved the private torrent info to the details tab.

closes: https://dev.deluge-torrent.org/ticket/1015
  • Loading branch information
DjLegolas committed Mar 6, 2022
1 parent a4bf482 commit 4f938aa
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 13 deletions.
6 changes: 6 additions & 0 deletions deluge/ui/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,12 @@ def connection_info(self):

return None

def connection_version(self):
if self.connected():
return self._daemon_proxy.daemon_info

return ''

def register_event_handler(self, event, handler):
"""
Registers a handler that will be called when an event is received from the daemon.
Expand Down
4 changes: 2 additions & 2 deletions deluge/ui/gtk3/glade/main_window.tabs.ui
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">1</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -824,7 +824,7 @@
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">1</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
Expand Down
57 changes: 46 additions & 11 deletions deluge/ui/gtk3/trackers_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@

import logging

from gi.repository.Gdk import EventType
from gi.repository.Gtk import CellRendererText, ListStore, SortType, TreeViewColumn

import deluge.component as component
from deluge.common import VersionSplit
from deluge.decorators import maybe_coroutine
from deluge.ui.client import client

from .tab_data_funcs import ftranslate
from .torrentdetails import Tab
Expand All @@ -36,6 +40,8 @@ def __init__(self):
self.trackers = {}
self.constant_rows = {}

self._can_get_trackers_info = False

# self.treeview.append_column(
# Gtk.TreeViewColumn(_('Tier'), Gtk.CellRendererText(), text=0)
# )
Expand Down Expand Up @@ -104,6 +110,16 @@ def _fill_constant_rows(self):
self.constant_rows[item.lower()] = row

def update(self):
if client.is_standalone():
self._can_get_trackers_info = True
else:
self._can_get_trackers_info = (
VersionSplit(client.connection_version()) > VersionSplit('2.0.5')
)
self.do_update()

@maybe_coroutine
async def do_update(self):
# Get the first selected torrent
torrent_id = component.get('TorrentView').get_selected_torrents()

Expand All @@ -124,24 +140,41 @@ def update(self):

session = component.get('SessionProxy')

tracker_keys = [
'trackers',
'trackers_status',
'trackers_peers',
]
if self._can_get_trackers_info:
tracker_keys = [
'trackers',
'trackers_status',
'trackers_peers',
]
else:
tracker_keys = [
'tracker_host',
'tracker_status',
]

perrs_sources = await session.get_torrent_status(torrent_id, ['peers_source'])
self._on_get_peers_source_status(perrs_sources)

session.get_torrent_status(torrent_id, tracker_keys).addCallback(
self._on_get_torrent_tracker_status
)
session.get_torrent_status(torrent_id, ['peers_source']).addCallback(
self._on_get_peers_source_status
)
status = await session.get_torrent_status(torrent_id, tracker_keys)
self._on_get_torrent_tracker_status(status)

def _on_get_torrent_tracker_status(self, status):
# Check to see if we got valid data from the core
if not status:
return

if not self._can_get_trackers_info:
status['trackers'] = [
{
'url': status['tracker_host'],
'message': ''
}
]
status['trackers_status'] = {
status['tracker_host']: status['tracker_status']
}
status['trackers_peers'] = {}

new_trackers = set()
for tracker in status['trackers']:
new_trackers.add(tracker['url'])
Expand Down Expand Up @@ -204,6 +237,8 @@ def _on_button_press_event(self, widget, event):
if event.button == 3:
self.trackers_menu.popup(None, None, None, None, event.button, event.time)
return True
elif event.type == EventType.DOUBLE_BUTTON_PRESS:
self.on_menuitem_edit_trackers_activate(event.button)

def on_menuitem_edit_trackers_activate(self, button):
torrent_id = component.get('TorrentView').get_selected_torrent()
Expand Down

0 comments on commit 4f938aa

Please sign in to comment.