fix new contacts API in pep

This commit is contained in:
Yann Leboulanger 2007-08-09 15:54:16 +00:00
parent 853448943b
commit a18e21c476

View file

@ -2,73 +2,76 @@ from common import gajim, xmpp
def user_mood(items, name, jid): def user_mood(items, name, jid):
(user, resource) = gajim.get_room_and_nick_from_fjid(jid) (user, resource) = gajim.get_room_and_nick_from_fjid(jid)
contacts = gajim.contacts.get_contact(name, user, resource=resource) contact = gajim.contacts.get_contact(name, user, resource=resource)
if not contact:
return
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 contact in contacts: 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():
for ch in child.getChildren(): if ch.getName() != 'text':
if ch.getName() != 'text': contact.mood['mood'] = ch.getName()
contact.mood['mood'] = ch.getName() else:
else: contact.mood['text'] = ch.getData()
contact.mood['text'] = ch.getData()
def user_tune(items, name, jid): def user_tune(items, name, jid):
(user, resource) = gajim.get_room_and_nick_from_fjid(jid) (user, resource) = gajim.get_room_and_nick_from_fjid(jid)
contacts = gajim.contacts.get_contact(name, user, resource=resource) contact = gajim.contacts.get_contact(name, user, resource=resource)
if not contact:
return
for item in items.getTags('item'): for item in items.getTags('item'):
child = item.getTag('tune') child = item.getTag('tune')
if child is not None: if child is not None:
for contact in contacts: 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'): del contact.tune['title']
del contact.tune['title'] if contact.tune.has_key('source'):
if contact.tune.has_key('source'): del contact.tune['source']
del contact.tune['source'] if contact.tune.has_key('track'):
if contact.tune.has_key('track'): 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():
for ch in child.getChildren(): if ch.getName() == 'artist':
if ch.getName() == 'artist': contact.tune['artist'] = ch.getData()
contact.tune['artist'] = ch.getData() elif ch.getName() == 'title':
elif ch.getName() == 'title': contact.tune['title'] = ch.getData()
contact.tune['title'] = ch.getData() elif ch.getName() == 'source':
elif ch.getName() == 'source': contact.tune['source'] = ch.getData()
contact.tune['source'] = ch.getData() elif ch.getName() == 'track':
elif ch.getName() == 'track': contact.tune['track'] = ch.getData()
contact.tune['track'] = ch.getData() elif ch.getName() == 'length':
elif ch.getName() == 'length': contact.tune['length'] = ch.getData()
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):
(user, resource) = gajim.get_room_and_nick_from_fjid(jid) (user, resource) = gajim.get_room_and_nick_from_fjid(jid)
contacts = gajim.contacts.get_contact(name, user, resource=resource) contact = gajim.contacts.get_contact(name, user, resource=resource)
if not contact:
return
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 contact in contacts: 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():
for ch in child.getChildren(): if ch.getName() != 'text':
if ch.getName() != 'text': contact.activity['activity'] = ch.getName()
contact.activity['activity'] = ch.getName() for chi in ch.getChildren():
for chi in ch.getChildren(): contact.activity['subactivity'] = chi.getName()
contact.activity['subactivity'] = chi.getName() else:
else: contact.activity['text'] = ch.getData()
contact.activity['text'] = ch.getData()
def user_send_mood(account, mood, message = ''): def user_send_mood(account, mood, message = ''):
item = xmpp.Node('mood', {'xmlns': xmpp.NS_MOOD}) item = xmpp.Node('mood', {'xmlns': xmpp.NS_MOOD})