diff --git a/data/glade/preferences_window.glade b/data/glade/preferences_window.glade
index b8282fa4d..7890842e9 100644
--- a/data/glade/preferences_window.glade
+++ b/data/glade/preferences_window.glade
@@ -751,7 +751,7 @@ Disabled
True
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
2
- 4
+ 5
6
6
@@ -792,6 +792,25 @@ Disabled
GTK_FILL
+
+
+ True
+ True
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+ Nickname
+ True
+ 0
+ True
+
+
+
+ 4
+ 5
+ 1
+ 2
+ GTK_FILL
+
+
True
@@ -843,6 +862,23 @@ Disabled
GTK_FILL
+
+
+ True
+ True
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+ Nickname
+ True
+ 0
+ True
+
+
+
+ 4
+ 5
+ GTK_FILL
+
+
True
diff --git a/src/common/config.py b/src/common/config.py
index 434754546..5ced3829f 100644
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -252,9 +252,11 @@ class Config:
'publish_mood': [opt_bool, False],
'publish_activity': [opt_bool, False],
'publish_tune': [opt_bool, False],
+ 'publish_nick': [opt_bool, True],
'subscribe_mood': [opt_bool, True],
'subscribe_activity': [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.')],
'check_idle_every_foo_seconds': [opt_int, 2, _('Choose interval between 2 checks of idleness.')],
}
diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py
index a0f9332f0..bf624655e 100644
--- a/src/common/connection_handlers.py
+++ b/src/common/connection_handlers.py
@@ -1809,6 +1809,9 @@ returns the session that we last sent a message to.'''
# XEP-0108: User Activity
items = event.getTag('items', {'node': common.xmpp.NS_ACTIVITY})
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')
if items is None: return
diff --git a/src/common/helpers.py b/src/common/helpers.py
index f6d99c149..6250ef037 100644
--- a/src/common/helpers.py
+++ b/src/common/helpers.py
@@ -1288,6 +1288,10 @@ def update_optional_features():
gajim.gajim_optional_features.append(xmpp.NS_TUNE)
if gajim.config.get('subscribe_tune'):
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':
gajim.gajim_optional_features.append(xmpp.NS_CHATSTATES)
if not gajim.config.get('ignore_incoming_xhtml'):
diff --git a/src/common/pep.py b/src/common/pep.py
index 6abc317b7..457875fc6 100644
--- a/src/common/pep.py
+++ b/src/common/pep.py
@@ -224,6 +224,44 @@ def user_activity(items, name, jid):
if contact.activity.has_key('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 = ''):
if not gajim.config.get('publish_mood'):
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')
+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):
gajim.connections[account].send_pb_retract('', xmpp.NS_MOOD, '0')
@@ -283,3 +330,6 @@ def user_retract_activity(account):
def user_retract_tune(account):
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')
diff --git a/src/config.py b/src/config.py
index df9c63826..1b66146df 100644
--- a/src/config.py
+++ b/src/config.py
@@ -263,6 +263,9 @@ class PreferencesWindow:
st = gajim.config.get('publish_tune')
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')
self.xml.get_widget('subscribe_mood_checkbutton').set_active(st)
@@ -272,6 +275,9 @@ class PreferencesWindow:
st = gajim.config.get('subscribe_tune')
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 ###
# On new event
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(
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):
self.on_checkbutton_toggled(widget, 'subscribe_mood')
helpers.update_optional_features()
@@ -572,6 +586,10 @@ class PreferencesWindow:
self.on_checkbutton_toggled(widget, 'subscribe_tune')
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):
self.on_checkbutton_toggled(widget, 'sort_by_show')
gajim.interface.roster.draw_roster()
diff --git a/src/profile_window.py b/src/profile_window.py
index 61ffcc19d..c690cc0ff 100644
--- a/src/profile_window.py
+++ b/src/profile_window.py
@@ -323,6 +323,8 @@ class ProfileWindow:
nick = ''
if vcard_.has_key('NICKNAME'):
nick = vcard_['NICKNAME']
+ from common import pep
+ pep.user_send_nickname(self.account, nick)
if nick == '':
nick = gajim.config.get_per('accounts', self.account, 'name')
gajim.nicks[self.account] = nick