def __buddy_updated_cb(self, account, contact_id, properties): #print('__buddy_updated_cb %r', contact_id) if contact_id is None: # Don't know the contact-id yet, will get the full state later return if contact_id not in self._buddies: #print('__buddy_updated_cb Unknown buddy with contact_id' # ' %r', contact_id) return buddy = self._buddies[contact_id] is_new = buddy.props.key is None and 'key' in properties if 'color' in properties: buddy.props.color = XoColor(properties['color']) if 'key' in properties: buddy.props.key = properties['key'] if 'nick' in properties: buddy.props.nick = properties['nick'] if is_new: self.emit('buddy-added', buddy)
def __init__(self): BaseBuddyModel.__init__(self) #client = gconf.client_get_default() #self.props.nick = client.get_string('/desktop/sugar/user/nick') self.props.nick = "rgs" #color = client.get_string('/desktop/sugar/user/color') self.props.color = XoColor(None) #self.props.key = get_profile().pubkey self.props.key = "foobar" self.connect('notify::nick', self.__property_changed_cb) self.connect('notify::color', self.__property_changed_cb) self.connect('notify::current-activity', self.__current_activity_changed_cb) bus = dbus.SessionBus() bus.add_signal_receiver(self.__name_owner_changed_cb, signal_name='NameOwnerChanged', dbus_interface='org.freedesktop.DBus') bus_object = bus.get_object(dbus.BUS_DAEMON_NAME, dbus.BUS_DAEMON_PATH) for service in bus_object.ListNames( dbus_interface=dbus.BUS_DAEMON_IFACE): if service.startswith(CONNECTION + '.'): path = '/%s' % service.replace('.', '/') Connection(service, path, bus, ready_handler=self.__connection_ready_cb)
def __activity_updated_cb(self, account, activity_id, properties): print('__activity_updated_cb %r %r', activity_id, properties) if activity_id not in self._activities: print( '__activity_updated_cb: Unknown activity with activity_id %r', activity_id) return # we should somehow emulate this and say we only have TurtleArtActivity # registry = bundleregistry.get_registry() # bundle = registry.get_bundle(properties['type']) # bundle = None # if not bundle: # print('Ignoring shared activity we don''t have') # return activity = self._activities[activity_id] is_new = activity.props.bundle is None if 'color' in properties: activity.props.color = XoColor(properties['color']) # FIXME: we have no access to the bundleregistry activity.props.bundle = None if 'name' in properties: activity.props.name = properties['name'] if 'private' in properties: activity.props.private = properties['private'] # FIXME: this should be configurable, we only care about the # activity thats using this lib i.e.: Turtle Art if properties['type']: activity.props.bundle = properties['type'] if is_new: print "The activity is new" self.emit('activity-added', activity) else: print "The activity is *NOT* new"