changeset 7512f7ddedd0 in /home/hg/repos/gajim-plugins
author: Denis Fomin <fominde(a)gmail.com>
branches:
details:gajim-plugins?cmd=changeset;node=7512f7ddedd0
description: Backed out changeset: 3d9cf0f26427
diffstat:
chatstate/chatstate.py | 123 +----------------------------------------
clients_icons/clients_icons.py | 4 +
2 файлов изменено, 5 вставок(+), 122 удалений(-)
различия (163 строк):
diff -r 3d9cf0f26427 -r 7512f7ddedd0 chatstate/chatstate.py
--- a/chatstate/chatstate.py Wed Nov 20 23:19:21 2013 +0400
+++ b/chatstate/chatstate.py Wed Nov 20 23:56:17 2013 +0400
@@ -10,9 +10,6 @@
from common import helpers
import gtkgui_helpers
import unicodedata
-from nbxmpp.protocol import NS_CHATSTATES
-import nbxmpp
-from common.connection_handlers_events import MessageOutgoingEvent
def paragraph_direction_mark(text):
"""
@@ -36,127 +33,9 @@
def init(self):
self.config_dialog = None # ChatstatePluginConfigDialog(self)
self.events_handlers = {'chatstate-received':
- (ged.GUI2, self.chatstate_received),
- 'message-received':
- (ged.GUI2, self.message_received),}
- self.gui_extension_points = {'chat_control_base_set_control_active':
- (self.set_control_active, None),}
+ (ged.GUI2, self.chatstate_received), }
self.active = None
- def set_control_active(self, control, state):
- if control.type_id != 'gc':
- return
- # print state, dir(control), control.room_jid, control.nick, control.contact.jid
- # send chatstate inactive to the one we're leaving
- # and active to the one we visit
- if state:
- message_buffer = control.msg_textview.get_buffer()
- if message_buffer.get_char_count():
- self.send_chatstate('paused', control.contact, control)
- else:
- self.send_chatstate('active', control.contact, control)
- #self.reset_kbd_mouse_timeout_vars()
- #gobject.source_remove(self.possible_paused_timeout_id)
- #gobject.source_remove(self.possible_inactive_timeout_id)
- #self._schedule_activity_timers()
- else:
- self.send_chatstate('inactive', control.contact, control)
- def send_chatstate(self, state, contact=None, control=None):
- chatstate_setting = gajim.config.get('outgoing_chat_state_notifications')
- if chatstate_setting == 'disabled':
- return
- elif chatstate_setting == 'composing_only' and state != 'active' and\
- state != 'composing':
- return
-
- if contact is None:
- contact = self.parent_win.get_active_contact()
- if contact is None:
- # contact was from pm in MUC, and left the room so contact is None
- # so we cannot send chatstate anymore
- return
-
- # Don't send chatstates to offline contacts
- if contact.show == 'offline':
- return
- print state
- #if not contact.supports(NS_CHATSTATES):
- #printNS_CHATSTATES
- #returnNS_CHATSTATES
-
- # if the new state we wanna send (state) equals
- # the current state (contact.our_chatstate) then return
- if contact.our_chatstate == state:
- return
-
- # if wel're inactive prevent composing (XEP violation)
- if contact.our_chatstate == 'inactive' and state == 'composing':
- # go active before
- msg_iq = nbxmpp.Message(control.room_jid, None, typ='groupchat')
- msg_iq.setTag('active', namespace=NS_CHATSTATES)
- control.connection.connection.send(msg_iq)
- contact.our_chatstate = 'active'
- #self.reset_kbd_mouse_timeout_vars()
- msg_iq = nbxmpp.Message(control.room_jid, None, typ='groupchat')
- msg_iq.setTag(state, namespace=NS_CHATSTATES)
- control.connection.connection.send(msg_iq)
- contact.our_chatstate = state
- #if state == 'active':
- #self.reset_kbd_mouse_timeout_vars()
-
- def _on_notebook_switch_page(self, notebook, page, page_num):
- old_no = notebook.get_current_page()
- if old_no >= 0:
- old_ctrl = self._widget_to_control(notebook.get_nth_page(old_no))
- old_ctrl.set_control_active(False)
-
- new_ctrl = self._widget_to_control(notebook.get_nth_page(page_num))
- new_ctrl.set_control_active(True)
- self.show_title(control = new_ctrl)
-
- control = self.get_active_control()
- if isinstance(control, ChatControlBase):
- control.msg_textview.grab_focus()
-
- def message_received(self, obj):
- if not self.active or not obj.gc_control or obj.mtype != 'groupchat':
- return
-
- obj.get_chatstate()
- chatstate = obj.chatstate
- nick = obj.resource
- gc_control = obj.gc_control
- if chatstate not in self.chatstates.keys():
- return
-
- iter_ = gc_control.get_contact_iter(nick)
- if not iter_:
- return
- gc_contact = gajim.contacts.get_gc_contact(obj.conn.name, obj.jid,
- nick)
-
- name = gobject.markup_escape_text(gc_contact.name)
- if chatstate != 'gone':
- color = self.chatstates[chatstate]
- name = '<span foreground="%s">%s</span>' % (color, name)
-
- # Strike name if blocked
- fjid = obj.fjid
- if helpers.jid_is_blocked(obj.conn.name, fjid):
- name = '<span strikethrough="true">%s</span>' % name
- status = gc_contact.status
- # add status msg, if not empty, under contact name in the treeview
- if status and gajim.config.get('show_status_msgs_in_roster'):
- status = status.strip()
- if status != '':
- status = helpers.reduce_chars_newlines(status, max_lines=1)
- # escape markup entities and make them small italic and fg color
- name += ('\n<span size="small" style="italic" foreground="%s">'
- '%s</span>') % (self.status_color, gobject.markup_escape_text(
- status))
-
- gc_control.model[iter_][3] = name
-
def chatstate_received(self, obj):
if not self.active:
return
diff -r 3d9cf0f26427 -r 7512f7ddedd0 clients_icons/clients_icons.py
--- a/clients_icons/clients_icons.py Wed Nov 20 23:19:21 2013 +0400
+++ b/clients_icons/clients_icons.py Wed Nov 20 23:56:17 2013 +0400
@@ -434,6 +434,8 @@
if not self.config['show_in_groupchats']:
continue
caps = gc_contact.client_caps._node
+ identities = gc_contact.client_caps._lookup_in_cache(
+ gajim.caps_cache.capscache).identities
self.set_icon(chat_control.model, iter_, self.muc_renderer_num,
caps, gc_contact)
chat_control.draw_all_roles()
@@ -524,6 +526,8 @@
gc_control = gajim.interface.msg_win_mgr.get_gc_control(
iq_obj.jid, iq_obj.conn.name)
iter_ = gc_control.get_contact_iter(nick)
+ identities = contact.client_caps._lookup_in_cache(
+ gajim.caps_cache.capscache).identities
self.set_icon(gc_control.model, iter_, self.muc_renderer_num,
None, contact)
return