From dde291d6dd28faf2a31f27c47dce11cb993ce19f Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Sat, 24 Nov 2007 03:51:11 +0000 Subject: [PATCH] add connection_speed setting --- glade/preferences_dialog.glade | 31 ++++++++++++++++++++++++++++++- src/core.py | 1 + src/deluge_core.cpp | 11 +++++++++++ src/dialogs.py | 2 ++ src/pref.py | 2 ++ 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/glade/preferences_dialog.glade b/glade/preferences_dialog.glade index 1bf4d665d..49f6eafd0 100644 --- a/glade/preferences_dialog.glade +++ b/glade/preferences_dialog.glade @@ -1175,8 +1175,37 @@ Either True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 + 6 2 + + + True + True + The maximum half-open connections. A high value may crash some cheap routers. Set -1 for unlimited. + 1 + -1 -1 9000 1 10 10 + 1 + + + 1 + 2 + 5 + 6 + GTK_FILL + + + + + True + The maximum half-open connections. A high value may crash some cheap routers. Set -1 for unlimited. + 0 + Maximum Connection Attempts per Second: + + + 5 + 6 + + True diff --git a/src/core.py b/src/core.py index c74024e7b..49bfe8763 100644 --- a/src/core.py +++ b/src/core.py @@ -70,6 +70,7 @@ DHT_FILENAME = "dht.state" PREF_FUNCTIONS = { "listen_on" : deluge_core.set_listen_on, "max_half_open" : deluge_core.set_max_half_open, + "connection_speed" : deluge_core.connection_speed, "max_connections_global" : deluge_core.set_max_connections_global, "max_active_torrents" : None, # no need for a function, applied constantly "max_upload_slots_global" : deluge_core.set_max_upload_slots_global, diff --git a/src/deluge_core.cpp b/src/deluge_core.cpp index 6322697ec..829696e25 100644 --- a/src/deluge_core.cpp +++ b/src/deluge_core.cpp @@ -510,6 +510,16 @@ static PyObject *torrent_set_max_half_open(PyObject *self, PyObject *args) Py_INCREF(Py_None); return Py_None; } +static PyObject *torrent_connection_speed(PyObject *self, PyObject *args) +{ + python_long arg; + if (!PyArg_ParseTuple(args, "i", &arg)) + return NULL; + M_settings->connection_speed = arg; + M_ses->set_settings(*M_settings); + + Py_INCREF(Py_None); return Py_None; +} static PyObject *torrent_set_download_rate_limit(PyObject *self, PyObject *args) { @@ -2022,6 +2032,7 @@ static PyMethodDef deluge_core_methods[] = {"quit", torrent_quit, METH_VARARGS, "."}, {"save_fastresume", torrent_save_fastresume, METH_VARARGS, "."}, {"set_max_half_open", torrent_set_max_half_open, METH_VARARGS, "."}, + {"connection_speed", torrent_connection_speed, METH_VARARGS, "."}, {"set_download_rate_limit", torrent_set_download_rate_limit, METH_VARARGS, "."}, {"set_upload_rate_limit", torrent_set_upload_rate_limit, METH_VARARGS, "."}, {"set_per_upload_rate_limit", torrent_set_per_upload_rate_limit, METH_VARARGS, "."}, diff --git a/src/dialogs.py b/src/dialogs.py index 840b90b10..68cd90fdd 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -144,6 +144,7 @@ class PreferencesDlg: self.glade.get_widget("spin_dht_proxy_port").set_value(self.preferences.get("dht_proxy_port")) self.glade.get_widget("spin_web_proxy_port").set_value(self.preferences.get("web_proxy_port")) self.glade.get_widget("spin_max_half_open").set_value(float(self.preferences.get("max_half_open"))) + self.glade.get_widget("spin_connection_speed").set_value(float(self.preferences.get("connection_speed"))) self.glade.get_widget("spin_torrents").set_value(float(self.preferences.get("max_active_torrents"))) self.glade.get_widget("chk_seedbottom").set_active(self.preferences.get("queue_seeds_to_bottom")) self.glade.get_widget("chk_queue_above_completed").set_sensitive(self.preferences.get("queue_seeds_to_bottom")) @@ -269,6 +270,7 @@ class PreferencesDlg: self.preferences.set("max_connections_global", int(self.glade.get_widget("spin_max_connections_global").get_value())) self.preferences.set("max_connections_per_torrent", int(self.glade.get_widget("spin_max_connections_per_torrent").get_value())) self.preferences.set("max_half_open", int(self.glade.get_widget("spin_max_half_open").get_value())) + self.preferences.set("connection_speed", int(self.glade.get_widget("spin_connection_speed").get_value())) self.preferences.set("max_active_torrents", int(self.glade.get_widget("spin_torrents").get_value())) self.preferences.set("queue_seeds_to_bottom", self.glade.get_widget("chk_seedbottom").get_active()) self.preferences.set("enable_dht", self.glade.get_widget("chk_dht").get_active()) diff --git a/src/pref.py b/src/pref.py index 50f03bc6b..2432b8efd 100644 --- a/src/pref.py +++ b/src/pref.py @@ -70,6 +70,7 @@ if common.windows_check(): "listen_on" : [6881,6889], "lock_tray" : False, "max_half_open" : 8, + "connection_speed" : -1, "max_active_torrents" : 8, "max_active_torrents_tmp" : 8, "max_connections_global" : 200, @@ -183,6 +184,7 @@ else: "listen_on" : [6881,6889], "lock_tray" : False, "max_half_open" : 20, + "connection_speed" : -1, "max_active_torrents" : 8, "max_active_torrents_tmp" : 8, "max_connections_global" : 200,