diff options
author | Denis Fomin <fominde@gmail.com> | 2010-10-15 14:56:22 +0400 |
---|---|---|
committer | Denis Fomin <fominde@gmail.com> | 2010-10-15 14:56:22 +0400 |
commit | 4bebe8f7ced020e6fd24c65541cd039e02205b46 (patch) | |
tree | b29ea02b9eae0b160a2305267eca2986ceb0bf20 /clients_icons | |
parent | 90ad0dea1467abfccbbb756dec64674bbcdbc51e (diff) |
clients_icons. don't use CAPS_RECEIVED event
Diffstat (limited to 'clients_icons')
-rw-r--r-- | clients_icons/clients_icons.py | 55 | ||||
-rw-r--r-- | clients_icons/manifest.ini | 2 |
2 files changed, 22 insertions, 35 deletions
diff --git a/clients_icons/clients_icons.py b/clients_icons/clients_icons.py index f756856..b446d81 100644 --- a/clients_icons/clients_icons.py +++ b/clients_icons/clients_icons.py @@ -84,9 +84,7 @@ class ClientsIconsPlugin(GajimPlugin): @log_calls('ClientsIconsPlugin') def init(self): self.pos_list = ['after statusicon', 'befor avatar'] - self.events_handlers = {'CAPS_RECEIVED': - (ged.POSTGUI, self.caps_received), - 'presence-received': + self.events_handlers = {'presence-received': (ged.POSTGUI, self.presence_received), 'gc-presence-received': (ged.POSTGUI, self.gc_presence_received),} @@ -186,38 +184,24 @@ class ClientsIconsPlugin(GajimPlugin): import time time.sleep(2) - def caps_received(self, account, data): + def presence_received(self, iq_obj): if not self.config['show_in_roster']: return roster = gajim.interface.roster - jid = data[0].split('/')[0] - for account in gajim.contacts.get_accounts(): - contact = gajim.contacts.get_contact_with_highest_priority( - account, jid) - if not contact: - continue - caps = contact.client_caps._node - iter_ = roster._get_contact_iter(jid, account, contact, - roster.model)[0] - if not caps: - if roster.model[iter_][self.renderer_num] is not None: - continue - if self.config['show_unknown_icon']: - roster.model[iter_][self.renderer_num] = self.default_pixbuf - continue - client_icon = clients.get(caps.split('#')[0], None) - if not client_icon: - if self.config['show_unknown_icon']: - roster.model[iter_][self.renderer_num] = self.default_pixbuf - continue - icon_path = os.path.join(self.local_file_path('icons'), client_icon) - pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 16, 16) - roster.model[iter_][self.renderer_num] = pixbuf - - def presence_received(self, iq_obj): - if iq_obj.new_show == 0: - self.caps_received(iq_obj.conn.name, [iq_obj.fjid]) + contact = gajim.contacts.get_contact_with_highest_priority( + iq_obj.conn.name, iq_obj.jid) + if not contact: + return + iter_ = roster._get_contact_iter(iq_obj.jid, iq_obj.conn.name, contact, + roster.model)[0] + caps = contact.client_caps._node + if not caps: + tag = iq_obj.iq_obj.getTags('c') + if tag: + caps = tag[0].getAttr('node') + self.set_icon(roster.model, iter_, self.renderer_num, caps) return + self.set_icon(roster.model, iter_, self.renderer_num, caps) def gc_presence_received(self, iq_obj): if not self.config['show_in_groupchats']: @@ -234,19 +218,22 @@ class ClientsIconsPlugin(GajimPlugin): model = iq_obj.gc_control.list_treeview.get_model() if model[iter_][self.muc_renderer_num] is not None: return + self.set_icon(model, iter_, self.muc_renderer_num, caps) + + def set_icon(self, model, iter_, pos, caps): if not caps: if self.config['show_unknown_icon']: - model[iter_][self.muc_renderer_num] = self.default_pixbuf + model[iter_][pos] = self.default_pixbuf return client_icon = clients.get(caps.split('#')[0], None) if not client_icon: if self.config['show_unknown_icon']: - model[iter_][self.muc_renderer_num] = self.default_pixbuf + model[iter_][pos] = self.default_pixbuf else: icon_path = os.path.join(self.local_file_path('icons'), client_icon) pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 16, 16) - model[iter_][self.muc_renderer_num] = pixbuf + model[iter_][pos] = pixbuf def tree_cell_data_func(self, column, renderer, model, iter_, control): if not model.iter_parent(iter_): diff --git a/clients_icons/manifest.ini b/clients_icons/manifest.ini index c834c52..baa0269 100644 --- a/clients_icons/manifest.ini +++ b/clients_icons/manifest.ini @@ -1,7 +1,7 @@ [info] name: Clients icons short_name: clients_icons -version: 0.1 +version: 0.2 description: Shows the client icons in the roster and in groupchats. authors = Denis Fomin <fominde@gmail.com> |