2006-07-19 21:27:37 +02:00
|
|
|
import gobject
|
2006-07-25 22:52:45 +02:00
|
|
|
import dbus
|
2006-06-14 20:42:44 +02:00
|
|
|
|
2006-06-09 23:23:42 +02:00
|
|
|
|
2006-07-19 21:27:37 +02:00
|
|
|
class Service(gobject.GObject):
|
2006-06-15 23:05:44 +02:00
|
|
|
|
2006-07-19 21:27:37 +02:00
|
|
|
_PRESENCE_SERVICE = "org.laptop.Presence"
|
|
|
|
_SERVICE_DBUS_INTERFACE = "org.laptop.Presence.Service"
|
2006-06-14 20:42:44 +02:00
|
|
|
|
2006-07-19 21:27:37 +02:00
|
|
|
def __init__(self, bus, new_obj_cb, del_obj_cb, object_path):
|
|
|
|
gobject.GObject.__init__(self)
|
|
|
|
self._object_path = object_path
|
|
|
|
self._ps_new_object = new_obj_cb
|
|
|
|
self._ps_del_object = del_obj_cb
|
|
|
|
sobj = bus.get_object(self._PRESENCE_SERVICE, object_path)
|
|
|
|
self._service = dbus.Interface(sobj, self._SERVICE_DBUS_INTERFACE)
|
2006-07-23 16:21:00 +02:00
|
|
|
self._service.connect_to_signal('PropertyChanged', self._property_changed_cb)
|
2006-07-23 06:56:40 +02:00
|
|
|
self._props = self._service.getProperties()
|
2006-06-13 00:31:26 +02:00
|
|
|
|
2006-07-19 21:27:37 +02:00
|
|
|
def object_path(self):
|
|
|
|
return self._object_path
|
2006-06-18 07:31:18 +02:00
|
|
|
|
2006-07-23 16:21:00 +02:00
|
|
|
def _property_changed_cb(self, prop_list):
|
|
|
|
self._props = self._service.getProperties()
|
2006-06-23 00:07:54 +02:00
|
|
|
|
2006-07-23 16:21:00 +02:00
|
|
|
def get_published_value(self, key):
|
2006-07-19 21:27:37 +02:00
|
|
|
value = self._service.getPublishedValue(key)
|
2006-07-23 06:56:40 +02:00
|
|
|
|
|
|
|
def get_name(self):
|
|
|
|
return self._props['name']
|
|
|
|
|
|
|
|
def get_type(self):
|
|
|
|
return self._props['type']
|
|
|
|
|
|
|
|
def get_domain(self):
|
|
|
|
return self._props['domain']
|
|
|
|
|
|
|
|
def get_address(self):
|
|
|
|
if self._props.has_key('address'):
|
|
|
|
return self._props['address']
|
|
|
|
return None
|
|
|
|
|
|
|
|
def get_activity_id(self):
|
|
|
|
if self._props.has_key('activityId'):
|
|
|
|
return self._props['activityId']
|
|
|
|
return None
|
|
|
|
|
|
|
|
def get_port(self):
|
|
|
|
if self._props.has_key('port'):
|
|
|
|
return self._props['port']
|
|
|
|
return None
|
|
|
|
|
|
|
|
def get_source_address(self):
|
|
|
|
if self._props.has_key('sourceAddress'):
|
|
|
|
return self._props['sourceAddress']
|
|
|
|
return None
|