[Florob] Send and handle nicknames reveices through PEP. Fixes #3651
This commit is contained in:
parent
ab1f59c433
commit
3193a8e8cf
7 changed files with 116 additions and 1 deletions
|
@ -751,7 +751,7 @@ Disabled</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
<property name="n_rows">2</property>
|
<property name="n_rows">2</property>
|
||||||
<property name="n_columns">4</property>
|
<property name="n_columns">5</property>
|
||||||
<property name="column_spacing">6</property>
|
<property name="column_spacing">6</property>
|
||||||
<property name="row_spacing">6</property>
|
<property name="row_spacing">6</property>
|
||||||
<child>
|
<child>
|
||||||
|
@ -792,6 +792,25 @@ Disabled</property>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkCheckButton" id="subscribe_nick_checkbutton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
|
<property name="label" translatable="yes">Nickname</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="response_id">0</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<signal name="toggled" handler="on_subscribe_nick_checkbutton_toggled"/>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">4</property>
|
||||||
|
<property name="right_attach">5</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="bottom_attach">2</property>
|
||||||
|
<property name="x_options">GTK_FILL</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkCheckButton" id="publish_mood_checkbutton">
|
<widget class="GtkCheckButton" id="publish_mood_checkbutton">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -843,6 +862,23 @@ Disabled</property>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkCheckButton" id="publish_nick_checkbutton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
|
<property name="label" translatable="yes">Nickname</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="response_id">0</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<signal name="toggled" handler="on_publish_nick_checkbutton_toggled"/>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">4</property>
|
||||||
|
<property name="right_attach">5</property>
|
||||||
|
<property name="x_options">GTK_FILL</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="label43">
|
<widget class="GtkLabel" id="label43">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
@ -252,9 +252,11 @@ class Config:
|
||||||
'publish_mood': [opt_bool, False],
|
'publish_mood': [opt_bool, False],
|
||||||
'publish_activity': [opt_bool, False],
|
'publish_activity': [opt_bool, False],
|
||||||
'publish_tune': [opt_bool, False],
|
'publish_tune': [opt_bool, False],
|
||||||
|
'publish_nick': [opt_bool, True],
|
||||||
'subscribe_mood': [opt_bool, True],
|
'subscribe_mood': [opt_bool, True],
|
||||||
'subscribe_activity': [opt_bool, True],
|
'subscribe_activity': [opt_bool, True],
|
||||||
'subscribe_tune': [opt_bool, True],
|
'subscribe_tune': [opt_bool, True],
|
||||||
|
'subscribe_nick': [opt_bool, True],
|
||||||
'attach_notifications_to_systray': [opt_bool, False, _('If True, notification windows from notification-daemon will be attached to systray icon.')],
|
'attach_notifications_to_systray': [opt_bool, False, _('If True, notification windows from notification-daemon will be attached to systray icon.')],
|
||||||
'check_idle_every_foo_seconds': [opt_int, 2, _('Choose interval between 2 checks of idleness.')],
|
'check_idle_every_foo_seconds': [opt_int, 2, _('Choose interval between 2 checks of idleness.')],
|
||||||
}
|
}
|
||||||
|
|
|
@ -1809,6 +1809,9 @@ returns the session that we last sent a message to.'''
|
||||||
# XEP-0108: User Activity
|
# XEP-0108: User Activity
|
||||||
items = event.getTag('items', {'node': common.xmpp.NS_ACTIVITY})
|
items = event.getTag('items', {'node': common.xmpp.NS_ACTIVITY})
|
||||||
if items: pep.user_activity(items, self.name, jid)
|
if items: pep.user_activity(items, self.name, jid)
|
||||||
|
# XEP-0172: User Nickname
|
||||||
|
items = event.getTag('items', {'node': common.xmpp.NS_NICK})
|
||||||
|
if items: pep.user_nickname(items, self.name, jid)
|
||||||
|
|
||||||
items = event.getTag('items')
|
items = event.getTag('items')
|
||||||
if items is None: return
|
if items is None: return
|
||||||
|
|
|
@ -1288,6 +1288,10 @@ def update_optional_features():
|
||||||
gajim.gajim_optional_features.append(xmpp.NS_TUNE)
|
gajim.gajim_optional_features.append(xmpp.NS_TUNE)
|
||||||
if gajim.config.get('subscribe_tune'):
|
if gajim.config.get('subscribe_tune'):
|
||||||
gajim.gajim_optional_features.append(xmpp.NS_TUNE + '+notify')
|
gajim.gajim_optional_features.append(xmpp.NS_TUNE + '+notify')
|
||||||
|
if gajim.config.get('publish_nick'):
|
||||||
|
gajim.gajim_optional_features.append(xmpp.NS_NICK)
|
||||||
|
if gajim.config.get('subscribe_nick'):
|
||||||
|
gajim.gajim_optional_features.append(xmpp.NS_NICK + '+notify')
|
||||||
if gajim.config.get('outgoing_chat_state_notifactions') != 'disabled':
|
if gajim.config.get('outgoing_chat_state_notifactions') != 'disabled':
|
||||||
gajim.gajim_optional_features.append(xmpp.NS_CHATSTATES)
|
gajim.gajim_optional_features.append(xmpp.NS_CHATSTATES)
|
||||||
if not gajim.config.get('ignore_incoming_xhtml'):
|
if not gajim.config.get('ignore_incoming_xhtml'):
|
||||||
|
|
|
@ -224,6 +224,44 @@ def user_activity(items, name, jid):
|
||||||
if contact.activity.has_key('text'):
|
if contact.activity.has_key('text'):
|
||||||
del contact.activity['text']
|
del contact.activity['text']
|
||||||
|
|
||||||
|
def user_nickname(items, name, jid):
|
||||||
|
has_child = False
|
||||||
|
retract = False
|
||||||
|
nick = None
|
||||||
|
|
||||||
|
for item in items.getTags('item'):
|
||||||
|
child = item.getTag('nick')
|
||||||
|
if child is not None:
|
||||||
|
has_child = True
|
||||||
|
nick = child.getData()
|
||||||
|
break
|
||||||
|
|
||||||
|
if items.getTag('retract') is not None:
|
||||||
|
retract = True
|
||||||
|
|
||||||
|
if jid == gajim.get_jid_from_account(name):
|
||||||
|
if has_child:
|
||||||
|
gajim.nicks[name] = nick
|
||||||
|
if retract:
|
||||||
|
gajim.nicks[name] = gajim.config.get_per('accounts', name, 'name')
|
||||||
|
|
||||||
|
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
|
||||||
|
contact = gajim.contacts.get_contact(name, user, resource=resource)
|
||||||
|
if not contact:
|
||||||
|
return
|
||||||
|
if has_child:
|
||||||
|
if nick is not None:
|
||||||
|
contact.contact_name = nick
|
||||||
|
gajim.interface.roster.draw_contact(user, name)
|
||||||
|
ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
|
||||||
|
if ctrl:
|
||||||
|
ctrl.update_ui()
|
||||||
|
win = gajim.interface.msg_win_mgr.get_window(user, name)
|
||||||
|
win.redraw_tab(ctrl)
|
||||||
|
win.show_title()
|
||||||
|
elif retract:
|
||||||
|
contact.contact_name = ''
|
||||||
|
|
||||||
def user_send_mood(account, mood, message = ''):
|
def user_send_mood(account, mood, message = ''):
|
||||||
if not gajim.config.get('publish_mood'):
|
if not gajim.config.get('publish_mood'):
|
||||||
return
|
return
|
||||||
|
@ -275,6 +313,15 @@ def user_send_tune(account, artist = '', title = '', source = '', track = 0,leng
|
||||||
|
|
||||||
gajim.connections[account].send_pb_publish('', xmpp.NS_TUNE, item, '0')
|
gajim.connections[account].send_pb_publish('', xmpp.NS_TUNE, item, '0')
|
||||||
|
|
||||||
|
def user_send_nickname(account, nick):
|
||||||
|
if not (gajim.config.get('publish_nick') and \
|
||||||
|
gajim.connections[account].pep_supported):
|
||||||
|
return
|
||||||
|
item = xmpp.Node('nick', {'xmlns': xmpp.NS_NICK})
|
||||||
|
item.addData(nick)
|
||||||
|
|
||||||
|
gajim.connections[account].send_pb_publish('', xmpp.NS_NICK, item, '0')
|
||||||
|
|
||||||
def user_retract_mood(account):
|
def user_retract_mood(account):
|
||||||
gajim.connections[account].send_pb_retract('', xmpp.NS_MOOD, '0')
|
gajim.connections[account].send_pb_retract('', xmpp.NS_MOOD, '0')
|
||||||
|
|
||||||
|
@ -283,3 +330,6 @@ def user_retract_activity(account):
|
||||||
|
|
||||||
def user_retract_tune(account):
|
def user_retract_tune(account):
|
||||||
gajim.connections[account].send_pb_retract('', xmpp.NS_TUNE, '0')
|
gajim.connections[account].send_pb_retract('', xmpp.NS_TUNE, '0')
|
||||||
|
|
||||||
|
def user_retract_nickname(account):
|
||||||
|
gajim.connections[account].send_pb_retract('', xmpp.NS_NICK, '0')
|
||||||
|
|
|
@ -263,6 +263,9 @@ class PreferencesWindow:
|
||||||
st = gajim.config.get('publish_tune')
|
st = gajim.config.get('publish_tune')
|
||||||
self.xml.get_widget('publish_tune_checkbutton').set_active(st)
|
self.xml.get_widget('publish_tune_checkbutton').set_active(st)
|
||||||
|
|
||||||
|
st = gajim.config.get('publish_nick')
|
||||||
|
self.xml.get_widget('publish_nick_checkbutton').set_active(st)
|
||||||
|
|
||||||
st = gajim.config.get('subscribe_mood')
|
st = gajim.config.get('subscribe_mood')
|
||||||
self.xml.get_widget('subscribe_mood_checkbutton').set_active(st)
|
self.xml.get_widget('subscribe_mood_checkbutton').set_active(st)
|
||||||
|
|
||||||
|
@ -272,6 +275,9 @@ class PreferencesWindow:
|
||||||
st = gajim.config.get('subscribe_tune')
|
st = gajim.config.get('subscribe_tune')
|
||||||
self.xml.get_widget('subscribe_tune_checkbutton').set_active(st)
|
self.xml.get_widget('subscribe_tune_checkbutton').set_active(st)
|
||||||
|
|
||||||
|
st = gajim.config.get('subscribe_nick')
|
||||||
|
self.xml.get_widget('subscribe_nick_checkbutton').set_active(st)
|
||||||
|
|
||||||
### Notifications tab ###
|
### Notifications tab ###
|
||||||
# On new event
|
# On new event
|
||||||
on_event_combobox = self.xml.get_widget('on_event_combobox')
|
on_event_combobox = self.xml.get_widget('on_event_combobox')
|
||||||
|
@ -560,6 +566,14 @@ class PreferencesWindow:
|
||||||
gajim.interface.roster.enable_syncing_status_msg_from_current_music_track(
|
gajim.interface.roster.enable_syncing_status_msg_from_current_music_track(
|
||||||
widget.get_active())
|
widget.get_active())
|
||||||
|
|
||||||
|
def on_publish_nick_checkbutton_toggled(self, widget):
|
||||||
|
if not widget.get_active():
|
||||||
|
for account in gajim.connections:
|
||||||
|
if gajim.connections[account].pep_supported:
|
||||||
|
pep.user_retract_nickname(account)
|
||||||
|
self.on_checkbutton_toggled(widget, 'publish_nick')
|
||||||
|
helpers.update_optional_features()
|
||||||
|
|
||||||
def on_subscribe_mood_checkbutton_toggled(self, widget):
|
def on_subscribe_mood_checkbutton_toggled(self, widget):
|
||||||
self.on_checkbutton_toggled(widget, 'subscribe_mood')
|
self.on_checkbutton_toggled(widget, 'subscribe_mood')
|
||||||
helpers.update_optional_features()
|
helpers.update_optional_features()
|
||||||
|
@ -572,6 +586,10 @@ class PreferencesWindow:
|
||||||
self.on_checkbutton_toggled(widget, 'subscribe_tune')
|
self.on_checkbutton_toggled(widget, 'subscribe_tune')
|
||||||
helpers.update_optional_features()
|
helpers.update_optional_features()
|
||||||
|
|
||||||
|
def on_subscribe_nick_checkbutton_toggled(self, widget):
|
||||||
|
self.on_checkbutton_toggled(widget, 'subscribe_nick')
|
||||||
|
helpers.update_optional_features()
|
||||||
|
|
||||||
def on_sort_by_show_checkbutton_toggled(self, widget):
|
def on_sort_by_show_checkbutton_toggled(self, widget):
|
||||||
self.on_checkbutton_toggled(widget, 'sort_by_show')
|
self.on_checkbutton_toggled(widget, 'sort_by_show')
|
||||||
gajim.interface.roster.draw_roster()
|
gajim.interface.roster.draw_roster()
|
||||||
|
|
|
@ -323,6 +323,8 @@ class ProfileWindow:
|
||||||
nick = ''
|
nick = ''
|
||||||
if vcard_.has_key('NICKNAME'):
|
if vcard_.has_key('NICKNAME'):
|
||||||
nick = vcard_['NICKNAME']
|
nick = vcard_['NICKNAME']
|
||||||
|
from common import pep
|
||||||
|
pep.user_send_nickname(self.account, nick)
|
||||||
if nick == '':
|
if nick == '':
|
||||||
nick = gajim.config.get_per('accounts', self.account, 'name')
|
nick = gajim.config.get_per('accounts', self.account, 'name')
|
||||||
gajim.nicks[self.account] = nick
|
gajim.nicks[self.account] = nick
|
||||||
|
|
Loading…
Add table
Reference in a new issue