~ubuntu-branches/ubuntu/maverick/telepathy-butterfly/maverick

« back to all changes in this revision

Viewing changes to butterfly/channel/text.py

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2009-08-04 15:26:55 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090804152655-ai2vrmsgq9u8w19e
Tags: 0.5.0-0ubuntu1
* New upstream release.
* Bump Standards-Version to 3.8.2.
* debian/control: change python-msn (>= 0.3.0) to python-papyon (>= 0.4.1)
  in Depends field.
* debian/control: change python-telepathy version to >= 0.15.9 in Depends
  field.
* Fix build-depends-without-arch-dep lintian info.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import time
23
23
 
24
24
import telepathy
25
 
import pymsn
26
 
import pymsn.event
 
25
import papyon
 
26
import papyon.event
27
27
 
28
28
from butterfly.util.decorator import async
29
29
from butterfly.handle import ButterflyHandleFactory
37
37
        telepathy.server.ChannelTypeText,
38
38
        telepathy.server.ChannelInterfaceGroup,
39
39
        telepathy.server.ChannelInterfaceChatState,
40
 
        pymsn.event.ConversationEventInterface):
 
40
        papyon.event.ConversationEventInterface):
41
41
 
42
 
    def __init__(self, connection, conversation, chan_manager):
 
42
    def __init__(self, conn, manager, conversation, props):
43
43
        self._recv_id = 0
44
44
        self._conversation = conversation
45
 
        self._conn_ref = weakref.ref(connection)
46
 
        self._chan_manager_ref = weakref.ref(chan_manager)
 
45
        self._conn_ref = weakref.ref(conn)
47
46
 
48
 
        telepathy.server.ChannelTypeText.__init__(self, connection, None)
 
47
        telepathy.server.ChannelTypeText.__init__(self, conn, manager, props)
49
48
        telepathy.server.ChannelInterfaceGroup.__init__(self)
50
49
        telepathy.server.ChannelInterfaceChatState.__init__(self)
51
 
        pymsn.event.ConversationEventInterface.__init__(self, self._conversation)
 
50
        papyon.event.ConversationEventInterface.__init__(self, self._conversation)
52
51
 
53
52
        self.GroupFlagsChanged(telepathy.CHANNEL_GROUP_FLAG_CAN_ADD, 0)
54
53
        self.__add_initial_participants()
61
60
 
62
61
    def Send(self, message_type, text):
63
62
        if message_type == telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
64
 
            self._conversation.send_text_message(pymsn.ConversationMessage(text))
 
63
            self._conversation.send_text_message(papyon.ConversationMessage(text))
65
64
        elif message_type == telepathy.CHANNEL_TEXT_MESSAGE_TYPE_ACTION and \
66
65
                text == u"nudge":
67
66
            self._conversation.send_nudge()
71
70
 
72
71
    def Close(self):
73
72
        self._conversation.leave()
74
 
        self._chan_manager_ref().remove_text_channel(self)
75
73
        telepathy.server.ChannelTypeText.Close(self)
76
74
        self.remove_from_connection()
77
75
 
80
78
    def GetSelfHandle(self):
81
79
        return self._conn.GetSelfHandle()
82
80
 
83
 
    # pymsn.event.ConversationEventInterface
 
81
    # papyon.event.ConversationEventInterface
84
82
    def on_conversation_user_joined(self, contact):
85
83
        handle = ButterflyHandleFactory(self._conn_ref(), 'contact',
86
84
                contact.account, contact.network_id)
88
86
        self.MembersChanged('', [handle], [], [], [],
89
87
                handle, telepathy.CHANNEL_GROUP_CHANGE_REASON_INVITED)
90
88
 
91
 
    # pymsn.event.ConversationEventInterface
 
89
    # papyon.event.ConversationEventInterface
92
90
    def on_conversation_user_left(self, contact):
93
91
        handle = ButterflyHandleFactory(self._conn_ref(), 'contact',
94
92
                contact.account, contact.network_id)
99
97
            self.MembersChanged('', [], [handle], [], [],
100
98
                    handle, telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE)
101
99
 
102
 
    # pymsn.event.ConversationEventInterface
 
100
    # papyon.event.ConversationEventInterface
103
101
    def on_conversation_user_typing(self, contact):
104
102
        handle = ButterflyHandleFactory(self._conn_ref(), 'contact',
105
103
                contact.account, contact.network_id)
106
104
        logger.info("User %r is typing" % handle)
107
105
        self.ChatStateChanged(handle, telepathy.CHANNEL_CHAT_STATE_COMPOSING)
108
106
 
109
 
    # pymsn.event.ConversationEventInterface
 
107
    # papyon.event.ConversationEventInterface
110
108
    def on_conversation_message_received(self, sender, message):
111
109
        id = self._recv_id
112
110
        timestamp = int(time.time())
118
116
        self.Received(id, timestamp, handle, type, 0, message)
119
117
        self._recv_id += 1
120
118
 
121
 
    # pymsn.event.ConversationEventInterface
 
119
    # papyon.event.ConversationEventInterface
122
120
    def on_conversation_nudge_received(self, sender):
123
121
        id = self._recv_id
124
122
        timestamp = int(time.time())
125
123
        handle = ButterflyHandleFactory(self._conn_ref(), 'contact',
126
124
                sender.account, sender.network_id)
127
125
        type = telepathy.CHANNEL_TEXT_MESSAGE_TYPE_ACTION
128
 
        text = unicode(_("sends you a nudge"), "utf-8")
 
126
        text = unicode("sends you a nudge", "utf-8")
129
127
        logger.info("User %r sent a nudge" % handle)
130
128
        self.Received(id, timestamp, handle, type, 0, text)
131
129
        self._recv_id += 1