[kupfer] Add a simple plugin to send updates via Gwibber (microblogging client)
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer] Add a simple plugin to send updates via Gwibber (microblogging client)
- Date: Mon, 28 Feb 2011 19:01:42 +0000 (UTC)
commit b1f29dd06b9250591f46d847ec5c16e82f84dd51
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Thu Feb 11 03:48:02 2010 +0100
Add a simple plugin to send updates via Gwibber (microblogging client)
kupfer/plugin/gwibber.py | 69 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/plugin/gwibber.py b/kupfer/plugin/gwibber.py
new file mode 100644
index 0000000..1e18047
--- /dev/null
+++ b/kupfer/plugin/gwibber.py
@@ -0,0 +1,69 @@
+from __future__ import absolute_import
+
+__kupfer_name__ = _("Gwibber")
+__kupfer_actions__ = (
+ "SendUpdate",
+ )
+__description__ = _("Send updates via the microblogging client Gwibber")
+__version__ = ""
+__author__ = ""
+
+import dbus
+
+from kupfer.objects import Action, TextLeaf, OperationError
+from kupfer import plugin_support
+from kupfer import pretty
+
+plugin_support.check_dbus_connection()
+
+SERVICE_NAME = "com.Gwibber.Service"
+OBJ_NAME = "/com/gwibber/Service"
+IFACE_NAME = "com.Gwibber.Service"
+
+
+def _get_interface(activate=False):
+ """Return the dbus proxy object for our Note Application.
+
+ if @activate, we will activate it over d-bus (start if not running)
+ """
+ bus = dbus.SessionBus()
+ proxy_obj = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
+ dbus_iface = dbus.Interface(proxy_obj, 'org.freedesktop.DBus')
+
+ if not activate and not dbus_iface.NameHasOwner(SERVICE_NAME):
+ return
+
+ try:
+ proxyobj = bus.get_object(SERVICE_NAME, OBJ_NAME)
+ except dbus.DBusException, e:
+ pretty.print_error(__name__, e)
+ return
+ return dbus.Interface(proxyobj, IFACE_NAME)
+
+# callback function for async callbacks
+def success():
+ pretty.print_debug(__name__, "Successful D-Bus method call")
+
+def error(exc):
+ pretty.print_error(__name__, "Encountered error in D-Bus method call:")
+ pretty.print_error(__name__, exc)
+
+class SendUpdate (Action):
+ def __init__(self):
+ Action.__init__(self, _("Send Update"))
+ def activate(self, leaf):
+ gwibber = _get_interface(True)
+ if gwibber:
+ gwibber.SendMessage(leaf.object,
+ reply_handler=success, error_handler=error)
+ else:
+ pretty.print_error(__name__, "Gwibber Service not found as:",
+ (SERVICE_NAME, OBJ_NAME, IFACE_NAME))
+ raise OperationError(_("Unable to activate Gwibber service"))
+
+ def item_types(self):
+ yield TextLeaf
+
+ def get_description(self):
+ return __description__
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]