add dht nodes to status bar

This commit is contained in:
Marcos Pinto 2008-01-29 06:58:23 +00:00
parent b29583024d
commit f757593146
5 changed files with 26 additions and 0 deletions

View File

@ -443,6 +443,10 @@ class Core(
"""Returns the current number of connections"""
return self.session.num_connections()
def export_get_dht_nodes(self):
"""Returns the number of dht nodes"""
return self.session.status().dht_nodes
def export_get_download_rate(self):
"""Returns the payload download rate"""
return self.session.status().payload_download_rate
@ -568,6 +572,9 @@ class Core(
log.debug("dht value set to %s", value)
if value:
self.session.start_dht(None)
self.session.add_dht_router("router.bittorrent.com", 6881)
self.session.add_dht_router("router.utorrent.com", 6881)
self.session.add_dht_router("router.bitcomet.com", 6881)
else:
self.session.stop_dht()

Binary file not shown.

After

Width:  |  Height:  |  Size: 607 B

View File

@ -0,0 +1 @@
2679

View File

@ -393,6 +393,9 @@ def get_upload_rate(callback):
def get_num_connections(callback):
get_core().call("get_num_connections", callback)
def get_dht_nodes(callback):
get_core().call("get_dht_nodes", callback)
def enable_plugin(plugin):
get_core().call("enable_plugin", None, plugin)

View File

@ -104,6 +104,7 @@ class StatusBar(component.Component):
self.download_rate = 0.0
self.max_upload_speed = -1.0
self.upload_rate = 0.0
self.dht_nodes = 0
self.config_value_changed_dict = {
"max_connections_global": self._on_max_connections_global,
@ -138,6 +139,10 @@ class StatusBar(component.Component):
image=deluge.common.get_pixmap("seeding16.png"))
self.hbox.pack_start(
self.upload_item.get_eventbox(), expand=False, fill=False)
self.dht_item = StatusBarItem(
image=deluge.common.get_pixmap("dht16.png"))
self.hbox.pack_start(
self.dht_item.get_eventbox(), expand=False, fill=False)
# Get some config values
client.get_config_value(
@ -153,6 +158,7 @@ class StatusBar(component.Component):
# When stopped, we just show the not connected thingy
try:
self.remove_item(self.connections_item)
self.remove_item(self.dht_item)
self.remove_item(self.download_item)
self.remove_item(self.upload_item)
self.remove_item(self.not_connected_item)
@ -187,6 +193,7 @@ class StatusBar(component.Component):
def send_status_request(self):
# Sends an async request for data from the core
client.get_num_connections(self._on_get_num_connections)
client.get_dht_nodes(self._on_get_dht_nodes)
client.get_download_rate(self._on_get_download_rate)
client.get_upload_rate(self._on_get_upload_rate)
@ -204,6 +211,9 @@ class StatusBar(component.Component):
def _on_get_num_connections(self, num_connections):
self.num_connections = num_connections
def _on_get_dht_nodes(self, dht_nodes):
self.dht_nodes = dht_nodes
def _on_max_download_speed(self, max_download_speed):
self.max_download_speed = max_download_speed
self.update_download_label()
@ -227,6 +237,10 @@ class StatusBar(component.Component):
self.connections_item.set_text("%s (%s)" % (
self.num_connections, max_connections))
def update_dht_label(self):
# Set the max connections label
self.dht_item.set_text("%s" % (self.dht_nodes))
def update_download_label(self):
# Set the download speed label
max_download_speed = self.max_download_speed
@ -253,6 +267,7 @@ class StatusBar(component.Component):
def update(self):
# Update the labels
self.update_connections_label()
self.update_dht_label()
self.update_download_label()
self.update_upload_label()