From: Ed Page Date: Wed, 6 Jan 2010 01:09:56 +0000 (-0600) Subject: Misc cleanup X-Git-Url: http://git.maemo.org/git/?p=theonering;a=commitdiff_plain;h=9c912670ff9941470952aa4083cc40528b666d50 Misc cleanup --- diff --git a/src/aliasing.py b/src/aliasing.py index bf73e06..a05e4fe 100644 --- a/src/aliasing.py +++ b/src/aliasing.py @@ -6,12 +6,6 @@ import gtk_toolbox import handle -USER_ALIAS_ACCOUNT = "account" -USER_ALIAS_CALLBACK = "callback" - -USER_ALIAS = USER_ALIAS_ACCOUNT - - _moduleLogger = logging.getLogger('aliasing') @@ -67,6 +61,9 @@ def make_pretty(phonenumber): class AliasingMixin(telepathy.server.ConnectionInterfaceAliasing): + USER_ALIAS_ACCOUNT = "account" + USER_ALIAS_CALLBACK = "callback" + def __init__(self): telepathy.server.ConnectionInterfaceAliasing.__init__(self) @@ -77,6 +74,13 @@ class AliasingMixin(telepathy.server.ConnectionInterfaceAliasing): """ raise NotImplementedError("Abstract property called") + @property + def userAliasType(self): + """ + @abstract + """ + raise NotImplementedError("Abstract property called") + def handle(self, handleType, handleId): """ @abstract @@ -105,10 +109,10 @@ class AliasingMixin(telepathy.server.ConnectionInterfaceAliasing): @gtk_toolbox.log_exception(_moduleLogger) def SetAliases(self, aliases): _moduleLogger.debug("Called SetAliases") - if USER_ALIAS == USER_ALIAS_ACCOUNT: + if self.userAliasType == self.USER_ALIAS_ACCOUNT: raise telepathy.errors.PermissionDenied("No user customizable aliases") - elif USER_ALIAS != USER_ALIAS_CALLBACK: - raise RuntimeError("Invalid alias type: %r" % USER_ALIAS) + elif self.userAliasType != self.USER_ALIAS_CALLBACK: + raise RuntimeError("Invalid alias type: %r" % self.userAliasType) # first validate that no other handle types are included userHandleAndAlias = None @@ -132,12 +136,12 @@ class AliasingMixin(telepathy.server.ConnectionInterfaceAliasing): def _get_alias(self, handleId): h = self.handle(telepathy.HANDLE_TYPE_CONTACT, handleId) if isinstance(h, handle.ConnectionHandle): - if USER_ALIAS == USER_ALIAS_CALLBACK: + if self.userAliasType == self.USER_ALIAS_CALLBACK: aliasNumber = self.session.backend.get_callback_number() - elif USER_ALIAS == USER_ALIAS_ACCOUNT: + elif self.userAliasType == self.USER_ALIAS_ACCOUNT: aliasNumber = self.session.backend.get_account_number() else: - raise RuntimeError("Invalid alias type: %r" % USER_ALIAS) + raise RuntimeError("Invalid alias type: %r" % self.userAliasType) userAlias = make_pretty(aliasNumber) return userAlias else: diff --git a/src/connection.py b/src/connection.py index 5f5ad3d..8c29f83 100644 --- a/src/connection.py +++ b/src/connection.py @@ -87,6 +87,10 @@ class TheOneRingConnection( def username(self): return self._credentials[0] + @property + def userAliasType(self): + return self.USER_ALIAS_ACCOUNT + def handle(self, handleType, handleId): self.check_handle(handleType, handleId) return self._handles[handleType, handleId] @@ -202,26 +206,37 @@ class TheOneRingConnection( handles = [] for name in names: - name = name.encode('utf-8') + requestedHandleName = name.encode('utf-8') if handleType == telepathy.HANDLE_TYPE_CONTACT: - _moduleLogger.info("RequestHandles Contact: %s" % name) - h = self._create_contact_handle(name) + _moduleLogger.info("RequestHandles Contact: %s" % requestedHandleName) + requestedContactId, requestedContactNumber = handle.ContactHandle.from_handle_name( + requestedHandleName + ) + h = handle.create_handle(self, 'contact', requestedContactId, requestedContactNumber) elif handleType == telepathy.HANDLE_TYPE_LIST: # Support only server side (immutable) lists - _moduleLogger.info("RequestHandles List: %s" % name) - h = handle.create_handle(self, 'list', name) + _moduleLogger.info("RequestHandles List: %s" % requestedHandleName) + h = handle.create_handle(self, 'list', requestedHandleName) else: raise telepathy.errors.NotAvailable('Handle type unsupported %d' % handleType) handles.append(h.id) self.add_client_handle(h, sender) return handles - def _create_contact_handle(self, requestedHandleName): - requestedContactId, requestedContactNumber = handle.ContactHandle.from_handle_name( - requestedHandleName - ) - h = handle.create_handle(self, 'contact', requestedContactId, requestedContactNumber) - return h + def _generate_props(self, channelType, handle, suppressHandler, initiatorHandle=None): + targetHandle = 0 if handle is None else handle.get_id() + targetHandleType = telepathy.HANDLE_TYPE_NONE if handle is None else handle.get_type() + props = { + telepathy.CHANNEL_INTERFACE + '.ChannelType': channelType, + telepathy.CHANNEL_INTERFACE + '.TargetHandle': targetHandle, + telepathy.CHANNEL_INTERFACE + '.TargetHandleType': targetHandleType, + telepathy.CHANNEL_INTERFACE + '.Requested': suppressHandler + } + + if initiatorHandle is not None: + props[telepathy.CHANNEL_INTERFACE + '.InitiatorHandle'] = initiatorHandle.id + + return props @gobject_utils.async @gtk_toolbox.log_exception(_moduleLogger) diff --git a/src/gvoice/browser_emu.py b/src/gvoice/browser_emu.py index d574e6a..1641044 100644 --- a/src/gvoice/browser_emu.py +++ b/src/gvoice/browser_emu.py @@ -155,7 +155,7 @@ class MozillaEmulator(object): ) u.addheaders = [( 'User-Agent', - 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4' + 'Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.4) Gecko/20091016 Firefox/3.5.4 (.NET CLR 3.5.30729)' )] if not postdata is None: req.add_data(postdata) diff --git a/src/gvoice/state_machine.py b/src/gvoice/state_machine.py index 6080abd..1049d53 100644 --- a/src/gvoice/state_machine.py +++ b/src/gvoice/state_machine.py @@ -37,9 +37,9 @@ class StateMachine(object): _ACTION_RESET = "reset" _ACTION_STOP = "stop" - _INITIAL_ACTIVE_PERIOD = int(_to_milliseconds(seconds=5)) - _FINAL_ACTIVE_PERIOD = int(_to_milliseconds(minutes=2)) - _IDLE_PERIOD = int(_to_milliseconds(minutes=10)) + _INITIAL_ACTIVE_PERIOD = int(_to_milliseconds(seconds=10)) + _FINAL_ACTIVE_PERIOD = int(_to_milliseconds(minutes=10)) + _IDLE_PERIOD = int(_to_milliseconds(minutes=30)) _INFINITE_PERIOD = -1 _IS_DAEMON = True