diff --git a/TODO.pep b/TODO.pep
index 05c924dbf..cf622c632 100644
--- a/TODO.pep
+++ b/TODO.pep
@@ -5,9 +5,7 @@ Tune use cases:
• on disconnection of an account set Tune to None
Tooltips use cases:
-• Show PEP in contact tooltips
• Show PEP in GC tooltips
-• Show PEP in account tooltips
Mood/Activity use cases
• on connection of an account set them to None
diff --git a/src/common/connection.py b/src/common/connection.py
index 91c89f220..9113f4a51 100644
--- a/src/common/connection.py
+++ b/src/common/connection.py
@@ -142,6 +142,9 @@ class Connection(ConnectionHandlers):
self.blocked_contacts = []
self.blocked_groups = []
self.pep_supported = False
+ self.mood = {}
+ self.tune = {}
+ self.activity = {}
# Do we continue connection when we get roster (send presence,get vcard..)
self.continue_connect_info = None
# To know the groupchat jid associated with a sranza ID. Useful to
diff --git a/src/common/contacts.py b/src/common/contacts.py
index ef02f43da..302f3390d 100644
--- a/src/common/contacts.py
+++ b/src/common/contacts.py
@@ -27,17 +27,14 @@ class Contact:
'''Information concerning each contact'''
def __init__(self, jid='', name='', groups=[], show='', status='', sub='',
ask='', resource='', priority=0, keyID='', our_chatstate=None,
- chatstate=None, last_status_time=None, msg_id = None, composing_xep = None):
+ chatstate=None, last_status_time=None, msg_id = None, composing_xep = None,
+ mood={}, tune={}, activity={}):
self.jid = jid
self.name = name
self.contact_name = '' # nick choosen by contact
self.groups = groups
self.show = show
self.status = status
- # FIXME
- self.mood = dict()
- self.activity = dict()
- self.tune = dict()
self.sub = sub
self.ask = ask
self.resource = resource
@@ -67,6 +64,10 @@ class Contact:
self.chatstate = chatstate
self.last_status_time = last_status_time
+ self.mood = mood.copy()
+ self.tune = tune.copy()
+ self.activity = activity.copy()
+
def get_full_jid(self):
if self.resource:
return self.jid + '/' + self.resource
@@ -166,10 +167,11 @@ class Contacts:
def create_contact(self, jid='', name='', groups=[], show='', status='',
sub='', ask='', resource='', priority=0, keyID='', our_chatstate=None,
- chatstate=None, last_status_time=None, composing_xep=None):
+ chatstate=None, last_status_time=None, composing_xep=None,
+ mood={}, tune={}, activity={}):
return Contact(jid, name, groups, show, status, sub, ask, resource,
priority, keyID, our_chatstate, chatstate, last_status_time,
- composing_xep)
+ None, composing_xep, mood, tune, activity)
def copy_contact(self, contact):
return self.create_contact(jid = contact.jid, name = contact.name,
diff --git a/src/common/pep.py b/src/common/pep.py
index 3106c1670..c9f2f59c2 100644
--- a/src/common/pep.py
+++ b/src/common/pep.py
@@ -1,77 +1,172 @@
from common import gajim, xmpp
def user_mood(items, name, jid):
- (user, resource) = gajim.get_room_and_nick_from_fjid(jid)
- contact = gajim.contacts.get_contact(name, user, resource=resource)
- if not contact:
- return
+ has_child = False
+ mood = None
+ text = None
for item in items.getTags('item'):
child = item.getTag('mood')
if child is not None:
- if contact.mood.has_key('mood'):
- del contact.mood['mood']
- if contact.mood.has_key('text'):
- del contact.mood['text']
+ has_child = True
for ch in child.getChildren():
if ch.getName() != 'text':
- contact.mood['mood'] = ch.getName()
+ mood = ch.getName()
else:
- contact.mood['text'] = ch.getData()
+ text = ch.getData()
+ if jid == gajim.get_jid_from_account(name):
+ acc = gajim.connections[name]
+ if has_child:
+ if acc.mood.has_key('mood'):
+ del acc.mood['mood']
+ if acc.mood.has_key('text'):
+ del acc.mood['text']
+ if mood != None:
+ acc.mood['mood'] = mood
+ if text != None:
+ acc.mood['text'] = text
-def user_tune(items, name, jid):
(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 contact.mood.has_key('mood'):
+ del contact.mood['mood']
+ if contact.mood.has_key('text'):
+ del contact.mood['text']
+ if mood != None:
+ contact.mood['mood'] = mood
+ if text != None:
+ contact.mood['text'] = text
+
+def user_tune(items, name, jid):
+ has_child = False
+ artist = None
+ title = None
+ source = None
+ track = None
+ length = None
+
for item in items.getTags('item'):
child = item.getTag('tune')
if child is not None:
- if contact.tune.has_key('artist'):
- del contact.tune['artist']
- if contact.tune.has_key('title'):
- del contact.tune['title']
- if contact.tune.has_key('source'):
- del contact.tune['source']
- if contact.tune.has_key('track'):
- del contact.tune['track']
- if contact.tune.has_key('length'):
- del contact.tune['length']
+ has_child = True
for ch in child.getChildren():
if ch.getName() == 'artist':
- contact.tune['artist'] = ch.getData()
+ artist = ch.getData()
elif ch.getName() == 'title':
- contact.tune['title'] = ch.getData()
+ title = ch.getData()
elif ch.getName() == 'source':
- contact.tune['source'] = ch.getData()
+ source = ch.getData()
elif ch.getName() == 'track':
- contact.tune['track'] = ch.getData()
+ track = ch.getData()
elif ch.getName() == 'length':
- contact.tune['length'] = ch.getData()
+ length = ch.getData()
+
+ if jid == gajim.get_jid_from_account(name):
+ acc = gajim.connections[name]
+ if has_child:
+ if acc.tune.has_key('artist'):
+ del acc.tune['artist']
+ if acc.tune.has_key('title'):
+ del acc.tune['title']
+ if acc.tune.has_key('source'):
+ del acc.tune['source']
+ if acc.tune.has_key('track'):
+ del acc.tune['track']
+ if acc.tune.has_key('length'):
+ del acc.tune['length']
+ if artist != None:
+ acc.tune['artist'] = artist
+ if title != None:
+ acc.tune['title'] = title
+ if source != None:
+ acc.tune['source'] = source
+ if track != None:
+ acc.tune['track'] = track
+ if length != None:
+ acc.tune['length'] = length
+
+ (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 contact.tune.has_key('artist'):
+ del contact.tune['artist']
+ if contact.tune.has_key('title'):
+ del contact.tune['title']
+ if contact.tune.has_key('source'):
+ del contact.tune['source']
+ if contact.tune.has_key('track'):
+ del contact.tune['track']
+ if contact.tune.has_key('length'):
+ del contact.tune['length']
+ if artist != None:
+ contact.tune['artist'] = artist
+ if title != None:
+ contact.tune['title'] = title
+ if source != None:
+ contact.tune['source'] = source
+ if track != None:
+ contact.tune['track'] = track
+ if length != None:
+ contact.tune['length'] = length
def user_geoloc(items, name, jid):
pass
def user_activity(items, name, jid):
+ has_child = False
+ activity = None
+ subactivity = None
+ text = None
+
+ for item in items.getTags('item'):
+ child = item.getTag('activity')
+ if child is not None:
+ has_child = True
+ for ch in child.getChildren():
+ if ch.getName() != 'text':
+ activity = ch.getName()
+ for chi in ch.getChildren():
+ subactivity = chi.getName()
+ else:
+ text = ch.getData()
+
+ if jid == gajim.get_jid_from_account(name):
+ acc = gajim.connections[name]
+ if has_child:
+ if acc.activity.has_key('activity'):
+ del acc.activity['activity']
+ if acc.activity.has_key('subactivity'):
+ del acc.activity['subactivity']
+ if acc.activity.has_key('text'):
+ del acc.activity['text']
+ if activity != None:
+ acc.activity['activity'] = activity
+ if subactivity != None:
+ acc.activity['subactivity'] = subactivity
+ if text != None:
+ acc.activity['text'] = text
+
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
contact = gajim.contacts.get_contact(name, user, resource=resource)
if not contact:
return
- for item in items.getTags('item'):
- child = item.getTag('activity')
- if child is not None:
- if contact.activity.has_key('activity'):
- del contact.activity['activity']
- if contact.activity.has_key('subactivity'):
- del contact.activity['subactivity']
- if contact.activity.has_key('text'):
- del contact.activity['text']
- for ch in child.getChildren():
- if ch.getName() != 'text':
- contact.activity['activity'] = ch.getName()
- for chi in ch.getChildren():
- contact.activity['subactivity'] = chi.getName()
- else:
- contact.activity['text'] = ch.getData()
+ if has_child:
+ if contact.activity.has_key('activity'):
+ del contact.activity['activity']
+ if contact.activity.has_key('subactivity'):
+ del contact.activity['subactivity']
+ if contact.activity.has_key('text'):
+ del contact.activity['text']
+ if activity != None:
+ contact.activity['activity'] = activity
+ if subactivity != None:
+ contact.activity['subactivity'] = subactivity
+ if text != None:
+ contact.activity['text'] = text
def user_send_mood(account, mood, message = ''):
if gajim.config.get('publish_mood') == False:
diff --git a/src/common/zeroconf/connection_zeroconf.py b/src/common/zeroconf/connection_zeroconf.py
index 36f56a347..1a497e3eb 100644
--- a/src/common/zeroconf/connection_zeroconf.py
+++ b/src/common/zeroconf/connection_zeroconf.py
@@ -86,6 +86,9 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
self.no_log_for = False
self.pep_supported = False
+ self.mood = {}
+ self.tune = {}
+ self.activity = {}
# Do we continue connection when we get roster (send presence,get vcard...)
self.continue_connect_info = None
if USE_GPG:
diff --git a/src/roster_window.py b/src/roster_window.py
index 1ab136976..801d533fa 100644
--- a/src/roster_window.py
+++ b/src/roster_window.py
@@ -1530,7 +1530,10 @@ class RosterWindow:
name = account_name, show = connection.get_status(), sub = '',
status = connection.status,
resource = connection.server_resource,
- priority = connection.priority)
+ priority = connection.priority,
+ mood = connection.mood,
+ tune = connection.tune,
+ activity = connection.activity)
if gajim.connections[account].gpg:
contact.keyID = gajim.config.get_per('accounts', connection.name,
'keyid')
diff --git a/src/tooltips.py b/src/tooltips.py
index ecc8741b8..bf9f34ec7 100644
--- a/src/tooltips.py
+++ b/src/tooltips.py
@@ -500,14 +500,14 @@ class RosterTooltip(NotificationAreaTooltip):
# we append show below
if contact.mood.has_key('mood'):
- mood_string = 'Mood: %s' % contact.mood['mood'].strip()
+ mood_string = _('Mood:') + ' %s' % contact.mood['mood'].strip()
if contact.mood.has_key('text') and contact.mood['text'] != '':
mood_string += ' (%s)' % contact.mood['text'].strip()
properties.append((mood_string, None))
if contact.activity.has_key('activity'):
activity = contact.activity['activity'].strip()
- activity_string = 'Activity: %s' % activity
+ activity_string = _('Activity:') + ' %s' % activity
if contact.activity.has_key('subactivity'):
activity_sub = contact.activity['subactivity'].strip()
activity_string += ' (%s)' % activity_sub
@@ -531,8 +531,8 @@ class RosterTooltip(NotificationAreaTooltip):
source = contact.tune['source'].strip()
else:
source = _('Unknown Source')
- tune_string = '♪ ' + _('"%(title)s" by %(artist)s\nfrom %(source)s' %\
- {'title': title, 'artist': artist, 'source': source}) + ' ♪'
+ tune_string = _('Tune:') + ' ' + _('"%(title)s" by %(artist)s\nfrom %(source)s' %\
+ {'title': title, 'artist': artist, 'source': source})
properties.append((tune_string, None))
if contact.status: