2008-08-15 19:31:51 +02:00
|
|
|
# -*- coding:utf-8 -*-
|
2008-08-15 05:39:27 +02:00
|
|
|
## src/common/pep.py
|
|
|
|
##
|
|
|
|
## Copyright (C) 2007 Piotr Gaczkowski <doomhammerng AT gmail.com>
|
|
|
|
## Copyright (C) 2007-2008 Yann Leboulanger <asterix AT lagaule.org>
|
|
|
|
## Copyright (C) 2008 Brendan Taylor <whateley AT gmail.com>
|
|
|
|
## Jean-Marie Traissard <jim AT lapin.org>
|
|
|
|
## Jonathan Schleifer <js-gajim AT webkeks.org>
|
|
|
|
## Stephan Erb <steve-e AT h3c.de>
|
|
|
|
##
|
|
|
|
## This file is part of Gajim.
|
|
|
|
##
|
|
|
|
## Gajim is free software; you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published
|
|
|
|
## by the Free Software Foundation; version 3 only.
|
|
|
|
##
|
|
|
|
## Gajim is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
##
|
|
|
|
|
2007-03-31 00:52:11 +02:00
|
|
|
from common import gajim, xmpp
|
2007-03-26 00:27:43 +02:00
|
|
|
|
2008-07-29 21:02:57 +02:00
|
|
|
MOODS = {
|
2008-10-30 20:01:26 +01:00
|
|
|
'afraid': _('Afraid'),
|
|
|
|
'amazed': _('Amazed'),
|
|
|
|
'amorous': _('Amorous'),
|
|
|
|
'angry': _('Angry'),
|
|
|
|
'annoyed': _('Annoyed'),
|
|
|
|
'anxious': _('Anxious'),
|
|
|
|
'aroused': _('Aroused'),
|
|
|
|
'ashamed': _('Ashamed'),
|
|
|
|
'bored': _('Bored'),
|
|
|
|
'brave': _('Brave'),
|
|
|
|
'calm': _('Calm'),
|
|
|
|
'cautious': _('Cautious'),
|
|
|
|
'cold': _('Cold'),
|
|
|
|
'confident': _('Confident'),
|
|
|
|
'confused': _('Confused'),
|
|
|
|
'contemplative': _('Contemplative'),
|
|
|
|
'contented': _('Contented'),
|
|
|
|
'cranky': _('Cranky'),
|
|
|
|
'crazy': _('Crazy'),
|
|
|
|
'creative': _('Creative'),
|
|
|
|
'curious': _('Curious'),
|
|
|
|
'dejected': _('Dejected'),
|
|
|
|
'depressed': _('Depressed'),
|
|
|
|
'disappointed': _('Disappointed'),
|
|
|
|
'disgusted': _('Disgusted'),
|
|
|
|
'dismayed': _('Dismayed'),
|
|
|
|
'distracted': _('Distracted'),
|
|
|
|
'embarrassed': _('Embarrassed'),
|
|
|
|
'envious': _('Envious'),
|
|
|
|
'excited': _('Excited'),
|
|
|
|
'flirtatious': _('Flirtatious'),
|
|
|
|
'frustrated': _('Frustrated'),
|
|
|
|
'grateful': _('Grateful'),
|
|
|
|
'grieving': _('Grieving'),
|
|
|
|
'grumpy': _('Grumpy'),
|
|
|
|
'guilty': _('Guilty'),
|
|
|
|
'happy': _('Happy'),
|
|
|
|
'hopeful': _('Hopeful'),
|
|
|
|
'hot': _('Hot'),
|
|
|
|
'humbled': _('Humbled'),
|
|
|
|
'humiliated': _('Humiliated'),
|
|
|
|
'hungry': _('Hungry'),
|
|
|
|
'hurt': _('Hurt'),
|
|
|
|
'impressed': _('Impressed'),
|
2008-10-30 22:49:49 +01:00
|
|
|
'in_awe': _('In Awe'),
|
|
|
|
'in_love': _('In Love'),
|
2008-10-30 20:01:26 +01:00
|
|
|
'indignant': _('Indignant'),
|
|
|
|
'interested': _('Interested'),
|
|
|
|
'intoxicated': _('Intoxicated'),
|
|
|
|
'invincible': _('Invincible'),
|
|
|
|
'jealous': _('Jealous'),
|
|
|
|
'lonely': _('Lonely'),
|
|
|
|
'lost': _('Lost'),
|
|
|
|
'lucky': _('Lucky'),
|
|
|
|
'mean': _('Mean'),
|
|
|
|
'moody': _('Moody'),
|
|
|
|
'nervous': _('Nervous'),
|
|
|
|
'neutral': _('Neutral'),
|
|
|
|
'offended': _('Offended'),
|
|
|
|
'outraged': _('Outraged'),
|
|
|
|
'playful': _('Playful'),
|
|
|
|
'proud': _('Proud'),
|
|
|
|
'relaxed': _('Relaxed'),
|
|
|
|
'relieved': _('Relieved'),
|
|
|
|
'remorseful': _('Remorseful'),
|
|
|
|
'restless': _('Restless'),
|
|
|
|
'sad': _('Sad'),
|
|
|
|
'sarcastic': _('Sarcastic'),
|
|
|
|
'satisfied': _('Satisfied'),
|
|
|
|
'serious': _('Serious'),
|
|
|
|
'shocked': _('Shocked'),
|
|
|
|
'shy': _('Shy'),
|
|
|
|
'sick': _('Sick'),
|
|
|
|
'sleepy': _('Sleepy'),
|
|
|
|
'spontaneous': _('Spontaneous'),
|
|
|
|
'stressed': _('Stressed'),
|
|
|
|
'strong': _('Strong'),
|
|
|
|
'surprised': _('Surprised'),
|
|
|
|
'thankful': _('Thankful'),
|
|
|
|
'thirsty': _('Thirsty'),
|
|
|
|
'tired': _('Tired'),
|
|
|
|
'undefined': _('Undefined'),
|
|
|
|
'weak': _('Weak'),
|
|
|
|
'worried': _('Worried')}
|
2008-07-22 23:08:52 +02:00
|
|
|
|
2008-07-28 22:57:56 +02:00
|
|
|
ACTIVITIES = {
|
2008-07-29 21:42:31 +02:00
|
|
|
'doing_chores': {'category': _('Doing Chores'),
|
|
|
|
'buying_groceries': _('Buying Groceries'),
|
|
|
|
'cleaning': _('Cleaning'),
|
|
|
|
'cooking': _('Cooking'),
|
|
|
|
'doing_maintenance': _('Doing Maintenance'),
|
|
|
|
'doing_the_dishes': _('Doing the Dishes'),
|
|
|
|
'doing_the_laundry': _('Doing the Laundry'),
|
|
|
|
'gardening': _('Gardening'),
|
|
|
|
'running_an_errand': _('Running an Errand'),
|
|
|
|
'walking_the_dog': _('Walking the Dog')},
|
|
|
|
'drinking': {'category': _('Drinking'),
|
|
|
|
'having_a_beer': _('Having a Beer'),
|
|
|
|
'having_coffee': _('Having Coffee'),
|
|
|
|
'having_tea': _('Having Tea')},
|
|
|
|
'eating': {'category': _('Eating'),
|
|
|
|
'having_a_snack': _('Having a Snack'),
|
|
|
|
'having_breakfast': _('Having Breakfast'),
|
|
|
|
'having_dinner': _('Having Dinner'),
|
|
|
|
'having_lunch': _('Having Lunch')},
|
|
|
|
'exercising': {'category': _('Exercising'),
|
|
|
|
'cycling': _('Cycling'),
|
2008-11-08 23:26:05 +01:00
|
|
|
'dancing': _('Dancing'),
|
2008-07-29 21:42:31 +02:00
|
|
|
'hiking': _('Hiking'),
|
|
|
|
'jogging': _('Jogging'),
|
|
|
|
'playing_sports': _('Playing Sports'),
|
|
|
|
'running': _('Running'),
|
|
|
|
'skiing': _('Skiing'),
|
|
|
|
'swimming': _('Swimming'),
|
|
|
|
'working_out': _('Working out')},
|
|
|
|
'grooming': {'category': _('Grooming'),
|
|
|
|
'at_the_spa': _('At the Spa'),
|
|
|
|
'brushing_teeth': _('Brushing Teeth'),
|
|
|
|
'getting_a_haircut': _('Getting a Haircut'),
|
|
|
|
'shaving': _('Shaving'),
|
|
|
|
'taking_a_bath': _('Taking a Bath'),
|
|
|
|
'taking_a_shower': _('Taking a Shower')},
|
|
|
|
'having_appointment': {'category': _('Having an Appointment')},
|
|
|
|
'inactive': {'category': _('Inactive'),
|
|
|
|
'day_off': _('Day Off'),
|
2008-08-09 18:40:48 +02:00
|
|
|
'hanging_out': _('Hanging out'),
|
2008-11-08 23:26:05 +01:00
|
|
|
'hiding': _('Hiding'),
|
2008-07-29 21:42:31 +02:00
|
|
|
'on_vacation': _('On Vacation'),
|
2008-11-08 23:26:05 +01:00
|
|
|
'praying': _('Praying'),
|
2008-07-29 21:42:31 +02:00
|
|
|
'scheduled_holiday': _('Scheduled Holiday'),
|
2008-11-08 23:26:05 +01:00
|
|
|
'sleeping': _('Sleeping'),
|
|
|
|
'thinking': _('Thinking')},
|
2008-07-29 21:42:31 +02:00
|
|
|
'relaxing': {'category': _('Relaxing'),
|
2008-11-08 23:26:05 +01:00
|
|
|
'fishing': _('Fishing'),
|
2008-07-29 21:42:31 +02:00
|
|
|
'gaming': _('Gaming'),
|
|
|
|
'going_out': _('Going out'),
|
|
|
|
'partying': _('Partying'),
|
|
|
|
'reading': _('Reading'),
|
|
|
|
'rehearsing': _('Rehearsing'),
|
|
|
|
'shopping': _('Shopping'),
|
2008-11-08 23:26:05 +01:00
|
|
|
'smoking': _('Smoking'),
|
2008-07-29 21:42:31 +02:00
|
|
|
'socializing': _('Socializing'),
|
|
|
|
'sunbathing': _('Sunbathing'),
|
|
|
|
'watching_tv': _('Watching TV'),
|
|
|
|
'watching_a_movie': _('Watching a Movie')},
|
|
|
|
'talking': {'category': _('Talking'),
|
|
|
|
'in_real_life': _('In Real Life'),
|
|
|
|
'on_the_phone': _('On the Phone'),
|
|
|
|
'on_video_phone': _('On Video Phone')},
|
|
|
|
'traveling': {'category': _('Traveling'),
|
|
|
|
'commuting': _('Commuting'),
|
|
|
|
'cycling': _('Cycling'),
|
|
|
|
'driving': _('Driving'),
|
|
|
|
'in_a_car': _('In a Car'),
|
|
|
|
'on_a_bus': _('On a Bus'),
|
|
|
|
'on_a_plane': _('On a Plane'),
|
|
|
|
'on_a_train': _('On a Train'),
|
|
|
|
'on_a_trip': _('On a Trip'),
|
|
|
|
'walking': _('Walking')},
|
|
|
|
'working': {'category': _('Working'),
|
|
|
|
'coding': _('Coding'),
|
|
|
|
'in_a_meeting': _('In a Meeting'),
|
|
|
|
'studying': _('Studying'),
|
|
|
|
'writing': _('Writing')}}
|
2008-07-28 22:57:56 +02:00
|
|
|
|
2007-03-26 00:27:43 +02:00
|
|
|
def user_mood(items, name, jid):
|
2007-12-13 21:26:13 +01:00
|
|
|
has_child = False
|
2008-05-05 09:48:13 +02:00
|
|
|
retract = False
|
2007-12-13 21:26:13 +01:00
|
|
|
mood = None
|
|
|
|
text = None
|
2007-03-26 00:27:43 +02:00
|
|
|
for item in items.getTags('item'):
|
|
|
|
child = item.getTag('mood')
|
|
|
|
if child is not None:
|
2007-12-13 21:26:13 +01:00
|
|
|
has_child = True
|
2007-08-09 17:54:16 +02:00
|
|
|
for ch in child.getChildren():
|
|
|
|
if ch.getName() != 'text':
|
2007-12-13 21:26:13 +01:00
|
|
|
mood = ch.getName()
|
2007-08-09 17:54:16 +02:00
|
|
|
else:
|
2007-12-13 21:26:13 +01:00
|
|
|
text = ch.getData()
|
2008-05-05 09:48:13 +02:00
|
|
|
if items.getTag('retract') is not None:
|
|
|
|
retract = True
|
|
|
|
|
2008-11-12 21:04:25 +01:00
|
|
|
if jid == gajim.get_jid_from_account(name):
|
|
|
|
acc = gajim.connections[name]
|
|
|
|
if has_child:
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'mood' in acc.mood:
|
2008-05-05 09:48:13 +02:00
|
|
|
del acc.mood['mood']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'text' in acc.mood:
|
2008-05-05 09:48:13 +02:00
|
|
|
del acc.mood['text']
|
2008-11-03 15:25:08 +01:00
|
|
|
if mood is not None:
|
|
|
|
acc.mood['mood'] = mood
|
|
|
|
if text is not None:
|
|
|
|
acc.mood['text'] = text
|
2008-11-12 21:04:25 +01:00
|
|
|
elif retract:
|
|
|
|
if 'mood' in acc.mood:
|
|
|
|
del acc.mood['mood']
|
|
|
|
if 'text' in acc.mood:
|
|
|
|
del acc.mood['text']
|
2007-03-26 00:27:43 +02:00
|
|
|
|
2008-10-20 23:38:06 +02:00
|
|
|
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
|
2008-11-12 21:04:25 +01:00
|
|
|
for contact in gajim.contacts.get_contacts(name, user):
|
|
|
|
if has_child:
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'mood' in contact.mood:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.mood['mood']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'text' in contact.mood:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.mood['text']
|
2008-11-03 15:25:08 +01:00
|
|
|
if mood is not None:
|
|
|
|
contact.mood['mood'] = mood
|
|
|
|
if text is not None:
|
|
|
|
contact.mood['text'] = text
|
2008-11-12 21:04:25 +01:00
|
|
|
elif retract:
|
|
|
|
if 'mood' in contact.mood:
|
|
|
|
del contact.mood['mood']
|
|
|
|
if 'text' in contact.mood:
|
|
|
|
del contact.mood['text']
|
2007-12-13 21:26:13 +01:00
|
|
|
|
2008-11-12 21:04:25 +01:00
|
|
|
if jid == gajim.get_jid_from_account(name):
|
|
|
|
gajim.interface.roster.draw_account(name)
|
|
|
|
gajim.interface.roster.draw_mood(user, name)
|
|
|
|
ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
|
|
|
|
if ctrl:
|
2008-08-05 00:44:48 +02:00
|
|
|
ctrl.update_mood()
|
2008-07-23 01:41:07 +02:00
|
|
|
|
2007-12-13 21:26:13 +01:00
|
|
|
def user_tune(items, name, jid):
|
|
|
|
has_child = False
|
2008-05-05 09:48:13 +02:00
|
|
|
retract = False
|
2007-12-13 21:26:13 +01:00
|
|
|
artist = None
|
|
|
|
title = None
|
|
|
|
source = None
|
|
|
|
track = None
|
|
|
|
length = None
|
|
|
|
|
2007-04-01 11:02:04 +02:00
|
|
|
for item in items.getTags('item'):
|
|
|
|
child = item.getTag('tune')
|
|
|
|
if child is not None:
|
2007-12-13 21:26:13 +01:00
|
|
|
has_child = True
|
2007-08-09 17:54:16 +02:00
|
|
|
for ch in child.getChildren():
|
|
|
|
if ch.getName() == 'artist':
|
2007-12-13 21:26:13 +01:00
|
|
|
artist = ch.getData()
|
2007-08-09 17:54:16 +02:00
|
|
|
elif ch.getName() == 'title':
|
2007-12-13 21:26:13 +01:00
|
|
|
title = ch.getData()
|
2007-08-09 17:54:16 +02:00
|
|
|
elif ch.getName() == 'source':
|
2007-12-13 21:26:13 +01:00
|
|
|
source = ch.getData()
|
2007-08-09 17:54:16 +02:00
|
|
|
elif ch.getName() == 'track':
|
2007-12-13 21:26:13 +01:00
|
|
|
track = ch.getData()
|
2007-08-09 17:54:16 +02:00
|
|
|
elif ch.getName() == 'length':
|
2007-12-13 21:26:13 +01:00
|
|
|
length = ch.getData()
|
2008-05-05 09:48:13 +02:00
|
|
|
if items.getTag('retract') is not None:
|
|
|
|
retract = True
|
2007-03-26 00:27:43 +02:00
|
|
|
|
2007-12-13 21:26:13 +01:00
|
|
|
if jid == gajim.get_jid_from_account(name):
|
|
|
|
acc = gajim.connections[name]
|
|
|
|
if has_child:
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'artist' in acc.tune:
|
2007-12-13 21:26:13 +01:00
|
|
|
del acc.tune['artist']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'title' in acc.tune:
|
2007-12-13 21:26:13 +01:00
|
|
|
del acc.tune['title']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'source' in acc.tune:
|
2007-12-13 21:26:13 +01:00
|
|
|
del acc.tune['source']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'track' in acc.tune:
|
2007-12-13 21:26:13 +01:00
|
|
|
del acc.tune['track']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'length' in acc.tune:
|
2007-12-13 21:26:13 +01:00
|
|
|
del acc.tune['length']
|
2008-04-18 02:26:07 +02:00
|
|
|
if artist is not None:
|
2007-12-13 21:26:13 +01:00
|
|
|
acc.tune['artist'] = artist
|
2008-04-18 02:26:07 +02:00
|
|
|
if title is not None:
|
2007-12-13 21:26:13 +01:00
|
|
|
acc.tune['title'] = title
|
2008-04-18 02:26:07 +02:00
|
|
|
if source is not None:
|
2007-12-13 21:26:13 +01:00
|
|
|
acc.tune['source'] = source
|
2008-04-18 02:26:07 +02:00
|
|
|
if track is not None:
|
2007-12-13 21:26:13 +01:00
|
|
|
acc.tune['track'] = track
|
2008-04-18 02:26:07 +02:00
|
|
|
if length is not None:
|
2007-12-13 21:26:13 +01:00
|
|
|
acc.tune['length'] = length
|
2008-05-05 09:48:13 +02:00
|
|
|
elif retract:
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'artist' in acc.tune:
|
2008-05-05 09:48:13 +02:00
|
|
|
del acc.tune['artist']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'title' in acc.tune:
|
2008-05-05 09:48:13 +02:00
|
|
|
del acc.tune['title']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'source' in acc.tune:
|
2008-05-05 09:48:13 +02:00
|
|
|
del acc.tune['source']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'track' in acc.tune:
|
2008-05-05 09:48:13 +02:00
|
|
|
del acc.tune['track']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'length' in acc.tune:
|
2008-05-05 09:48:13 +02:00
|
|
|
del acc.tune['length']
|
2007-03-28 23:18:16 +02:00
|
|
|
|
2008-10-20 23:38:06 +02:00
|
|
|
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
|
2008-05-20 16:30:19 +02:00
|
|
|
for contact in gajim.contacts.get_contacts(name, user):
|
2008-05-20 16:18:12 +02:00
|
|
|
if has_child:
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'artist' in contact.tune:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.tune['artist']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'title' in contact.tune:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.tune['title']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'source' in contact.tune:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.tune['source']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'track' in contact.tune:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.tune['track']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'length' in contact.tune:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.tune['length']
|
|
|
|
if artist is not None:
|
|
|
|
contact.tune['artist'] = artist
|
|
|
|
if title is not None:
|
|
|
|
contact.tune['title'] = title
|
|
|
|
if source is not None:
|
|
|
|
contact.tune['source'] = source
|
|
|
|
if track is not None:
|
|
|
|
contact.tune['track'] = track
|
|
|
|
if length is not None:
|
|
|
|
contact.tune['length'] = length
|
|
|
|
elif retract:
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'artist' in contact.tune:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.tune['artist']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'title' in contact.tune:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.tune['title']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'source' in contact.tune:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.tune['source']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'track' in contact.tune:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.tune['track']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'length' in contact.tune:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.tune['length']
|
2007-12-13 21:26:13 +01:00
|
|
|
|
2008-07-25 16:11:14 +02:00
|
|
|
if jid == gajim.get_jid_from_account(name):
|
|
|
|
gajim.interface.roster.draw_account(name)
|
2008-08-05 00:44:48 +02:00
|
|
|
gajim.interface.roster.draw_tune(user, name)
|
|
|
|
ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
|
|
|
|
if ctrl:
|
|
|
|
ctrl.update_tune()
|
2008-07-23 01:39:45 +02:00
|
|
|
|
2007-12-13 21:26:13 +01:00
|
|
|
def user_geoloc(items, name, jid):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def user_activity(items, name, jid):
|
|
|
|
has_child = False
|
2008-05-05 09:48:13 +02:00
|
|
|
retract = False
|
2007-12-13 21:26:13 +01:00
|
|
|
activity = None
|
|
|
|
subactivity = None
|
|
|
|
text = None
|
|
|
|
|
2007-03-28 23:18:16 +02:00
|
|
|
for item in items.getTags('item'):
|
|
|
|
child = item.getTag('activity')
|
|
|
|
if child is not None:
|
2007-12-13 21:26:13 +01:00
|
|
|
has_child = True
|
2007-08-09 17:54:16 +02:00
|
|
|
for ch in child.getChildren():
|
|
|
|
if ch.getName() != 'text':
|
2007-12-13 21:26:13 +01:00
|
|
|
activity = ch.getName()
|
2007-08-09 17:54:16 +02:00
|
|
|
for chi in ch.getChildren():
|
2007-12-13 21:26:13 +01:00
|
|
|
subactivity = chi.getName()
|
2007-08-09 17:54:16 +02:00
|
|
|
else:
|
2007-12-13 21:26:13 +01:00
|
|
|
text = ch.getData()
|
2008-05-05 09:48:13 +02:00
|
|
|
if items.getTag('retract') is not None:
|
|
|
|
retract = True
|
2007-12-13 21:26:13 +01:00
|
|
|
|
|
|
|
if jid == gajim.get_jid_from_account(name):
|
|
|
|
acc = gajim.connections[name]
|
|
|
|
if has_child:
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'activity' in acc.activity:
|
2007-12-13 21:26:13 +01:00
|
|
|
del acc.activity['activity']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'subactivity' in acc.activity:
|
2007-12-13 21:26:13 +01:00
|
|
|
del acc.activity['subactivity']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'text' in acc.activity:
|
2007-12-13 21:26:13 +01:00
|
|
|
del acc.activity['text']
|
2008-04-18 02:26:07 +02:00
|
|
|
if activity is not None:
|
2007-12-13 21:26:13 +01:00
|
|
|
acc.activity['activity'] = activity
|
2008-10-24 19:10:30 +02:00
|
|
|
if subactivity is not None and subactivity != 'other':
|
2007-12-13 21:26:13 +01:00
|
|
|
acc.activity['subactivity'] = subactivity
|
2008-04-18 02:26:07 +02:00
|
|
|
if text is not None:
|
2007-12-13 21:26:13 +01:00
|
|
|
acc.activity['text'] = text
|
2008-05-05 09:48:13 +02:00
|
|
|
elif retract:
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'activity' in acc.activity:
|
2008-05-05 09:48:13 +02:00
|
|
|
del acc.activity['activity']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'subactivity' in acc.activity:
|
2008-05-05 09:48:13 +02:00
|
|
|
del acc.activity['subactivity']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'text' in acc.activity:
|
2008-05-05 09:48:13 +02:00
|
|
|
del acc.activity['text']
|
2007-12-13 21:26:13 +01:00
|
|
|
|
2008-10-20 23:38:06 +02:00
|
|
|
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
|
2008-05-20 16:30:19 +02:00
|
|
|
for contact in gajim.contacts.get_contacts(name, user):
|
2008-05-20 16:18:12 +02:00
|
|
|
if has_child:
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'activity' in contact.activity:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.activity['activity']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'subactivity' in contact.activity:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.activity['subactivity']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'text' in contact.activity:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.activity['text']
|
|
|
|
if activity is not None:
|
|
|
|
contact.activity['activity'] = activity
|
2008-10-24 19:10:30 +02:00
|
|
|
if subactivity is not None and subactivity != 'other':
|
2008-05-20 16:18:12 +02:00
|
|
|
contact.activity['subactivity'] = subactivity
|
|
|
|
if text is not None:
|
|
|
|
contact.activity['text'] = text
|
|
|
|
elif retract:
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'activity' in contact.activity:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.activity['activity']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'subactivity' in contact.activity:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.activity['subactivity']
|
2008-10-07 22:41:59 +02:00
|
|
|
if 'text' in contact.activity:
|
2008-05-20 16:18:12 +02:00
|
|
|
del contact.activity['text']
|
2007-03-31 00:52:11 +02:00
|
|
|
|
2008-07-29 04:32:57 +02:00
|
|
|
if jid == gajim.get_jid_from_account(name):
|
|
|
|
gajim.interface.roster.draw_account(name)
|
2008-08-05 00:44:48 +02:00
|
|
|
gajim.interface.roster.draw_activity(user, name)
|
2008-07-29 00:33:20 +02:00
|
|
|
ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
|
|
|
|
if ctrl:
|
|
|
|
ctrl.update_activity()
|
|
|
|
|
2008-05-05 23:55:59 +02:00
|
|
|
def user_nickname(items, name, jid):
|
|
|
|
has_child = False
|
|
|
|
retract = False
|
|
|
|
nick = None
|
|
|
|
|
|
|
|
for item in items.getTags('item'):
|
|
|
|
child = item.getTag('nick')
|
|
|
|
if child is not None:
|
|
|
|
has_child = True
|
|
|
|
nick = child.getData()
|
|
|
|
break
|
|
|
|
|
|
|
|
if items.getTag('retract') is not None:
|
|
|
|
retract = True
|
|
|
|
|
|
|
|
if jid == gajim.get_jid_from_account(name):
|
|
|
|
if has_child:
|
|
|
|
gajim.nicks[name] = nick
|
|
|
|
if retract:
|
2008-07-23 01:22:49 +02:00
|
|
|
gajim.nicks[name] = gajim.config.get_per('accounts',
|
|
|
|
name, 'name')
|
2008-05-05 23:55:59 +02:00
|
|
|
|
|
|
|
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
|
|
|
|
if has_child:
|
|
|
|
if nick is not None:
|
2008-05-20 16:30:19 +02:00
|
|
|
for contact in gajim.contacts.get_contacts(name, user):
|
2008-05-20 16:18:12 +02:00
|
|
|
contact.contact_name = nick
|
2008-05-05 23:55:59 +02:00
|
|
|
gajim.interface.roster.draw_contact(user, name)
|
2008-06-27 01:36:58 +02:00
|
|
|
|
2008-07-23 01:22:49 +02:00
|
|
|
ctrl = gajim.interface.msg_win_mgr.get_control(user,
|
|
|
|
name)
|
2008-06-27 01:36:58 +02:00
|
|
|
if ctrl:
|
2008-05-05 23:55:59 +02:00
|
|
|
ctrl.update_ui()
|
2008-05-13 03:59:10 +02:00
|
|
|
win = ctrl.parent_win
|
2008-05-11 15:17:28 +02:00
|
|
|
win.redraw_tab(ctrl)
|
|
|
|
win.show_title()
|
2008-05-05 23:55:59 +02:00
|
|
|
elif retract:
|
|
|
|
contact.contact_name = ''
|
|
|
|
|
2007-03-31 00:52:11 +02:00
|
|
|
def user_send_mood(account, mood, message = ''):
|
2008-07-29 08:15:41 +02:00
|
|
|
if not gajim.connections[account].pep_supported:
|
2007-08-10 01:05:43 +02:00
|
|
|
return
|
2007-03-31 00:52:11 +02:00
|
|
|
item = xmpp.Node('mood', {'xmlns': xmpp.NS_MOOD})
|
2007-08-10 01:05:43 +02:00
|
|
|
if mood != '':
|
2008-10-30 20:01:26 +01:00
|
|
|
item.addChild(mood)
|
2007-03-31 00:52:11 +02:00
|
|
|
if message != '':
|
|
|
|
i = item.addChild('text')
|
|
|
|
i.addData(message)
|
|
|
|
|
|
|
|
gajim.connections[account].send_pb_publish('', xmpp.NS_MOOD, item, '0')
|
2007-03-31 11:09:16 +02:00
|
|
|
|
|
|
|
def user_send_activity(account, activity, subactivity = '', message = ''):
|
2008-07-29 08:15:41 +02:00
|
|
|
if not gajim.connections[account].pep_supported:
|
2007-08-10 01:05:43 +02:00
|
|
|
return
|
2007-03-31 11:09:16 +02:00
|
|
|
item = xmpp.Node('activity', {'xmlns': xmpp.NS_ACTIVITY})
|
2007-08-10 01:05:43 +02:00
|
|
|
if activity != '':
|
|
|
|
i = item.addChild(activity)
|
2007-03-31 11:09:16 +02:00
|
|
|
if subactivity != '':
|
|
|
|
i.addChild(subactivity)
|
|
|
|
if message != '':
|
|
|
|
i = item.addChild('text')
|
|
|
|
i.addData(message)
|
|
|
|
|
2008-07-23 01:22:49 +02:00
|
|
|
gajim.connections[account].send_pb_publish('', xmpp.NS_ACTIVITY,
|
|
|
|
item, '0')
|
2007-04-01 11:02:04 +02:00
|
|
|
|
2008-07-23 01:22:49 +02:00
|
|
|
def user_send_tune(account, artist = '', title = '', source = '', track = 0,
|
|
|
|
length = 0, items = None):
|
2008-05-30 23:43:53 +02:00
|
|
|
if not (gajim.config.get_per('accounts', account, 'publish_tune') and \
|
2008-04-22 20:48:41 +02:00
|
|
|
gajim.connections[account].pep_supported):
|
2007-08-10 01:05:43 +02:00
|
|
|
return
|
2007-04-01 11:02:04 +02:00
|
|
|
item = xmpp.Node('tune', {'xmlns': xmpp.NS_TUNE})
|
|
|
|
if artist != '':
|
|
|
|
i = item.addChild('artist')
|
|
|
|
i.addData(artist)
|
|
|
|
if title != '':
|
|
|
|
i = item.addChild('title')
|
|
|
|
i.addData(title)
|
|
|
|
if source != '':
|
|
|
|
i = item.addChild('source')
|
|
|
|
i.addData(source)
|
|
|
|
if track != 0:
|
|
|
|
i = item.addChild('track')
|
|
|
|
i.addData(track)
|
|
|
|
if length != 0:
|
|
|
|
i = item.addChild('length')
|
|
|
|
i.addData(length)
|
|
|
|
if items is not None:
|
|
|
|
item.addChild(payload=items)
|
|
|
|
|
|
|
|
gajim.connections[account].send_pb_publish('', xmpp.NS_TUNE, item, '0')
|
2008-05-05 09:48:13 +02:00
|
|
|
|
2008-05-05 23:55:59 +02:00
|
|
|
def user_send_nickname(account, nick):
|
2008-07-29 08:15:41 +02:00
|
|
|
if not gajim.connections[account].pep_supported:
|
2008-05-05 23:55:59 +02:00
|
|
|
return
|
|
|
|
item = xmpp.Node('nick', {'xmlns': xmpp.NS_NICK})
|
|
|
|
item.addData(nick)
|
|
|
|
|
|
|
|
gajim.connections[account].send_pb_publish('', xmpp.NS_NICK, item, '0')
|
|
|
|
|
2008-05-05 09:48:13 +02:00
|
|
|
def user_retract_mood(account):
|
|
|
|
gajim.connections[account].send_pb_retract('', xmpp.NS_MOOD, '0')
|
|
|
|
|
|
|
|
def user_retract_activity(account):
|
|
|
|
gajim.connections[account].send_pb_retract('', xmpp.NS_ACTIVITY, '0')
|
|
|
|
|
|
|
|
def user_retract_tune(account):
|
|
|
|
gajim.connections[account].send_pb_retract('', xmpp.NS_TUNE, '0')
|
2008-05-05 23:55:59 +02:00
|
|
|
|
|
|
|
def user_retract_nickname(account):
|
|
|
|
gajim.connections[account].send_pb_retract('', xmpp.NS_NICK, '0')
|
2008-07-29 21:49:31 +02:00
|
|
|
|
2008-08-28 13:43:10 +02:00
|
|
|
def delete_pep(jid, name):
|
2008-10-20 23:38:06 +02:00
|
|
|
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
|
2008-08-28 13:43:10 +02:00
|
|
|
|
|
|
|
if jid == gajim.get_jid_from_account(name):
|
|
|
|
acc = gajim.connections[name]
|
2008-08-29 00:43:28 +02:00
|
|
|
del acc.activity
|
|
|
|
acc.activity = {}
|
2008-11-26 23:44:17 +01:00
|
|
|
user_send_tune(name)
|
2008-08-29 00:43:28 +02:00
|
|
|
del acc.tune
|
|
|
|
acc.tune = {}
|
|
|
|
del acc.mood
|
|
|
|
acc.mood = {}
|
2008-08-28 13:43:10 +02:00
|
|
|
|
|
|
|
for contact in gajim.contacts.get_contacts(name, user):
|
2008-08-29 00:43:28 +02:00
|
|
|
del contact.activity
|
|
|
|
contact.activity = {}
|
|
|
|
del contact.tune
|
|
|
|
contact.tune = {}
|
|
|
|
del contact.mood
|
|
|
|
contact.mood = {}
|
2008-08-28 13:43:10 +02:00
|
|
|
|
|
|
|
if jid == gajim.get_jid_from_account(name):
|
|
|
|
gajim.interface.roster.draw_account(name)
|
|
|
|
|
|
|
|
gajim.interface.roster.draw_activity(user, name)
|
|
|
|
gajim.interface.roster.draw_tune(user, name)
|
|
|
|
gajim.interface.roster.draw_mood(user, name)
|
|
|
|
ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
|
|
|
|
if ctrl:
|
|
|
|
ctrl.update_activity()
|
|
|
|
ctrl.update_tune()
|
|
|
|
ctrl.update_mood()
|
|
|
|
|
2008-08-05 00:44:48 +02:00
|
|
|
# vim: se ts=3:
|