Permalink
Browse files

QML UI: Claim gPodder's D-Bus name (bug 1477)

Right now, this does not expose the /gui or /podcasts
objects, but ideally this should be added in the future.

Based on a patch by Neal Walfield.
  • Loading branch information...
1 parent 4b69105 commit 6c2d6b022096f32b9511e120b3c5e74293f8daa3 @thp thp committed Mar 8, 2012
Showing with 26 additions and 3 deletions.
  1. +2 −0 bin/gpodder
  2. +24 −3 src/gpodder/qmlui/__init__.py
View
2 bin/gpodder
@@ -40,6 +40,8 @@ import gettext
import subprocess
+logger = logging.getLogger(__name__)
+
try:
import dbus
import dbus.glib
View
27 src/gpodder/qmlui/__init__.py
@@ -30,9 +30,16 @@
import threading
import signal
import functools
-import gpodder
import subprocess
+import dbus
+import dbus.service
+
+from dbus.mainloop.glib import DBusGMainLoop
+
+
+import gpodder
+
_ = gpodder.gettext
N_ = gpodder.ngettext
@@ -675,9 +682,13 @@ def closeEvent(self, event):
event.ignore()
class qtPodder(QObject):
- def __init__(self, args, gpodder_core):
+ def __init__(self, args, gpodder_core, dbus_bus_name):
QObject.__init__(self)
+ self.dbus_bus_name = dbus_bus_name
+ # TODO: Expose the same D-Bus API as the Gtk UI D-Bus object (/gui)
+ # TODO: Create a gpodder.dbusproxy.DBusPodcastsProxy object (/podcasts)
+
# Enable OpenGL rendering without requiring QtOpenGL
# On Harmattan we let the system choose the best graphicssystem
if '-graphicssystem' not in args and not gpodder.ui.harmattan:
@@ -933,6 +944,16 @@ def extensions_episode_download_cb(self, episode):
logger.exception('extensions_episode_download_cb(%s): %s', episode, e)
def main(args):
- gui = qtPodder(args, core.Core())
+ try:
+ dbus_main_loop = DBusGMainLoop(set_as_default=True)
+ gpodder.dbus_session_bus = dbus.SessionBus(dbus_main_loop)
+
+ bus_name = dbus.service.BusName(gpodder.dbus_bus_name,
+ bus=gpodder.dbus_session_bus)
+ except dbus.exceptions.DBusException, dbe:
+ logger.warn('Cannot get "on the bus".', exc_info=True)
+ bus_name = None
+
+ gui = qtPodder(args, core.Core(), bus_name)
return gui.run()

0 comments on commit 6c2d6b0

Please sign in to comment.