diff --git a/deluge/core/daemon.py b/deluge/core/daemon.py index e1c32f7c2..21a011c4d 100644 --- a/deluge/core/daemon.py +++ b/deluge/core/daemon.py @@ -64,19 +64,19 @@ def is_daemon_running(pid_file): class Daemon(object): """The Deluge Daemon class""" - def __init__(self, listen_interface=None, interface=None, port=None, classic=False, + def __init__(self, listen_interface=None, interface=None, port=None, standalone=False, read_only_config_keys=None): """ Args: listen_interface (str, optional): The IP address to listen to bittorrent connections on. interface (str, optional): The IP address the daemon will listen for UI connections on. port (int, optional): The port the daemon will listen for UI connections on. - classic (bool, optional): If True the client is in Classic (Standalone) mode otherwise, if + standalone (bool, optional): If True the client is in Standalone mode otherwise, if False, start the daemon as separate process. read_only_config_keys (list of str, optional): A list of config keys that will not be altered by core.set_config() RPC method. """ - self.classic = classic + self.standalone = standalone self.pid_file = get_config_dir("deluged.pid") log.info("Deluge daemon %s", get_version()) if is_daemon_running(self.pid_file): @@ -110,7 +110,7 @@ class Daemon(object): self.rpcserver = RPCServer( port=port, allow_remote=self.core.config["allow_remote"], - listen=not classic, + listen=not standalone, interface=interface ) @@ -124,7 +124,7 @@ class Daemon(object): # Make sure we start the PreferencesManager first component.start("PreferencesManager") - if not self.classic: + if not self.standalone: log.info("Deluge daemon starting...") # Create pid file to track if deluged is running, also includes the port number. pid = os.getpid() @@ -148,7 +148,7 @@ class Daemon(object): def _shutdown(self, *args, **kwargs): log.info("Deluge daemon shutting down, waiting for components to shutdown...") - if not self.classic: + if not self.standalone: return component.shutdown() @export() diff --git a/deluge/plugins/Stats/deluge/plugins/stats/tests/test_stats.py b/deluge/plugins/Stats/deluge/plugins/stats/tests/test_stats.py index a9ca8dc6a..36bd1c235 100644 --- a/deluge/plugins/Stats/deluge/plugins/stats/tests/test_stats.py +++ b/deluge/plugins/Stats/deluge/plugins/stats/tests/test_stats.py @@ -31,12 +31,12 @@ class StatsTestCase(BaseTestCase): def set_up(self): defer.setDebugging(True) tests_common.set_tmp_config_dir() - client.start_classic_mode() + client.start_standalone() client.core.enable_plugin("Stats") return component.start() def tear_down(self): - client.stop_classic_mode() + client.stop_standalone() return component.shutdown() @defer.inlineCallbacks diff --git a/deluge/ui/client.py b/deluge/ui/client.py index 1bcd92bf2..2ec72b086 100644 --- a/deluge/ui/client.py +++ b/deluge/ui/client.py @@ -424,18 +424,18 @@ class DaemonSSLProxy(DaemonProxy): return self.protocol.get_bytes_sent() -class DaemonClassicProxy(DaemonProxy): +class DaemonStandaloneProxy(DaemonProxy): def __init__(self, event_handlers=None): if event_handlers is None: event_handlers = {} from deluge.core import daemon - self.__daemon = daemon.Daemon(classic=True) + self.__daemon = daemon.Daemon(standalone=True) self.__daemon.start() log.debug("daemon created!") self.connected = True self.host = "localhost" self.port = 58846 - # Running in classic mode, it's safe to import auth level + # Running in standalone mode, it's safe to import auth level from deluge.core.authmanager import (AUTH_LEVEL_ADMIN, AUTH_LEVELS_MAPPING, AUTH_LEVELS_MAPPING_REVERSE) @@ -528,7 +528,7 @@ class Client(object): def __init__(self): self._daemon_proxy = None self.disconnect_callback = None - self.__started_in_classic = False + self.__started_standalone = False def connect(self, host="127.0.0.1", port=58846, username="", password="", skip_authentication=False): @@ -586,27 +586,35 @@ class Client(object): """ Disconnects from the daemon. """ - if self.is_classicmode(): + if self.is_standalone(): self._daemon_proxy.disconnect() - self.stop_classic_mode() + self.stop_standalone() return defer.succeed(True) if self._daemon_proxy: return self._daemon_proxy.disconnect() - def start_classic_mode(self): + def start_standalone(self): """ Starts a daemon in the same process as the client. """ - self._daemon_proxy = DaemonClassicProxy(self.__event_handlers) - self.__started_in_classic = True + self._daemon_proxy = DaemonStandaloneProxy(self.__event_handlers) + self.__started_standalone = True - def stop_classic_mode(self): + def stop_standalone(self): """ Stops the daemon process in the client. """ self._daemon_proxy = None - self.__started_in_classic = False + self.__started_standalone = False + + def start_classic_mode(self): + """Deprecated""" + self.start_standalone() + + def stop_classic_mode(self): + """Deprecated""" + self.stop_standalone() def start_daemon(self, port, config): """ @@ -649,18 +657,22 @@ that you forgot to install the deluged package or it's not in your PATH.")) """ if (self._daemon_proxy and self._daemon_proxy.host in ("127.0.0.1", "localhost") or - isinstance(self._daemon_proxy, DaemonClassicProxy)): + isinstance(self._daemon_proxy, DaemonStandaloneProxy)): return True return False + def is_standalone(self): + """ + Checks to see if the client has been started in standalone mode. + + :returns: bool, True if in standalone mode + + """ + return self.__started_standalone + def is_classicmode(self): - """ - Checks to see if the client has been started in classic mode. - - :returns: bool, True if in classic mode - - """ - return self.__started_in_classic + """Deprecated""" + self.is_standalone() def connected(self): """ diff --git a/deluge/ui/gtkui/aboutdialog.py b/deluge/ui/gtkui/aboutdialog.py index 8ef54e296..037411423 100644 --- a/deluge/ui/gtkui/aboutdialog.py +++ b/deluge/ui/gtkui/aboutdialog.py @@ -254,7 +254,7 @@ class AboutDialog(object): self.about.set_logo(gtk.gdk.pixbuf_new_from_file(get_pixmap("deluge-about.png"))) if client.connected(): - if not client.is_classicmode(): + if not client.is_standalone(): self.about.set_comments( self.about.get_comments() + _("Server:") + " %coreversion%\n") @@ -272,7 +272,7 @@ class AboutDialog(object): self.about.set_comments(c) client.core.get_libtorrent_version().addCallback(on_lt_version) - if not client.is_classicmode(): + if not client.is_standalone(): client.daemon.info().addCallback(on_info) else: client.core.get_libtorrent_version().addCallback(on_lt_version) diff --git a/deluge/ui/gtkui/glade/preferences_dialog.ui b/deluge/ui/gtkui/glade/preferences_dialog.ui index d3855a908..04e74e10a 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.ui +++ b/deluge/ui/gtkui/glade/preferences_dialog.ui @@ -374,7 +374,7 @@ True False - + Standalone False True @@ -399,7 +399,7 @@ False Connect to a Deluge daemon (deluged) True - radio_classic + radio_standalone False diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index 3709451fa..b9201611b 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -71,7 +71,7 @@ except ImportError: DEFAULT_PREFS = { - "classic_mode": True, + "standalone": True, "interactive_add": True, "focus_add_dialog": True, "enable_system_tray": True, @@ -167,10 +167,6 @@ class GtkUI(object): if not os.path.exists(os.path.join(get_config_dir(), "gtkui_state")): os.makedirs(os.path.join(get_config_dir(), "gtkui_state")) - # We need to check on exit if it was started in classic mode to ensure we - # shutdown the daemon. - self.started_in_classic = self.config["classic_mode"] - # Set language if self.config["language"] is not None: lang.set_language(self.config["language"]) @@ -246,7 +242,7 @@ class GtkUI(object): def shutdown(self, *args, **kwargs): log.debug("GTKUI shutting down...") # Shutdown all components - if self.started_in_classic: + if client.is_standalone: return component.shutdown() @defer.inlineCallbacks @@ -287,19 +283,19 @@ class GtkUI(object): log.debug("_on_reactor_start") self.mainwindow.first_show() - if self.config["classic_mode"]: + if self.config["standalone"]: def on_dialog_response(response): if response != gtk.RESPONSE_YES: # The user does not want to turn Standalone Mode off, so just quit self.mainwindow.quit() return - # Turning off classic_mode - self.config["classic_mode"] = False - self.__start_non_classic() + # Turning off standalone + self.config["standalone"] = False + self.__start_thinclient() try: try: - client.start_classic_mode() + client.start_standalone() except DaemonRunningError: d = YesNoDialog( _("Switch to Thin Client Mode?"), @@ -307,7 +303,6 @@ class GtkUI(object): "To use Standalone mode, stop this daemon and restart Deluge." "\n\n" "Continue in Thin Client mode?")).run() - self.started_in_classic = False d.addCallback(on_dialog_response) except ImportError as ex: if "No module named libtorrent" in ex.message: @@ -316,7 +311,6 @@ class GtkUI(object): _("Only Thin Client mode is available because libtorrent is not installed." "\n\n" "To use Deluge Standalone mode, please install libtorrent.")).run() - self.started_in_classic = False d.addCallback(on_dialog_response) else: raise ex @@ -337,14 +331,13 @@ class GtkUI(object): _("Switch to Thin Client Mode?"), _("Unable to start Standalone mode would you like to continue in Thin Client mode?") ).run() - self.started_in_classic = False d.addCallback(on_dialog_response) ed.addCallback(on_ed_response) else: self.rpc_stats.start(10) - self.__start_non_classic() + self.__start_thinclient() - def __start_non_classic(self): + def __start_thinclient(self): # Autoconnect to a host if self.config["autoconnect"]: diff --git a/deluge/ui/gtkui/mainwindow.py b/deluge/ui/gtkui/mainwindow.py index cd2e1c137..c365daac5 100644 --- a/deluge/ui/gtkui/mainwindow.py +++ b/deluge/ui/gtkui/mainwindow.py @@ -216,7 +216,7 @@ class MainWindow(component.Component): if shutdown: client.daemon.shutdown().addCallback(stop_gtk_reactor) - elif not client.is_classicmode() and client.connected(): + elif not client.is_standalone() and client.connected(): client.disconnect().addCallback(stop_gtk_reactor) else: stop_gtk_reactor() diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index 082d6433e..b36f45e71 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -176,9 +176,9 @@ class MenuBar(component.Component): self.builder.get_object(widget).hide() self.builder.get_object(widget).set_no_show_all(True) - self.main_builder.get_object("separatormenuitem").set_visible(not self.config["classic_mode"]) - self.main_builder.get_object("menuitem_quitdaemon").set_visible(not self.config["classic_mode"]) - self.main_builder.get_object("menuitem_connectionmanager").set_visible(not self.config["classic_mode"]) + self.main_builder.get_object("separatormenuitem").set_visible(not self.config["standalone"]) + self.main_builder.get_object("menuitem_quitdaemon").set_visible(not self.config["standalone"]) + self.main_builder.get_object("menuitem_connectionmanager").set_visible(not self.config["standalone"]) # Show the Torrent menu because we're connected to a host self.menu_torrent.show() diff --git a/deluge/ui/gtkui/menubar_osx.py b/deluge/ui/gtkui/menubar_osx.py index 7411233f5..5593cd155 100644 --- a/deluge/ui/gtkui/menubar_osx.py +++ b/deluge/ui/gtkui/menubar_osx.py @@ -68,7 +68,7 @@ def menubar_osx(gtkui, osxapp): osxapp.insert_app_menu_item(about_item, 0) osxapp.insert_app_menu_item(gtk.SeparatorMenuItem(), 1) osxapp.insert_app_menu_item(pref_item, 2) - if not config["classic_mode"]: + if not config["standalone"]: osxapp.insert_app_menu_item(conn_item, 3) if quit_all_item.get_visible(): osxapp.insert_app_menu_item(gtk.SeparatorMenuItem(), 4) diff --git a/deluge/ui/gtkui/new_release_dialog.py b/deluge/ui/gtkui/new_release_dialog.py index b8f47dd42..cff8ce93d 100644 --- a/deluge/ui/gtkui/new_release_dialog.py +++ b/deluge/ui/gtkui/new_release_dialog.py @@ -43,7 +43,7 @@ class NewReleaseDialog(object): builder.get_object("label_server_version").show() builder.get_object("label_server_version_text").show() - if not client.is_classicmode(): + if not client.is_standalone(): builder.get_object("label_client_version_text").set_label(_("Client Version")) client.daemon.info().addCallback(on_info) diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 8880dd94e..420003721 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -449,8 +449,8 @@ class Preferences(component.Component): self.builder.get_object("chk_start_in_tray").set_active(self.gtkui_config["start_in_tray"]) self.builder.get_object("radio_appind").set_active(self.gtkui_config["enable_appindicator"]) self.builder.get_object("chk_lock_tray").set_active(self.gtkui_config["lock_tray"]) - self.builder.get_object("radio_classic").set_active(self.gtkui_config["classic_mode"]) - self.builder.get_object("radio_thinclient").set_active(not self.gtkui_config["classic_mode"]) + self.builder.get_object("radio_standalone").set_active(self.gtkui_config["standalone"]) + self.builder.get_object("radio_thinclient").set_active(not self.gtkui_config["standalone"]) self.builder.get_object("chk_show_rate_in_title").set_active(self.gtkui_config["show_rate_in_title"]) self.builder.get_object("chk_focus_main_window_on_add").set_active( self.gtkui_config["focus_main_window_on_add"]) @@ -492,7 +492,6 @@ class Preferences(component.Component): :param hide: bool, if True, will not re-show the dialog and will hide it instead """ - classic_mode_was_set = self.gtkui_config["classic_mode"] # Get the values from the dialog new_core_config = {} @@ -583,8 +582,9 @@ class Preferences(component.Component): if passhex != "c07eb5a8c0dc7bb81c217b67f11c3b7a5e95ffd7": new_gtkui_config["tray_password"] = passhex - new_gtkui_in_classic_mode = self.builder.get_object("radio_classic").get_active() - new_gtkui_config["classic_mode"] = new_gtkui_in_classic_mode + was_standalone = self.gtkui_config["standalone"] + new_gtkui_standalone = self.builder.get_object("radio_standalone").get_active() + new_gtkui_config["standalone"] = new_gtkui_standalone new_gtkui_config["show_rate_in_title"] = self.builder.get_object( "chk_show_rate_in_title").get_active() @@ -698,19 +698,19 @@ class Preferences(component.Component): # Re-show the dialog to make sure everything has been updated self.show() - if classic_mode_was_set != new_gtkui_in_classic_mode: + if was_standalone != new_gtkui_standalone: def on_response(response): if response == gtk.RESPONSE_YES: - shutdown_daemon = (not client.is_classicmode() and + shutdown_daemon = (not client.is_standalone() and client.connected() and client.is_localhost()) component.get("MainWindow").quit(shutdown=shutdown_daemon) else: - self.gtkui_config["classic_mode"] = not new_gtkui_in_classic_mode - self.builder.get_object("radio_classic").set_active( - self.gtkui_config["classic_mode"]) + self.gtkui_config["standalone"] = not new_gtkui_standalone + self.builder.get_object("radio_standalone").set_active( + self.gtkui_config["standalone"]) self.builder.get_object("radio_thinclient").set_active( - not self.gtkui_config["classic_mode"]) + not self.gtkui_config["standalone"]) dialog = YesNoDialog( _("Switching client mode..."), _("Your current session will be stopped. Do you wish to continue?") diff --git a/deluge/ui/gtkui/queuedtorrents.py b/deluge/ui/gtkui/queuedtorrents.py index 9f22b5bd8..750432bb5 100644 --- a/deluge/ui/gtkui/queuedtorrents.py +++ b/deluge/ui/gtkui/queuedtorrents.py @@ -66,7 +66,7 @@ class QueuedTorrents(component.Component): # We only want the add button sensitive if we're connected to a host self.builder.get_object("button_add").set_sensitive(True) - if self.config["autoadd_queued"] or self.config["classic_mode"]: + if self.config["autoadd_queued"] or self.config["standalone"]: self.on_button_add_clicked(None) else: self.run() diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtkui/systemtray.py index 215bad354..5fe1f2793 100644 --- a/deluge/ui/gtkui/systemtray.py +++ b/deluge/ui/gtkui/systemtray.py @@ -128,7 +128,7 @@ class SystemTray(component.Component): def __start(self): if self.config["enable_system_tray"]: - if self.config["classic_mode"]: + if self.config["standalone"]: try: self.hide_widget_list.remove("menuitem_quitdaemon") self.hide_widget_list.remove("separatormenuitem4") diff --git a/deluge/ui/gtkui/toolbar.py b/deluge/ui/gtkui/toolbar.py index 0ea3b1a53..2a78f4b7f 100644 --- a/deluge/ui/gtkui/toolbar.py +++ b/deluge/ui/gtkui/toolbar.py @@ -55,7 +55,7 @@ class ToolBar(component.Component): def start(self): self.window.get_builder().get_object("toolbutton_connectionmanager").set_visible( - not self.config["classic_mode"]) + not self.config["standalone"]) for widget in self.change_sensitivity: self.window.get_builder().get_object(widget).set_sensitive(True) diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index 495fd9219..f7c370012 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -90,7 +90,7 @@ class JSON(resource.Resource, component.Component): component.Component.__init__(self, "JSON") self._remote_methods = [] self._local_methods = {} - if client.is_classicmode(): + if client.is_standalone(): self.get_remote_methods() def get_remote_methods(self, result=None): @@ -378,7 +378,7 @@ class WebApi(JSONComponent): client.deregister_event_handler("PluginEnabledEvent", self._json.get_remote_methods) client.deregister_event_handler("PluginDisabledEvent", self._json.get_remote_methods) - if client.is_classicmode(): + if client.is_standalone(): component.get("Web.PluginManager").stop() else: client.disconnect() @@ -388,7 +388,7 @@ class WebApi(JSONComponent): client.register_event_handler("PluginEnabledEvent", self._json.get_remote_methods) client.register_event_handler("PluginDisabledEvent", self._json.get_remote_methods) - if client.is_classicmode(): + if client.is_standalone(): component.get("Web.PluginManager").start() else: client.set_disconnect_callback(self._on_client_disconnect)