Exemple #1
0
	def SetAliases(self, aliases):
		_moduleLogger.debug("Called SetAliases")
		# first validate that no other handle types are included
		handleId, alias = None, None
		for handleId, alias in aliases.iteritems():
			h = self.get_handle_by_id(telepathy.HANDLE_TYPE_CONTACT, handleId)
			if isinstance(h, handle.ConnectionHandle):
				break
		else:
			raise telepathy.errors.PermissionDenied("No user customizable aliases")

		uglyNumber = misc_utils.normalize_number(alias)
		if len(uglyNumber) == 0:
			# Reset to the original from login if one was provided
			uglyNumber = self.callbackNumberParameter
		if not misc_utils.is_valid_number(uglyNumber):
			raise telepathy.errors.InvalidArgument("Invalid phone number %r" % (uglyNumber, ))

		# Update callback
		self.session.backend.set_callback_number(uglyNumber)

		# Inform of change
		userAlias = make_pretty(uglyNumber)
		changedAliases = ((handleId, userAlias), )
		self.AliasesChanged(changedAliases)
Exemple #2
0
    def __init__(self, manager, parameters):
        self._loggers = []

        self.check_parameters(parameters)
        account = unicode(parameters["account"])
        encodedAccount = parameters["account"].encode("utf-8")
        encodedPassword = parameters["password"].encode("utf-8")
        encodedCallback = misc_utils.normalize_number(parameters["forward"].encode("utf-8"))
        if encodedCallback and not misc_utils.is_valid_number(encodedCallback):
            raise telepathy.errors.InvalidArgument("Invalid forwarding number")

            # Connection init must come first
        self.__options = TheOneRingOptions(parameters)
        self.__accountName = account
        self.__session = None
        tp.Connection.__init__(
            self, constants._telepathy_protocol_name_, account, constants._telepathy_implementation_name_
        )
        aliasing.AliasingMixin.__init__(self)
        avatars.AvatarsMixin.__init__(self)
        capabilities.CapabilitiesMixin.__init__(self)
        contacts.ContactsMixin.__init__(self)
        requests.RequestsMixin.__init__(self)
        simple_presence.TheOneRingPresence.__init__(self, self.__options.ignoreDND)
        simple_presence.SimplePresenceMixin.__init__(self, self)
        presence.PresenceMixin.__init__(self, self)

        self.__manager = weakref.proxy(manager)
        self.__credentials = (encodedAccount, encodedPassword)
        self.__callbackNumberParameter = encodedCallback
        self.__channelManager = channel_manager.ChannelManager(self)

        self.__cachePath = os.sep.join((constants._data_path_, "cache", self.username))
        try:
            os.makedirs(self.__cachePath)
        except OSError, e:
            if e.errno != 17:
                raise