Mercurial > pidgin.yaz
annotate src/status.c @ 11677:8004885fabbe
[gaim-migrate @ 13963]
Remove some things from the public namespace by making them static
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 17 Oct 2005 05:50:30 +0000 |
parents | bf6ba37db13b |
children | a647f92e1d57 |
rev | line source |
---|---|
9944 | 1 /** |
10067 | 2 * @file status.c Status API |
9944 | 3 * @ingroup core |
4 * | |
6065 | 5 * gaim |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
9944 | 10 * |
6065 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
9949 | 25 #include "internal.h" |
6065 | 26 |
9949 | 27 #include "blist.h" |
10400 | 28 #include "core.h" |
11187 | 29 #include "dbus-maybe.h" |
9949 | 30 #include "debug.h" |
10337 | 31 #include "notify.h" |
9949 | 32 #include "prefs.h" |
6065 | 33 #include "status.h" |
34 | |
9949 | 35 /** |
36 * A type of status. | |
37 */ | |
38 struct _GaimStatusType | |
39 { | |
40 GaimStatusPrimitive primitive; | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
41 |
9949 | 42 char *id; |
43 char *name; | |
44 char *primary_attr_id; | |
45 | |
46 gboolean saveable; | |
47 gboolean user_settable; | |
48 gboolean independent; | |
49 | |
50 GList *attrs; | |
51 }; | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
52 |
9949 | 53 /** |
54 * A status attribute. | |
55 */ | |
56 struct _GaimStatusAttr | |
57 { | |
58 char *id; | |
59 char *name; | |
60 GaimValue *value_type; | |
61 }; | |
6065 | 62 |
9949 | 63 /** |
64 * A list of statuses. | |
65 */ | |
66 struct _GaimPresence | |
67 { | |
68 GaimPresenceContext context; | |
69 | |
70 gboolean idle; | |
71 time_t idle_time; | |
11249 | 72 time_t login_time; |
9949 | 73 |
74 GList *statuses; | |
75 GHashTable *status_table; | |
76 | |
77 GaimStatus *active_status; | |
6065 | 78 |
9949 | 79 union |
80 { | |
81 GaimAccount *account; | |
82 | |
83 struct | |
84 { | |
85 GaimConversation *conv; | |
86 char *user; | |
87 | |
88 } chat; | |
6065 | 89 |
9949 | 90 struct |
91 { | |
92 GaimAccount *account; | |
93 char *name; | |
94 size_t ref_count; | |
95 GList *buddies; | |
96 | |
97 } buddy; | |
98 | |
99 } u; | |
100 }; | |
101 | |
102 /** | |
103 * An active status. | |
104 */ | |
105 struct _GaimStatus | |
6065 | 106 { |
9949 | 107 GaimStatusType *type; |
108 GaimPresence *presence; | |
109 | |
110 const char *title; | |
6065 | 111 |
9949 | 112 gboolean active; |
6065 | 113 |
9949 | 114 GHashTable *attr_values; |
115 }; | |
6065 | 116 |
117 typedef struct | |
118 { | |
9949 | 119 GaimAccount *account; |
120 char *name; | |
121 } GaimStatusBuddyKey; | |
122 | |
123 static int primitive_scores[] = | |
124 { | |
125 0, /* unset */ | |
126 -500, /* offline */ | |
127 0, /* online */ | |
128 100, /* available */ | |
129 -75, /* unavailable */ | |
130 -50, /* hidden */ | |
131 -100, /* away */ | |
10860 | 132 -200, /* extended away */ |
9949 | 133 -10, /* idle, special case. */ |
134 -5 /* idle time, special case. */ | |
135 }; | |
136 | |
137 static GHashTable *buddy_presences = NULL; | |
138 | |
10860 | 139 #define SCORE_IDLE 8 |
140 #define SCORE_IDLE_TIME 9 | |
9949 | 141 |
142 /************************************************************************** | |
10419 | 143 * GaimStatusPrimitive API |
144 **************************************************************************/ | |
145 static struct GaimStatusPrimitiveMap | |
146 { | |
147 GaimStatusPrimitive type; | |
148 const char *id; | |
149 const char *name; | |
150 | |
151 } const status_primitive_map[] = | |
152 { | |
153 { GAIM_STATUS_UNSET, "unset", N_("Unset") }, | |
154 { GAIM_STATUS_OFFLINE, "offline", N_("Offline") }, | |
155 { GAIM_STATUS_AVAILABLE, "available", N_("Available") }, | |
156 { GAIM_STATUS_UNAVAILABLE, "unavailable", N_("Unavailable") }, | |
157 { GAIM_STATUS_HIDDEN, "hidden", N_("Hidden") }, | |
158 { GAIM_STATUS_AWAY, "away", N_("Away") }, | |
159 { GAIM_STATUS_EXTENDED_AWAY, "extended_away", N_("Extended Away") } | |
160 }; | |
161 | |
162 const char * | |
163 gaim_primitive_get_id_from_type(GaimStatusPrimitive type) | |
164 { | |
165 int i; | |
166 | |
167 for (i = 0; i < GAIM_STATUS_NUM_PRIMITIVES; i++) | |
168 { | |
169 if (type == status_primitive_map[i].type) | |
170 return status_primitive_map[i].id; | |
171 } | |
172 | |
173 return status_primitive_map[0].id; | |
174 } | |
175 | |
176 const char * | |
177 gaim_primitive_get_name_from_type(GaimStatusPrimitive type) | |
178 { | |
179 int i; | |
180 | |
181 for (i = 0; i < GAIM_STATUS_NUM_PRIMITIVES; i++) | |
182 { | |
183 if (type == status_primitive_map[i].type) | |
184 return status_primitive_map[i].name; | |
185 } | |
186 | |
187 return status_primitive_map[0].name; | |
188 } | |
189 | |
190 GaimStatusPrimitive | |
191 gaim_primitive_get_type_from_id(const char *id) | |
192 { | |
193 int i; | |
194 | |
195 g_return_val_if_fail(id != NULL, GAIM_STATUS_UNSET); | |
196 | |
197 for (i = 0; i < GAIM_STATUS_NUM_PRIMITIVES; i++) | |
198 { | |
199 if (!strcmp(id, status_primitive_map[i].id)) | |
200 return status_primitive_map[i].type; | |
201 } | |
202 | |
203 return status_primitive_map[0].type; | |
204 } | |
205 | |
206 | |
207 /************************************************************************** | |
9949 | 208 * GaimStatusType API |
209 **************************************************************************/ | |
210 GaimStatusType * | |
211 gaim_status_type_new_full(GaimStatusPrimitive primitive, const char *id, | |
10009 | 212 const char *name, gboolean saveable, |
213 gboolean user_settable, gboolean independent) | |
9949 | 214 { |
215 GaimStatusType *status_type; | |
216 | |
217 g_return_val_if_fail(primitive != GAIM_STATUS_UNSET, NULL); | |
218 g_return_val_if_fail(id != NULL, NULL); | |
219 g_return_val_if_fail(name != NULL, NULL); | |
220 | |
221 status_type = g_new0(GaimStatusType, 1); | |
11187 | 222 GAIM_DBUS_REGISTER_POINTER(status_type, GaimStatusType); |
9949 | 223 |
224 status_type->primitive = primitive; | |
225 status_type->id = g_strdup(id); | |
226 status_type->name = g_strdup(name); | |
227 status_type->saveable = saveable; | |
228 status_type->user_settable = user_settable; | |
229 status_type->independent = independent; | |
230 | |
231 return status_type; | |
232 } | |
233 | |
234 GaimStatusType * | |
235 gaim_status_type_new(GaimStatusPrimitive primitive, const char *id, | |
10009 | 236 const char *name, gboolean user_settable) |
9949 | 237 { |
238 g_return_val_if_fail(primitive != GAIM_STATUS_UNSET, NULL); | |
239 g_return_val_if_fail(id != NULL, NULL); | |
240 g_return_val_if_fail(name != NULL, NULL); | |
241 | |
242 return gaim_status_type_new_full(primitive, id, name, FALSE, | |
243 user_settable, FALSE); | |
244 } | |
245 | |
246 GaimStatusType * | |
247 gaim_status_type_new_with_attrs(GaimStatusPrimitive primitive, | |
248 const char *id, const char *name, | |
249 gboolean saveable, gboolean user_settable, | |
250 gboolean independent, const char *attr_id, | |
251 const char *attr_name, GaimValue *attr_value, | |
252 ...) | |
253 { | |
254 GaimStatusType *status_type; | |
255 va_list args; | |
256 | |
257 g_return_val_if_fail(primitive != GAIM_STATUS_UNSET, NULL); | |
258 g_return_val_if_fail(id != NULL, NULL); | |
259 g_return_val_if_fail(name != NULL, NULL); | |
10012 | 260 g_return_val_if_fail(attr_id != NULL, NULL); |
9949 | 261 g_return_val_if_fail(attr_name != NULL, NULL); |
262 g_return_val_if_fail(attr_value != NULL, NULL); | |
263 | |
264 status_type = gaim_status_type_new_full(primitive, id, name, saveable, | |
265 user_settable, independent); | |
266 | |
10010 | 267 /* Add the first attribute */ |
9949 | 268 gaim_status_type_add_attr(status_type, attr_id, attr_name, attr_value); |
269 | |
270 va_start(args, attr_value); | |
271 gaim_status_type_add_attrs_vargs(status_type, args); | |
272 va_end(args); | |
273 | |
274 return status_type; | |
275 } | |
276 | |
277 void | |
278 gaim_status_type_destroy(GaimStatusType *status_type) | |
279 { | |
280 GList *l; | |
281 | |
282 g_return_if_fail(status_type != NULL); | |
283 | |
284 g_free(status_type->id); | |
285 g_free(status_type->name); | |
286 | |
287 if (status_type->primary_attr_id != NULL) | |
288 g_free(status_type->primary_attr_id); | |
289 | |
290 if (status_type->attrs != NULL) | |
291 { | |
292 for (l = status_type->attrs; l != NULL; l = l->next) | |
293 gaim_status_attr_destroy((GaimStatusAttr *)l->data); | |
294 | |
295 g_list_free(status_type->attrs); | |
296 } | |
297 | |
11187 | 298 GAIM_DBUS_UNREGISTER_POINTER(status_type); |
9949 | 299 g_free(status_type); |
300 } | |
301 | |
302 void | |
303 gaim_status_type_set_primary_attr(GaimStatusType *status_type, const char *id) | |
304 { | |
305 g_return_if_fail(status_type != NULL); | |
306 | |
307 if (status_type->primary_attr_id != NULL) | |
308 g_free(status_type->primary_attr_id); | |
309 | |
310 status_type->primary_attr_id = (id == NULL ? NULL : g_strdup(id)); | |
311 } | |
312 | |
313 void | |
10197 | 314 gaim_status_type_add_attr(GaimStatusType *status_type, const char *id, |
9949 | 315 const char *name, GaimValue *value) |
316 { | |
317 GaimStatusAttr *attr; | |
318 | |
319 g_return_if_fail(status_type != NULL); | |
320 g_return_if_fail(id != NULL); | |
321 g_return_if_fail(name != NULL); | |
322 g_return_if_fail(value != NULL); | |
323 | |
324 attr = gaim_status_attr_new(id, name, value); | |
325 | |
326 status_type->attrs = g_list_append(status_type->attrs, attr); | |
327 } | |
328 | |
329 void | |
330 gaim_status_type_add_attrs_vargs(GaimStatusType *status_type, va_list args) | |
331 { | |
332 const char *id, *name; | |
333 GaimValue *value; | |
334 | |
335 g_return_if_fail(status_type != NULL); | |
336 | |
337 while ((id = va_arg(args, const char *)) != NULL) | |
338 { | |
339 name = va_arg(args, const char *); | |
340 g_return_if_fail(name != NULL); | |
341 | |
342 value = va_arg(args, GaimValue *); | |
343 g_return_if_fail(value != NULL); | |
6065 | 344 |
9949 | 345 gaim_status_type_add_attr(status_type, id, name, value); |
346 } | |
347 } | |
348 | |
10010 | 349 void |
350 gaim_status_type_add_attrs(GaimStatusType *status_type, const char *id, | |
351 const char *name, GaimValue *value, ...) | |
352 { | |
353 va_list args; | |
354 | |
355 g_return_if_fail(status_type != NULL); | |
356 g_return_if_fail(id != NULL); | |
357 g_return_if_fail(name != NULL); | |
358 g_return_if_fail(value != NULL); | |
359 | |
360 /* Add the first attribute */ | |
361 gaim_status_type_add_attr(status_type, id, name, value); | |
362 | |
363 va_start(args, value); | |
364 gaim_status_type_add_attrs_vargs(status_type, args); | |
365 va_end(args); | |
366 } | |
367 | |
9949 | 368 GaimStatusPrimitive |
369 gaim_status_type_get_primitive(const GaimStatusType *status_type) | |
370 { | |
371 g_return_val_if_fail(status_type != NULL, GAIM_STATUS_UNSET); | |
372 | |
373 return status_type->primitive; | |
374 } | |
375 | |
376 const char * | |
377 gaim_status_type_get_id(const GaimStatusType *status_type) | |
378 { | |
379 g_return_val_if_fail(status_type != NULL, NULL); | |
380 | |
381 return status_type->id; | |
382 } | |
383 | |
384 const char * | |
385 gaim_status_type_get_name(const GaimStatusType *status_type) | |
386 { | |
387 g_return_val_if_fail(status_type != NULL, NULL); | |
388 | |
389 return status_type->name; | |
390 } | |
391 | |
392 gboolean | |
393 gaim_status_type_is_saveable(const GaimStatusType *status_type) | |
394 { | |
395 g_return_val_if_fail(status_type != NULL, FALSE); | |
396 | |
397 return status_type->saveable; | |
398 } | |
399 | |
400 gboolean | |
401 gaim_status_type_is_user_settable(const GaimStatusType *status_type) | |
402 { | |
403 g_return_val_if_fail(status_type != NULL, FALSE); | |
404 | |
405 return status_type->user_settable; | |
406 } | |
407 | |
408 gboolean | |
409 gaim_status_type_is_independent(const GaimStatusType *status_type) | |
410 { | |
411 g_return_val_if_fail(status_type != NULL, FALSE); | |
412 | |
413 return status_type->independent; | |
414 } | |
415 | |
416 gboolean | |
10067 | 417 gaim_status_type_is_exclusive(const GaimStatusType *status_type) |
418 { | |
419 g_return_val_if_fail(status_type != NULL, FALSE); | |
420 | |
421 return !status_type->independent; | |
422 } | |
423 | |
424 gboolean | |
9949 | 425 gaim_status_type_is_available(const GaimStatusType *status_type) |
426 { | |
427 GaimStatusPrimitive primitive; | |
428 | |
429 g_return_val_if_fail(status_type != NULL, FALSE); | |
430 | |
431 primitive = gaim_status_type_get_primitive(status_type); | |
432 | |
10500 | 433 /* Why does "hidden" mean the person is available? */ |
9949 | 434 return (primitive == GAIM_STATUS_AVAILABLE || |
435 primitive == GAIM_STATUS_HIDDEN); | |
436 } | |
437 | |
438 const char * | |
439 gaim_status_type_get_primary_attr(const GaimStatusType *status_type) | |
440 { | |
441 g_return_val_if_fail(status_type != NULL, NULL); | |
442 | |
443 return status_type->primary_attr_id; | |
444 } | |
445 | |
446 GaimStatusAttr * | |
447 gaim_status_type_get_attr(const GaimStatusType *status_type, const char *id) | |
448 { | |
449 GList *l; | |
450 | |
451 g_return_val_if_fail(status_type != NULL, NULL); | |
452 g_return_val_if_fail(id != NULL, NULL); | |
453 | |
454 for (l = status_type->attrs; l != NULL; l = l->next) | |
455 { | |
456 GaimStatusAttr *attr = (GaimStatusAttr *)l->data; | |
457 | |
458 if (!strcmp(gaim_status_attr_get_id(attr), id)) | |
459 return attr; | |
460 } | |
461 | |
462 return NULL; | |
463 } | |
464 | |
465 const GList * | |
466 gaim_status_type_get_attrs(const GaimStatusType *status_type) | |
467 { | |
468 g_return_val_if_fail(status_type != NULL, NULL); | |
469 | |
470 return status_type->attrs; | |
471 } | |
472 | |
10348 | 473 const GaimStatusType * |
474 gaim_status_type_find_with_id(GList *status_types, const char *id) | |
475 { | |
476 GaimStatusType *status_type; | |
477 | |
478 g_return_val_if_fail(id != NULL, NULL); | |
479 | |
480 while (status_types != NULL) | |
481 { | |
482 status_type = status_types->data; | |
483 | |
484 if (!strcmp(id, status_type->id)) | |
485 return status_type; | |
10895 | 486 |
487 status_types = status_types->next; | |
10348 | 488 } |
489 | |
490 return NULL; | |
491 } | |
492 | |
9949 | 493 |
494 /************************************************************************** | |
495 * GaimStatusAttr API | |
496 **************************************************************************/ | |
497 GaimStatusAttr * | |
498 gaim_status_attr_new(const char *id, const char *name, GaimValue *value_type) | |
499 { | |
500 GaimStatusAttr *attr; | |
501 | |
502 g_return_val_if_fail(id != NULL, NULL); | |
503 g_return_val_if_fail(name != NULL, NULL); | |
504 g_return_val_if_fail(value_type != NULL, NULL); | |
505 | |
506 attr = g_new0(GaimStatusAttr, 1); | |
11187 | 507 GAIM_DBUS_REGISTER_POINTER(attr, GaimStatusAttr); |
9949 | 508 |
509 attr->id = g_strdup(id); | |
510 attr->name = g_strdup(name); | |
511 attr->value_type = value_type; | |
512 | |
513 return attr; | |
514 } | |
515 | |
516 void | |
517 gaim_status_attr_destroy(GaimStatusAttr *attr) | |
518 { | |
519 g_return_if_fail(attr != NULL); | |
520 | |
521 g_free(attr->id); | |
522 g_free(attr->name); | |
523 | |
524 gaim_value_destroy(attr->value_type); | |
525 | |
11187 | 526 GAIM_DBUS_UNREGISTER_POINTER(attr); |
9949 | 527 g_free(attr); |
528 } | |
529 | |
530 const char * | |
531 gaim_status_attr_get_id(const GaimStatusAttr *attr) | |
532 { | |
533 g_return_val_if_fail(attr != NULL, NULL); | |
534 | |
535 return attr->id; | |
536 } | |
537 | |
538 const char * | |
539 gaim_status_attr_get_name(const GaimStatusAttr *attr) | |
540 { | |
541 g_return_val_if_fail(attr != NULL, NULL); | |
542 | |
543 return attr->name; | |
544 } | |
545 | |
546 GaimValue * | |
11249 | 547 gaim_status_attr_get_value(const GaimStatusAttr *attr) |
9949 | 548 { |
549 g_return_val_if_fail(attr != NULL, NULL); | |
550 | |
551 return attr->value_type; | |
552 } | |
553 | |
554 | |
555 /************************************************************************** | |
556 * GaimStatus API | |
557 **************************************************************************/ | |
558 GaimStatus * | |
559 gaim_status_new(GaimStatusType *status_type, GaimPresence *presence) | |
560 { | |
561 GaimStatus *status; | |
562 const GList *l; | |
563 | |
564 g_return_val_if_fail(status_type != NULL, NULL); | |
565 g_return_val_if_fail(presence != NULL, NULL); | |
566 | |
567 status = g_new0(GaimStatus, 1); | |
11187 | 568 GAIM_DBUS_REGISTER_POINTER(status, GaimStatus); |
9949 | 569 |
570 status->type = status_type; | |
571 status->presence = presence; | |
572 | |
573 status->attr_values = | |
574 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, | |
575 (GDestroyNotify)gaim_value_destroy); | |
576 | |
577 for (l = gaim_status_type_get_attrs(status_type); l != NULL; l = l->next) | |
578 { | |
579 GaimStatusAttr *attr = (GaimStatusAttr *)l->data; | |
11249 | 580 GaimValue *value = gaim_status_attr_get_value(attr); |
9949 | 581 GaimValue *new_value = gaim_value_dup(value); |
582 | |
583 g_hash_table_insert(status->attr_values, | |
10197 | 584 g_strdup(gaim_status_attr_get_id(attr)), |
585 new_value); | |
9949 | 586 } |
587 | |
588 return status; | |
589 } | |
590 | |
10754 | 591 /* |
592 * TODO: If the GaimStatus is in a GaimPresence, then | |
593 * remove it from the GaimPresence? | |
594 */ | |
9949 | 595 void |
596 gaim_status_destroy(GaimStatus *status) | |
597 { | |
598 g_return_if_fail(status != NULL); | |
599 | |
600 g_hash_table_destroy(status->attr_values); | |
601 | |
11187 | 602 GAIM_DBUS_UNREGISTER_POINTER(status); |
9949 | 603 g_free(status); |
604 } | |
6065 | 605 |
606 static void | |
9949 | 607 notify_buddy_status_update(GaimBuddy *buddy, GaimPresence *presence, |
608 GaimStatus *old_status, GaimStatus *new_status) | |
609 { | |
610 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); | |
611 | |
612 if (gaim_prefs_get_bool("/core/logging/log_system") && | |
613 gaim_prefs_get_bool("/core/logging/log_away_state")) | |
614 { | |
615 time_t current_time = time(NULL); | |
616 const char *buddy_alias = gaim_buddy_get_alias(buddy); | |
617 char *tmp = NULL; | |
618 | |
11624 | 619 if (((old_status == NULL) || !gaim_status_is_available(old_status)) && |
9949 | 620 gaim_status_is_available(new_status)) |
621 { | |
622 tmp = g_strdup_printf(_("%s came back"), buddy_alias); | |
623 } | |
11624 | 624 else if ((old_status != NULL) && gaim_status_is_available(old_status) && |
9949 | 625 !gaim_status_is_available(new_status)) |
626 { | |
627 tmp = g_strdup_printf(_("%s went away"), buddy_alias); | |
628 } | |
629 | |
630 if (tmp != NULL) | |
631 { | |
632 GaimLog *log = gaim_account_get_log(buddy->account); | |
633 | |
634 gaim_log_write(log, GAIM_MESSAGE_SYSTEM, buddy_alias, | |
635 current_time, tmp); | |
636 g_free(tmp); | |
637 } | |
638 } | |
639 | |
10012 | 640 if (ops != NULL && ops->update != NULL) |
641 ops->update(gaim_get_blist(), (GaimBlistNode*)buddy); | |
9949 | 642 } |
643 | |
644 static void | |
645 notify_status_update(GaimPresence *presence, GaimStatus *old_status, | |
10176
0109f3a518d2
[gaim-migrate @ 11291]
Christian Hammond <chipx86@chipx86.com>
parents:
10153
diff
changeset
|
646 GaimStatus *new_status) |
6065 | 647 { |
9949 | 648 GaimPresenceContext context = gaim_presence_get_context(presence); |
649 | |
650 if (context == GAIM_PRESENCE_CONTEXT_ACCOUNT) | |
651 { | |
10176
0109f3a518d2
[gaim-migrate @ 11291]
Christian Hammond <chipx86@chipx86.com>
parents:
10153
diff
changeset
|
652 GaimAccount *account = gaim_presence_get_account(presence); |
9949 | 653 GaimAccountUiOps *ops = gaim_accounts_get_ui_ops(); |
654 | |
10400 | 655 if (gaim_account_get_enabled(account, gaim_core_get_ui())) |
10447 | 656 gaim_prpl_change_account_status(account, old_status, new_status); |
10176
0109f3a518d2
[gaim-migrate @ 11291]
Christian Hammond <chipx86@chipx86.com>
parents:
10153
diff
changeset
|
657 |
9949 | 658 if (ops != NULL && ops->status_changed != NULL) |
659 { | |
10176
0109f3a518d2
[gaim-migrate @ 11291]
Christian Hammond <chipx86@chipx86.com>
parents:
10153
diff
changeset
|
660 ops->status_changed(account, new_status); |
9949 | 661 } |
662 } | |
663 else if (context == GAIM_PRESENCE_CONTEXT_CONV) | |
664 { | |
665 #if 0 | |
666 GaimConversationUiOps *ops; | |
667 GaimConversation *conv; | |
668 | |
669 conv = gaim_status_get_conversation(new_status); | |
10348 | 670 /* |
671 * TODO: Probably need to do some of the following here? This is copied | |
672 * from some old status code that was removed. | |
673 * | |
674 * char *tmp = g_strdup_printf(_("%s logged in."), alias); | |
675 * gaim_conversation_write(c, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
676 * g_free(tmp); | |
677 * | |
678 * char *tmp = g_strdup_printf(_("%s logged out."), alias); | |
679 * gaim_conversation_write(c, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
680 * g_free(tmp); | |
681 * | |
682 * char *tmp = g_strdup_printf(_("%s signed off"), alias); | |
683 * gaim_log_write(log, GAIM_MESSAGE_SYSTEM, (alias ? alias : name), current_time, tmp); | |
684 * g_free(tmp); | |
685 * | |
686 * serv_got_typing_stopped(gc, name); | |
687 * | |
688 * gaim_conversation_update(c, GAIM_CONV_UPDATE_AWAY); | |
689 */ | |
9949 | 690 #endif |
691 } | |
692 else if (context == GAIM_PRESENCE_CONTEXT_BUDDY) | |
693 { | |
694 const GList *l; | |
695 | |
696 for (l = gaim_presence_get_buddies(presence); l != NULL; l = l->next) | |
697 { | |
698 notify_buddy_status_update((GaimBuddy *)l->data, presence, | |
699 old_status, new_status); | |
700 } | |
10348 | 701 |
702 /* | |
703 * TODO: Maybe we should do this here? | |
704 * GaimLog *log = gaim_account_get_log(account); | |
705 * char *tmp = g_strdup_printf(_("%s signed on"), alias); | |
706 * gaim_log_write(log, GAIM_MESSAGE_SYSTEM, (alias ? alias : name), current_time, tmp); | |
707 * g_free(tmp); | |
708 */ | |
9949 | 709 } |
710 } | |
711 | |
10204 | 712 static void |
713 status_has_changed(GaimStatus *status) | |
9949 | 714 { |
715 GaimPresence *presence; | |
716 GaimStatus *old_status; | |
717 | |
718 presence = gaim_status_get_presence(status); | |
719 | |
10204 | 720 /* |
721 * If this status is exclusive, then we must be setting it to "active." | |
722 * Since we are setting it to active, we want to set the currently | |
723 * active status to "inactive." | |
724 */ | |
725 if (gaim_status_is_exclusive(status)) | |
9949 | 726 { |
10754 | 727 old_status = gaim_presence_get_active_status(presence); |
10760 | 728 if (old_status != NULL && (old_status != status)) |
10754 | 729 old_status->active = FALSE; |
730 presence->active_status = status; | |
9949 | 731 } |
10754 | 732 else |
733 old_status = NULL; | |
9949 | 734 |
10204 | 735 notify_status_update(presence, old_status, status); |
736 } | |
737 | |
738 void | |
739 gaim_status_set_active(GaimStatus *status, gboolean active) | |
740 { | |
10754 | 741 gaim_status_set_active_with_attrs(status, active, NULL); |
10204 | 742 } |
743 | |
11249 | 744 /* |
745 * This used to parse the va_list directly, but now it creates a GList | |
746 * and passes it to gaim_status_set_active_with_attrs_list(). That | |
747 * function was created because accounts.c needs to pass a GList of | |
748 * attributes to the status API. | |
749 */ | |
10204 | 750 void |
751 gaim_status_set_active_with_attrs(GaimStatus *status, gboolean active, va_list args) | |
752 { | |
11249 | 753 GList *attrs = NULL; |
754 const gchar *id; | |
755 gpointer data; | |
756 | |
757 if (args != NULL) | |
758 { | |
759 while ((id = va_arg(args, const char *)) != NULL) | |
760 { | |
761 attrs = g_list_append(attrs, (char *)id); | |
762 data = va_arg(args, void *); | |
763 attrs = g_list_append(attrs, data); | |
764 } | |
765 } | |
766 gaim_status_set_active_with_attrs_list(status, active, attrs); | |
767 g_list_free(attrs); | |
768 } | |
769 | |
770 void | |
771 gaim_status_set_active_with_attrs_list(GaimStatus *status, gboolean active, | |
772 const GList *attrs) | |
773 { | |
10204 | 774 gboolean changed = FALSE; |
775 const gchar *id; | |
776 | |
10714 | 777 g_return_if_fail(status != NULL); |
778 | |
10204 | 779 if (!active && gaim_status_is_exclusive(status)) |
780 { | |
781 gaim_debug_error("status", | |
782 "Cannot deactivate an exclusive status (%s).\n", | |
783 gaim_status_get_id(status)); | |
784 return; | |
785 } | |
786 | |
787 if (status->active != active) | |
10738 | 788 { |
10204 | 789 changed = TRUE; |
10738 | 790 } |
10204 | 791 |
9949 | 792 status->active = active; |
6065 | 793 |
10204 | 794 /* Set any attributes */ |
11249 | 795 while (attrs) |
10204 | 796 { |
797 GaimValue *value; | |
11249 | 798 |
799 id = attrs->data; | |
800 attrs = attrs->next; | |
10204 | 801 value = gaim_status_get_attr_value(status, id); |
10713 | 802 if (value == NULL) |
803 { | |
804 gaim_debug_warning("status", "The attribute \"%s\" on the status \"%s\" is " | |
10714 | 805 "not supported.\n", id, status->type->name); |
10713 | 806 /* Skip over the data and move on to the next attribute */ |
11249 | 807 attrs = attrs->next; |
10713 | 808 continue; |
809 } | |
810 | |
10204 | 811 if (value->type == GAIM_TYPE_STRING) |
812 { | |
11249 | 813 const gchar *string_data = attrs->data; |
814 attrs = attrs->next; | |
10204 | 815 if (((string_data == NULL) && (value->data.string_data == NULL)) || |
816 ((string_data != NULL) && (value->data.string_data != NULL) && | |
817 !strcmp(string_data, value->data.string_data))) | |
818 { | |
819 continue; | |
820 } | |
821 gaim_status_set_attr_string(status, id, string_data); | |
822 changed = TRUE; | |
823 } | |
824 else if (value->type == GAIM_TYPE_INT) | |
825 { | |
11586 | 826 int int_data = GPOINTER_TO_INT(attrs->data); |
11249 | 827 attrs = attrs->next; |
10204 | 828 if (int_data == value->data.int_data) |
829 continue; | |
830 gaim_status_set_attr_int(status, id, int_data); | |
831 changed = TRUE; | |
832 } | |
833 else if (value->type == GAIM_TYPE_BOOLEAN) | |
834 { | |
11586 | 835 gboolean boolean_data = GPOINTER_TO_INT(attrs->data); |
11249 | 836 attrs = attrs->next; |
10204 | 837 if (boolean_data == value->data.boolean_data) |
838 continue; | |
839 gaim_status_set_attr_int(status, id, boolean_data); | |
840 changed = TRUE; | |
841 } | |
842 else | |
843 { | |
844 /* We don't know what the data is--skip over it */ | |
11249 | 845 attrs = attrs->next; |
10204 | 846 } |
847 } | |
848 | |
849 if (!changed) | |
850 return; | |
851 status_has_changed(status); | |
9949 | 852 } |
853 | |
854 void | |
855 gaim_status_set_attr_boolean(GaimStatus *status, const char *id, | |
856 gboolean value) | |
857 { | |
858 GaimStatusType *status_type; | |
859 GaimValue *attr_value; | |
860 | |
861 g_return_if_fail(status != NULL); | |
862 g_return_if_fail(id != NULL); | |
863 | |
864 status_type = gaim_status_get_type(status); | |
865 | |
10197 | 866 /* Make sure this attribute exists and is the correct type. */ |
867 attr_value = gaim_status_get_attr_value(status, id); | |
868 g_return_if_fail(attr_value != NULL); | |
9949 | 869 g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_BOOLEAN); |
870 | |
871 gaim_value_set_boolean(attr_value, value); | |
872 } | |
873 | |
874 void | |
875 gaim_status_set_attr_int(GaimStatus *status, const char *id, int value) | |
876 { | |
877 GaimStatusType *status_type; | |
878 GaimValue *attr_value; | |
879 | |
880 g_return_if_fail(status != NULL); | |
881 g_return_if_fail(id != NULL); | |
882 | |
883 status_type = gaim_status_get_type(status); | |
884 | |
10197 | 885 /* Make sure this attribute exists and is the correct type. */ |
886 attr_value = gaim_status_get_attr_value(status, id); | |
887 g_return_if_fail(attr_value != NULL); | |
9949 | 888 g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_INT); |
889 | |
890 gaim_value_set_int(attr_value, value); | |
6065 | 891 } |
892 | |
9949 | 893 void |
894 gaim_status_set_attr_string(GaimStatus *status, const char *id, | |
895 const char *value) | |
896 { | |
897 GaimStatusType *status_type; | |
898 GaimValue *attr_value; | |
899 | |
900 g_return_if_fail(status != NULL); | |
901 g_return_if_fail(id != NULL); | |
902 | |
903 status_type = gaim_status_get_type(status); | |
904 | |
10197 | 905 /* Make sure this attribute exists and is the correct type. */ |
10196 | 906 attr_value = gaim_status_get_attr_value(status, id); |
10197 | 907 g_return_if_fail(attr_value != NULL); |
9949 | 908 g_return_if_fail(gaim_value_get_type(attr_value) == GAIM_TYPE_STRING); |
909 | |
910 gaim_value_set_string(attr_value, value); | |
911 } | |
912 | |
913 GaimStatusType * | |
914 gaim_status_get_type(const GaimStatus *status) | |
915 { | |
916 g_return_val_if_fail(status != NULL, NULL); | |
917 | |
918 return status->type; | |
919 } | |
920 | |
921 GaimPresence * | |
922 gaim_status_get_presence(const GaimStatus *status) | |
6065 | 923 { |
9949 | 924 g_return_val_if_fail(status != NULL, NULL); |
925 | |
926 return status->presence; | |
927 } | |
928 | |
929 const char * | |
930 gaim_status_get_id(const GaimStatus *status) | |
931 { | |
932 g_return_val_if_fail(status != NULL, NULL); | |
933 | |
934 return gaim_status_type_get_id(gaim_status_get_type(status)); | |
935 } | |
936 | |
937 const char * | |
938 gaim_status_get_name(const GaimStatus *status) | |
939 { | |
940 g_return_val_if_fail(status != NULL, NULL); | |
941 | |
942 return gaim_status_type_get_name(gaim_status_get_type(status)); | |
943 } | |
944 | |
945 gboolean | |
946 gaim_status_is_independent(const GaimStatus *status) | |
947 { | |
948 g_return_val_if_fail(status != NULL, FALSE); | |
949 | |
950 return gaim_status_type_is_independent(gaim_status_get_type(status)); | |
951 } | |
952 | |
953 gboolean | |
10067 | 954 gaim_status_is_exclusive(const GaimStatus *status) |
955 { | |
956 g_return_val_if_fail(status != NULL, FALSE); | |
957 | |
958 return gaim_status_type_is_exclusive(gaim_status_get_type(status)); | |
959 } | |
960 | |
961 gboolean | |
9949 | 962 gaim_status_is_available(const GaimStatus *status) |
963 { | |
964 g_return_val_if_fail(status != NULL, FALSE); | |
965 | |
966 return gaim_status_type_is_available(gaim_status_get_type(status)); | |
967 } | |
6216 | 968 |
9949 | 969 gboolean |
970 gaim_status_is_active(const GaimStatus *status) | |
971 { | |
972 g_return_val_if_fail(status != NULL, FALSE); | |
973 | |
974 return status->active; | |
975 } | |
976 | |
10040
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10013
diff
changeset
|
977 gboolean |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10013
diff
changeset
|
978 gaim_status_is_online(const GaimStatus *status) |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10013
diff
changeset
|
979 { |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10013
diff
changeset
|
980 GaimStatusPrimitive primitive; |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10013
diff
changeset
|
981 |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10013
diff
changeset
|
982 g_return_val_if_fail( status != NULL, FALSE); |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10013
diff
changeset
|
983 |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10013
diff
changeset
|
984 primitive = gaim_status_type_get_primitive(gaim_status_get_type(status)); |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10013
diff
changeset
|
985 |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10013
diff
changeset
|
986 return (primitive != GAIM_STATUS_UNSET && |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10013
diff
changeset
|
987 primitive != GAIM_STATUS_OFFLINE); |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10013
diff
changeset
|
988 } |
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10013
diff
changeset
|
989 |
9949 | 990 GaimValue * |
991 gaim_status_get_attr_value(const GaimStatus *status, const char *id) | |
992 { | |
993 GaimStatusType *status_type; | |
994 GaimStatusAttr *attr; | |
995 | |
996 g_return_val_if_fail(status != NULL, NULL); | |
997 g_return_val_if_fail(id != NULL, NULL); | |
998 | |
999 status_type = gaim_status_get_type(status); | |
1000 | |
1001 /* Make sure this attribute exists. */ | |
1002 attr = gaim_status_type_get_attr(status_type, id); | |
1003 g_return_val_if_fail(attr != NULL, NULL); | |
1004 | |
1005 return (GaimValue *)g_hash_table_lookup(status->attr_values, id); | |
1006 } | |
1007 | |
1008 gboolean | |
1009 gaim_status_get_attr_boolean(const GaimStatus *status, const char *id) | |
1010 { | |
1011 const GaimValue *value; | |
1012 | |
1013 g_return_val_if_fail(status != NULL, FALSE); | |
1014 g_return_val_if_fail(id != NULL, FALSE); | |
1015 | |
1016 if ((value = gaim_status_get_attr_value(status, id)) == NULL) | |
1017 return FALSE; | |
1018 | |
10197 | 1019 g_return_val_if_fail(gaim_value_get_type(value) == GAIM_TYPE_BOOLEAN, FALSE); |
9949 | 1020 |
1021 return gaim_value_get_boolean(value); | |
1022 } | |
1023 | |
1024 int | |
1025 gaim_status_get_attr_int(const GaimStatus *status, const char *id) | |
1026 { | |
1027 const GaimValue *value; | |
1028 | |
10507 | 1029 g_return_val_if_fail(status != NULL, 0); |
1030 g_return_val_if_fail(id != NULL, 0); | |
9949 | 1031 |
1032 if ((value = gaim_status_get_attr_value(status, id)) == NULL) | |
10507 | 1033 return 0; |
9949 | 1034 |
1035 g_return_val_if_fail(gaim_value_get_type(value) == GAIM_TYPE_INT, 0); | |
1036 | |
1037 return gaim_value_get_int(value); | |
1038 } | |
1039 | |
1040 const char * | |
1041 gaim_status_get_attr_string(const GaimStatus *status, const char *id) | |
1042 { | |
1043 const GaimValue *value; | |
1044 | |
10507 | 1045 g_return_val_if_fail(status != NULL, NULL); |
1046 g_return_val_if_fail(id != NULL, NULL); | |
9949 | 1047 |
1048 if ((value = gaim_status_get_attr_value(status, id)) == NULL) | |
10504 | 1049 return NULL; |
9949 | 1050 |
1051 g_return_val_if_fail(gaim_value_get_type(value) == GAIM_TYPE_STRING, NULL); | |
1052 | |
1053 return gaim_value_get_string(value); | |
1054 } | |
1055 | |
1056 gint | |
1057 gaim_status_compare(const GaimStatus *status1, const GaimStatus *status2) | |
1058 { | |
1059 GaimStatusType *type1, *type2; | |
1060 int score1 = 0, score2 = 0; | |
6065 | 1061 |
9949 | 1062 if ((status1 == NULL && status2 == NULL) || |
1063 (status1 == status2)) | |
1064 { | |
1065 return 0; | |
1066 } | |
1067 else if (status1 == NULL) | |
1068 return 1; | |
1069 else if (status2 == NULL) | |
1070 return -1; | |
1071 | |
1072 type1 = gaim_status_get_type(status1); | |
1073 type2 = gaim_status_get_type(status2); | |
1074 | |
1075 if (gaim_status_is_active(status1)) | |
1076 score1 = primitive_scores[gaim_status_type_get_primitive(type1)]; | |
1077 | |
1078 if (gaim_status_is_active(status2)) | |
1079 score2 = primitive_scores[gaim_status_type_get_primitive(type2)]; | |
1080 | |
1081 if (score1 > score2) | |
1082 return -1; | |
1083 else if (score1 < score2) | |
1084 return 1; | |
1085 | |
1086 return 0; | |
1087 } | |
1088 | |
1089 | |
1090 /************************************************************************** | |
1091 * GaimPresence API | |
1092 **************************************************************************/ | |
1093 GaimPresence * | |
1094 gaim_presence_new(GaimPresenceContext context) | |
1095 { | |
1096 GaimPresence *presence; | |
1097 | |
1098 g_return_val_if_fail(context != GAIM_PRESENCE_CONTEXT_UNSET, NULL); | |
1099 | |
1100 presence = g_new0(GaimPresence, 1); | |
11187 | 1101 GAIM_DBUS_REGISTER_POINTER(presence, GaimPresence); |
9949 | 1102 |
1103 presence->context = context; | |
1104 | |
1105 presence->status_table = | |
10009 | 1106 g_hash_table_new_full(g_str_hash, g_str_equal, |
11638 | 1107 g_free, NULL); |
9949 | 1108 |
1109 return presence; | |
1110 } | |
1111 | |
1112 GaimPresence * | |
1113 gaim_presence_new_for_account(GaimAccount *account) | |
1114 { | |
10012 | 1115 GaimPresence *presence = NULL; |
9949 | 1116 g_return_val_if_fail(account != NULL, NULL); |
1117 | |
1118 presence = gaim_presence_new(GAIM_PRESENCE_CONTEXT_ACCOUNT); | |
1119 presence->u.account = account; | |
10006 | 1120 presence->statuses = gaim_prpl_get_statuses(account, presence); |
9949 | 1121 |
1122 return presence; | |
1123 } | |
1124 | |
1125 GaimPresence * | |
1126 gaim_presence_new_for_conv(GaimConversation *conv) | |
1127 { | |
1128 GaimPresence *presence; | |
1129 | |
1130 g_return_val_if_fail(conv != NULL, NULL); | |
1131 | |
1132 presence = gaim_presence_new(GAIM_PRESENCE_CONTEXT_CONV); | |
1133 presence->u.chat.conv = conv; | |
10006 | 1134 /* presence->statuses = gaim_prpl_get_statuses(conv->account, presence); ? */ |
9949 | 1135 |
1136 return presence; | |
1137 } | |
6216 | 1138 |
9949 | 1139 GaimPresence * |
1140 gaim_presence_new_for_buddy(GaimBuddy *buddy) | |
1141 { | |
1142 GaimPresence *presence; | |
1143 GaimStatusBuddyKey *key; | |
10006 | 1144 GaimAccount *account; |
9949 | 1145 |
1146 g_return_val_if_fail(buddy != NULL, NULL); | |
10012 | 1147 account = buddy->account; |
9949 | 1148 |
1149 key = g_new0(GaimStatusBuddyKey, 1); | |
1150 key->account = buddy->account; | |
1151 key->name = g_strdup(buddy->name); | |
10006 | 1152 |
1153 presence = g_hash_table_lookup(buddy_presences, key); | |
1154 if (presence == NULL) | |
9949 | 1155 { |
1156 presence = gaim_presence_new(GAIM_PRESENCE_CONTEXT_BUDDY); | |
1157 | |
1158 presence->u.buddy.name = g_strdup(buddy->name); | |
1159 presence->u.buddy.account = buddy->account; | |
10006 | 1160 presence->statuses = gaim_prpl_get_statuses(buddy->account, presence); |
9949 | 1161 |
1162 g_hash_table_insert(buddy_presences, key, presence); | |
1163 } | |
1164 else | |
1165 { | |
1166 g_free(key->name); | |
1167 g_free(key); | |
1168 } | |
1169 | |
1170 presence->u.buddy.ref_count++; | |
1171 presence->u.buddy.buddies = g_list_append(presence->u.buddy.buddies, | |
1172 buddy); | |
1173 | |
1174 return presence; | |
1175 } | |
1176 | |
1177 void | |
1178 gaim_presence_destroy(GaimPresence *presence) | |
1179 { | |
1180 g_return_if_fail(presence != NULL); | |
6216 | 1181 |
9949 | 1182 if (gaim_presence_get_context(presence) == GAIM_PRESENCE_CONTEXT_BUDDY) |
1183 { | |
1184 GaimStatusBuddyKey key; | |
1185 | |
10077 | 1186 if(presence->u.buddy.ref_count != 0) |
1187 return; | |
9949 | 1188 |
1189 key.account = presence->u.buddy.account; | |
1190 key.name = presence->u.buddy.name; | |
1191 | |
1192 g_hash_table_remove(buddy_presences, &key); | |
1193 | |
1194 if (presence->u.buddy.name != NULL) | |
1195 g_free(presence->u.buddy.name); | |
1196 } | |
1197 else if (gaim_presence_get_context(presence) == GAIM_PRESENCE_CONTEXT_CONV) | |
1198 { | |
1199 if (presence->u.chat.user != NULL) | |
1200 g_free(presence->u.chat.user); | |
1201 } | |
1202 | |
11638 | 1203 if (presence->statuses != NULL) { |
1204 g_list_foreach(presence->statuses, (GFunc)gaim_status_destroy, NULL); | |
9949 | 1205 g_list_free(presence->statuses); |
11638 | 1206 } |
9949 | 1207 |
1208 g_hash_table_destroy(presence->status_table); | |
1209 | |
11187 | 1210 GAIM_DBUS_UNREGISTER_POINTER(presence); |
9949 | 1211 g_free(presence); |
1212 } | |
1213 | |
10580 | 1214 /* |
1215 * TODO: Maybe we should cal gaim_presence_destroy() after we | |
1216 * decrement the ref count? I don't see why we should | |
1217 * make other places do it manually when we can do it here. | |
1218 */ | |
9949 | 1219 void |
1220 gaim_presence_remove_buddy(GaimPresence *presence, GaimBuddy *buddy) | |
1221 { | |
1222 g_return_if_fail(presence != NULL); | |
1223 g_return_if_fail(buddy != NULL); | |
1224 g_return_if_fail(gaim_presence_get_context(presence) == | |
1225 GAIM_PRESENCE_CONTEXT_BUDDY); | |
1226 | |
1227 if (g_list_find(presence->u.buddy.buddies, buddy) != NULL) | |
1228 { | |
1229 presence->u.buddy.buddies = g_list_remove(presence->u.buddy.buddies, | |
1230 buddy); | |
1231 presence->u.buddy.ref_count--; | |
1232 } | |
6065 | 1233 } |
1234 | |
9949 | 1235 void |
1236 gaim_presence_add_status(GaimPresence *presence, GaimStatus *status) | |
1237 { | |
1238 g_return_if_fail(presence != NULL); | |
1239 g_return_if_fail(status != NULL); | |
1240 | |
1241 presence->statuses = g_list_append(presence->statuses, status); | |
1242 | |
1243 g_hash_table_insert(presence->status_table, | |
1244 g_strdup(gaim_status_get_id(status)), status); | |
1245 } | |
1246 | |
1247 void | |
11318 | 1248 gaim_presence_add_list(GaimPresence *presence, const GList *source_list) |
9949 | 1249 { |
1250 const GList *l; | |
1251 | |
1252 g_return_if_fail(presence != NULL); | |
1253 g_return_if_fail(source_list != NULL); | |
1254 | |
1255 for (l = source_list; l != NULL; l = l->next) | |
1256 gaim_presence_add_status(presence, (GaimStatus *)l->data); | |
1257 } | |
1258 | |
1259 void | |
1260 gaim_presence_set_status_active(GaimPresence *presence, const char *status_id, | |
1261 gboolean active) | |
1262 { | |
1263 GaimStatus *status; | |
1264 | |
1265 g_return_if_fail(presence != NULL); | |
1266 g_return_if_fail(status_id != NULL); | |
1267 | |
1268 status = gaim_presence_get_status(presence, status_id); | |
1269 | |
1270 g_return_if_fail(status != NULL); | |
10348 | 1271 /* TODO: Should we do the following? */ |
1272 /* g_return_if_fail(active == status->active); */ | |
9949 | 1273 |
10067 | 1274 if (gaim_status_is_exclusive(status)) |
9949 | 1275 { |
1276 if (!active) | |
1277 { | |
1278 gaim_debug_warning("status", | |
1279 "Attempted to set a non-independent status " | |
1280 "(%s) inactive. Only independent statuses " | |
1281 "can be specifically marked inactive.", | |
1282 status_id); | |
1283 return; | |
1284 } | |
1285 } | |
1286 | |
1287 gaim_status_set_active(status, active); | |
1288 } | |
1289 | |
1290 void | |
1291 gaim_presence_switch_status(GaimPresence *presence, const char *status_id) | |
1292 { | |
10754 | 1293 gaim_presence_set_status_active(presence, status_id, TRUE); |
9949 | 1294 } |
1295 | |
1296 static void | |
1297 update_buddy_idle(GaimBuddy *buddy, GaimPresence *presence, | |
1298 time_t current_time, gboolean old_idle, gboolean idle) | |
1299 { | |
1300 GaimBlistUiOps *ops = gaim_get_blist()->ui_ops; | |
1301 | |
1302 if (!old_idle && idle) | |
1303 { | |
1304 gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle", buddy); | |
1305 | |
1306 if (gaim_prefs_get_bool("/core/logging/log_system") && | |
1307 gaim_prefs_get_bool("/core/logging/log_idle_state")) | |
1308 { | |
1309 GaimLog *log = gaim_account_get_log(buddy->account); | |
1310 char *tmp = g_strdup_printf(_("%s became idle"), | |
1311 gaim_buddy_get_alias(buddy)); | |
1312 | |
1313 gaim_log_write(log, GAIM_MESSAGE_SYSTEM, | |
1314 gaim_buddy_get_alias(buddy), current_time, tmp); | |
1315 g_free(tmp); | |
1316 } | |
1317 } | |
1318 else if (old_idle && !idle) | |
1319 { | |
1320 gaim_signal_emit(gaim_blist_get_handle(), "buddy-unidle", buddy); | |
1321 | |
1322 if (gaim_prefs_get_bool("/core/logging/log_system") && | |
1323 gaim_prefs_get_bool("/core/logging/log_idle_state")) | |
1324 { | |
1325 GaimLog *log = gaim_account_get_log(buddy->account); | |
1326 char *tmp = g_strdup_printf(_("%s became unidle"), | |
1327 gaim_buddy_get_alias(buddy)); | |
1328 | |
1329 gaim_log_write(log, GAIM_MESSAGE_SYSTEM, | |
1330 gaim_buddy_get_alias(buddy), current_time, tmp); | |
1331 g_free(tmp); | |
1332 } | |
1333 } | |
1334 | |
10378 | 1335 gaim_contact_invalidate_priority_buddy(gaim_buddy_get_contact(buddy)); |
9949 | 1336 |
1337 if (ops != NULL && ops->update != NULL) | |
1338 ops->update(gaim_get_blist(), (GaimBlistNode *)buddy); | |
1339 } | |
1340 | |
1341 void | |
1342 gaim_presence_set_idle(GaimPresence *presence, gboolean idle, time_t idle_time) | |
1343 { | |
1344 gboolean old_idle; | |
1345 | |
1346 g_return_if_fail(presence != NULL); | |
1347 | |
1348 if (presence->idle == idle && presence->idle_time == idle_time) | |
1349 return; | |
1350 | |
1351 old_idle = presence->idle; | |
1352 presence->idle = idle; | |
1353 presence->idle_time = (idle ? idle_time : 0); | |
1354 | |
1355 if (gaim_presence_get_context(presence) == GAIM_PRESENCE_CONTEXT_BUDDY) | |
1356 { | |
1357 const GList *l; | |
1358 time_t current_time = time(NULL); | |
1359 | |
1360 for (l = gaim_presence_get_buddies(presence); l != NULL; l = l->next) | |
1361 { | |
1362 update_buddy_idle((GaimBuddy *)l->data, presence, current_time, | |
1363 old_idle, idle); | |
1364 } | |
1365 } | |
11551
78aad676fdb2
[gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1366 else if(gaim_presence_get_context(presence) == GAIM_PRESENCE_CONTEXT_ACCOUNT) |
78aad676fdb2
[gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1367 { |
78aad676fdb2
[gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1368 GaimConnection *gc = |
78aad676fdb2
[gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1369 gaim_account_get_connection(gaim_presence_get_account(presence)); |
78aad676fdb2
[gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1370 GaimPluginProtocolInfo *prpl_info = NULL; |
78aad676fdb2
[gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1371 |
78aad676fdb2
[gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1372 if (gc != NULL && gc->prpl != NULL) |
78aad676fdb2
[gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1373 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
78aad676fdb2
[gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1374 |
78aad676fdb2
[gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1375 if (prpl_info && g_list_find(gaim_connections_get_all(), gc) && |
78aad676fdb2
[gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1376 prpl_info->set_idle) |
78aad676fdb2
[gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1377 prpl_info->set_idle(gc, time(NULL) - idle_time); |
78aad676fdb2
[gaim-migrate @ 13806]
Luke Schierer <lschiere@pidgin.im>
parents:
11522
diff
changeset
|
1378 } |
9949 | 1379 } |
1380 | |
1381 void | |
10006 | 1382 gaim_presence_set_login_time(GaimPresence *presence, time_t login_time) |
1383 { | |
1384 g_return_if_fail(presence != NULL); | |
1385 | |
1386 if (presence->login_time == login_time) | |
1387 return; | |
1388 | |
1389 presence->login_time = login_time; | |
1390 } | |
1391 | |
9949 | 1392 GaimPresenceContext |
1393 gaim_presence_get_context(const GaimPresence *presence) | |
1394 { | |
1395 g_return_val_if_fail(presence != NULL, GAIM_PRESENCE_CONTEXT_UNSET); | |
1396 | |
1397 return presence->context; | |
1398 } | |
1399 | |
1400 GaimAccount * | |
1401 gaim_presence_get_account(const GaimPresence *presence) | |
1402 { | |
1403 GaimPresenceContext context; | |
1404 | |
1405 g_return_val_if_fail(presence != NULL, NULL); | |
1406 | |
1407 context = gaim_presence_get_context(presence); | |
1408 | |
1409 g_return_val_if_fail(context == GAIM_PRESENCE_CONTEXT_ACCOUNT || | |
1410 context == GAIM_PRESENCE_CONTEXT_BUDDY, NULL); | |
1411 | |
1412 return presence->u.account; | |
1413 } | |
1414 | |
1415 GaimConversation * | |
1416 gaim_presence_get_conversation(const GaimPresence *presence) | |
1417 { | |
1418 g_return_val_if_fail(presence != NULL, NULL); | |
1419 g_return_val_if_fail(gaim_presence_get_context(presence) == | |
1420 GAIM_PRESENCE_CONTEXT_CONV, NULL); | |
1421 | |
1422 return presence->u.chat.conv; | |
1423 } | |
1424 | |
1425 const char * | |
1426 gaim_presence_get_chat_user(const GaimPresence *presence) | |
1427 { | |
1428 g_return_val_if_fail(presence != NULL, NULL); | |
1429 g_return_val_if_fail(gaim_presence_get_context(presence) == | |
1430 GAIM_PRESENCE_CONTEXT_CONV, NULL); | |
1431 | |
1432 return presence->u.chat.user; | |
1433 } | |
1434 | |
1435 const GList * | |
1436 gaim_presence_get_buddies(const GaimPresence *presence) | |
1437 { | |
1438 g_return_val_if_fail(presence != NULL, NULL); | |
1439 g_return_val_if_fail(gaim_presence_get_context(presence) == | |
1440 GAIM_PRESENCE_CONTEXT_BUDDY, NULL); | |
1441 | |
1442 return presence->u.buddy.buddies; | |
1443 } | |
1444 | |
1445 const GList * | |
1446 gaim_presence_get_statuses(const GaimPresence *presence) | |
1447 { | |
1448 g_return_val_if_fail(presence != NULL, NULL); | |
1449 | |
1450 return presence->statuses; | |
1451 } | |
1452 | |
1453 GaimStatus * | |
1454 gaim_presence_get_status(const GaimPresence *presence, const char *status_id) | |
1455 { | |
1456 GaimStatus *status; | |
10006 | 1457 const GList *l = NULL; |
9949 | 1458 |
1459 g_return_val_if_fail(presence != NULL, NULL); | |
1460 g_return_val_if_fail(status_id != NULL, NULL); | |
1461 | |
10006 | 1462 /* What's the purpose of this hash table? */ |
10012 | 1463 status = (GaimStatus *)g_hash_table_lookup(presence->status_table, |
10006 | 1464 status_id); |
10012 | 1465 |
10006 | 1466 if (status == NULL) { |
10012 | 1467 for (l = gaim_presence_get_statuses(presence); |
10006 | 1468 l != NULL && status == NULL; l = l->next) |
1469 { | |
1470 GaimStatus *temp_status = l->data; | |
10012 | 1471 |
10006 | 1472 if (!strcmp(status_id, gaim_status_get_id(temp_status))) |
1473 status = temp_status; | |
1474 } | |
1475 | |
1476 if (status != NULL) | |
1477 g_hash_table_insert(presence->status_table, | |
1478 g_strdup(gaim_status_get_id(status)), status); | |
10012 | 1479 } |
9949 | 1480 |
1481 return status; | |
1482 } | |
1483 | |
1484 GaimStatus * | |
1485 gaim_presence_get_active_status(const GaimPresence *presence) | |
1486 { | |
1487 g_return_val_if_fail(presence != NULL, NULL); | |
1488 | |
1489 return presence->active_status; | |
1490 } | |
1491 | |
1492 gboolean | |
1493 gaim_presence_is_available(const GaimPresence *presence) | |
1494 { | |
1495 GaimStatus *status; | |
1496 | |
1497 g_return_val_if_fail(presence != NULL, FALSE); | |
1498 | |
1499 status = gaim_presence_get_active_status(presence); | |
1500 | |
1501 return ((status != NULL && gaim_status_is_available(status)) && | |
1502 !gaim_presence_is_idle(presence)); | |
1503 } | |
1504 | |
1505 gboolean | |
1506 gaim_presence_is_online(const GaimPresence *presence) | |
1507 { | |
1508 GaimStatus *status; | |
1509 | |
1510 g_return_val_if_fail(presence != NULL, FALSE); | |
1511 | |
1512 if ((status = gaim_presence_get_active_status(presence)) == NULL) | |
1513 return FALSE; | |
1514 | |
10040
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10013
diff
changeset
|
1515 return gaim_status_is_online(status); |
9949 | 1516 } |
1517 | |
1518 gboolean | |
1519 gaim_presence_is_status_active(const GaimPresence *presence, | |
1520 const char *status_id) | |
1521 { | |
1522 GaimStatus *status; | |
1523 | |
1524 g_return_val_if_fail(presence != NULL, FALSE); | |
1525 g_return_val_if_fail(status_id != NULL, FALSE); | |
1526 | |
1527 status = gaim_presence_get_status(presence, status_id); | |
1528 | |
1529 return (status != NULL && gaim_status_is_active(status)); | |
1530 } | |
1531 | |
1532 gboolean | |
1533 gaim_presence_is_status_primitive_active(const GaimPresence *presence, | |
1534 GaimStatusPrimitive primitive) | |
1535 { | |
1536 GaimStatus *status; | |
1537 GaimStatusType *status_type; | |
1538 | |
1539 g_return_val_if_fail(presence != NULL, FALSE); | |
1540 g_return_val_if_fail(primitive != GAIM_STATUS_UNSET, FALSE); | |
1541 | |
1542 status = gaim_presence_get_active_status(presence); | |
1543 status_type = gaim_status_get_type(status); | |
1544 | |
1545 if (gaim_status_type_get_primitive(status_type) == primitive) | |
1546 return TRUE; | |
6065 | 1547 |
1548 return FALSE; | |
1549 } | |
1550 | |
9949 | 1551 gboolean |
1552 gaim_presence_is_idle(const GaimPresence *presence) | |
6065 | 1553 { |
9949 | 1554 g_return_val_if_fail(presence != NULL, FALSE); |
1555 | |
11634 | 1556 return gaim_presence_is_online(presence) && presence->idle; |
6065 | 1557 } |
1558 | |
9949 | 1559 time_t |
1560 gaim_presence_get_idle_time(const GaimPresence *presence) | |
6065 | 1561 { |
9949 | 1562 g_return_val_if_fail(presence != NULL, 0); |
6065 | 1563 |
9949 | 1564 return presence->idle_time; |
1565 } | |
6065 | 1566 |
10567 | 1567 time_t |
1568 gaim_presence_get_login_time(const GaimPresence *presence) | |
1569 { | |
1570 g_return_val_if_fail(presence != NULL, 0); | |
1571 | |
1572 return presence->login_time; | |
1573 } | |
1574 | |
9949 | 1575 gint |
1576 gaim_presence_compare(const GaimPresence *presence1, | |
1577 const GaimPresence *presence2) | |
6065 | 1578 { |
9949 | 1579 gboolean idle1, idle2; |
10860 | 1580 time_t idle_time_1, idle_time_2; |
9949 | 1581 int score1 = 0, score2 = 0; |
1582 const GList *l; | |
6065 | 1583 |
9949 | 1584 if ((presence1 == NULL && presence2 == NULL) || (presence1 == presence2)) |
1585 return 0; | |
1586 else if (presence1 == NULL) | |
10151
d83e6f2125b1
[gaim-migrate @ 11228]
Christian Hammond <chipx86@chipx86.com>
parents:
10087
diff
changeset
|
1587 return 1; |
9949 | 1588 else if (presence2 == NULL) |
10151
d83e6f2125b1
[gaim-migrate @ 11228]
Christian Hammond <chipx86@chipx86.com>
parents:
10087
diff
changeset
|
1589 return -1; |
6065 | 1590 |
9949 | 1591 /* Compute the score of the first set of statuses. */ |
1592 for (l = gaim_presence_get_statuses(presence1); l != NULL; l = l->next) | |
1593 { | |
1594 GaimStatus *status = (GaimStatus *)l->data; | |
1595 GaimStatusType *type = gaim_status_get_type(status); | |
6065 | 1596 |
9949 | 1597 if (gaim_status_is_active(status)) |
1598 score1 += primitive_scores[gaim_status_type_get_primitive(type)]; | |
6065 | 1599 } |
1600 | |
9949 | 1601 /* Compute the score of the second set of statuses. */ |
10151
d83e6f2125b1
[gaim-migrate @ 11228]
Christian Hammond <chipx86@chipx86.com>
parents:
10087
diff
changeset
|
1602 for (l = gaim_presence_get_statuses(presence2); l != NULL; l = l->next) |
9949 | 1603 { |
1604 GaimStatus *status = (GaimStatus *)l->data; | |
1605 GaimStatusType *type = gaim_status_get_type(status); | |
6065 | 1606 |
9949 | 1607 if (gaim_status_is_active(status)) |
1608 score2 += primitive_scores[gaim_status_type_get_primitive(type)]; | |
6065 | 1609 } |
1610 | |
9949 | 1611 idle1 = gaim_presence_is_idle(presence1); |
1612 idle2 = gaim_presence_is_idle(presence2); | |
6065 | 1613 |
9949 | 1614 if (idle1) |
1615 score1 += primitive_scores[SCORE_IDLE]; | |
6065 | 1616 |
9949 | 1617 if (idle2) |
1618 score2 += primitive_scores[SCORE_IDLE]; | |
6065 | 1619 |
10860 | 1620 idle_time_1 = time(NULL) - gaim_presence_get_idle_time(presence1); |
1621 idle_time_2 = time(NULL) - gaim_presence_get_idle_time(presence2); | |
6065 | 1622 |
9949 | 1623 if (idle_time_1 > idle_time_2) |
1624 score1 += primitive_scores[SCORE_IDLE_TIME]; | |
1625 else if (idle_time_1 < idle_time_2) | |
1626 score2 += primitive_scores[SCORE_IDLE_TIME]; | |
6065 | 1627 |
9949 | 1628 if (score1 < score2) |
1629 return 1; | |
1630 else if (score1 > score2) | |
1631 return -1; | |
1632 | |
1633 return 0; | |
1634 } | |
1635 | |
6065 | 1636 |
9949 | 1637 /************************************************************************** |
1638 * Status subsystem | |
1639 **************************************************************************/ | |
1640 static void | |
1641 score_pref_changed_cb(const char *name, GaimPrefType type, gpointer value, | |
1642 gpointer data) | |
1643 { | |
1644 int index = GPOINTER_TO_INT(data); | |
6065 | 1645 |
9949 | 1646 primitive_scores[index] = GPOINTER_TO_INT(value); |
6065 | 1647 } |
1648 | |
10519 | 1649 static guint |
10006 | 1650 gaim_buddy_presences_hash(gconstpointer key) |
1651 { | |
10012 | 1652 const GaimStatusBuddyKey *me = key; |
1653 guint ret; | |
1654 char *str; | |
1655 | |
1656 str = g_strdup_printf("%p%s", me->account, me->name); | |
1657 ret = g_str_hash(str); | |
1658 g_free(str); | |
1659 | |
1660 return ret; | |
10006 | 1661 } |
1662 | |
10519 | 1663 static gboolean |
10006 | 1664 gaim_buddy_presences_equal(gconstpointer a, gconstpointer b) |
1665 { | |
1666 GaimStatusBuddyKey *key_a = (GaimStatusBuddyKey *)a; | |
1667 GaimStatusBuddyKey *key_b = (GaimStatusBuddyKey *)b; | |
1668 | |
10012 | 1669 if(key_a->account == key_b->account && |
1670 !strcmp(key_a->name, key_b->name)) | |
10006 | 1671 return TRUE; |
1672 else | |
1673 return FALSE; | |
1674 } | |
1675 | |
10519 | 1676 static void |
1677 gaim_buddy_presences_key_free(gpointer a) | |
1678 { | |
1679 GaimStatusBuddyKey *key = (GaimStatusBuddyKey *)a; | |
1680 g_free(key->name); | |
1681 g_free(key); | |
1682 } | |
1683 | |
10087 | 1684 void * |
10418 | 1685 gaim_status_get_handle(void) { |
10087 | 1686 static int handle; |
1687 | |
1688 return &handle; | |
1689 } | |
1690 | |
9949 | 1691 void |
10418 | 1692 gaim_status_init(void) |
6065 | 1693 { |
10418 | 1694 void *handle = gaim_status_get_handle; |
10087 | 1695 |
9949 | 1696 gaim_prefs_add_none("/core/status"); |
1697 gaim_prefs_add_none("/core/status/scores"); | |
6065 | 1698 |
11654 | 1699 gaim_prefs_add_string("/core/status/current", _("Default")); |
1700 gaim_prefs_add_string("/core/status/idleaway", _("Default auto-away")); | |
1701 | |
9949 | 1702 gaim_prefs_add_int("/core/status/scores/offline", |
1703 primitive_scores[GAIM_STATUS_OFFLINE]); | |
1704 gaim_prefs_add_int("/core/status/scores/available", | |
1705 primitive_scores[GAIM_STATUS_AVAILABLE]); | |
1706 gaim_prefs_add_int("/core/status/scores/hidden", | |
1707 primitive_scores[GAIM_STATUS_HIDDEN]); | |
1708 gaim_prefs_add_int("/core/status/scores/away", | |
1709 primitive_scores[GAIM_STATUS_AWAY]); | |
1710 gaim_prefs_add_int("/core/status/scores/extended_away", | |
1711 primitive_scores[GAIM_STATUS_EXTENDED_AWAY]); | |
1712 gaim_prefs_add_int("/core/status/scores/idle", | |
1713 primitive_scores[SCORE_IDLE]); | |
6065 | 1714 |
10087 | 1715 gaim_prefs_connect_callback(handle, "/core/status/scores/offline", |
9949 | 1716 score_pref_changed_cb, |
1717 GINT_TO_POINTER(GAIM_STATUS_OFFLINE)); | |
10087 | 1718 gaim_prefs_connect_callback(handle, "/core/status/scores/available", |
9949 | 1719 score_pref_changed_cb, |
1720 GINT_TO_POINTER(GAIM_STATUS_AVAILABLE)); | |
10087 | 1721 gaim_prefs_connect_callback(handle, "/core/status/scores/hidden", |
9949 | 1722 score_pref_changed_cb, |
1723 GINT_TO_POINTER(GAIM_STATUS_HIDDEN)); | |
10087 | 1724 gaim_prefs_connect_callback(handle, "/core/status/scores/away", |
9949 | 1725 score_pref_changed_cb, |
1726 GINT_TO_POINTER(GAIM_STATUS_AWAY)); | |
10087 | 1727 gaim_prefs_connect_callback(handle, "/core/status/scores/extended_away", |
9949 | 1728 score_pref_changed_cb, |
1729 GINT_TO_POINTER(GAIM_STATUS_EXTENDED_AWAY)); | |
10087 | 1730 gaim_prefs_connect_callback(handle, "/core/status/scores/idle", |
9949 | 1731 score_pref_changed_cb, |
1732 GINT_TO_POINTER(SCORE_IDLE)); | |
10006 | 1733 |
10519 | 1734 buddy_presences = g_hash_table_new_full(gaim_buddy_presences_hash, |
1735 gaim_buddy_presences_equal, | |
1736 gaim_buddy_presences_key_free, NULL); | |
9949 | 1737 } |
6065 | 1738 |
9949 | 1739 void |
10418 | 1740 gaim_status_uninit(void) |
9949 | 1741 { |
10176
0109f3a518d2
[gaim-migrate @ 11291]
Christian Hammond <chipx86@chipx86.com>
parents:
10153
diff
changeset
|
1742 if (buddy_presences != NULL) |
0109f3a518d2
[gaim-migrate @ 11291]
Christian Hammond <chipx86@chipx86.com>
parents:
10153
diff
changeset
|
1743 { |
10077 | 1744 g_hash_table_destroy(buddy_presences); |
10176
0109f3a518d2
[gaim-migrate @ 11291]
Christian Hammond <chipx86@chipx86.com>
parents:
10153
diff
changeset
|
1745 |
0109f3a518d2
[gaim-migrate @ 11291]
Christian Hammond <chipx86@chipx86.com>
parents:
10153
diff
changeset
|
1746 buddy_presences = NULL; |
0109f3a518d2
[gaim-migrate @ 11291]
Christian Hammond <chipx86@chipx86.com>
parents:
10153
diff
changeset
|
1747 } |
9949 | 1748 } |