示例#1
0
	def get_handle_by_name(self, handleType, handleName):
		requestedHandleName = handleName.encode('utf-8')
		if handleType == telepathy.HANDLE_TYPE_CONTACT:
			h = handle.create_handle(self, 'contact', requestedHandleName)
		elif handleType == telepathy.HANDLE_TYPE_LIST:
			# Support only server side (immutable) lists
			h = handle.create_handle(self, 'list', requestedHandleName)
		else:
			raise telepathy.errors.NotAvailable('Handle type unsupported %d' % handleType)
		return h
示例#2
0
	def _process_refresh(self, addressbook, added, removed, changed):
		_moduleLogger.info(
			"%s Added: %r, Removed: %r" % (self.__listHandle.get_name(), len(added), len(removed))
		)
		connection = self._conn

		# convert changed into added/removed
		alsoAdded = set(
			number
			for number in changed
			if self._is_now_on_list(number)
		)
		alsoRemoved = set(
			number
			for number in changed
			if self._was_on_list(number)
		)

		# Merge the added/removed with changed
		added = [
			contactNumber
			for contactNumber in added
			if self._is_on_list(contactNumber)
		]
		added.extend(alsoAdded)
		added.sort()
		handlesAdded = [
			handle.create_handle(connection, "contact", contactNumber)
			for contactNumber in added
		]
		self.__members.union(added)

		removed = list(removed)
		removed.extend(alsoRemoved)
		handlesRemoved = [
			handle.create_handle(connection, "contact", contactNumber)
			for contactNumber in removed
		]
		self.__members.difference(removed)

		message = ""
		actor = 0
		reason = telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE
		self.MembersChanged(
			message,
			handlesAdded, handlesRemoved,
			(), (),
			actor,
			reason,
		)
示例#3
0
	def __init__(self, manager, parameters):
		self.check_parameters(parameters)

		# Connection init must come first
		self.__options = BluewireOptions(parameters)
		self.__session = protocol.session.Session(
			defaults = {
				"contacts": (self.__options.contactsPollPeriodInHours, "hours"),
			},
		)
		tp.Connection.__init__(
			self,
			constants._telepathy_protocol_name_,
			"device",
			constants._telepathy_implementation_name_
		)
		aliasing.AliasingMixin.__init__(self)
		#avatars.AvatarsMixin.__init__(self)
		#capabilities.CapabilitiesMixin.__init__(self)
		#contacts.ContactsMixin.__init__(self)
		presence.PresenceMixin.__init__(self)
		requests.RequestsMixin.__init__(self)
		simple_presence.SimplePresenceMixin.__init__(self)

		self.__manager = weakref.proxy(manager)
		self.__channelManager = channel_manager.ChannelManager(self)

		self.set_self_handle(handle.create_handle(self, 'connection'))
		self._plumbing = [
			autogv.AutoDisconnect(weakref.ref(self)),
		]

		_moduleLogger.info("Connection created")
		self._timedDisconnect = autogv.TimedDisconnect(weakref.ref(self))
		self._timedDisconnect.start()
示例#4
0
    def get_handle_by_name(self, handleType, handleName):
        requestedHandleName = handleName.encode("utf-8")

        # We need to return an existing or create a new handle.  Unfortunately
        # handle init's take care of normalizing the handle name.  So we have
        # to create a new handle regardless and burn some handle id's and burn
        # some extra memory of creating objects we throw away if the handle
        # already exists.
        if handleType == telepathy.HANDLE_TYPE_CONTACT:
            h = handle.create_handle(self, "contact", requestedHandleName)
        elif handleType == telepathy.HANDLE_TYPE_LIST:
            # Support only server side (immutable) lists
            h = handle.create_handle(self, "list", requestedHandleName)
        else:
            raise telepathy.errors.NotAvailable("Handle type unsupported %d" % handleType)

        for candidate in self._handles.itervalues():
            if candidate.get_name() == h.get_name():
                h = candidate
                _moduleLogger.debug("Re-used handle for %s, I hoped this helped" % handleName)
                break

        return h