From b5952a89cc8688e13329c9b6198a8b8498167208 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 20 Jan 2010 21:20:28 -0600 Subject: [PATCH] Adding conic dependency, fixing bug with disconnecting from conic, reducing the number of text channels created --- src/channel/text.py | 3 ++- src/connection.py | 23 +++++++++++++++++------ support/builddeb.py | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/channel/text.py b/src/channel/text.py index 294b4c8..0e3ad97 100644 --- a/src/channel/text.py +++ b/src/channel/text.py @@ -138,7 +138,8 @@ class TextChannel(tp.ChannelTypeText): if self.__lastMessageTimestamp < conversation.time ) - def _filter_out_read(self, conversations): + @staticmethod + def _filter_out_read(conversations): return ( conversation for conversation in conversations diff --git a/src/connection.py b/src/connection.py index d1ca887..e94e0b8 100644 --- a/src/connection.py +++ b/src/connection.py @@ -101,10 +101,8 @@ class TheOneRingConnection( if conic is not None: self.__connection = conic.Connection() - self.__connectionEventId = None else: self.__connection = None - self.__connectionEventId = None self.__cachePath = os.sep.join((constants._data_path_, "cache", self.username)) try: os.makedirs(self.__cachePath) @@ -276,10 +274,6 @@ class TheOneRingConnection( self.session.save(self.__cachePath) self.session.logout() self.session.close() - self.__session = None - if self.__connection is not None: - self.__connection.disconnect(self.__connectionEventId) - self.__connectionEventId = None self.manager.disconnected(self) _moduleLogger.info("Disconnected") @@ -291,6 +285,20 @@ class TheOneRingConnection( h = self.get_handle_by_name(telepathy.HANDLE_TYPE_CONTACT, phoneNumber) # Just let the TextChannel decide whether it should be reported to the user or not props = self._generate_props(telepathy.CHANNEL_TYPE_TEXT, h, False) + if self.__channelManager.channel_exists(props): + continue + + # Maemo 4.1's RTComm opens a window for a chat regardless if a + # message is received or not, so we need to do some filtering here + mergedConv = conv.get_conversation(phoneNumber) + unreadConvs = [ + conversation + for conversation in mergedConv.conversations + if not conversation.isRead and not conversation.isArchived + ] + if not unreadConvs: + continue + chan = self.__channelManager.channel_for_props(props, signal=True) @gtk_toolbox.log_exception(_moduleLogger) @@ -300,6 +308,9 @@ class TheOneRingConnection( @todo Make this delayed to handle background switching of networks. First I need to verify I receive connected """ + if not self.session.is_logged_in(): + _moduleLogger.info("Received connection change event when not logged in") + return status = event.get_status() error = event.get_error() iap_id = event.get_iap_id() diff --git a/support/builddeb.py b/support/builddeb.py index f105046..a5c4ad8 100755 --- a/support/builddeb.py +++ b/support/builddeb.py @@ -97,7 +97,7 @@ def build_package(distribution): p.depends += { "debian": "", "chinook": "", - "diablo": ", account-plugin-haze", + "diablo": "python2.5-conic, account-plugin-haze", "fremantle": ", account-plugin-haze", "mer": "", }[distribution] -- 1.7.9.5