2
from gwibber.microblog import util
6
GwibberPublic is the public python class which provides convience methods
11
self.bus = dbus.SessionBus()
12
self.accounts = self.getbus("Accounts")
13
self.service = self.getbus("Service")
14
self.shortener = self.getbus("URLShorten")
16
def getbus(self, name):
17
obj = self.bus.get_object(
18
"com.Gwibber.%s" % name,
19
"/com/gwibber/%s" % name,
20
follow_name_owner_changes=True)
22
return dbus.Interface(obj, "com.Gwibber.%s" % name)
24
def post(self, message):
26
self.microblog.operation({
31
def GetServices(self):
33
Returns a list of services available as json string
35
import json, gwibber.lib
36
gw = gwibber.lib.GwibberPublic()
37
services = json.loads(gw.GetServices())
39
return self.service.GetServices()
41
def GetAccounts(self):
43
Returns a list of services available as json string
45
import json, gwibber.lib
46
gw = gwibber.lib.GwibberPublic()
47
accounts = json.loads(gw.GetAccounts())
49
return self.accounts.List()
51
def SendMessage(self, message):
53
Posts a message/status update to all accounts with send_enabled = True. It
54
takes one argument, which is a message formated as a string.
57
gw = gwibber.lib.GwibberPublic()
58
gw.SendMessage("This is a message")
60
return self.service.SendMessage(message)
64
Calls the Gwibber Service to trigger a refresh operation
67
gw = gwibber.lib.GwibberPublic()
70
return self.service.Refresh()
72
def Shorten(self, url):
74
Takes a long url in and returns a shortened url as a string, based on your
75
configured shortening service
78
gw = gwibber.lib.GwibberPublic()
81
return self.shortener.Shorten(url)
83
def MonitorAccountCreated(self, cb):
84
self.accounts.connect_to_signal("AccountCreated", cb)
86
def MonitorAccountChanged(self, cb):
87
self.accounts.connect_to_signal("AccountChanged", cb)
89
def MonitorAccountDeleted(self, cb):
90
self.accounts.connect_to_signal("AccountDeleted", cb)