gajim-plural/src/common/pep.py

50 lines
1.5 KiB
Python
Raw Normal View History

2007-03-31 00:52:11 +02:00
from common import gajim, xmpp
2007-03-26 00:27:43 +02:00
def user_mood(items, name, jid):
2007-03-31 00:52:11 +02:00
#FIXME: text deletion
2007-03-29 21:04:14 +02:00
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
contacts = gajim.contacts.get_contact(name, user, resource=resource)
2007-03-26 00:27:43 +02:00
for item in items.getTags('item'):
child = item.getTag('mood')
if child is not None:
for ch in child.getChildren():
if ch.getName() != 'text':
for contact in contacts:
2007-03-29 21:04:14 +02:00
contact.mood['mood'] = ch.getName()
2007-03-26 00:27:43 +02:00
else:
for contact in contacts:
2007-03-29 21:04:14 +02:00
contact.mood['text'] = ch.getData()
2007-03-26 00:27:43 +02:00
def user_tune(items, name, jid):
pass
def user_geoloc(items, name, jid):
pass
def user_activity(items, name, jid):
2007-03-31 00:52:11 +02:00
#FIXME: text deletion
2007-03-29 21:04:14 +02:00
(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'):
child = item.getTag('activity')
if child is not None:
for ch in child.getChildren():
if ch.getName() != 'text':
for contact in contacts:
2007-03-29 21:04:14 +02:00
contact.activity['activity'] = ch.getName()
for chi in ch.getChildren():
for contact in contacts:
contact.activity['subactivity'] = chi.getName()
else:
for contact in contacts:
2007-03-29 21:04:14 +02:00
contact.activity['text'] = ch.getData()
2007-03-31 00:52:11 +02:00
def user_send_mood(account, mood, message = ''):
item = xmpp.Node('mood', {'xmlns': xmpp.NS_MOOD})
item.addChild(mood)
if message != '':
i = item.addChild('text')
i.addData(message)
gajim.connections[account].send_pb_publish('', xmpp.NS_MOOD, item, '0')