Taking the same python-telepathy caution elsewhere
authorEd Page <eopage@byu.net>
Sun, 10 Jan 2010 01:46:01 +0000 (19:46 -0600)
committerEd Page <eopage@byu.net>
Sun, 10 Jan 2010 01:46:01 +0000 (19:46 -0600)
src/channel/call.py
src/channel/contact_list.py
src/channel/debug_prompt.py
src/channel/text.py

index abe820f..c6fd368 100644 (file)
@@ -16,8 +16,8 @@ class CallChannel(
        ):
 
        def __init__(self, connection, manager, props, contactHandle):
-               self._manager = manager
-               self._props = props
+               self.__manager = manager
+               self.__props = props
 
                try:
                        # HACK Older python-telepathy way
@@ -27,7 +27,7 @@ class CallChannel(
                        telepathy.server.ChannelTypeStreamedMedia.__init__(self, connection, manager, props)
                telepathy.server.ChannelInterfaceCallState.__init__(self)
                telepathy.server.ChannelInterfaceGroup.__init__(self)
-               self._contactHandle = contactHandle
+               self.__contactHandle = contactHandle
                self._implement_property_get(
                        telepathy.interfaces.CHANNEL_TYPE_STREAMED_MEDIA,
                        {
@@ -48,9 +48,9 @@ class CallChannel(
 
        def close(self):
                telepathy.server.ChannelTypeStreamedMedia.Close(self)
-               if self._manager.channel_exists(self._props):
+               if self.__manager.channel_exists(self.__props):
                        # HACK Older python-telepathy requires doing this manually
-                       self._manager.remove_channel(self)
+                       self.__manager.remove_channel(self)
                self.remove_from_connection()
 
        @gtk_toolbox.log_exception(_moduleLogger)
@@ -85,12 +85,12 @@ class CallChannel(
                @returns [(Stream ID, contact, stream type, stream state, stream direction, pending send flags)]
                """
                contact = self._conn.handle(telepathy.constants.HANDLE_TYPE_CONTACT, contactId)
-               assert self._contactHandle == contact, "%r != %r" % (self._contactHandle, contact)
+               assert self.__contactHandle == contact, "%r != %r" % (self.__contactHandle, contact)
                contactId, contactNumber = handle.ContactHandle.from_handle_name(contact.name)
 
-               self.CallStateChanged(self._contactHandle, telepathy.constants.CHANNEL_CALL_STATE_RINGING)
+               self.CallStateChanged(self.__contactHandle, telepathy.constants.CHANNEL_CALL_STATE_RINGING)
                self._conn.session.backend.call(contactNumber)
-               self.CallStateChanged(self._contactHandle, telepathy.constants.CHANNEL_CALL_STATE_FORWARDED)
+               self.CallStateChanged(self.__contactHandle, telepathy.constants.CHANNEL_CALL_STATE_FORWARDED)
 
                streamId = 0
                streamState = telepathy.constants.MEDIA_STREAM_STATE_DISCONNECTED
@@ -106,4 +106,4 @@ class CallChannel(
                Get the current call states for all contacts involved in this call. 
                @returns {Contact: telepathy.constants.CHANNEL_CALL_STATE_*}
                """
-               return {self._contactHandle: telepathy.constants.CHANNEL_CALL_STATE_FORWARDED}
+               return {self.__contactHandle: telepathy.constants.CHANNEL_CALL_STATE_FORWARDED}
index 79b3f4a..78a0e01 100644 (file)
@@ -2,7 +2,6 @@ import logging
 
 import telepathy
 
-import util.go_utils as gobject_utils
 import util.coroutines as coroutines
 import gtk_toolbox
 import handle
@@ -11,16 +10,15 @@ import handle
 _moduleLogger = logging.getLogger("channel.contact_list")
 
 
-class AbstractListChannel(
+class AllContactsListChannel(
                telepathy.server.ChannelTypeContactList,
                telepathy.server.ChannelInterfaceGroup,
        ):
-       "Abstract Contact List channels"
+       """
+       The group of contacts for whom you receive presence
+       """
 
        def __init__(self, connection, manager, props, h):
-               self._manager = manager
-               self._props = props
-
                try:
                        # HACK Older python-telepathy way
                        telepathy.server.ChannelTypeContactList.__init__(self, connection, h)
@@ -29,23 +27,16 @@ class AbstractListChannel(
                        telepathy.server.ChannelTypeContactList.__init__(self, connection, manager, props)
                telepathy.server.ChannelInterfaceGroup.__init__(self)
 
-               self._session = connection.session
-
-
-class AllContactsListChannel(AbstractListChannel):
-       """
-       The group of contacts for whom you receive presence
-       """
-
-       def __init__(self, connection, manager, props, h):
-               AbstractListChannel.__init__(self, connection, manager, props, h)
+               self.__manager = manager
+               self.__props = props
+               self.__session = connection.session
 
                self._callback = coroutines.func_sink(
                        coroutines.expand_positional(
                                self._on_contacts_refreshed
                        )
                )
-               self._session.addressbook.updateSignalHandler.register_sink(
+               self.__session.addressbook.updateSignalHandler.register_sink(
                        self._callback
                )
 
@@ -60,15 +51,15 @@ class AllContactsListChannel(AbstractListChannel):
                self.close()
 
        def close(self):
-               self._session.addressbook.updateSignalHandler.unregister_sink(
+               self.__session.addressbook.updateSignalHandler.unregister_sink(
                        self._callback
                )
                self._callback = None
 
                telepathy.server.ChannelTypeContactList.Close(self)
-               if self._manager.channel_exists(self._props):
+               if self.__manager.channel_exists(self.__props):
                        # HACK Older python-telepathy requires doing this manually
-                       self._manager.remove_channel(self)
+                       self.__manager.remove_channel(self)
                self.remove_from_connection()
 
        @gtk_toolbox.log_exception(_moduleLogger)
index a491212..f7dcef1 100644 (file)
@@ -18,8 +18,8 @@ class DebugPromptChannel(telepathy.server.ChannelTypeText, cmd.Cmd):
        """
 
        def __init__(self, connection, manager, props, contactHandle):
-               self._manager = manager
-               self._props = props
+               self.__manager = manager
+               self.__props = props
 
                cmd.Cmd.__init__(self, "Debug Prompt")
                self.use_rawinput = False
@@ -29,10 +29,10 @@ class DebugPromptChannel(telepathy.server.ChannelTypeText, cmd.Cmd):
                except TypeError:
                        # HACK Newer python-telepathy way
                        telepathy.server.ChannelTypeText.__init__(self, connection, manager, props)
-               self._nextRecievedId = 0
-               self._lastMessageTimestamp = datetime.datetime(1, 1, 1)
+               self.__nextRecievedId = 0
+               self.__lastMessageTimestamp = datetime.datetime(1, 1, 1)
 
-               self._otherHandle = contactHandle
+               self.__otherHandle = contactHandle
 
        @gtk_toolbox.log_exception(_moduleLogger)
        def Send(self, messageType, text):
@@ -57,20 +57,20 @@ class DebugPromptChannel(telepathy.server.ChannelTypeText, cmd.Cmd):
 
        def close(self):
                telepathy.server.ChannelTypeText.Close(self)
-               if self._manager.channel_exists(self._props):
+               if self.__manager.channel_exists(self.__props):
                        # HACK Older python-telepathy requires doing this manually
-                       self._manager.remove_channel(self)
+                       self.__manager.remove_channel(self)
                self.remove_from_connection()
 
        def _report_new_message(self, message):
-               currentReceivedId = self._nextRecievedId
+               currentReceivedId = self.__nextRecievedId
 
                timestamp = int(time.time())
                type = telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL
 
-               self.Received(currentReceivedId, timestamp, self._otherHandle, type, 0, message.strip())
+               self.Received(currentReceivedId, timestamp, self.__otherHandle, type, 0, message.strip())
 
-               self._nextRecievedId += 1
+               self.__nextRecievedId += 1
 
        def do_reset_state_machine(self, args):
                if args:
index 5f06973..f2b8af0 100644 (file)
@@ -18,8 +18,8 @@ class TextChannel(telepathy.server.ChannelTypeText):
        """
 
        def __init__(self, connection, manager, props, contactHandle):
-               self._manager = manager
-               self._props = props
+               self.__manager = manager
+               self.__props = props
 
                try:
                        # HACK Older python-telepathy way
@@ -27,21 +27,21 @@ class TextChannel(telepathy.server.ChannelTypeText):
                except TypeError:
                        # HACK Newer python-telepathy way
                        telepathy.server.ChannelTypeText.__init__(self, connection, manager, props)
-               self._nextRecievedId = 0
-               self._lastMessageTimestamp = datetime.datetime(1, 1, 1)
+               self.__nextRecievedId = 0
+               self.__lastMessageTimestamp = datetime.datetime(1, 1, 1)
 
-               self._otherHandle = contactHandle
+               self.__otherHandle = contactHandle
 
-               self._callback = coroutines.func_sink(
+               self.__callback = coroutines.func_sink(
                        coroutines.expand_positional(
                                self._on_conversations_updated
                        )
                )
                self._conn.session.voicemails.updateSignalHandler.register_sink(
-                       self._callback
+                       self.__callback
                )
                self._conn.session.texts.updateSignalHandler.register_sink(
-                       self._callback
+                       self.__callback
                )
 
                # The only reason there should be anything in the conversation is if
@@ -64,7 +64,7 @@ class TextChannel(telepathy.server.ChannelTypeText):
                if messageType != telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
                        raise telepathy.errors.NotImplemented("Unhandled message type: %r" % messageType)
 
-               self._conn.session.backend.send_sms(self._otherHandle.phoneNumber, text)
+               self._conn.session.backend.send_sms(self.__otherHandle.phoneNumber, text)
                self._conn.session.textsStateMachine.reset_timers()
 
                self.Sent(int(time.time()), messageType, text)
@@ -75,22 +75,22 @@ class TextChannel(telepathy.server.ChannelTypeText):
 
        def close(self):
                self._conn.session.voicemails.updateSignalHandler.unregister_sink(
-                       self._callback
+                       self.__callback
                )
                self._conn.session.texts.updateSignalHandler.unregister_sink(
-                       self._callback
+                       self.__callback
                )
-               self._callback = None
+               self.__callback = None
 
                telepathy.server.ChannelTypeText.Close(self)
-               if self._manager.channel_exists(self._props):
+               if self.__manager.channel_exists(self.__props):
                        # HACK Older python-telepathy requires doing this manually
-                       self._manager.remove_channel(self)
+                       self.__manager.remove_channel(self)
                self.remove_from_connection()
 
        @property
        def _contactKey(self):
-               contactKey = self._otherHandle.contactID, self._otherHandle.phoneNumber
+               contactKey = self.__otherHandle.contactID, self.__otherHandle.phoneNumber
                return contactKey
 
        @gtk_toolbox.log_exception(_moduleLogger)
@@ -111,7 +111,7 @@ class TextChannel(telepathy.server.ChannelTypeText):
                                "New messages for %r have already been read externally" % (self._contactKey, )
                        )
                        return
-               self._lastMessageTimestamp = newConversations[-1].time
+               self.__lastMessageTimestamp = newConversations[-1].time
 
                messages = [
                        newMessage
@@ -133,7 +133,7 @@ class TextChannel(telepathy.server.ChannelTypeText):
                return (
                        conversation
                        for conversation in conversations
-                       if self._lastMessageTimestamp < conversation.time
+                       if self.__lastMessageTimestamp < conversation.time
                )
 
        def _filter_out_read(self, conversations):
@@ -147,11 +147,11 @@ class TextChannel(telepathy.server.ChannelTypeText):
                return " ".join(part.text.strip() for part in message.body)
 
        def _report_new_message(self, message):
-               currentReceivedId = self._nextRecievedId
+               currentReceivedId = self.__nextRecievedId
                timestamp = int(time.time())
                type = telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL
 
-               _moduleLogger.info("Received message from User %r" % self._otherHandle)
-               self.Received(currentReceivedId, timestamp, self._otherHandle, type, 0, message)
+               _moduleLogger.info("Received message from User %r" % self.__otherHandle)
+               self.Received(currentReceivedId, timestamp, self.__otherHandle, type, 0, message)
 
-               self._nextRecievedId += 1
+               self.__nextRecievedId += 1