annotate src/status.c @ 13961:b0e37dcb3987

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