diff options
author | Krzysztof Klinikowski <kkszysiu@gmail.com> | 2010-01-28 20:57:29 +0100 |
---|---|---|
committer | Krzysztof Klinikowski <kkszysiu@gmail.com> | 2010-01-28 20:57:29 +0100 |
commit | 53d1c2163ac8d7a7eab56b662465b209e494d8ee (patch) | |
tree | 443f62e056ec511395989f66c96d92dbf399f507 /sunshine | |
parent | 9de81cef88f419d4531b13dcacf8ea89da052765 (diff) |
Removing contacts implemented.
Diffstat (limited to 'sunshine')
-rw-r--r-- | sunshine/channel/contact_list.py | 6 | ||||
-rwxr-xr-x | sunshine/lqsoft/pygadu/models.py | 8 | ||||
-rwxr-xr-x | sunshine/lqsoft/pygadu/network_base.py | 2 | ||||
-rwxr-xr-x | sunshine/lqsoft/pygadu/twisted_protocol.py | 8 |
4 files changed, 22 insertions, 2 deletions
diff --git a/sunshine/channel/contact_list.py b/sunshine/channel/contact_list.py index 31b4a02..9ec893e 100644 --- a/sunshine/channel/contact_list.py +++ b/sunshine/channel/contact_list.py @@ -236,7 +236,11 @@ class SunshineSubscribeListChannel(SunshineListChannel): def RemoveMembers(self, contacts, message): for h in contacts: - self._remove(h) + handle = self._conn.handle(telepathy.HANDLE_TYPE_CONTACT, h) + contact = handle.contact + self._conn_ref().gadu_client.removeContact(contact, notify=True) + self.MembersChanged('', (), [handle], (), (), 0, + telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE) def _filter_contact(self, contact): return (True, False, False) diff --git a/sunshine/lqsoft/pygadu/models.py b/sunshine/lqsoft/pygadu/models.py index c309a70..12d8e87 100755 --- a/sunshine/lqsoft/pygadu/models.py +++ b/sunshine/lqsoft/pygadu/models.py @@ -76,6 +76,14 @@ class GaduProfile(object): if self.connected: self.setNotifyState(contact.uin, contact.notify_flags) + def removeContact(self, contact, notify=False): + if self.__contacts.has_key(contact.uin): + if self.connected: + del self.__contacts[contact.uin] + + if notify == True: + self.__connection.delContact(contact) + def notifyAboutContact(self, contact): """Notify GG server when new GG contact is added to the contacts list.""" self.__connection.addNewContact(contact) diff --git a/sunshine/lqsoft/pygadu/network_base.py b/sunshine/lqsoft/pygadu/network_base.py index e3471fc..a3c581f 100755 --- a/sunshine/lqsoft/pygadu/network_base.py +++ b/sunshine/lqsoft/pygadu/network_base.py @@ -102,7 +102,7 @@ class AddNoticePacket(GaduPacket): contact = complex.StructField(0, struct=StructNotice) @outpacket(0x0e) -class RemoveNoticePacker(GaduPacket): +class RemoveNoticePacket(GaduPacket): contact = complex.StructField(0, struct=StructNotice) @outpacket(0x08) diff --git a/sunshine/lqsoft/pygadu/twisted_protocol.py b/sunshine/lqsoft/pygadu/twisted_protocol.py index 644213f..f7e6147 100755 --- a/sunshine/lqsoft/pygadu/twisted_protocol.py +++ b/sunshine/lqsoft/pygadu/twisted_protocol.py @@ -202,6 +202,14 @@ class GaduClient(Protocol): StructNotice(uin=contact.uin)) ) self._log("New contact %s added." % contact.uin) return self + + def delContact(self, contact): + add_class = Resolver.by_name('RemoveNoticePacket') + + self._sendPacket( add_class(contact= \ + StructNotice(uin=contact.uin)) ) + self._log("Contact %s removed." % contact.uin) + return self def changeStatus(self, status, desc=''): change_status_class = Resolver.by_name('ChangeStatusPacket') |