本文整理汇总了Python中sugar3.presence.presenceservice.get_instance函数的典型用法代码示例。如果您正苦于以下问题:Python get_instance函数的具体用法?Python get_instance怎么用?Python get_instance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_instance函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, handle, *args, **kwargs):
'''
Initialize the ShareableActivity class.
Kwargs:
service_path
'''
activity.Activity.__init__(self, handle, *args, **kwargs)
self._sync_hid = None
self._message_cbs = {}
self._connection = None
self._tube_conn = None
self._pservice = presenceservice.get_instance()
self._owner = self._pservice.get_owner()
self._owner_id = str(self._owner.props.nick)
self._service_path = kwargs.get('service_path',
self._generate_service_path())
self._dbus_object = None
_logger.debug('Setting service name %s, service path %s',
IFACE, self._service_path)
self._connect_to_ps()
示例2: __init__
def __init__(self, handle):
activity.Activity.__init__(self, handle)
self.set_title("SocialCalc")
self._logger = logging.getLogger("OnePageWiki-Activity")
# The XOCom object helps us communicate with the browser
# This uses web/index.html as the default page to load
self.xocom = XOCom(
self.control_sending_text
) # REMEMBER THAT I HAVE STILL TO SEND THE ARGUMENT IN THE XOCOM CLASS
toolbox = ToolbarBox()
activity_button = ActivityButton(self)
toolbox.toolbar.insert(activity_button, 0)
activity_button.show()
title_entry = TitleEntry(self)
toolbox.toolbar.insert(title_entry, -1)
title_entry.show()
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
toolbox.toolbar.insert(separator, -1)
separator.show()
stop_button = ShareButton(self)
toolbox.toolbar.insert(stop_button, -1)
stop_button.show()
self.set_toolbar_box(toolbox)
toolbox.show()
stop_button = StopButton(self)
toolbox.toolbar.insert(stop_button, -1)
stop_button.show()
self.set_toolbar_box(toolbox)
toolbox.show()
##self.xocom.send_to_browser_localize(['initlocalize'])
self.set_canvas(self.xocom.create_webview())
self.hellotube = None # Shared session #REQUIRED
self.initiating = False
self.pservice = presenceservice.get_instance()
owner = self.pservice.get_owner()
self.owner = owner
self.connect("shared", self._shared_cb)
self.connect("joined", self._joined_cb)
self.filename = "" # ADDED SPECIFICALLY TO CALL WRITE AND READ METHODS
self.content = ""
# calling to initialize strings in localization
# should wait for init complete from browser
GObject.timeout_add(4000, self.xocom.send_to_browser_localize, ["initlocalize"])
示例3: __share_menu_cb
def __share_menu_cb(self, menu_item):
if self._account.url_cache is None:
pservice = presenceservice.get_instance()
if self._activity_id is not None:
logging.debug('getting shared activity from activity id')
self._shared_activity = pservice.get_activity(
self._activity_id, warn_if_none=False)
else:
logging.error('Cannot get activity from pservice.')
self.emit('transfer-state-changed',
_('Cannot join Journal Share activity'))
return
# We set up sharing in the same way as
# sugar-toolkit-gtk3/src/sugar3/activity/activity.py
# There's already an instance on the mesh, so join it
logging.debug('*** Act %s joining existing mesh instance %r',
self._activity_id, self._shared_activity)
self._join_id = self._shared_activity.connect('joined',
self.__joined_cb)
self._shared_activity.join()
else:
logging.debug('skipping join setup')
self.__joined_cb(self, True, '')
示例4: _object_added_cb
def _object_added_cb(self, cb_service, cb_object):
""" Code snippet to tag clipboard objects from shared activities """
shell = get_model()
logging.debug(shell.get_active_activity())
current = shell.get_active_activity()
active_id = current.get_activity_id()
logging.debug(active_id)
pservice = presenceservice.get_instance()
instance = pservice.get_activity(active_id, warn_if_none=False)
""" For a shared activity should have a pservice entry """
if instance is None:
return
logging.debug("cbobject path " + str(cb_object.get_id()))
if self._icons:
group = self._icons.values()[0]
else:
group = None
icon = ClipboardIcon(cb_object, group)
self.add_item(icon)
icon.show()
self._icons[cb_object.get_id()] = icon
objects_to_delete = self.get_children()[:-self.MAX_ITEMS]
for icon in objects_to_delete:
logging.debug('ClipboardTray: deleting surplus object')
cb_service = clipboard.get_instance()
cb_service.delete_object(icon.get_object_id())
logging.debug('ClipboardTray: %r was added', cb_object.get_id())
示例5: __init__
def __init__(self, handle):
Activity.__init__(self, handle)
# Self-Enforced max_participants
self.max_participants = SUGAR_MAX_PARTICIPANTS
# Prepare Storage Components
self.network_stack = None
self.gstreamer_stack = None
# Set Owner
self.owner = presenceservice.get_instance().get_owner()
""" Setup GUI """
logger.debug("Preparing GUI")
self.set_canvas(Gui(self))
""" Setup GSTStack """
logger.debug("Setting up GSTStack")
self.gststack = GSTStack()
self.get_canvas().set_gstreamer_stack(self.gststack);
""" Setup Network Stack """
logger.debug("Connect Event to Setup Network Stack on Demand")
self.establish_activity_sharing(handle)
示例6: _get_buddy
def _get_buddy(self, cs_handle):
'''Get a Buddy from a (possibly channel-specific) handle.'''
# XXX This will be made redundant once Presence Service
# provides buddy resolution
# Get the Presence Service
pservice = presenceservice.get_instance()
# Get the Telepathy Connection
tp_name, tp_path = pservice.get_preferred_connection()
conn = Connection(tp_name, tp_path)
group = self._text_chan[CHANNEL_INTERFACE_GROUP]
my_csh = group.GetSelfHandle()
if my_csh == cs_handle:
handle = conn.GetSelfHandle()
elif (group.GetGroupFlags() &
CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES):
handle = group.GetHandleOwners([cs_handle])[0]
else:
handle = cs_handle
# XXX: deal with failure to get the handle owner
assert handle != 0
return pservice.get_buddy_by_telepathy_handle(
tp_name, tp_path, handle)
示例7: _setup_presence_service
def _setup_presence_service(self):
''' Setup the Presence Service. '''
self.pservice = presenceservice.get_instance()
owner = self.pservice.get_owner()
self.owner = owner
self._share = ''
self.connect('shared', self._shared_cb)
self.connect('joined', self._joined_cb)
示例8: _setup_presence_service
def _setup_presence_service(self):
""" Setup the Presence Service. """
self.pservice = presenceservice.get_instance()
self.initiating = None # sharing (True) or joining (False)
owner = self.pservice.get_owner()
self.owner = owner
self._share = ""
self.connect('shared', self._shared_cb)
self.connect('joined', self._joined_cb)
示例9: _setup_presence_service
def _setup_presence_service(self):
''' Setup the Presence Service. '''
self.pservice = presenceservice.get_instance()
self.initiating = None # sharing (True) or joining (False)
owner = self.pservice.get_owner()
self.owner = owner
self.vmw.buddies.append(self.owner)
self._share = ''
self.connect('shared', self._shared_cb)
self.connect('joined', self._joined_cb)
示例10: _send_invites
def _send_invites(self):
while self._invites_queue:
account_path, contact_id = self._invites_queue.pop()
pservice = presenceservice.get_instance()
buddy = pservice.get_buddy(account_path, contact_id)
if buddy:
self.shared_activity.invite(
buddy, '', self._invite_response_cb)
else:
logging.error('Cannot invite %s %s, no such buddy',
account_path, contact_id)
示例11: add_buddy
def add_buddy(self, buddy):
"""
Passes buddy nick to ovc
"""
if buddy == presenceservice.get_instance().get_owner():
return
if buddy:
nick = buddy.props.nick
else:
nick = '???'
self.activity.net_cb('buddy_add', nick)
示例12: __init__
def __init__(self, activity, buddy_joined_cb, buddy_left_cb, play_cb, undostack, bootstrap):
self.activity = activity
self.buddy_joined = buddy_joined_cb
self.buddy_left = buddy_left_cb
self.Play_cb = play_cb
self.undostack = undostack
self.bootstrap = bootstrap
self.world = False
self.entered = False
self.presence_service = presenceservice.get_instance()
self.owner = self.presence_service.get_owner()
示例13: setup
def setup(self):
# TODO: hand off role of master if sharer leaves
self.pservice = presenceservice.get_instance()
self.initiating = None # sharing (True) or joining (False)
# Add my buddy object to the list
owner = self.pservice.get_owner()
self.owner = owner
self._tw.buddies.append(self.owner)
self._share = ''
self._activity.connect('shared', self._shared_cb)
self._activity.connect('joined', self._joined_cb)
示例14: _setup_presence_service
def _setup_presence_service(self):
""" Setup the Presence Service. """
self.pservice = presenceservice.get_instance()
self.initiating = None # sharing (True) or joining (False)
owner = self.pservice.get_owner()
self.owner = owner
self._game.buddies.append(self.nick)
self._player_colors = [self.colors]
self._player_pixbuf = [svg_str_to_pixbuf(
generate_xo(scale=0.8, colors=self.colors))]
self._share = ""
self.connect('shared', self._shared_cb)
self.connect('joined', self._joined_cb)
示例15: init_context
def init_context(self, args):
"""Init Javascript context sending buddy information"""
# Get XO colors
buddy = {}
client = gconf.client_get_default()
colors = client.get_string("/desktop/sugar/user/color")
buddy["colors"] = colors.split(",")
# Get XO name
presenceService = presenceservice.get_instance()
buddy["name"] = presenceService.get_owner().props.nick
self.enyo.send_message("buddy", buddy)
if self.context != {}:
self.enyo.send_message("load-context", self.context)