Buggy. Don\'t touch

This commit is contained in:
Piotr Gaczkowski 2007-03-29 19:04:14 +00:00
parent 512db7618b
commit 149b0fcdef
4 changed files with 34 additions and 19 deletions

View file

@ -717,7 +717,6 @@ class ConnectionDisco:
iq = iq_obj.buildReply('result') iq = iq_obj.buildReply('result')
q = iq.getTag('query') q = iq.getTag('query')
if node: if node:
print node
q.setAttr('node', node) q.setAttr('node', node)
q.addChild('identity', attrs = {'type': 'pc', 'category': 'client', q.addChild('identity', attrs = {'type': 'pc', 'category': 'client',
'name': 'Gajim'}) 'name': 'Gajim'})
@ -1512,7 +1511,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
''' Called when we receive <message/> with pubsub event. ''' ''' Called when we receive <message/> with pubsub event. '''
# TODO: Logging? (actually services where logging would be useful, should # TODO: Logging? (actually services where logging would be useful, should
# TODO: allow to access archives remotely...) # TODO: allow to access archives remotely...)
jid = msg.getAttr('from') jid = helpers.get_jid_from_iq(msg)
event = msg.getTag('event') event = msg.getTag('event')
# XEP-0107: User Mood # XEP-0107: User Mood

View file

@ -18,7 +18,7 @@ import common.gajim
class Contact: class Contact:
'''Information concerning each contact''' '''Information concerning each contact'''
def __init__(self, jid='', name='', groups=[], show='', status='', mood='', activity='', sub='', def __init__(self, jid='', name='', groups=[], show='', status='', mood={}, activity={}, 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_jep = None): chatstate=None, last_status_time=None, msg_id = None, composing_jep = None):
self.jid = jid self.jid = jid
@ -141,7 +141,7 @@ class Contacts:
del self._gc_contacts[account] del self._gc_contacts[account]
del self._metacontacts_tags[account] del self._metacontacts_tags[account]
def create_contact(self, jid='', name='', groups=[], show='', status='', mood='', activity='', def create_contact(self, jid='', name='', groups=[], show='', status='', mood={}, activity={},
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_jep=None): chatstate=None, last_status_time=None, composing_jep=None):
return Contact(jid, name, groups, show, status, mood, return Contact(jid, name, groups, show, status, mood,

View file

@ -1,17 +1,19 @@
from common import gajim from common import gajim
#from common import helpers
def user_mood(items, name, jid): def user_mood(items, name, jid):
contacts = gajim.contacts.get_contact(name, jid) (user, resource) = gajim.get_room_and_nick_from_fjid(jid)
contacts = gajim.contacts.get_contact(name, user, resource=resource)
for item in items.getTags('item'): for item in items.getTags('item'):
child = item.getTag('mood') child = item.getTag('mood')
if child is not None: if child is not None:
for ch in child.getChildren(): for ch in child.getChildren():
if ch.getName() != 'text': if ch.getName() != 'text':
for contact in contacts: for contact in contacts:
contact.mood = ch.getName() contact.mood['mood'] = ch.getName()
else: else:
for contact in contacts: for contact in contacts:
contact.mood_text = ch.getData() contact.mood['text'] = ch.getData()
def user_tune(items, name, jid): def user_tune(items, name, jid):
pass pass
@ -20,14 +22,18 @@ def user_geoloc(items, name, jid):
pass pass
def user_activity(items, name, jid): def user_activity(items, name, jid):
contacts = gajim.contacts.get_contact(name, jid) (user, resource) = gajim.get_room_and_nick_from_fjid(jid)
contacts = gajim.contacts.get_contact(name, user, resource=resource)
for item in items.getTags('item'): for item in items.getTags('item'):
child = item.getTag('activity') child = item.getTag('activity')
if child is not None: if child is not None:
for ch in child.getChildren(): for ch in child.getChildren():
if ch.getName() != 'text': if ch.getName() != 'text':
for contact in contacts: for contact in contacts:
contact.activity = ch.getName() contact.activity['activity'] = ch.getName()
for chi in ch.getChildren():
for contact in contacts:
contact.activity['subactivity'] = chi.getName()
else: else:
for contact in contacts: for contact in contacts:
contact.activity_text = ch.getData() contact.activity['text'] = ch.getData()

View file

@ -478,17 +478,27 @@ class RosterTooltip(NotificationAreaTooltip):
show = '<i>' + show + '</i>' show = '<i>' + show + '</i>'
# we append show below # we append show below
if contact.mood: if contact.mood.has_key('mood'):
mood = contact.mood.strip() mood = contact.mood['mood'].strip()
mood_text = contact.mood_text.strip() if contact.mood.has_key('text'):
mood_text = contact.mood['text'].strip()
else:
mood_text = ''
if mood: if mood:
properties.append(('<b>%s:</b> %s' % (mood, mood_text), None)) properties.append(('Mood: <b>%s</b> (%s)' % (mood, mood_text), None))
if contact.activity: if contact.activity.has_key('activity'):
activity = contact.activity.strip() activity = contact.activity['activity'].strip()
activity_text = contact.activity_text.strip() activity_string = 'Activity: <b>%s' % activity
if activity: if contact.activity.has_key('subactivity'):
properties.append(('<b>%s:</b> %s' % (activity, activity_text), None)) activity_sub = contact.activity['subactivity'].strip()
activity_string += ' (%s)</b>' % activity_sub
else:
activity_string += '</b>'
if contact.activity.has_key('text'):
activity_text = contact.activity['text'].strip()
activity_string += ' (%s)' % activity_text
properties.append((activity_string, None))
if contact.status: if contact.status:
status = contact.status.strip() status = contact.status.strip()