~jhonnyc/cgmail/jonathanc-branch

« back to all changes in this revision

Viewing changes to src/dbusinterface.py

  • Committer: Marco Ferragina
  • Date: 2007-05-06 15:51:12 UTC
  • Revision ID: marco.ferragina@gmail.com-20070506155112-874uk2m8blrknyuf
Restructured package source dir. Now is much more organized. Implemented right click menu on account window treeview

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import dbus
2
 
import dbus.service
3
 
import dbus.mainloop.glib
4
 
 
5
 
class CgmailDbusService(dbus.service.Object):
6
 
        def __init__(self, bus, obj):
7
 
                dbus.service.Object.__init__(self, bus, obj)
8
 
 
9
 
                self.on_exit_cb = None
10
 
                self.on_refresh_cb = None
11
 
        
12
 
        @dbus.service.method("org.tuxfamily.cgmail.Interface",
13
 
                                in_signature="", out_signature="")
14
 
        def exit(self):
15
 
                print "exit called"
16
 
                if self.on_exit_cb is not None:
17
 
                        self.on_exit_cb()
18
 
        
19
 
        @dbus.service.method("org.tuxfamily.cgmail.Interface",
20
 
                                in_signature="", out_signature="")
21
 
        def refresh(self):
22
 
                print "refresh called"
23
 
                if self.on_refresh_cb is not None:
24
 
                        self.on_refresh_cb()
25
 
        
26
 
        def set_on_refresh_cb(self, cb):
27
 
                self.on_refresh_cb = cb
28
 
        
29
 
        def set_on_exit_cb(self, cb):
30
 
                self.on_exit_cb = cb
31
 
        
32
 
 
33
 
def get_dbus_interface():
34
 
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
35
 
        bus = dbus.SessionBus()
36
 
        try:
37
 
                obj = bus.get_object("org.tuxfamily.cgmail.Service", "/Object")
38
 
                iface = dbus.Interface(obj, "org.tuxfamily.cgmail.Interface")
39
 
        except dbus.DBusException:
40
 
                return None
41
 
 
42
 
        return iface
43