~ubuntu-branches/ubuntu/lucid/telepathy-butterfly/lucid-proposed

« back to all changes in this revision

Viewing changes to butterfly/channel/group.py

  • Committer: Bazaar Package Importer
  • Author(s): Ken VanDine
  • Date: 2009-10-20 10:33:53 UTC
  • mfrom: (1.1.10 upstream) (8.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20091020103353-3fxta9vmps4hjiqw
Tags: 0.5.2-0ubuntu1
* New upstream release (LP: #437828)
  - offline messages no longer get lost
* debian/patches/001_lp410376_python_syntax.patch
  - Updated to apply to 0.5.2
* debian/patches/002_disable_a-v_support.patch
  - Updated to apply to 0.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        @async
48
48
        def create_group():
49
49
            if self._handle.group is None:
50
 
                connection.msn_client.address_book.add_group(self._handle.name)
 
50
                name = self._handle.name.encode("utf-8")
 
51
                connection.msn_client.address_book.add_group(name)
51
52
        create_group()
52
53
 
53
54
    def AddMembers(self, contacts, message):
56
57
            for contact_handle_id in contacts:
57
58
                contact_handle = self._conn.handle(telepathy.HANDLE_TYPE_CONTACT,
58
59
                            contact_handle_id)
59
 
                logger.info("Adding contact %r to pending group %r" %
60
 
                        (contact_handle, self._handle))
 
60
                logger.info("Adding contact %s to pending group %s" %
 
61
                        (unicode(contact_handle), unicode(self._handle)))
61
62
                if contact_handle_id in self.__pending_remove:
62
63
                    self.__pending_remove.remove(contact_handle_id)
63
64
                else:
67
68
            for contact_handle_id in contacts:
68
69
                contact_handle = self._conn.handle(telepathy.HANDLE_TYPE_CONTACT,
69
70
                            contact_handle_id)
70
 
                logger.info("Adding contact %r to group %r" %
71
 
                        (contact_handle, self._handle))
 
71
                logger.info("Adding contact %s to group %s" %
 
72
                        (unicode(contact_handle), unicode(self._handle)))
72
73
                contact = contact_handle.contact
73
74
                group = self._handle.group
74
75
                if contact is not None and contact.is_member(papyon.Membership.FORWARD):
82
83
            for contact_handle_id in contacts:
83
84
                contact_handle = self._conn.handle(telepathy.HANDLE_TYPE_CONTACT,
84
85
                            contact_handle_id)
85
 
                logger.info("Adding contact %r to pending group %r" %
86
 
                        (contact_handle, self._handle))
 
86
                logger.info("Adding contact %s to pending group %s" %
 
87
                        (unicode(contact_handle), unicode(self._handle)))
87
88
                if contact_handle_id in self.__pending_add:
88
89
                    self.__pending_add.remove(contact_handle_id)
89
90
                else:
93
94
            for contact_handle_id in contacts:
94
95
                contact_handle = self._conn.handle(telepathy.HANDLE_TYPE_CONTACT,
95
96
                            contact_handle_id)
96
 
                logger.info("Removing contact %r from pending group %r" %
97
 
                        (contact_handle, self._handle))
 
97
                logger.info("Removing contact %s from pending group %s" %
 
98
                        (unicode(contact_handle), unicode(self._handle)))
98
99
                contact = contact_handle.contact
99
100
                group = self._handle.group
100
101
                if contact is not None and contact.is_member(papyon.Membership.FORWARD):
109
110
        ab.delete_group(group)
110
111
 
111
112
    def _filter_contact(self, contact):
112
 
        for group in contact.groups:
113
 
            if group.name == self._handle.name:
114
 
                return (True, False, False)
 
113
        if contact.is_member(papyon.Membership.FORWARD):
 
114
            for group in contact.groups:
 
115
                if group.name.decode("utf-8") == self._handle.name:
 
116
                    return (True, False, False)
115
117
        return (False, False, False)
116
118
 
117
119
    def on_addressbook_group_added(self, group):
118
 
        if group.name == self._handle.name:
 
120
        if group.name.decode("utf-8") == self._handle.name:
119
121
            self.AddMembers(self.__pending_add, None)
120
122
            self.__pending_add = []
121
123
            self.RemoveMembers(self.__pending_remove, None)
122
124
            self.__pending_remove = []
123
125
 
124
126
    def on_addressbook_group_deleted(self, group):
125
 
        if group.name == self._handle.name:
 
127
        if group.name.decode("utf-8") == self._handle.name:
126
128
            self.Closed()
127
129
            self._conn.remove_channel(self)
128
130
 
129
131
    def on_addressbook_group_contact_added(self, group, contact):
130
 
        if group.name == self._handle.name:
 
132
        group_name = group.name.decode("utf-8")
 
133
        if group_name == self._handle.name:
131
134
            handle = ButterflyHandleFactory(self._conn_ref(), 'contact',
132
135
                    contact.account, contact.network_id)
133
136
 
137
140
            self.MembersChanged('', added, (), (), (), 0,
138
141
                    telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE)
139
142
 
140
 
            logger.debug("Contact %s added to group %s" % (handle.name,
141
 
                    group.name))
 
143
            logger.debug("Contact %s added to group %s" %
 
144
                    (handle.name, group_name))
142
145
 
143
146
    def on_addressbook_group_contact_deleted(self, group, contact):
144
 
        if group.name == self._handle.name:
 
147
        group_name = group.name.decode("utf-8")
 
148
        if group_name == self._handle.name:
145
149
            handle = ButterflyHandleFactory(self._conn_ref(), 'contact',
146
150
                    contact.account, contact.network_id)
147
151
 
151
155
            self.MembersChanged('', (), removed, (), (), 0,
152
156
                    telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE)
153
157
 
154
 
            logger.debug("Contact %s removed from group %s" % (handle.name,
155
 
                    group.name))
 
158
            logger.debug("Contact %s removed from group %s" %
 
159
                    (handle.name, group_name))
156
160