Improve handle marshalling. Add an uri to the handle.
This commit is contained in:
parent
0556d5f51f
commit
0d7bdeb20a
@ -60,7 +60,7 @@ class ActivityCreationHandler(gobject.GObject):
|
||||
proxy_obj = bus.get_object(service_name, bundle.get_object_path())
|
||||
factory = dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityFactory")
|
||||
|
||||
factory.create(str(self._activity_handle),
|
||||
factory.create(self._activity_handle.get_dict(),
|
||||
reply_handler=self._reply_handler,
|
||||
error_handler=self._error_handler)
|
||||
|
||||
|
@ -48,9 +48,9 @@ class ActivityFactoryService(dbus.service.Object):
|
||||
object_path = '/' + service_name.replace('.', '/')
|
||||
dbus.service.Object.__init__(self, bus_name, object_path)
|
||||
|
||||
@dbus.service.method("com.redhat.Sugar.ActivityFactory")
|
||||
@dbus.service.method("com.redhat.Sugar.ActivityFactory", in_signature="a{ss}")
|
||||
def create(self, handle):
|
||||
activity_handle = activityhandle.create_from_string(handle)
|
||||
activity_handle = activityhandle.create_from_dict(handle)
|
||||
activity = self._constructor(activity_handle)
|
||||
|
||||
self._activities.append(activity)
|
||||
|
@ -21,14 +21,29 @@ class ActivityHandle(object):
|
||||
def __init__(self, activity_id):
|
||||
self.activity_id = activity_id
|
||||
self.pservice_id = None
|
||||
self.uri = None
|
||||
|
||||
def __str__(self):
|
||||
return self.activity_id
|
||||
|
||||
def get_presence_service():
|
||||
def get_presence_service(self):
|
||||
if self.pservice_id:
|
||||
pservice = PresenceService.get_instance()
|
||||
return pservice.get_activity(self._pservice_id)
|
||||
return pservice.get_activity(self.pservice_id)
|
||||
else:
|
||||
return None
|
||||
|
||||
def create_from_string(handle):
|
||||
activity_handle = ActivityHandle(handle)
|
||||
activity_handle.pservice_id = handle
|
||||
def get_dict(self):
|
||||
result = { 'activity_id' : self.activity_id }
|
||||
if self.pservice_id:
|
||||
result['pservice_id'] = self.pservice_id
|
||||
if self.uri:
|
||||
result['uri'] = self.uri
|
||||
|
||||
return result
|
||||
|
||||
def create_from_dict(handle_dict):
|
||||
result = ActivityHandle(handle_dict['activity_id'])
|
||||
if handle_dict.has_key('pservice_id'):
|
||||
result.pservice_id = handle_dict['pservice_id']
|
||||
if handle_dict.has_key('uri'):
|
||||
result.uri = handle_dict['uri']
|
||||
|
||||
return result
|
||||
|
Loading…
Reference in New Issue
Block a user