4 ## Copyright (C) 2007 Piotr Gaczkowski <doomhammerng AT gmail.com>
5 ## Copyright (C) 2007-2008 Yann Leboulanger <asterix AT lagaule.org>
6 ## Copyright (C) 2008 Brendan Taylor <whateley AT gmail.com>
7 ## Jean-Marie Traissard <jim AT lapin.org>
8 ## Jonathan Schleifer <js-gajim AT webkeks.org>
9 ## Stephan Erb <steve-e AT h3c.de>
11 ## This file is part of Gajim.
13 ## Gajim is free software; you can redistribute it and/or modify
14 ## it under the terms of the GNU General Public License as published
15 ## by the Free Software Foundation; version 3 only.
17 ## Gajim is distributed in the hope that it will be useful,
18 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ## GNU General Public License for more details.
22 ## You should have received a copy of the GNU General Public License
23 ## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
26 from common
import gajim
, xmpp
29 'afraid': _('Afraid'),
30 'amazed': _('Amazed'),
31 'amorous': _('Amorous'),
33 'annoyed': _('Annoyed'),
34 'anxious': _('Anxious'),
35 'aroused': _('Aroused'),
36 'ashamed': _('Ashamed'),
40 'cautious': _('Cautious'),
42 'confident': _('Confident'),
43 'confused': _('Confused'),
44 'contemplative': _('Contemplative'),
45 'contented': _('Contented'),
46 'cranky': _('Cranky'),
48 'creative': _('Creative'),
49 'curious': _('Curious'),
50 'dejected': _('Dejected'),
51 'depressed': _('Depressed'),
52 'disappointed': _('Disappointed'),
53 'disgusted': _('Disgusted'),
54 'dismayed': _('Dismayed'),
55 'distracted': _('Distracted'),
56 'embarrassed': _('Embarrassed'),
57 'envious': _('Envious'),
58 'excited': _('Excited'),
59 'flirtatious': _('Flirtatious'),
60 'frustrated': _('Frustrated'),
61 'grateful': _('Grateful'),
62 'grieving': _('Grieving'),
63 'grumpy': _('Grumpy'),
64 'guilty': _('Guilty'),
66 'hopeful': _('Hopeful'),
68 'humbled': _('Humbled'),
69 'humiliated': _('Humiliated'),
70 'hungry': _('Hungry'),
72 'impressed': _('Impressed'),
73 'in_awe': _('In Awe'),
74 'in_love': _('In Love'),
75 'indignant': _('Indignant'),
76 'interested': _('Interested'),
77 'intoxicated': _('Intoxicated'),
78 'invincible': _('Invincible'),
79 'jealous': _('Jealous'),
80 'lonely': _('Lonely'),
85 'nervous': _('Nervous'),
86 'neutral': _('Neutral'),
87 'offended': _('Offended'),
88 'outraged': _('Outraged'),
89 'playful': _('Playful'),
91 'relaxed': _('Relaxed'),
92 'relieved': _('Relieved'),
93 'remorseful': _('Remorseful'),
94 'restless': _('Restless'),
96 'sarcastic': _('Sarcastic'),
97 'satisfied': _('Satisfied'),
98 'serious': _('Serious'),
99 'shocked': _('Shocked'),
102 'sleepy': _('Sleepy'),
103 'spontaneous': _('Spontaneous'),
104 'stressed': _('Stressed'),
105 'strong': _('Strong'),
106 'surprised': _('Surprised'),
107 'thankful': _('Thankful'),
108 'thirsty': _('Thirsty'),
110 'undefined': _('Undefined'),
112 'worried': _('Worried')}
115 'doing_chores': {'category': _('Doing Chores'),
116 'buying_groceries': _('Buying Groceries'),
117 'cleaning': _('Cleaning'),
118 'cooking': _('Cooking'),
119 'doing_maintenance': _('Doing Maintenance'),
120 'doing_the_dishes': _('Doing the Dishes'),
121 'doing_the_laundry': _('Doing the Laundry'),
122 'gardening': _('Gardening'),
123 'running_an_errand': _('Running an Errand'),
124 'walking_the_dog': _('Walking the Dog')},
125 'drinking': {'category': _('Drinking'),
126 'having_a_beer': _('Having a Beer'),
127 'having_coffee': _('Having Coffee'),
128 'having_tea': _('Having Tea')},
129 'eating': {'category': _('Eating'),
130 'having_a_snack': _('Having a Snack'),
131 'having_breakfast': _('Having Breakfast'),
132 'having_dinner': _('Having Dinner'),
133 'having_lunch': _('Having Lunch')},
134 'exercising': {'category': _('Exercising'),
135 'cycling': _('Cycling'),
136 'dancing': _('Dancing'),
137 'hiking': _('Hiking'),
138 'jogging': _('Jogging'),
139 'playing_sports': _('Playing Sports'),
140 'running': _('Running'),
141 'skiing': _('Skiing'),
142 'swimming': _('Swimming'),
143 'working_out': _('Working out')},
144 'grooming': {'category': _('Grooming'),
145 'at_the_spa': _('At the Spa'),
146 'brushing_teeth': _('Brushing Teeth'),
147 'getting_a_haircut': _('Getting a Haircut'),
148 'shaving': _('Shaving'),
149 'taking_a_bath': _('Taking a Bath'),
150 'taking_a_shower': _('Taking a Shower')},
151 'having_appointment': {'category': _('Having an Appointment')},
152 'inactive': {'category': _('Inactive'),
153 'day_off': _('Day Off'),
154 'hanging_out': _('Hanging out'),
155 'hiding': _('Hiding'),
156 'on_vacation': _('On Vacation'),
157 'praying': _('Praying'),
158 'scheduled_holiday': _('Scheduled Holiday'),
159 'sleeping': _('Sleeping'),
160 'thinking': _('Thinking')},
161 'relaxing': {'category': _('Relaxing'),
162 'fishing': _('Fishing'),
163 'gaming': _('Gaming'),
164 'going_out': _('Going out'),
165 'partying': _('Partying'),
166 'reading': _('Reading'),
167 'rehearsing': _('Rehearsing'),
168 'shopping': _('Shopping'),
169 'smoking': _('Smoking'),
170 'socializing': _('Socializing'),
171 'sunbathing': _('Sunbathing'),
172 'watching_tv': _('Watching TV'),
173 'watching_a_movie': _('Watching a Movie')},
174 'talking': {'category': _('Talking'),
175 'in_real_life': _('In Real Life'),
176 'on_the_phone': _('On the Phone'),
177 'on_video_phone': _('On Video Phone')},
178 'traveling': {'category': _('Traveling'),
179 'commuting': _('Commuting'),
180 'cycling': _('Cycling'),
181 'driving': _('Driving'),
182 'in_a_car': _('In a Car'),
183 'on_a_bus': _('On a Bus'),
184 'on_a_plane': _('On a Plane'),
185 'on_a_train': _('On a Train'),
186 'on_a_trip': _('On a Trip'),
187 'walking': _('Walking')},
188 'working': {'category': _('Working'),
189 'coding': _('Coding'),
190 'in_a_meeting': _('In a Meeting'),
191 'studying': _('Studying'),
192 'writing': _('Writing')}}
194 def user_mood(items
, name
, jid
):
199 for item
in items
.getTags('item'):
200 child
= item
.getTag('mood')
201 if child
is not None:
203 for ch
in child
.getChildren():
204 if ch
.getName() != 'text':
208 if items
.getTag('retract') is not None:
211 if jid
== gajim
.get_jid_from_account(name
):
212 acc
= gajim
.connections
[name
]
214 if 'mood' in acc
.mood
:
216 if 'text' in acc
.mood
:
219 acc
.mood
['mood'] = mood
221 acc
.mood
['text'] = text
223 if 'mood' in acc
.mood
:
225 if 'text' in acc
.mood
:
228 (user
, resource
) = gajim
.get_room_and_nick_from_fjid(jid
)
229 for contact
in gajim
.contacts
.get_contacts(name
, user
):
231 if 'mood' in contact
.mood
:
232 del contact
.mood
['mood']
233 if 'text' in contact
.mood
:
234 del contact
.mood
['text']
236 contact
.mood
['mood'] = mood
238 contact
.mood
['text'] = text
240 if 'mood' in contact
.mood
:
241 del contact
.mood
['mood']
242 if 'text' in contact
.mood
:
243 del contact
.mood
['text']
245 if jid
== gajim
.get_jid_from_account(name
):
246 gajim
.interface
.roster
.draw_account(name
)
247 gajim
.interface
.roster
.draw_mood(user
, name
)
248 ctrl
= gajim
.interface
.msg_win_mgr
.get_control(user
, name
)
252 def user_tune(items
, name
, jid
):
261 for item
in items
.getTags('item'):
262 child
= item
.getTag('tune')
263 if child
is not None:
265 for ch
in child
.getChildren():
266 if ch
.getName() == 'artist':
267 artist
= ch
.getData()
268 elif ch
.getName() == 'title':
270 elif ch
.getName() == 'source':
271 source
= ch
.getData()
272 elif ch
.getName() == 'track':
274 elif ch
.getName() == 'length':
275 length
= ch
.getData()
276 if items
.getTag('retract') is not None:
279 if jid
== gajim
.get_jid_from_account(name
):
280 acc
= gajim
.connections
[name
]
282 if 'artist' in acc
.tune
:
283 del acc
.tune
['artist']
284 if 'title' in acc
.tune
:
285 del acc
.tune
['title']
286 if 'source' in acc
.tune
:
287 del acc
.tune
['source']
288 if 'track' in acc
.tune
:
289 del acc
.tune
['track']
290 if 'length' in acc
.tune
:
291 del acc
.tune
['length']
292 if artist
is not None:
293 acc
.tune
['artist'] = artist
294 if title
is not None:
295 acc
.tune
['title'] = title
296 if source
is not None:
297 acc
.tune
['source'] = source
298 if track
is not None:
299 acc
.tune
['track'] = track
300 if length
is not None:
301 acc
.tune
['length'] = length
303 if 'artist' in acc
.tune
:
304 del acc
.tune
['artist']
305 if 'title' in acc
.tune
:
306 del acc
.tune
['title']
307 if 'source' in acc
.tune
:
308 del acc
.tune
['source']
309 if 'track' in acc
.tune
:
310 del acc
.tune
['track']
311 if 'length' in acc
.tune
:
312 del acc
.tune
['length']
314 (user
, resource
) = gajim
.get_room_and_nick_from_fjid(jid
)
315 for contact
in gajim
.contacts
.get_contacts(name
, user
):
317 if 'artist' in contact
.tune
:
318 del contact
.tune
['artist']
319 if 'title' in contact
.tune
:
320 del contact
.tune
['title']
321 if 'source' in contact
.tune
:
322 del contact
.tune
['source']
323 if 'track' in contact
.tune
:
324 del contact
.tune
['track']
325 if 'length' in contact
.tune
:
326 del contact
.tune
['length']
327 if artist
is not None:
328 contact
.tune
['artist'] = artist
329 if title
is not None:
330 contact
.tune
['title'] = title
331 if source
is not None:
332 contact
.tune
['source'] = source
333 if track
is not None:
334 contact
.tune
['track'] = track
335 if length
is not None:
336 contact
.tune
['length'] = length
338 if 'artist' in contact
.tune
:
339 del contact
.tune
['artist']
340 if 'title' in contact
.tune
:
341 del contact
.tune
['title']
342 if 'source' in contact
.tune
:
343 del contact
.tune
['source']
344 if 'track' in contact
.tune
:
345 del contact
.tune
['track']
346 if 'length' in contact
.tune
:
347 del contact
.tune
['length']
349 if jid
== gajim
.get_jid_from_account(name
):
350 gajim
.interface
.roster
.draw_account(name
)
351 gajim
.interface
.roster
.draw_tune(user
, name
)
352 ctrl
= gajim
.interface
.msg_win_mgr
.get_control(user
, name
)
356 def user_geoloc(items
, name
, jid
):
359 def user_activity(items
, name
, jid
):
366 for item
in items
.getTags('item'):
367 child
= item
.getTag('activity')
368 if child
is not None:
370 for ch
in child
.getChildren():
371 if ch
.getName() != 'text':
372 activity
= ch
.getName()
373 for chi
in ch
.getChildren():
374 subactivity
= chi
.getName()
377 if items
.getTag('retract') is not None:
380 if jid
== gajim
.get_jid_from_account(name
):
381 acc
= gajim
.connections
[name
]
383 if 'activity' in acc
.activity
:
384 del acc
.activity
['activity']
385 if 'subactivity' in acc
.activity
:
386 del acc
.activity
['subactivity']
387 if 'text' in acc
.activity
:
388 del acc
.activity
['text']
389 if activity
is not None:
390 acc
.activity
['activity'] = activity
391 if subactivity
is not None and subactivity
!= 'other':
392 acc
.activity
['subactivity'] = subactivity
394 acc
.activity
['text'] = text
396 if 'activity' in acc
.activity
:
397 del acc
.activity
['activity']
398 if 'subactivity' in acc
.activity
:
399 del acc
.activity
['subactivity']
400 if 'text' in acc
.activity
:
401 del acc
.activity
['text']
403 (user
, resource
) = gajim
.get_room_and_nick_from_fjid(jid
)
404 for contact
in gajim
.contacts
.get_contacts(name
, user
):
406 if 'activity' in contact
.activity
:
407 del contact
.activity
['activity']
408 if 'subactivity' in contact
.activity
:
409 del contact
.activity
['subactivity']
410 if 'text' in contact
.activity
:
411 del contact
.activity
['text']
412 if activity
is not None:
413 contact
.activity
['activity'] = activity
414 if subactivity
is not None and subactivity
!= 'other':
415 contact
.activity
['subactivity'] = subactivity
417 contact
.activity
['text'] = text
419 if 'activity' in contact
.activity
:
420 del contact
.activity
['activity']
421 if 'subactivity' in contact
.activity
:
422 del contact
.activity
['subactivity']
423 if 'text' in contact
.activity
:
424 del contact
.activity
['text']
426 if jid
== gajim
.get_jid_from_account(name
):
427 gajim
.interface
.roster
.draw_account(name
)
428 gajim
.interface
.roster
.draw_activity(user
, name
)
429 ctrl
= gajim
.interface
.msg_win_mgr
.get_control(user
, name
)
431 ctrl
.update_activity()
433 def user_nickname(items
, name
, jid
):
438 for item
in items
.getTags('item'):
439 child
= item
.getTag('nick')
440 if child
is not None:
442 nick
= child
.getData()
445 if items
.getTag('retract') is not None:
448 if jid
== gajim
.get_jid_from_account(name
):
450 gajim
.nicks
[name
] = nick
452 gajim
.nicks
[name
] = gajim
.config
.get_per('accounts',
455 (user
, resource
) = gajim
.get_room_and_nick_from_fjid(jid
)
458 for contact
in gajim
.contacts
.get_contacts(name
, user
):
459 contact
.contact_name
= nick
460 gajim
.interface
.roster
.draw_contact(user
, name
)
462 ctrl
= gajim
.interface
.msg_win_mgr
.get_control(user
,
466 win
= ctrl
.parent_win
470 contact
.contact_name
= ''
472 def user_send_mood(account
, mood
, message
= ''):
473 if not gajim
.connections
[account
].pep_supported
:
475 item
= xmpp
.Node('mood', {'xmlns': xmpp
.NS_MOOD
})
479 i
= item
.addChild('text')
482 gajim
.connections
[account
].send_pb_publish('', xmpp
.NS_MOOD
, item
, '0')
484 def user_send_activity(account
, activity
, subactivity
= '', message
= ''):
485 if not gajim
.connections
[account
].pep_supported
:
487 item
= xmpp
.Node('activity', {'xmlns': xmpp
.NS_ACTIVITY
})
489 i
= item
.addChild(activity
)
490 if subactivity
!= '':
491 i
.addChild(subactivity
)
493 i
= item
.addChild('text')
496 gajim
.connections
[account
].send_pb_publish('', xmpp
.NS_ACTIVITY
,
499 def user_send_tune(account
, artist
= '', title
= '', source
= '', track
= 0,
500 length
= 0, items
= None):
501 if not (gajim
.config
.get_per('accounts', account
, 'publish_tune') and \
502 gajim
.connections
[account
].pep_supported
):
504 item
= xmpp
.Node('tune', {'xmlns': xmpp
.NS_TUNE
})
506 i
= item
.addChild('artist')
509 i
= item
.addChild('title')
512 i
= item
.addChild('source')
515 i
= item
.addChild('track')
518 i
= item
.addChild('length')
520 if items
is not None:
521 item
.addChild(payload
=items
)
523 gajim
.connections
[account
].send_pb_publish('', xmpp
.NS_TUNE
, item
, '0')
525 def user_send_nickname(account
, nick
):
526 if not gajim
.connections
[account
].pep_supported
:
528 item
= xmpp
.Node('nick', {'xmlns': xmpp
.NS_NICK
})
531 gajim
.connections
[account
].send_pb_publish('', xmpp
.NS_NICK
, item
, '0')
533 def user_retract_mood(account
):
534 gajim
.connections
[account
].send_pb_retract('', xmpp
.NS_MOOD
, '0')
536 def user_retract_activity(account
):
537 gajim
.connections
[account
].send_pb_retract('', xmpp
.NS_ACTIVITY
, '0')
539 def user_retract_tune(account
):
540 gajim
.connections
[account
].send_pb_retract('', xmpp
.NS_TUNE
, '0')
542 def user_retract_nickname(account
):
543 gajim
.connections
[account
].send_pb_retract('', xmpp
.NS_NICK
, '0')
545 def delete_pep(jid
, name
):
546 (user
, resource
) = gajim
.get_room_and_nick_from_fjid(jid
)
548 if jid
== gajim
.get_jid_from_account(name
):
549 acc
= gajim
.connections
[name
]
557 for contact
in gajim
.contacts
.get_contacts(name
, user
):
559 contact
.activity
= {}
565 if jid
== gajim
.get_jid_from_account(name
):
566 gajim
.interface
.roster
.draw_account(name
)
568 gajim
.interface
.roster
.draw_activity(user
, name
)
569 gajim
.interface
.roster
.draw_tune(user
, name
)
570 gajim
.interface
.roster
.draw_mood(user
, name
)
571 ctrl
= gajim
.interface
.msg_win_mgr
.get_control(user
, name
)
573 ctrl
.update_activity()