More new PS fixes
This commit is contained in:
parent
4cf8f321f0
commit
76a0f45aa8
@ -1,4 +1,4 @@
|
|||||||
[D-BUS Service]
|
[D-BUS Service]
|
||||||
Name = org.laptop.Presence
|
Name = org.laptop.Sugar.Presence
|
||||||
Exec = @bindir@/sugar-presence-service
|
Exec = @bindir@/sugar-presence-service
|
||||||
|
|
||||||
|
@ -326,6 +326,7 @@ class ServerPlugin(gobject.GObject):
|
|||||||
if not cur_activity_handle:
|
if not cur_activity_handle:
|
||||||
# dont advertise a current activity that's not shared
|
# dont advertise a current activity that's not shared
|
||||||
cur_activity = ""
|
cur_activity = ""
|
||||||
|
print "cur_activity is '%s', handle is %s" % (cur_activity, cur_activity_handle)
|
||||||
self._conn[CONN_INTERFACE_BUDDY_INFO].SetCurrentActivity(cur_activity, cur_activity_handle)
|
self._conn[CONN_INTERFACE_BUDDY_INFO].SetCurrentActivity(cur_activity, cur_activity_handle)
|
||||||
|
|
||||||
self._upload_avatar()
|
self._upload_avatar()
|
||||||
@ -404,6 +405,16 @@ class ServerPlugin(gobject.GObject):
|
|||||||
if not props.has_key('key'):
|
if not props.has_key('key'):
|
||||||
raise InvalidBuddyError("no key")
|
raise InvalidBuddyError("no key")
|
||||||
|
|
||||||
|
# Convert from D-Bus array types to a standard python byte array
|
||||||
|
key = ""
|
||||||
|
for item in props["key"]:
|
||||||
|
try:
|
||||||
|
# int type
|
||||||
|
key = key + "%s" % chr(item)
|
||||||
|
except TypeError:
|
||||||
|
# string type
|
||||||
|
key = key + str(item)
|
||||||
|
|
||||||
jid = self._conn[CONN_INTERFACE].InspectHandles(CONNECTION_HANDLE_TYPE_CONTACT, [handle])[0]
|
jid = self._conn[CONN_INTERFACE].InspectHandles(CONNECTION_HANDLE_TYPE_CONTACT, [handle])[0]
|
||||||
nick = self._conn[CONN_INTERFACE_ALIASING].RequestAliases([handle])[0]
|
nick = self._conn[CONN_INTERFACE_ALIASING].RequestAliases([handle])[0]
|
||||||
if not nick:
|
if not nick:
|
||||||
@ -411,6 +422,8 @@ class ServerPlugin(gobject.GObject):
|
|||||||
props['nick'] = nick
|
props['nick'] = nick
|
||||||
|
|
||||||
self._online_contacts[handle] = jid
|
self._online_contacts[handle] = jid
|
||||||
|
# Any properties that are returned by TP as dbus.ByteArray or dbus.Array
|
||||||
|
# must be converted before emitting signals
|
||||||
self.emit("contact-online", handle, props)
|
self.emit("contact-online", handle, props)
|
||||||
|
|
||||||
activities = self._conn[CONN_INTERFACE_BUDDY_INFO].GetActivities(handle)
|
activities = self._conn[CONN_INTERFACE_BUDDY_INFO].GetActivities(handle)
|
||||||
|
@ -52,7 +52,10 @@ class BuddyModel(gobject.GObject):
|
|||||||
if not buddy:
|
if not buddy:
|
||||||
self._name = name
|
self._name = name
|
||||||
# FIXME: use public key, not name
|
# FIXME: use public key, not name
|
||||||
buddy = self._pservice.get_buddy_by_name(self._name)
|
for iter_buddy in self._pservice.get_buddies():
|
||||||
|
if iter_buddy.props.nick == name:
|
||||||
|
buddy = iter_buddy
|
||||||
|
break
|
||||||
|
|
||||||
# If successful, copy properties from the PS buddy object
|
# If successful, copy properties from the PS buddy object
|
||||||
if buddy:
|
if buddy:
|
||||||
|
@ -25,8 +25,7 @@ from hardware import hardwaremanager
|
|||||||
from hardware import nmclient
|
from hardware import nmclient
|
||||||
|
|
||||||
class ActivityModel:
|
class ActivityModel:
|
||||||
def __init__(self, activity, bundle, service):
|
def __init__(self, activity, bundle):
|
||||||
self._service = service
|
|
||||||
self._activity = activity
|
self._activity = activity
|
||||||
self._bundle = bundle
|
self._bundle = bundle
|
||||||
|
|
||||||
@ -39,8 +38,6 @@ class ActivityModel:
|
|||||||
def get_color(self):
|
def get_color(self):
|
||||||
return XoColor(self._activity.get_color())
|
return XoColor(self._activity.get_color())
|
||||||
|
|
||||||
def get_service(self):
|
|
||||||
return self._service
|
|
||||||
|
|
||||||
class MeshModel(gobject.GObject):
|
class MeshModel(gobject.GObject):
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
@ -75,8 +72,8 @@ class MeshModel(gobject.GObject):
|
|||||||
self._bundle_registry = bundleregistry.get_registry()
|
self._bundle_registry = bundleregistry.get_registry()
|
||||||
|
|
||||||
self._pservice = presenceservice.get_instance()
|
self._pservice = presenceservice.get_instance()
|
||||||
self._pservice.connect("service-appeared",
|
self._pservice.connect("activity-appeared",
|
||||||
self._service_appeared_cb)
|
self._activity_appeared_cb)
|
||||||
self._pservice.connect('activity-disappeared',
|
self._pservice.connect('activity-disappeared',
|
||||||
self._activity_disappeared_cb)
|
self._activity_disappeared_cb)
|
||||||
self._pservice.connect("buddy-appeared",
|
self._pservice.connect("buddy-appeared",
|
||||||
@ -88,8 +85,8 @@ class MeshModel(gobject.GObject):
|
|||||||
for buddy in self._pservice.get_buddies():
|
for buddy in self._pservice.get_buddies():
|
||||||
self._buddy_appeared_cb(self._pservice, buddy)
|
self._buddy_appeared_cb(self._pservice, buddy)
|
||||||
|
|
||||||
for service in self._pservice.get_services():
|
for activity in self._pservice.get_activities():
|
||||||
self._check_service(service)
|
self._check_activity(activity)
|
||||||
|
|
||||||
network_manager = hardwaremanager.get_network_manager()
|
network_manager = hardwaremanager.get_network_manager()
|
||||||
if network_manager:
|
if network_manager:
|
||||||
@ -196,18 +193,18 @@ class MeshModel(gobject.GObject):
|
|||||||
self.emit('buddy-removed', buddy)
|
self.emit('buddy-removed', buddy)
|
||||||
del self._buddies[buddy.get_name()]
|
del self._buddies[buddy.get_name()]
|
||||||
|
|
||||||
def _service_appeared_cb(self, pservice, service):
|
def _activity_appeared_cb(self, pservice, activity):
|
||||||
self._check_service(service)
|
self._check_activity(activity)
|
||||||
|
|
||||||
def _check_service(self, service):
|
def _check_activity(self, activity):
|
||||||
service_type = service.get_type()
|
atype = activity.get_type()
|
||||||
bundle = self._bundle_registry.find_by_default_type(service_type)
|
bundle = self._bundle_registry.get_bundle(atype)
|
||||||
if bundle != None:
|
if not bundle:
|
||||||
activity_id = service.get_activity_id()
|
return
|
||||||
if not self.has_activity(activity_id):
|
activity_id = activity.get_id()
|
||||||
activity = self._pservice.get_activity(activity_id)
|
if self.has_activity(activity_id):
|
||||||
if activity != None:
|
return
|
||||||
self.add_activity(bundle, activity, service)
|
self.add_activity(bundle, activity)
|
||||||
|
|
||||||
def has_activity(self, activity_id):
|
def has_activity(self, activity_id):
|
||||||
return self._activities.has_key(activity_id)
|
return self._activities.has_key(activity_id)
|
||||||
@ -218,14 +215,14 @@ class MeshModel(gobject.GObject):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def add_activity(self, bundle, activity, service):
|
def add_activity(self, bundle, activity):
|
||||||
model = ActivityModel(activity, bundle, service)
|
model = ActivityModel(activity, bundle)
|
||||||
self._activities[model.get_id()] = model
|
self._activities[model.get_id()] = model
|
||||||
self.emit('activity-added', model)
|
self.emit('activity-added', model)
|
||||||
|
|
||||||
for buddy in self._pservice.get_buddies():
|
for buddy in self._pservice.get_buddies():
|
||||||
cur_activity = buddy.get_current_activity()
|
cur_activity = buddy.props.current_activity
|
||||||
name = buddy.get_name()
|
name = buddy.props.nick
|
||||||
if cur_activity == activity and self._buddies.has_key(name):
|
if cur_activity == activity and self._buddies.has_key(name):
|
||||||
buddy_model = self._buddies[name]
|
buddy_model = self._buddies[name]
|
||||||
self.emit('buddy-moved', buddy_model, model)
|
self.emit('buddy-moved', buddy_model, model)
|
||||||
|
@ -47,7 +47,6 @@ class ShellModel(gobject.GObject):
|
|||||||
self._pservice = presenceservice.get_instance()
|
self._pservice = presenceservice.get_instance()
|
||||||
|
|
||||||
self._owner = ShellOwner()
|
self._owner = ShellOwner()
|
||||||
self._owner.announce()
|
|
||||||
|
|
||||||
self._friends = Friends()
|
self._friends = Friends()
|
||||||
self._mesh = MeshModel()
|
self._mesh = MeshModel()
|
||||||
|
@ -45,14 +45,10 @@ class FriendView(hippo.CanvasBox):
|
|||||||
self._buddy.connect('color-changed', self._buddy_color_changed_cb)
|
self._buddy.connect('color-changed', self._buddy_color_changed_cb)
|
||||||
|
|
||||||
def _get_new_icon_name(self, activity):
|
def _get_new_icon_name(self, activity):
|
||||||
# FIXME: do something better here; we probably need to use "flagship"
|
registry = shell.get_model().get_bundle_registry()
|
||||||
# services like mDNS where activities default services are marked
|
bundle = registry.get_bundle(activity.get_type())
|
||||||
# somehow.
|
if bundle:
|
||||||
activity_registry = shell.get_model().get_bundle_registry()
|
return bundle.get_icon()
|
||||||
for serv in activity.get_services():
|
|
||||||
bundle = activity_registry.get_bundle(serv.get_type())
|
|
||||||
if bundle:
|
|
||||||
return bundle.get_icon()
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _remove_activity_icon(self):
|
def _remove_activity_icon(self):
|
||||||
|
@ -53,7 +53,9 @@ class LogWriter:
|
|||||||
elif level == STDOUT_LEVEL:
|
elif level == STDOUT_LEVEL:
|
||||||
level_txt = 'STDOUT'
|
level_txt = 'STDOUT'
|
||||||
|
|
||||||
fmt = "%s - %s\n" % (level_txt, msg)
|
if msg[len(msg) - 1] != '\n':
|
||||||
|
msg += "\n"
|
||||||
|
fmt = "%s - %s" % (level_txt, msg)
|
||||||
fmt = fmt.encode("utf8")
|
fmt = fmt.encode("utf8")
|
||||||
self._log_file.write(fmt)
|
self._log_file.write(fmt)
|
||||||
self._log_file.flush()
|
self._log_file.flush()
|
||||||
|
@ -83,10 +83,10 @@ class PresenceService(gobject.GObject):
|
|||||||
obj = self._objcache.get(object_path)
|
obj = self._objcache.get(object_path)
|
||||||
if not obj:
|
if not obj:
|
||||||
if object_path.startswith(self._PS_BUDDY_OP):
|
if object_path.startswith(self._PS_BUDDY_OP):
|
||||||
obj = Buddy.Buddy(self._bus, self._new_object,
|
obj = buddy.Buddy(self._bus, self._new_object,
|
||||||
self._del_object, object_path)
|
self._del_object, object_path)
|
||||||
elif object_path.startswith(self._PS_ACTIVITY_OP):
|
elif object_path.startswith(self._PS_ACTIVITY_OP):
|
||||||
obj = Activity.Activity(self._bus, self._new_object,
|
obj = activity.Activity(self._bus, self._new_object,
|
||||||
self._del_object, object_path)
|
self._del_object, object_path)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Unknown object type")
|
raise RuntimeError("Unknown object type")
|
||||||
@ -158,7 +158,7 @@ class PresenceService(gobject.GObject):
|
|||||||
return self._new_object(act_op)
|
return self._new_object(act_op)
|
||||||
|
|
||||||
def get_buddies(self):
|
def get_buddies(self):
|
||||||
resp = self._ps.getBuddies()
|
resp = self._ps.GetBuddies()
|
||||||
buddies = []
|
buddies = []
|
||||||
for item in resp:
|
for item in resp:
|
||||||
buddies.append(self._new_object(item))
|
buddies.append(self._new_object(item))
|
||||||
|
Loading…
Reference in New Issue
Block a user