Cut over to new PresenceService
This commit is contained in:
parent
2509d990e4
commit
bc083dae5a
@ -123,7 +123,6 @@ data/Makefile
|
||||
browser/Makefile
|
||||
services/Makefile
|
||||
services/presence/Makefile
|
||||
services/presence2/Makefile
|
||||
services/clipboard/Makefile
|
||||
services/datastore/Makefile
|
||||
shell/Makefile
|
||||
|
@ -1 +1 @@
|
||||
SUBDIRS = presence presence2 clipboard datastore console
|
||||
SUBDIRS = presence clipboard datastore console
|
||||
|
@ -1,4 +1,11 @@
|
||||
sugardir = $(pkgdatadir)/services/presence2
|
||||
servicedir = $(datadir)/dbus-1/services
|
||||
service_in_files = org.laptop.Sugar.Presence.service.in
|
||||
service_DATA = $(service_in_files:.service.in=.service)
|
||||
|
||||
$(service_DATA): $(service_in_files) Makefile
|
||||
@sed -e "s|\@bindir\@|$(bindir)|" $< > $@
|
||||
|
||||
sugardir = $(pkgdatadir)/services/presence
|
||||
sugar_PYTHON = \
|
||||
__init__.py \
|
||||
activity.py \
|
||||
@ -8,6 +15,8 @@ sugar_PYTHON = \
|
||||
presenceservice.py \
|
||||
server_plugin.py
|
||||
|
||||
bin_SCRIPTS = sugar-presence-service2
|
||||
bin_SCRIPTS = sugar-presence-service
|
||||
|
||||
EXTRA_DIST = $(bin_SCRIPTS)
|
||||
DISTCLEANFILES = $(service_DATA)
|
||||
|
||||
EXTRA_DIST = $(service_in_files) $(bin_SCRIPTS)
|
||||
|
@ -170,6 +170,7 @@ class Buddy(DBusGObject):
|
||||
props['owner'] = self.props.owner
|
||||
props['key'] = self.props.key
|
||||
props['color'] = self.props.color
|
||||
props['current-activity'] = self.props.current_activity
|
||||
return props
|
||||
|
||||
# methods
|
||||
|
@ -24,7 +24,7 @@ import os
|
||||
from sugar import logger
|
||||
from sugar import env
|
||||
|
||||
sys.path.insert(0, env.get_service_path('presence2'))
|
||||
sys.path.insert(0, env.get_service_path('presence'))
|
||||
|
||||
logger.start('presenceservice')
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
from sugar.presence import PresenceService
|
||||
from sugar.presence import presenceservice
|
||||
from sugar.graphics.xocolor import XoColor
|
||||
import gobject
|
||||
|
||||
@ -44,7 +44,7 @@ class BuddyModel(gobject.GObject):
|
||||
self._bic_handler = None
|
||||
self._cac_handler = None
|
||||
|
||||
self._pservice = PresenceService.get_instance()
|
||||
self._pservice = presenceservice.get_instance()
|
||||
|
||||
self._buddy = None
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
import gobject
|
||||
|
||||
from sugar.graphics.xocolor import XoColor
|
||||
from sugar.presence import PresenceService
|
||||
from sugar.presence import presenceservice
|
||||
from sugar.activity import bundleregistry
|
||||
from model.BuddyModel import BuddyModel
|
||||
from model.accesspointmodel import AccessPointModel
|
||||
@ -74,7 +74,7 @@ class MeshModel(gobject.GObject):
|
||||
self._mesh = None
|
||||
self._bundle_registry = bundleregistry.get_registry()
|
||||
|
||||
self._pservice = PresenceService.get_instance()
|
||||
self._pservice = presenceservice.get_instance()
|
||||
self._pservice.connect("service-appeared",
|
||||
self._service_appeared_cb)
|
||||
self._pservice.connect('activity-disappeared',
|
||||
|
@ -25,7 +25,7 @@ import dbus
|
||||
from sugar import env
|
||||
from sugar import profile
|
||||
from sugar.p2p import Stream
|
||||
from sugar.presence import PresenceService
|
||||
from sugar.presence import presenceservice
|
||||
from sugar import util
|
||||
from model.Invites import Invites
|
||||
|
||||
@ -68,7 +68,7 @@ class ShellOwner(gobject.GObject):
|
||||
digest = md5.new(self._icon).digest()
|
||||
self._icon_hash = util.printable_hash(digest)
|
||||
|
||||
self._pservice = PresenceService.get_instance()
|
||||
self._pservice = presenceservice.get_instance()
|
||||
|
||||
self._invites = Invites()
|
||||
|
||||
|
@ -18,7 +18,7 @@ import os
|
||||
|
||||
import gobject
|
||||
|
||||
from sugar.presence import PresenceService
|
||||
from sugar.presence import presenceservice
|
||||
from sugar.activity.bundleregistry import BundleRegistry
|
||||
from model.Friends import Friends
|
||||
from model.MeshModel import MeshModel
|
||||
@ -44,8 +44,7 @@ class ShellModel(gobject.GObject):
|
||||
self._current_activity = None
|
||||
self._state = self.STATE_RUNNING
|
||||
|
||||
PresenceService.start()
|
||||
self._pservice = PresenceService.get_instance()
|
||||
self._pservice = presenceservice.get_instance()
|
||||
|
||||
self._owner = ShellOwner()
|
||||
self._owner.announce()
|
||||
|
@ -21,7 +21,7 @@ import gobject
|
||||
import dbus
|
||||
|
||||
from sugar.graphics.xocolor import XoColor
|
||||
from sugar.presence import PresenceService
|
||||
from sugar.presence import presenceservice
|
||||
from sugar import profile
|
||||
|
||||
class HomeActivity(gobject.GObject):
|
||||
@ -89,7 +89,7 @@ class HomeActivity(gobject.GObject):
|
||||
return self._bundle.get_icon()
|
||||
|
||||
def get_icon_color(self):
|
||||
pservice = PresenceService.get_instance()
|
||||
pservice = presenceservice.get_instance()
|
||||
activity = pservice.get_activity(self._activity_id)
|
||||
if activity != None:
|
||||
return XoColor(activity.get_color())
|
||||
|
@ -22,7 +22,7 @@ import hippo
|
||||
from sugar.graphics.menu import Menu, MenuItem
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar.graphics import units
|
||||
from sugar.presence import PresenceService
|
||||
from sugar.presence import presenceservice
|
||||
|
||||
class BuddyMenu(Menu):
|
||||
ACTION_MAKE_FRIEND = 0
|
||||
@ -80,7 +80,7 @@ class BuddyMenu(Menu):
|
||||
|
||||
def _add_items(self):
|
||||
shell_model = self._shell.get_model()
|
||||
pservice = PresenceService.get_instance()
|
||||
pservice = presenceservice.get_instance()
|
||||
|
||||
friends = shell_model.get_friends()
|
||||
if friends.has_buddy(self._buddy):
|
||||
|
@ -18,7 +18,7 @@ import hippo
|
||||
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar.graphics import color
|
||||
from sugar.presence import PresenceService
|
||||
from sugar.presence import presenceservice
|
||||
from view.BuddyIcon import BuddyIcon
|
||||
from model.BuddyModel import BuddyModel
|
||||
|
||||
@ -46,7 +46,7 @@ class FriendsBox(hippo.CanvasBox):
|
||||
self._left_hid = -1
|
||||
self._buddies = {}
|
||||
|
||||
self._pservice = PresenceService.get_instance()
|
||||
self._pservice = presenceservice.get_instance()
|
||||
self._pservice.connect('activity-appeared',
|
||||
self.__activity_appeared_cb)
|
||||
|
||||
|
@ -20,13 +20,13 @@ import gobject
|
||||
from view.BuddyIcon import BuddyIcon
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar.graphics import units
|
||||
from sugar.presence import PresenceService
|
||||
from sugar.presence import presenceservice
|
||||
|
||||
class FriendView(hippo.CanvasBox):
|
||||
def __init__(self, shell, menu_shell, buddy, **kwargs):
|
||||
hippo.CanvasBox.__init__(self, **kwargs)
|
||||
|
||||
self._pservice = PresenceService.get_instance()
|
||||
self._pservice = presenceservice.get_instance()
|
||||
|
||||
self._buddy = buddy
|
||||
self._buddy_icon = BuddyIcon(shell, menu_shell, buddy)
|
||||
|
@ -21,7 +21,7 @@ import os
|
||||
import gtk
|
||||
import hippo
|
||||
|
||||
from sugar.presence import PresenceService
|
||||
from sugar.presence import presenceservice
|
||||
from sugar.activity.activityservice import ActivityService
|
||||
from sugar.graphics.window import Window
|
||||
|
||||
@ -35,7 +35,7 @@ class Activity(Window, gtk.Container):
|
||||
|
||||
self._shared = False
|
||||
self._activity_id = handle.activity_id
|
||||
self._pservice = PresenceService.get_instance()
|
||||
self._pservice = presenceservice.get_instance()
|
||||
self._service = None
|
||||
|
||||
service = handle.get_presence_service()
|
||||
|
@ -21,7 +21,7 @@ import dbus
|
||||
import gobject
|
||||
import gtk
|
||||
|
||||
from sugar.presence import PresenceService
|
||||
from sugar.presence import presenceservice
|
||||
from sugar.activity import bundleregistry
|
||||
from sugar.activity.activityhandle import ActivityHandle
|
||||
from sugar import util
|
||||
@ -31,7 +31,7 @@ _ACTIVITY_SERVICE_PATH = "/org/laptop/Activity"
|
||||
_ACTIVITY_INTERFACE = "org.laptop.Activity"
|
||||
|
||||
def create_activity_id():
|
||||
pservice = PresenceService.get_instance()
|
||||
pservice = presenceservice.get_instance()
|
||||
|
||||
# create a new unique activity ID
|
||||
i = 0
|
||||
|
@ -15,7 +15,7 @@
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
from sugar.presence import PresenceService
|
||||
from sugar.presence import presenceservice
|
||||
|
||||
class ActivityHandle(object):
|
||||
def __init__(self, activity_id):
|
||||
@ -26,7 +26,7 @@ class ActivityHandle(object):
|
||||
|
||||
def get_presence_service(self):
|
||||
if self.pservice_id:
|
||||
pservice = PresenceService.get_instance()
|
||||
pservice = presenceservice.get_instance()
|
||||
return pservice.get_activity(self.pservice_id)
|
||||
else:
|
||||
return None
|
||||
|
@ -1,7 +1,7 @@
|
||||
sugardir = $(pythondir)/sugar/presence
|
||||
sugar_PYTHON = \
|
||||
__init__.py \
|
||||
Activity.py \
|
||||
Buddy.py \
|
||||
PresenceService.py \
|
||||
Service.py
|
||||
activity.py \
|
||||
buddy.py \
|
||||
presenceservice.py
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2006, Red Hat, Inc.
|
||||
# Copyright (C) 2007, Red Hat, Inc.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@ -25,14 +25,12 @@ class Activity(gobject.GObject):
|
||||
([gobject.TYPE_PYOBJECT])),
|
||||
'buddy-left': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
([gobject.TYPE_PYOBJECT])),
|
||||
'service-appeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
([gobject.TYPE_PYOBJECT])),
|
||||
'service-disappeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
'new-channel': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
([gobject.TYPE_PYOBJECT]))
|
||||
}
|
||||
|
||||
_PRESENCE_SERVICE = "org.laptop.Presence"
|
||||
_ACTIVITY_DBUS_INTERFACE = "org.laptop.Presence.Activity"
|
||||
_PRESENCE_SERVICE = "org.laptop.Sugar.Presence"
|
||||
_ACTIVITY_DBUS_INTERFACE = "org.laptop.Sugar.Presence.Activity"
|
||||
|
||||
def __init__(self, bus, new_obj_cb, del_obj_cb, object_path):
|
||||
gobject.GObject.__init__(self)
|
||||
@ -43,11 +41,13 @@ class Activity(gobject.GObject):
|
||||
self._activity = dbus.Interface(bobj, self._ACTIVITY_DBUS_INTERFACE)
|
||||
self._activity.connect_to_signal('BuddyJoined', self._buddy_joined_cb)
|
||||
self._activity.connect_to_signal('BuddyLeft', self._buddy_left_cb)
|
||||
self._activity.connect_to_signal('ServiceAppeared', self._service_appeared_cb)
|
||||
self._activity.connect_to_signal('ServiceDisappeared', self._service_disappeared_cb)
|
||||
|
||||
self._activity.connect_to_signal('NewChannel', self._new_channel_cb)
|
||||
|
||||
self._id = None
|
||||
self._color = None
|
||||
self._name = None
|
||||
self._type = None
|
||||
self._joined = False
|
||||
|
||||
def object_path(self):
|
||||
return self._object_path
|
||||
@ -66,52 +66,51 @@ class Activity(gobject.GObject):
|
||||
def _buddy_left_cb(self, object_path):
|
||||
gobject.idle_add(self._emit_buddy_left_signal, object_path)
|
||||
|
||||
def _emit_service_appeared_signal(self, object_path):
|
||||
self.emit('service-appeared', self._ps_new_object(object_path))
|
||||
def _emit_new_channel_signal(self, object_path):
|
||||
self.emit('new-channel', object_path)
|
||||
return False
|
||||
|
||||
def _service_appeared_cb(self, object_path):
|
||||
gobject.idle_add(self._emit_service_appeared_signal, object_path)
|
||||
|
||||
def _emit_service_disappeared_signal(self, object_path):
|
||||
self.emit('service-disappeared', self._ps_new_object(object_path))
|
||||
return False
|
||||
|
||||
def _service_disappeared_cb(self, object_path):
|
||||
gobject.idle_add(self._emit_service_disappeared_signal, object_path)
|
||||
def _new_channel_cb(self, object_path):
|
||||
gobject.idle_add(self._emit_new_channel_signal, object_path)
|
||||
|
||||
def get_id(self):
|
||||
# Cache activity ID, which should never change anyway
|
||||
if not self._id:
|
||||
self._id = self._activity.getId()
|
||||
self._id = self._activity.GetId()
|
||||
return self._id
|
||||
|
||||
def get_color(self):
|
||||
if not self._color:
|
||||
self._color = self._activity.getColor()
|
||||
self._color = self._activity.GetColor()
|
||||
return self._color
|
||||
|
||||
def get_services(self):
|
||||
resp = self._activity.getServices()
|
||||
servs = []
|
||||
for item in resp:
|
||||
servs.append(self._ps_new_object(item))
|
||||
return servs
|
||||
def get_name(self):
|
||||
if not self._name:
|
||||
self._name = self._activity.GetName()
|
||||
return self._name
|
||||
|
||||
def get_services_of_type(self, stype):
|
||||
resp = self._activity.getServicesOfType(stype)
|
||||
servs = []
|
||||
for item in resp:
|
||||
servs.append(self._ps_new_object(item))
|
||||
return servs
|
||||
def get_type(self):
|
||||
if not self._type:
|
||||
self._type = self._activity.GetType()
|
||||
return self._type
|
||||
|
||||
def get_joined_buddies(self):
|
||||
resp = self._activity.getJoinedBuddies()
|
||||
resp = self._activity.GetJoinedBuddies()
|
||||
buddies = []
|
||||
for item in resp:
|
||||
buddies.append(self._ps_new_object(item))
|
||||
return buddies
|
||||
|
||||
def join(self):
|
||||
if self._joined:
|
||||
return
|
||||
self._activity.Join()
|
||||
self._joined = True
|
||||
|
||||
def get_channels(self):
|
||||
(bus_name, connection, channels) = self._activity.GetChannels()
|
||||
return bus_name, connection, channels
|
||||
|
||||
def owner_has_joined(self):
|
||||
# FIXME
|
||||
return False
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2006, Red Hat, Inc.
|
||||
# Copyright (C) 2007, Red Hat, Inc.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@ -24,24 +24,25 @@ class Buddy(gobject.GObject):
|
||||
__gsignals__ = {
|
||||
'icon-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
([])),
|
||||
'disappeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
([])),
|
||||
'service-appeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
([gobject.TYPE_PYOBJECT])),
|
||||
'service-disappeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
([gobject.TYPE_PYOBJECT])),
|
||||
'joined-activity': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
([gobject.TYPE_PYOBJECT])),
|
||||
'left-activity': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
([gobject.TYPE_PYOBJECT])),
|
||||
'property-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
([gobject.TYPE_PYOBJECT])),
|
||||
'current-activity-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
([gobject.TYPE_PYOBJECT]))
|
||||
}
|
||||
|
||||
_PRESENCE_SERVICE = "org.laptop.Presence"
|
||||
_BUDDY_DBUS_INTERFACE = "org.laptop.Presence.Buddy"
|
||||
__gproperties__ = {
|
||||
'key' : (str, None, None, None, gobject.PARAM_READABLE),
|
||||
'icon' : (object, None, None, gobject.PARAM_READABLE),
|
||||
'nick' : (str, None, None, None, gobject.PARAM_READABLE),
|
||||
'color' : (str, None, None, None, gobject.PARAM_READABLE),
|
||||
'current-activity' : (str, None, None, None, gobject.PARAM_READABLE),
|
||||
'owner' : (bool, None, None, False, gobject.PARAM_READABLE)
|
||||
}
|
||||
|
||||
_PRESENCE_SERVICE = "org.laptop.Sugar.Presence"
|
||||
_BUDDY_DBUS_INTERFACE = "org.laptop.Sugar.Presence.Buddy"
|
||||
|
||||
def __init__(self, bus, new_obj_cb, del_obj_cb, object_path):
|
||||
gobject.GObject.__init__(self)
|
||||
@ -52,62 +53,61 @@ class Buddy(gobject.GObject):
|
||||
bobj = bus.get_object(self._PRESENCE_SERVICE, object_path)
|
||||
self._buddy = dbus.Interface(bobj, self._BUDDY_DBUS_INTERFACE)
|
||||
self._buddy.connect_to_signal('IconChanged', self._icon_changed_cb)
|
||||
self._buddy.connect_to_signal('ServiceAppeared', self._service_appeared_cb)
|
||||
self._buddy.connect_to_signal('ServiceDisappeared', self._service_disappeared_cb)
|
||||
self._buddy.connect_to_signal('Disappeared', self._disappeared_cb)
|
||||
self._buddy.connect_to_signal('JoinedActivity', self._joined_activity_cb)
|
||||
self._buddy.connect_to_signal('LeftActivity', self._left_activity_cb)
|
||||
self._buddy.connect_to_signal('PropertyChanged', self._property_changed_cb)
|
||||
self._buddy.connect_to_signal('CurrentActivityChanged', self._current_activity_changed_cb)
|
||||
self._properties = self._get_properties_helper()
|
||||
|
||||
self._current_activity = None
|
||||
try:
|
||||
self._current_activity = self._buddy.getCurrentActivity()
|
||||
except Exception, e:
|
||||
pass
|
||||
self._activities = {}
|
||||
self._icon = None
|
||||
|
||||
def _get_properties_helper(self):
|
||||
props = self._buddy.getProperties()
|
||||
props = self._buddy.GetProperties()
|
||||
if not props:
|
||||
return {}
|
||||
return props
|
||||
|
||||
def do_get_property(self, pspec):
|
||||
if pspec.name == "key":
|
||||
return self._properties["key"]
|
||||
elif pspec.name == "nick":
|
||||
return self._properties["nick"]
|
||||
elif pspec.name == "color":
|
||||
return self._properties["color"]
|
||||
elif pspec.name == "current-activity":
|
||||
if not self._properties.has_key("current-activity"):
|
||||
return None
|
||||
curact = self._properties["current-activity"]
|
||||
if not len(curact):
|
||||
return None
|
||||
if not self._activities.has_key(curact):
|
||||
return None
|
||||
return self._activities[curact]
|
||||
elif pspec.name == "owner":
|
||||
return self._properties["owner"]
|
||||
elif pspec.name == "icon":
|
||||
if not self._icon:
|
||||
self._icon = self._buddy.GetIcon()
|
||||
return self._icon
|
||||
|
||||
def object_path(self):
|
||||
return self._object_path
|
||||
|
||||
def _emit_icon_changed_signal(self):
|
||||
self._icon = self._buddy.GetIcon()
|
||||
self.emit('icon-changed')
|
||||
return False
|
||||
|
||||
def _icon_changed_cb(self):
|
||||
gobject.idle_add(self._emit_icon_changed_signal)
|
||||
|
||||
def _emit_disappeared_signal(self):
|
||||
self.emit('disappeared')
|
||||
|
||||
def _disappeared_cb(self):
|
||||
gobject.idle_add(self._emit_disappeared_signal)
|
||||
|
||||
def _emit_service_appeared_signal(self, object_path):
|
||||
self.emit('service-appeared', self._ps_new_object(object_path))
|
||||
return False
|
||||
|
||||
def _service_appeared_cb(self, object_path):
|
||||
gobject.idle_add(self._emit_service_appeared_signal, object_path)
|
||||
|
||||
def _emit_service_disappeared_signal(self, object_path):
|
||||
self.emit('service-disappeared', self._ps_new_object(object_path))
|
||||
return False
|
||||
|
||||
def _service_disappeared_cb(self, object_path):
|
||||
gobject.idle_add(self._emit_service_disappeared_signal, object_path)
|
||||
|
||||
def _emit_joined_activity_signal(self, object_path):
|
||||
self.emit('joined-activity', self._ps_new_object(object_path))
|
||||
return False
|
||||
|
||||
def _joined_activity_cb(self, object_path):
|
||||
if not self._activities.has_key(object_path):
|
||||
self._activities[object_path] = self._ps_new_object(object_path)
|
||||
gobject.idle_add(self._emit_joined_activity_signal, object_path)
|
||||
|
||||
def _emit_left_activity_signal(self, object_path):
|
||||
@ -115,56 +115,24 @@ class Buddy(gobject.GObject):
|
||||
return False
|
||||
|
||||
def _left_activity_cb(self, object_path):
|
||||
if self._activities.has_key(object_path):
|
||||
del self._activities[object_path]
|
||||
gobject.idle_add(self._emit_left_activity_signal, object_path)
|
||||
|
||||
def _handle_property_changed_signal(self, prop_list):
|
||||
self._properties = self._get_properties_helper()
|
||||
# FIXME: don't leak unexposed property names
|
||||
self.emit('property-changed', prop_list)
|
||||
return False
|
||||
|
||||
def _property_changed_cb(self, prop_list):
|
||||
gobject.idle_add(self._handle_property_changed_signal, prop_list)
|
||||
|
||||
def _handle_current_activity_changed_signal(self, act_list):
|
||||
if len(act_list) == 0:
|
||||
self._current_activity = None
|
||||
self.emit('current-activity-changed', None)
|
||||
else:
|
||||
self._current_activity = act_list[0]
|
||||
self.emit('current-activity-changed', self._ps_new_object(act_list[0]))
|
||||
return False
|
||||
|
||||
def _current_activity_changed_cb(self, act_list):
|
||||
gobject.idle_add(self._handle_current_activity_changed_signal, act_list)
|
||||
|
||||
def get_name(self):
|
||||
return self._properties['name']
|
||||
|
||||
def get_ip4_address(self):
|
||||
return self._properties['ip4_address']
|
||||
|
||||
def is_owner(self):
|
||||
return self._properties['owner']
|
||||
|
||||
def get_color(self):
|
||||
return self._properties['color']
|
||||
|
||||
def get_icon(self):
|
||||
return self._buddy.getIcon()
|
||||
|
||||
def get_current_activity(self):
|
||||
if not self._current_activity:
|
||||
return None
|
||||
return self._ps_new_object(self._current_activity)
|
||||
|
||||
def get_icon_pixbuf(self):
|
||||
icon = self._buddy.getIcon()
|
||||
if icon and len(icon):
|
||||
if self.props.icon and len(self.props.icon):
|
||||
pbl = gtk.gdk.PixbufLoader()
|
||||
icon_data = ""
|
||||
for item in icon:
|
||||
if item < 0:
|
||||
item = item + 128
|
||||
for item in self.props.icon:
|
||||
icon_data = icon_data + chr(item)
|
||||
pbl.write(icon_data)
|
||||
pbl.close()
|
||||
@ -172,19 +140,9 @@ class Buddy(gobject.GObject):
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_service_of_type(self, stype, activity=None):
|
||||
try:
|
||||
act_op = "/"
|
||||
if activity:
|
||||
act_op = activity.object_path()
|
||||
object_path = self._buddy.getServiceOfType(stype, act_op)
|
||||
except dbus.exceptions.DBusException:
|
||||
return None
|
||||
return self._ps_new_object(object_path)
|
||||
|
||||
def get_joined_activities(self):
|
||||
try:
|
||||
resp = self._buddy.getJoinedActivities()
|
||||
resp = self._buddy.GetJoinedActivities()
|
||||
except dbus.exceptions.DBusException:
|
||||
return []
|
||||
acts = []
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2006, Red Hat, Inc.
|
||||
# Copyright (C) 2007, Red Hat, Inc.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
import dbus, dbus.glib, gobject
|
||||
|
||||
import buddy, service, activity
|
||||
import buddy, activity
|
||||
|
||||
class ObjectCache(object):
|
||||
def __init__(self):
|
||||
@ -63,7 +63,6 @@ class PresenceService(gobject.GObject):
|
||||
}
|
||||
|
||||
_PS_BUDDY_OP = DBUS_PATH + "/Buddies/"
|
||||
_PS_SERVICE_OP = DBUS_PATH + "/Services/"
|
||||
_PS_ACTIVITY_OP = DBUS_PATH + "/Activities/"
|
||||
|
||||
|
||||
@ -83,10 +82,7 @@ class PresenceService(gobject.GObject):
|
||||
def _new_object(self, object_path):
|
||||
obj = self._objcache.get(object_path)
|
||||
if not obj:
|
||||
if object_path.startswith(self._PS_SERVICE_OP):
|
||||
obj = Service.Service(self._bus, self._new_object,
|
||||
self._del_object, object_path)
|
||||
elif object_path.startswith(self._PS_BUDDY_OP):
|
||||
if object_path.startswith(self._PS_BUDDY_OP):
|
||||
obj = Buddy.Buddy(self._bus, self._new_object,
|
||||
self._del_object, object_path)
|
||||
elif object_path.startswith(self._PS_ACTIVITY_OP):
|
||||
@ -115,19 +111,20 @@ class PresenceService(gobject.GObject):
|
||||
def _buddy_disappeared_cb(self, object_path):
|
||||
gobject.idle_add(self._emit_buddy_disappeared_signal, object_path)
|
||||
|
||||
def _emit_service_appeared_signal(self, object_path):
|
||||
self.emit('service-appeared', self._new_object(object_path))
|
||||
def _emit_activity_invitation_signal(self, object_path):
|
||||
self.emit('activity-invitation', self._new_object(object_path))
|
||||
return False
|
||||
|
||||
def _service_appeared_cb(self, object_path):
|
||||
gobject.idle_add(self._emit_service_appeared_signal, object_path)
|
||||
def _activity_invitation_cb(self, object_path):
|
||||
gobject.idle_add(self._emit_activity_invitation_signal, object_path)
|
||||
|
||||
def _emit_service_disappeared_signal(self, object_path):
|
||||
self.emit('service-disappeared', self._new_object(object_path))
|
||||
def _emit_private_invitation_signal(self, bus_name, connection, channel):
|
||||
self.emit('service-disappeared', bus_name, connection, channel)
|
||||
return False
|
||||
|
||||
def _service_disappeared_cb(self, object_path):
|
||||
gobject.idle_add(self._emit_service_disappeared_signal, object_path)
|
||||
def _private_invitation_cb(self, bus_name, connection, channel):
|
||||
gobject.idle_add(self._emit_service_disappeared_signal, bus_name,
|
||||
connection, channel)
|
||||
|
||||
def _emit_activity_appeared_signal(self, object_path):
|
||||
self.emit('activity-appeared', self._new_object(object_path))
|
||||
@ -146,22 +143,8 @@ class PresenceService(gobject.GObject):
|
||||
def get(self, object_path):
|
||||
return self._new_object(object_path)
|
||||
|
||||
def get_services(self):
|
||||
resp = self._ps.getServices()
|
||||
servs = []
|
||||
for item in resp:
|
||||
servs.append(self._new_object(item))
|
||||
return servs
|
||||
|
||||
def get_services_of_type(self, stype):
|
||||
resp = self._ps.getServicesOfType(stype)
|
||||
servs = []
|
||||
for item in resp:
|
||||
servs.append(self._new_object(item))
|
||||
return servs
|
||||
|
||||
def get_activities(self):
|
||||
resp = self._ps.getActivities()
|
||||
resp = self._ps.GetActivities()
|
||||
acts = []
|
||||
for item in resp:
|
||||
acts.append(self._new_object(item))
|
||||
@ -169,7 +152,7 @@ class PresenceService(gobject.GObject):
|
||||
|
||||
def get_activity(self, activity_id):
|
||||
try:
|
||||
act_op = self._ps.getActivity(activity_id)
|
||||
act_op = self._ps.GetActivityById(activity_id)
|
||||
except dbus.exceptions.DBusException:
|
||||
return None
|
||||
return self._new_object(act_op)
|
||||
@ -181,49 +164,27 @@ class PresenceService(gobject.GObject):
|
||||
buddies.append(self._new_object(item))
|
||||
return buddies
|
||||
|
||||
def get_buddy_by_name(self, name):
|
||||
def get_buddy(self, key):
|
||||
try:
|
||||
buddy_op = self._ps.getBuddyByName(name)
|
||||
except dbus.exceptions.DBusException:
|
||||
return None
|
||||
return self._new_object(buddy_op)
|
||||
|
||||
def get_buddy_by_address(self, addr):
|
||||
try:
|
||||
buddy_op = self._ps.getBuddyByAddress(addr)
|
||||
buddy_op = self._ps.GetBuddyByPublicKey(dbus.ByteArray(key))
|
||||
except dbus.exceptions.DBusException:
|
||||
return None
|
||||
return self._new_object(buddy_op)
|
||||
|
||||
def get_owner(self):
|
||||
try:
|
||||
owner_op = self._ps.getOwner()
|
||||
owner_op = self._ps.GetOwner()
|
||||
except dbus.exceptions.DBusException:
|
||||
return None
|
||||
return self._new_object(owner_op)
|
||||
|
||||
def share_activity(self, activity, stype, properties={}, address=None, port=-1, domain=u"local"):
|
||||
def share_activity(self, activity, properties={}):
|
||||
actid = activity.get_id()
|
||||
if address == None:
|
||||
address = u""
|
||||
serv_op = self._ps.shareActivity(actid, stype, properties, address, port, domain)
|
||||
atype = activity.get_service_name()
|
||||
name = activity.props.title
|
||||
serv_op = self._ps.ShareActivity(actid, atype, name, properties)
|
||||
return self._new_object(serv_op)
|
||||
|
||||
def register_service(self, name, stype, properties={}, address=None, port=-1, domain=u"local"):
|
||||
if address == None:
|
||||
address = u""
|
||||
serv_op = self._ps.registerService(name, stype, properties, address, port, domain)
|
||||
return self._new_object(serv_op)
|
||||
|
||||
def unregister_service(self, service):
|
||||
self._ps.unregisterService(service.object_path())
|
||||
|
||||
def register_service_type(self, stype):
|
||||
self._ps.registerServiceType(stype)
|
||||
|
||||
def unregister_service_type(self, stype):
|
||||
self._ps.unregisterServiceType(stype)
|
||||
|
||||
_ps = None
|
||||
def get_instance():
|
||||
global _ps
|
||||
|
Loading…
Reference in New Issue
Block a user