X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fconnection.py;h=69ed50ce7c7f4df796bca7d89e34ace024f0fa15;hb=cd56d4ab7a3beaa59e8ef4a5d6c2624419038fee;hp=2db7df6ebfc276b411dae6362fd105a95521a2ff;hpb=8b77cf6f2a6b8f1ec930395d8f9b762fa1d4bfbc;p=theonering diff --git a/src/connection.py b/src/connection.py index 2db7df6..69ed50c 100644 --- a/src/connection.py +++ b/src/connection.py @@ -59,11 +59,16 @@ class TheOneRingConnection( self._callbackNumber = parameters['forward'].encode('utf-8') self._channelManager = channel_manager.ChannelManager(self) - cookieFilePath = "%s/cookies.txt" % constants._data_path_ + cookieFilePath = None self._session = gvoice.session.Session(cookieFilePath) self.set_self_handle(handle.create_handle(self, 'connection')) + self._callback = coroutines.func_sink( + coroutines.expand_positional( + self._on_conversations_updated + ) + ) _moduleLogger.info("Connection to the account %s created" % account) except Exception, e: _moduleLogger.exception("Failed to create Connection") @@ -96,6 +101,9 @@ class TheOneRingConnection( telepathy.CONNECTION_STATUS_REASON_REQUESTED ) try: + self.session.conversations.updateSignalHandler.register_sink( + self._callback + ) self.session.login(*self._credentials) self.session.backend.set_callback_number(self._callbackNumber) except gvoice.backend.NetworkError, e: @@ -125,6 +133,10 @@ class TheOneRingConnection( """ _moduleLogger.info("Disconnecting") try: + self.session.conversations.updateSignalHandler.unregister_sink( + self._callback + ) + self._channelManager.close() self.session.logout() _moduleLogger.info("Disconnected") except Exception: @@ -198,15 +210,15 @@ class TheOneRingConnection( h = handle.create_handle(self, 'contact', requestedContactId, requestedContactNumber) return h - @coroutines.func_sink - @coroutines.expand_positional @gobject_utils.async - def _on_conversations_updated(self, conversationIds): + @gtk_toolbox.log_exception(_moduleLogger) + def _on_conversations_updated(self, conv, conversationIds): # @todo get conversations update running # @todo test conversatiuons + _moduleLogger.info("Incoming messages from: %r" % (conversationIds, )) channelManager = self._channelManager for contactId, phoneNumber in conversationIds: - h = self._create_contact_handle(contactId, phoneNumber) + h = handle.create_handle(self, 'contact', contactId, phoneNumber) # if its new, __init__ will take care of things # if its old, its own update will take care of it - channel = channelManager.channel_for_text(handle) + channel = channelManager.channel_for_text(h)