chatstate plugin 0.4

remove unused imports.Use 'chatstate-received'signal instead of 'raw-message-received'
This commit is contained in:
Denis Fomin
2010-12-12 12:40:07 +03:00
parent 2e2a54722b
commit f3f183c5e5
2 changed files with 12 additions and 17 deletions

View File

@@ -1,12 +1,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
## ##
import gtk
import gobject import gobject
import pango
from plugins import GajimPlugin from plugins import GajimPlugin
from plugins.helpers import log_calls, log from plugins.helpers import log_calls
from common import ged from common import ged
from common import gajim from common import gajim
from common import helpers from common import helpers
@@ -18,30 +16,27 @@ class ChatstatePlugin(GajimPlugin):
@log_calls('ChatstatePlugin') @log_calls('ChatstatePlugin')
def init(self): def init(self):
self.config_dialog = None # ChatstatePluginConfigDialog(self) self.config_dialog = None # ChatstatePluginConfigDialog(self)
self.events_handlers = {'raw-message-received': self.events_handlers = {'chatstate-received':
(ged.POSTCORE, self.raw_pres_received), } (ged.GUI2, self.chatstate_received), }
self.chatstates = ('active', 'composing', 'gone', 'inactive', 'paused') self.chatstates = ('active', 'composing', 'gone', 'inactive', 'paused')
self.active = None self.active = None
def raw_pres_received(self, event_object): def chatstate_received(self, obj):
if not self.active: if not self.active:
return return
jid = str(event_object.stanza.getFrom())
account = event_object.account contact = gajim.contacts.get_contact_from_full_jid(obj.conn.name,
contact = gajim.contacts.get_contact_from_full_jid(account, jid) obj.fjid)
if not contact: if not contact:
return return
for chatstate in self.chatstates: chatstate = obj.chatstate
state = event_object.stanza.getTag(chatstate) if chatstate not in self.chatstates:
if state:
break
if not state:
return return
self.model = gajim.interface.roster.model self.model = gajim.interface.roster.model
child_iters = gajim.interface.roster._get_contact_iter( child_iters = gajim.interface.roster._get_contact_iter(obj.jid,
jid.split('/')[0], account, contact, self.model) obj.conn.name, contact, self.model)
for child_iter in child_iters: for child_iter in child_iters:
name = gobject.markup_escape_text(contact.get_shown_name()) name = gobject.markup_escape_text(contact.get_shown_name())

View File

@@ -1,7 +1,7 @@
[info] [info]
name: Chatstate in roster name: Chatstate in roster
short_name: chatstate short_name: chatstate
version: 0.3 version: 0.4
description: Chat State Notifications in roster. description: Chat State Notifications in roster.
Font color of the contact varies depending on the chat state. Font color of the contact varies depending on the chat state.
The plugin does not work if you use custom font color for contacts in roster. The plugin does not work if you use custom font color for contacts in roster.