[js & I] show pep info in account tooltip, fix a bug in create_contact()
This commit is contained in:
parent
192669b64e
commit
19761f081f
7 changed files with 160 additions and 56 deletions
2
TODO.pep
2
TODO.pep
|
@ -5,9 +5,7 @@ Tune use cases:
|
||||||
• on disconnection of an account set Tune to None
|
• on disconnection of an account set Tune to None
|
||||||
|
|
||||||
Tooltips use cases:
|
Tooltips use cases:
|
||||||
• Show PEP in contact tooltips
|
|
||||||
• Show PEP in GC tooltips
|
• Show PEP in GC tooltips
|
||||||
• Show PEP in account tooltips
|
|
||||||
|
|
||||||
Mood/Activity use cases
|
Mood/Activity use cases
|
||||||
• on connection of an account set them to None
|
• on connection of an account set them to None
|
||||||
|
|
|
@ -142,6 +142,9 @@ class Connection(ConnectionHandlers):
|
||||||
self.blocked_contacts = []
|
self.blocked_contacts = []
|
||||||
self.blocked_groups = []
|
self.blocked_groups = []
|
||||||
self.pep_supported = False
|
self.pep_supported = False
|
||||||
|
self.mood = {}
|
||||||
|
self.tune = {}
|
||||||
|
self.activity = {}
|
||||||
# Do we continue connection when we get roster (send presence,get vcard..)
|
# Do we continue connection when we get roster (send presence,get vcard..)
|
||||||
self.continue_connect_info = None
|
self.continue_connect_info = None
|
||||||
# To know the groupchat jid associated with a sranza ID. Useful to
|
# To know the groupchat jid associated with a sranza ID. Useful to
|
||||||
|
|
|
@ -27,17 +27,14 @@ class Contact:
|
||||||
'''Information concerning each contact'''
|
'''Information concerning each contact'''
|
||||||
def __init__(self, jid='', name='', groups=[], show='', status='', sub='',
|
def __init__(self, jid='', name='', groups=[], show='', status='', sub='',
|
||||||
ask='', resource='', priority=0, keyID='', our_chatstate=None,
|
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.jid = jid
|
||||||
self.name = name
|
self.name = name
|
||||||
self.contact_name = '' # nick choosen by contact
|
self.contact_name = '' # nick choosen by contact
|
||||||
self.groups = groups
|
self.groups = groups
|
||||||
self.show = show
|
self.show = show
|
||||||
self.status = status
|
self.status = status
|
||||||
# FIXME
|
|
||||||
self.mood = dict()
|
|
||||||
self.activity = dict()
|
|
||||||
self.tune = dict()
|
|
||||||
self.sub = sub
|
self.sub = sub
|
||||||
self.ask = ask
|
self.ask = ask
|
||||||
self.resource = resource
|
self.resource = resource
|
||||||
|
@ -67,6 +64,10 @@ class Contact:
|
||||||
self.chatstate = chatstate
|
self.chatstate = chatstate
|
||||||
self.last_status_time = last_status_time
|
self.last_status_time = last_status_time
|
||||||
|
|
||||||
|
self.mood = mood.copy()
|
||||||
|
self.tune = tune.copy()
|
||||||
|
self.activity = activity.copy()
|
||||||
|
|
||||||
def get_full_jid(self):
|
def get_full_jid(self):
|
||||||
if self.resource:
|
if self.resource:
|
||||||
return self.jid + '/' + self.resource
|
return self.jid + '/' + self.resource
|
||||||
|
@ -166,10 +167,11 @@ class Contacts:
|
||||||
|
|
||||||
def create_contact(self, jid='', name='', groups=[], show='', status='',
|
def create_contact(self, jid='', name='', groups=[], show='', status='',
|
||||||
sub='', ask='', resource='', priority=0, keyID='', our_chatstate=None,
|
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,
|
return Contact(jid, name, groups, show, status, sub, ask, resource,
|
||||||
priority, keyID, our_chatstate, chatstate, last_status_time,
|
priority, keyID, our_chatstate, chatstate, last_status_time,
|
||||||
composing_xep)
|
None, composing_xep, mood, tune, activity)
|
||||||
|
|
||||||
def copy_contact(self, contact):
|
def copy_contact(self, contact):
|
||||||
return self.create_contact(jid = contact.jid, name = contact.name,
|
return self.create_contact(jid = contact.jid, name = contact.name,
|
||||||
|
|
|
@ -1,31 +1,97 @@
|
||||||
from common import gajim, xmpp
|
from common import gajim, xmpp
|
||||||
|
|
||||||
def user_mood(items, name, jid):
|
def user_mood(items, name, jid):
|
||||||
|
has_child = False
|
||||||
|
mood = None
|
||||||
|
text = None
|
||||||
|
for item in items.getTags('item'):
|
||||||
|
child = item.getTag('mood')
|
||||||
|
if child is not None:
|
||||||
|
has_child = True
|
||||||
|
for ch in child.getChildren():
|
||||||
|
if ch.getName() != 'text':
|
||||||
|
mood = ch.getName()
|
||||||
|
else:
|
||||||
|
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
|
||||||
|
|
||||||
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
|
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
|
||||||
contact = gajim.contacts.get_contact(name, user, resource=resource)
|
contact = gajim.contacts.get_contact(name, user, resource=resource)
|
||||||
if not contact:
|
if not contact:
|
||||||
return
|
return
|
||||||
for item in items.getTags('item'):
|
if has_child:
|
||||||
child = item.getTag('mood')
|
|
||||||
if child is not None:
|
|
||||||
if contact.mood.has_key('mood'):
|
if contact.mood.has_key('mood'):
|
||||||
del contact.mood['mood']
|
del contact.mood['mood']
|
||||||
if contact.mood.has_key('text'):
|
if contact.mood.has_key('text'):
|
||||||
del contact.mood['text']
|
del contact.mood['text']
|
||||||
for ch in child.getChildren():
|
if mood != None:
|
||||||
if ch.getName() != 'text':
|
contact.mood['mood'] = mood
|
||||||
contact.mood['mood'] = ch.getName()
|
if text != None:
|
||||||
else:
|
contact.mood['text'] = text
|
||||||
contact.mood['text'] = ch.getData()
|
|
||||||
|
|
||||||
def user_tune(items, name, jid):
|
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:
|
||||||
|
has_child = True
|
||||||
|
for ch in child.getChildren():
|
||||||
|
if ch.getName() == 'artist':
|
||||||
|
artist = ch.getData()
|
||||||
|
elif ch.getName() == 'title':
|
||||||
|
title = ch.getData()
|
||||||
|
elif ch.getName() == 'source':
|
||||||
|
source = ch.getData()
|
||||||
|
elif ch.getName() == 'track':
|
||||||
|
track = ch.getData()
|
||||||
|
elif ch.getName() == 'length':
|
||||||
|
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)
|
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
|
||||||
contact = gajim.contacts.get_contact(name, user, resource=resource)
|
contact = gajim.contacts.get_contact(name, user, resource=resource)
|
||||||
if not contact:
|
if not contact:
|
||||||
return
|
return
|
||||||
for item in items.getTags('item'):
|
if has_child:
|
||||||
child = item.getTag('tune')
|
|
||||||
if child is not None:
|
|
||||||
if contact.tune.has_key('artist'):
|
if contact.tune.has_key('artist'):
|
||||||
del contact.tune['artist']
|
del contact.tune['artist']
|
||||||
if contact.tune.has_key('title'):
|
if contact.tune.has_key('title'):
|
||||||
|
@ -36,42 +102,71 @@ def user_tune(items, name, jid):
|
||||||
del contact.tune['track']
|
del contact.tune['track']
|
||||||
if contact.tune.has_key('length'):
|
if contact.tune.has_key('length'):
|
||||||
del contact.tune['length']
|
del contact.tune['length']
|
||||||
for ch in child.getChildren():
|
if artist != None:
|
||||||
if ch.getName() == 'artist':
|
contact.tune['artist'] = artist
|
||||||
contact.tune['artist'] = ch.getData()
|
if title != None:
|
||||||
elif ch.getName() == 'title':
|
contact.tune['title'] = title
|
||||||
contact.tune['title'] = ch.getData()
|
if source != None:
|
||||||
elif ch.getName() == 'source':
|
contact.tune['source'] = source
|
||||||
contact.tune['source'] = ch.getData()
|
if track != None:
|
||||||
elif ch.getName() == 'track':
|
contact.tune['track'] = track
|
||||||
contact.tune['track'] = ch.getData()
|
if length != None:
|
||||||
elif ch.getName() == 'length':
|
contact.tune['length'] = length
|
||||||
contact.tune['length'] = ch.getData()
|
|
||||||
|
|
||||||
def user_geoloc(items, name, jid):
|
def user_geoloc(items, name, jid):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def user_activity(items, name, jid):
|
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)
|
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
|
||||||
contact = gajim.contacts.get_contact(name, user, resource=resource)
|
contact = gajim.contacts.get_contact(name, user, resource=resource)
|
||||||
if not contact:
|
if not contact:
|
||||||
return
|
return
|
||||||
for item in items.getTags('item'):
|
if has_child:
|
||||||
child = item.getTag('activity')
|
|
||||||
if child is not None:
|
|
||||||
if contact.activity.has_key('activity'):
|
if contact.activity.has_key('activity'):
|
||||||
del contact.activity['activity']
|
del contact.activity['activity']
|
||||||
if contact.activity.has_key('subactivity'):
|
if contact.activity.has_key('subactivity'):
|
||||||
del contact.activity['subactivity']
|
del contact.activity['subactivity']
|
||||||
if contact.activity.has_key('text'):
|
if contact.activity.has_key('text'):
|
||||||
del contact.activity['text']
|
del contact.activity['text']
|
||||||
for ch in child.getChildren():
|
if activity != None:
|
||||||
if ch.getName() != 'text':
|
contact.activity['activity'] = activity
|
||||||
contact.activity['activity'] = ch.getName()
|
if subactivity != None:
|
||||||
for chi in ch.getChildren():
|
contact.activity['subactivity'] = subactivity
|
||||||
contact.activity['subactivity'] = chi.getName()
|
if text != None:
|
||||||
else:
|
contact.activity['text'] = text
|
||||||
contact.activity['text'] = ch.getData()
|
|
||||||
|
|
||||||
def user_send_mood(account, mood, message = ''):
|
def user_send_mood(account, mood, message = ''):
|
||||||
if gajim.config.get('publish_mood') == False:
|
if gajim.config.get('publish_mood') == False:
|
||||||
|
|
|
@ -86,6 +86,9 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
|
||||||
self.no_log_for = False
|
self.no_log_for = False
|
||||||
|
|
||||||
self.pep_supported = False
|
self.pep_supported = False
|
||||||
|
self.mood = {}
|
||||||
|
self.tune = {}
|
||||||
|
self.activity = {}
|
||||||
# Do we continue connection when we get roster (send presence,get vcard...)
|
# Do we continue connection when we get roster (send presence,get vcard...)
|
||||||
self.continue_connect_info = None
|
self.continue_connect_info = None
|
||||||
if USE_GPG:
|
if USE_GPG:
|
||||||
|
|
|
@ -1530,7 +1530,10 @@ class RosterWindow:
|
||||||
name = account_name, show = connection.get_status(), sub = '',
|
name = account_name, show = connection.get_status(), sub = '',
|
||||||
status = connection.status,
|
status = connection.status,
|
||||||
resource = connection.server_resource,
|
resource = connection.server_resource,
|
||||||
priority = connection.priority)
|
priority = connection.priority,
|
||||||
|
mood = connection.mood,
|
||||||
|
tune = connection.tune,
|
||||||
|
activity = connection.activity)
|
||||||
if gajim.connections[account].gpg:
|
if gajim.connections[account].gpg:
|
||||||
contact.keyID = gajim.config.get_per('accounts', connection.name,
|
contact.keyID = gajim.config.get_per('accounts', connection.name,
|
||||||
'keyid')
|
'keyid')
|
||||||
|
|
|
@ -500,14 +500,14 @@ class RosterTooltip(NotificationAreaTooltip):
|
||||||
# we append show below
|
# we append show below
|
||||||
|
|
||||||
if contact.mood.has_key('mood'):
|
if contact.mood.has_key('mood'):
|
||||||
mood_string = 'Mood: <b>%s</b>' % contact.mood['mood'].strip()
|
mood_string = _('Mood:') + ' <b>%s</b>' % contact.mood['mood'].strip()
|
||||||
if contact.mood.has_key('text') and contact.mood['text'] != '':
|
if contact.mood.has_key('text') and contact.mood['text'] != '':
|
||||||
mood_string += ' (%s)' % contact.mood['text'].strip()
|
mood_string += ' (%s)' % contact.mood['text'].strip()
|
||||||
properties.append((mood_string, None))
|
properties.append((mood_string, None))
|
||||||
|
|
||||||
if contact.activity.has_key('activity'):
|
if contact.activity.has_key('activity'):
|
||||||
activity = contact.activity['activity'].strip()
|
activity = contact.activity['activity'].strip()
|
||||||
activity_string = 'Activity: <b>%s' % activity
|
activity_string = _('Activity:') + ' <b>%s' % activity
|
||||||
if contact.activity.has_key('subactivity'):
|
if contact.activity.has_key('subactivity'):
|
||||||
activity_sub = contact.activity['subactivity'].strip()
|
activity_sub = contact.activity['subactivity'].strip()
|
||||||
activity_string += ' (%s)</b>' % activity_sub
|
activity_string += ' (%s)</b>' % activity_sub
|
||||||
|
@ -531,8 +531,8 @@ class RosterTooltip(NotificationAreaTooltip):
|
||||||
source = contact.tune['source'].strip()
|
source = contact.tune['source'].strip()
|
||||||
else:
|
else:
|
||||||
source = _('Unknown Source')
|
source = _('Unknown Source')
|
||||||
tune_string = '♪ ' + _('<b>"%(title)s"</b> by <i>%(artist)s</i>\nfrom <i>%(source)s</i>' %\
|
tune_string = _('Tune:') + ' ' + _('<b>"%(title)s"</b> by <i>%(artist)s</i>\nfrom <i>%(source)s</i>' %\
|
||||||
{'title': title, 'artist': artist, 'source': source}) + ' ♪'
|
{'title': title, 'artist': artist, 'source': source})
|
||||||
properties.append((tune_string, None))
|
properties.append((tune_string, None))
|
||||||
|
|
||||||
if contact.status:
|
if contact.status:
|
||||||
|
|
Loading…
Add table
Reference in a new issue