Remove DBUS dependency for Windows port
This commit is contained in:
parent
1f80de044b
commit
0779618917
|
@ -34,8 +34,6 @@
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import gtk
|
|
||||||
import gobject
|
|
||||||
# Import DBUS
|
# Import DBUS
|
||||||
import dbus, dbus.service
|
import dbus, dbus.service
|
||||||
|
|
||||||
|
@ -46,15 +44,12 @@ elif dbus.version >= (0,80,0):
|
||||||
DBusGMainLoop(set_as_default=True)
|
DBusGMainLoop(set_as_default=True)
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.ui.client import aclient as client
|
|
||||||
import deluge.common
|
import deluge.common
|
||||||
from deluge.configmanager import ConfigManager
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import LOG as log
|
||||||
|
|
||||||
class DbusInterface(dbus.service.Object, component.Component):
|
class DbusInterface(dbus.service.Object, component.Component):
|
||||||
def __init__(self, args, path="/org/deluge_torrent/Deluge"):
|
def __init__(self, args, path="/org/deluge_torrent/Deluge"):
|
||||||
component.Component.__init__(self, "DbusInterface")
|
component.Component.__init__(self, "DbusInterface")
|
||||||
self.config = ConfigManager("gtkui.conf")
|
|
||||||
# Check to see if the daemon is already running and if not, start it
|
# Check to see if the daemon is already running and if not, start it
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
obj = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
|
obj = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
|
||||||
|
@ -92,34 +87,6 @@ class DbusInterface(dbus.service.Object, component.Component):
|
||||||
@dbus.service.method("org.deluge_torrent.Deluge", in_signature="as")
|
@dbus.service.method("org.deluge_torrent.Deluge", in_signature="as")
|
||||||
def process_args(self, args):
|
def process_args(self, args):
|
||||||
"""Process arguments sent to already running Deluge"""
|
"""Process arguments sent to already running Deluge"""
|
||||||
# Pythonize the values from Dbus
|
from ipcinterface import process_args
|
||||||
dbus_args = args
|
process_args(args)
|
||||||
args = []
|
|
||||||
for arg in dbus_args:
|
|
||||||
args.append(str(arg))
|
|
||||||
log.debug("Processing args from other process: %s", args)
|
|
||||||
if not client.connected():
|
|
||||||
# We're not connected so add these to the queue
|
|
||||||
log.debug("Not connected to host.. Adding to queue.")
|
|
||||||
component.get("QueuedTorrents").add_to_queue(args)
|
|
||||||
return
|
|
||||||
|
|
||||||
for arg in args:
|
|
||||||
if deluge.common.is_url(arg):
|
|
||||||
log.debug("Attempting to add %s from external source..",
|
|
||||||
arg)
|
|
||||||
if self.config["interactive_add"]:
|
|
||||||
component.get("AddTorrentDialog").add_from_url(arg)
|
|
||||||
component.get("AddTorrentDialog").show(self.config["focus_add_dialog"])
|
|
||||||
else:
|
|
||||||
client.add_torrent_url(arg)
|
|
||||||
else:
|
|
||||||
# Just a file
|
|
||||||
log.debug("Attempting to add %s from external source..",
|
|
||||||
os.path.abspath(arg))
|
|
||||||
if self.config["interactive_add"]:
|
|
||||||
component.get("AddTorrentDialog").add_from_files([os.path.abspath(arg)])
|
|
||||||
component.get("AddTorrentDialog").show(self.config["focus_add_dialog"])
|
|
||||||
else:
|
|
||||||
client.add_torrent_file([os.path.abspath(arg)])
|
|
||||||
|
|
||||||
|
|
|
@ -57,10 +57,7 @@ from statusbar import StatusBar
|
||||||
from connectionmanager import ConnectionManager
|
from connectionmanager import ConnectionManager
|
||||||
from signals import Signals
|
from signals import Signals
|
||||||
from pluginmanager import PluginManager
|
from pluginmanager import PluginManager
|
||||||
try:
|
from ipcinterface import IPCInterface
|
||||||
from dbusinterface import DbusInterface
|
|
||||||
except Exception, e:
|
|
||||||
log.error("Unable to load DBUS component. This will limit functionality!")
|
|
||||||
|
|
||||||
from queuedtorrents import QueuedTorrents
|
from queuedtorrents import QueuedTorrents
|
||||||
from addtorrentdialog import AddTorrentDialog
|
from addtorrentdialog import AddTorrentDialog
|
||||||
|
@ -98,7 +95,8 @@ DEFAULT_PREFS = {
|
||||||
"autoadd_location": "",
|
"autoadd_location": "",
|
||||||
"choose_directory_dialog_path": deluge.common.get_default_download_dir(),
|
"choose_directory_dialog_path": deluge.common.get_default_download_dir(),
|
||||||
"classic_mode": False,
|
"classic_mode": False,
|
||||||
"show_new_releases": True
|
"show_new_releases": True,
|
||||||
|
"signal_port": 40000
|
||||||
}
|
}
|
||||||
|
|
||||||
class GtkUI:
|
class GtkUI:
|
||||||
|
@ -150,10 +148,8 @@ class GtkUI:
|
||||||
# Start the Dbus Interface before anything else.. Just in case we are
|
# Start the Dbus Interface before anything else.. Just in case we are
|
||||||
# already running.
|
# already running.
|
||||||
self.queuedtorrents = QueuedTorrents()
|
self.queuedtorrents = QueuedTorrents()
|
||||||
try:
|
|
||||||
self.dbusinterface = DbusInterface(args)
|
self.ipcinterface = IPCInterface(args)
|
||||||
except Exception, e:
|
|
||||||
log.warning("Unable to start DBUS component. This will limit functionality!")
|
|
||||||
|
|
||||||
# We make sure that the UI components start once we get a core URI
|
# We make sure that the UI components start once we get a core URI
|
||||||
client.connect_on_new_core(self._on_new_core)
|
client.connect_on_new_core(self._on_new_core)
|
||||||
|
@ -205,6 +201,7 @@ class GtkUI:
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _on_new_core(self, data):
|
def _on_new_core(self, data):
|
||||||
component.start()
|
component.start()
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ class MenuBar(component.Component):
|
||||||
self.on_menuitem_remove_both_activate,
|
self.on_menuitem_remove_both_activate,
|
||||||
|
|
||||||
"on_menuitem_recheck_activate": self.on_menuitem_recheck_activate,
|
"on_menuitem_recheck_activate": self.on_menuitem_recheck_activate,
|
||||||
"on_menuitem_open_folder": self.on_menuitem_open_folder_activate,
|
"on_menuitem_open_folder_activate": self.on_menuitem_open_folder_activate,
|
||||||
"on_menuitem_move_activate": self.on_menuitem_move_activate,
|
"on_menuitem_move_activate": self.on_menuitem_move_activate,
|
||||||
"on_menuitem_queue_top_activate": self.on_menuitem_queue_top_activate,
|
"on_menuitem_queue_top_activate": self.on_menuitem_queue_top_activate,
|
||||||
"on_menuitem_queue_up_activate": self.on_menuitem_queue_up_activate,
|
"on_menuitem_queue_up_activate": self.on_menuitem_queue_up_activate,
|
||||||
|
|
|
@ -50,6 +50,7 @@ class Signals(component.Component):
|
||||||
self.receiver.set_remote(True)
|
self.receiver.set_remote(True)
|
||||||
|
|
||||||
self.receiver.run()
|
self.receiver.run()
|
||||||
|
self.config["signal_port"] = self.receiver.get_port()
|
||||||
self.receiver.connect_to_signal("torrent_added",
|
self.receiver.connect_to_signal("torrent_added",
|
||||||
self.torrent_added_signal)
|
self.torrent_added_signal)
|
||||||
self.receiver.connect_to_signal("torrent_removed",
|
self.receiver.connect_to_signal("torrent_removed",
|
||||||
|
@ -69,6 +70,8 @@ class Signals(component.Component):
|
||||||
self.torrent_resume_at_stop_ratio)
|
self.torrent_resume_at_stop_ratio)
|
||||||
self.receiver.connect_to_signal("new_version_available",
|
self.receiver.connect_to_signal("new_version_available",
|
||||||
self.new_version_available)
|
self.new_version_available)
|
||||||
|
self.receiver.connect_to_signal("args_from_external",
|
||||||
|
self.args_from_external)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
try:
|
try:
|
||||||
|
@ -136,3 +139,8 @@ class Signals(component.Component):
|
||||||
from deluge.ui.gtkui.new_release_dialog import NewReleaseDialog
|
from deluge.ui.gtkui.new_release_dialog import NewReleaseDialog
|
||||||
NewReleaseDialog().show(value)
|
NewReleaseDialog().show(value)
|
||||||
|
|
||||||
|
def args_from_external(self, value):
|
||||||
|
log.debug("args_from_external: %s", value)
|
||||||
|
import ipcinterface
|
||||||
|
ipcinterface.process_args(value)
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,10 @@ class SignalReceiver(ThreadingMixIn, SimpleXMLRPCServer.SimpleXMLRPCServer):
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.debug("handle_thread: %s", e)
|
log.debug("handle_thread: %s", e)
|
||||||
|
|
||||||
|
def get_port(self):
|
||||||
|
"""Get the port that the SignalReceiver is listening on"""
|
||||||
|
return self.port
|
||||||
|
|
||||||
def emit_signal(self, signal, *data):
|
def emit_signal(self, signal, *data):
|
||||||
"""Exported method used by the core to emit a signal to the client"""
|
"""Exported method used by the core to emit a signal to the client"""
|
||||||
self.emitted_signals.append((signal, data))
|
self.emitted_signals.append((signal, data))
|
||||||
|
|
Loading…
Reference in New Issue