Mercurial > pidgin
annotate src/pounce.c @ 13951:614c56622453
[gaim-migrate @ 16496]
Rename gaim_buffer.c and .h to circbuffer.c and .h
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 16 Jul 2006 19:08:31 +0000 |
parents | a9ff4499d9ce |
children | 8bda65b88e49 |
rev | line source |
---|---|
5032
cb700c07ee07
[gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1 /** |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
2 * @file pounce.c Buddy Pounce API |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
3 * @ingroup core |
5032
cb700c07ee07
[gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
4 * |
4687 | 5 * gaim |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
10 * |
4687 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5866
diff
changeset
|
25 #include "internal.h" |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
26 #include "conversation.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5866
diff
changeset
|
27 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5866
diff
changeset
|
28 #include "pounce.h" |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
29 |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
30 #include "debug.h" |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
31 #include "pounce.h" |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
32 #include "util.h" |
4687 | 33 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
34 typedef struct |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
35 { |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
36 GString *buffer; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
37 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
38 GaimPounce *pounce; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
39 GaimPounceEvent events; |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
40 GaimPounceOption options; |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
41 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
42 char *ui_name; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
43 char *pouncee; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
44 char *protocol_id; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
45 char *event_type; |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
46 char *option_type; |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
47 char *action_name; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
48 char *param_name; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
49 char *account_name; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
50 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
51 } PounceParserData; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
52 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
53 typedef struct |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
54 { |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
55 char *name; |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
56 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
57 gboolean enabled; |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
58 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
59 GHashTable *atts; |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
60 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
61 } GaimPounceActionData; |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
62 |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
63 typedef struct |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
64 { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
65 char *ui; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
66 GaimPounceCb cb; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
67 void (*new_pounce)(GaimPounce *); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
68 void (*free_pounce)(GaimPounce *); |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
69 |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
70 } GaimPounceHandler; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
71 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
72 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
73 static GHashTable *pounce_handlers = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
74 static GList *pounces = NULL; |
10432 | 75 static guint save_timer = 0; |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
76 static gboolean pounces_loaded = FALSE; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
77 |
4687 | 78 |
10432 | 79 /********************************************************************* |
80 * Private utility functions * | |
81 *********************************************************************/ | |
82 | |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
83 static GaimPounceActionData * |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
84 find_action_data(const GaimPounce *pounce, const char *name) |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
85 { |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
86 GaimPounceActionData *action; |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
87 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
88 g_return_val_if_fail(pounce != NULL, NULL); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
89 g_return_val_if_fail(name != NULL, NULL); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
90 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
91 action = g_hash_table_lookup(pounce->actions, name); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
92 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
93 return action; |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
94 } |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
95 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
96 static void |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
97 free_action_data(gpointer data) |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
98 { |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
99 GaimPounceActionData *action_data = data; |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
100 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
101 g_free(action_data->name); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
102 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
103 g_hash_table_destroy(action_data->atts); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
104 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
105 g_free(action_data); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
106 } |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
107 |
10432 | 108 |
109 /********************************************************************* | |
110 * Writing to disk * | |
111 *********************************************************************/ | |
112 | |
113 static void | |
114 action_parameter_to_xmlnode(gpointer key, gpointer value, gpointer user_data) | |
115 { | |
116 const char *name, *param_value; | |
117 xmlnode *node, *child; | |
118 | |
119 name = (const char *)key; | |
120 param_value = (const char *)value; | |
121 node = (xmlnode *)user_data; | |
122 | |
123 child = xmlnode_new_child(node, "param"); | |
124 xmlnode_set_attrib(child, "name", name); | |
125 xmlnode_insert_data(child, param_value, -1); | |
126 } | |
127 | |
128 static void | |
129 action_parameter_list_to_xmlnode(gpointer key, gpointer value, gpointer user_data) | |
130 { | |
131 const char *action; | |
132 GaimPounceActionData *action_data; | |
133 xmlnode *node, *child; | |
134 | |
135 action = (const char *)key; | |
136 action_data = (GaimPounceActionData *)value; | |
137 node = (xmlnode *)user_data; | |
138 | |
139 if (!action_data->enabled) | |
140 return; | |
141 | |
142 child = xmlnode_new_child(node, "action"); | |
143 xmlnode_set_attrib(child, "type", action); | |
144 | |
145 g_hash_table_foreach(action_data->atts, action_parameter_to_xmlnode, child); | |
146 } | |
147 | |
148 static void | |
149 add_event_to_xmlnode(xmlnode *node, const char *type) | |
150 { | |
151 xmlnode *child; | |
152 | |
153 child = xmlnode_new_child(node, "event"); | |
154 xmlnode_set_attrib(child, "type", type); | |
155 } | |
156 | |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
157 static void |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
158 add_option_to_xmlnode(xmlnode *node, const char *type) |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
159 { |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
160 xmlnode *child; |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
161 |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
162 child = xmlnode_new_child(node, "option"); |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
163 xmlnode_set_attrib(child, "type", type); |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
164 } |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
165 |
10432 | 166 static xmlnode * |
167 pounce_to_xmlnode(GaimPounce *pounce) | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
168 { |
10432 | 169 xmlnode *node, *child; |
170 GaimAccount *pouncer; | |
171 GaimPounceEvent events; | |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
172 GaimPounceOption options; |
10432 | 173 |
174 pouncer = gaim_pounce_get_pouncer(pounce); | |
175 events = gaim_pounce_get_events(pounce); | |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
176 options = gaim_pounce_get_options(pounce); |
10432 | 177 |
178 node = xmlnode_new("pounce"); | |
179 xmlnode_set_attrib(node, "ui", pounce->ui_type); | |
180 | |
181 child = xmlnode_new_child(node, "account"); | |
182 xmlnode_set_attrib(child, "protocol", pouncer->protocol_id); | |
183 xmlnode_insert_data(child, gaim_account_get_username(pouncer), -1); | |
184 | |
185 child = xmlnode_new_child(node, "pouncee"); | |
186 xmlnode_insert_data(child, gaim_pounce_get_pouncee(pounce), -1); | |
187 | |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
188 /* Write pounce options */ |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
189 child = xmlnode_new_child(node, "options"); |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
190 if (options & GAIM_POUNCE_OPTION_AWAY) |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
191 add_option_to_xmlnode(child, "on-away"); |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
192 |
10432 | 193 /* Write pounce events */ |
194 child = xmlnode_new_child(node, "events"); | |
195 if (events & GAIM_POUNCE_SIGNON) | |
196 add_event_to_xmlnode(child, "sign-on"); | |
197 if (events & GAIM_POUNCE_SIGNOFF) | |
198 add_event_to_xmlnode(child, "sign-off"); | |
199 if (events & GAIM_POUNCE_AWAY) | |
200 add_event_to_xmlnode(child, "away"); | |
201 if (events & GAIM_POUNCE_AWAY_RETURN) | |
202 add_event_to_xmlnode(child, "return-from-away"); | |
203 if (events & GAIM_POUNCE_IDLE) | |
204 add_event_to_xmlnode(child, "idle"); | |
205 if (events & GAIM_POUNCE_IDLE_RETURN) | |
206 add_event_to_xmlnode(child, "return-from-idle"); | |
207 if (events & GAIM_POUNCE_TYPING) | |
208 add_event_to_xmlnode(child, "start-typing"); | |
13842 | 209 if (events & GAIM_POUNCE_TYPED) |
210 add_event_to_xmlnode(child, "typed"); | |
10432 | 211 if (events & GAIM_POUNCE_TYPING_STOPPED) |
212 add_event_to_xmlnode(child, "stop-typing"); | |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
213 if (events & GAIM_POUNCE_MESSAGE_RECEIVED) |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
214 add_event_to_xmlnode(child, "message-received"); |
10432 | 215 |
216 /* Write pounce actions */ | |
217 child = xmlnode_new_child(node, "actions"); | |
218 g_hash_table_foreach(pounce->actions, action_parameter_list_to_xmlnode, child); | |
219 | |
220 if (gaim_pounce_get_save(pounce)) | |
221 child = xmlnode_new_child(node, "save"); | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
222 |
10432 | 223 return node; |
224 } | |
225 | |
226 static xmlnode * | |
227 pounces_to_xmlnode(void) | |
228 { | |
229 xmlnode *node, *child; | |
230 GList *cur; | |
231 | |
232 node = xmlnode_new("pounces"); | |
233 xmlnode_set_attrib(node, "version", "1.0"); | |
234 | |
235 for (cur = gaim_pounces_get_all(); cur != NULL; cur = cur->next) | |
236 { | |
237 child = pounce_to_xmlnode(cur->data); | |
238 xmlnode_insert_child(node, child); | |
239 } | |
240 | |
241 return node; | |
242 } | |
243 | |
244 static void | |
245 sync_pounces(void) | |
246 { | |
247 xmlnode *node; | |
248 char *data; | |
249 | |
250 if (!pounces_loaded) | |
251 { | |
252 gaim_debug_error("pounce", "Attempted to save buddy pounces before " | |
253 "they were read!\n"); | |
254 return; | |
255 } | |
256 | |
257 node = pounces_to_xmlnode(); | |
258 data = xmlnode_to_formatted_str(node, NULL); | |
259 gaim_util_write_data_to_file("pounces.xml", data, -1); | |
260 g_free(data); | |
261 xmlnode_free(node); | |
262 } | |
263 | |
264 static gboolean | |
265 save_cb(gpointer data) | |
266 { | |
267 sync_pounces(); | |
268 save_timer = 0; | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
269 return FALSE; |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
270 } |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
271 |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
272 static void |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
273 schedule_pounces_save(void) |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
274 { |
10432 | 275 if (save_timer == 0) |
276 save_timer = gaim_timeout_add(5000, save_cb, NULL); | |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
277 } |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
278 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
279 |
10432 | 280 /********************************************************************* |
281 * Reading from disk * | |
282 *********************************************************************/ | |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
283 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
284 static void |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
285 free_parser_data(gpointer user_data) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
286 { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
287 PounceParserData *data = user_data; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
288 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
289 if (data->buffer != NULL) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
290 g_string_free(data->buffer, TRUE); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
291 |
13228
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
292 g_free(data->ui_name); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
293 g_free(data->pouncee); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
294 g_free(data->protocol_id); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
295 g_free(data->event_type); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
296 g_free(data->option_type); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
297 g_free(data->action_name); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
298 g_free(data->param_name); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
299 g_free(data->account_name); |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
300 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
301 g_free(data); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
302 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
303 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
304 static void |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
305 start_element_handler(GMarkupParseContext *context, |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
306 const gchar *element_name, |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
307 const gchar **attribute_names, |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
308 const gchar **attribute_values, |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
309 gpointer user_data, GError **error) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
310 { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
311 PounceParserData *data = user_data; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
312 GHashTable *atts; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
313 int i; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
314 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
315 atts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
316 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
317 for (i = 0; attribute_names[i] != NULL; i++) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
318 g_hash_table_insert(atts, g_strdup(attribute_names[i]), |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
319 g_strdup(attribute_values[i])); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
320 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
321 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
322 if (data->buffer != NULL) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
323 g_string_free(data->buffer, TRUE); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
324 data->buffer = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
325 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
326 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
327 if (!strcmp(element_name, "pounce")) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
328 const char *ui = g_hash_table_lookup(atts, "ui"); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
329 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
330 if (ui == NULL) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
331 gaim_debug(GAIM_DEBUG_ERROR, "pounce", |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
332 "Unset 'ui' parameter for pounce!\n"); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
333 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
334 else |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
335 data->ui_name = g_strdup(ui); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
336 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
337 data->events = 0; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
338 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
339 else if (!strcmp(element_name, "account")) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
340 const char *protocol_id = g_hash_table_lookup(atts, "protocol"); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
341 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
342 if (protocol_id == NULL) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
343 gaim_debug(GAIM_DEBUG_ERROR, "pounce", |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
344 "Unset 'protocol' parameter for account!\n"); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
345 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
346 else |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
347 data->protocol_id = g_strdup(protocol_id); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
348 } |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
349 else if (!strcmp(element_name, "option")) { |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
350 const char *type = g_hash_table_lookup(atts, "type"); |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
351 |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
352 if (type == NULL) { |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
353 gaim_debug(GAIM_DEBUG_ERROR, "pounce", |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
354 "Unset 'type' parameter for option!\n"); |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
355 } |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
356 else |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
357 data->option_type = g_strdup(type); |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
358 } |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
359 else if (!strcmp(element_name, "event")) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
360 const char *type = g_hash_table_lookup(atts, "type"); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
361 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
362 if (type == NULL) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
363 gaim_debug(GAIM_DEBUG_ERROR, "pounce", |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
364 "Unset 'type' parameter for event!\n"); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
365 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
366 else |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
367 data->event_type = g_strdup(type); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
368 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
369 else if (!strcmp(element_name, "action")) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
370 const char *type = g_hash_table_lookup(atts, "type"); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
371 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
372 if (type == NULL) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
373 gaim_debug(GAIM_DEBUG_ERROR, "pounce", |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
374 "Unset 'type' parameter for action!\n"); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
375 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
376 else |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
377 data->action_name = g_strdup(type); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
378 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
379 else if (!strcmp(element_name, "param")) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
380 const char *param_name = g_hash_table_lookup(atts, "name"); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
381 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
382 if (param_name == NULL) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
383 gaim_debug(GAIM_DEBUG_ERROR, "pounce", |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
384 "Unset 'name' parameter for param!\n"); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
385 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
386 else |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
387 data->param_name = g_strdup(param_name); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
388 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
389 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
390 g_hash_table_destroy(atts); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
391 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
392 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
393 static void |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
394 end_element_handler(GMarkupParseContext *context, const gchar *element_name, |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
395 gpointer user_data, GError **error) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
396 { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
397 PounceParserData *data = user_data; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
398 gchar *buffer = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
399 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
400 if (data->buffer != NULL) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
401 buffer = g_string_free(data->buffer, FALSE); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
402 data->buffer = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
403 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
404 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
405 if (!strcmp(element_name, "account")) { |
9598 | 406 g_free(data->account_name); |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
407 data->account_name = g_strdup(buffer); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
408 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
409 else if (!strcmp(element_name, "pouncee")) { |
9598 | 410 g_free(data->pouncee); |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
411 data->pouncee = g_strdup(buffer); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
412 } |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
413 else if (!strcmp(element_name, "option")) { |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
414 if (!strcmp(data->option_type, "on-away")) |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
415 data->options |= GAIM_POUNCE_OPTION_AWAY; |
13842 | 416 |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
417 g_free(data->option_type); |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
418 data->option_type = NULL; |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
419 } |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
420 else if (!strcmp(element_name, "event")) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
421 if (!strcmp(data->event_type, "sign-on")) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
422 data->events |= GAIM_POUNCE_SIGNON; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
423 else if (!strcmp(data->event_type, "sign-off")) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
424 data->events |= GAIM_POUNCE_SIGNOFF; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
425 else if (!strcmp(data->event_type, "away")) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
426 data->events |= GAIM_POUNCE_AWAY; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
427 else if (!strcmp(data->event_type, "return-from-away")) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
428 data->events |= GAIM_POUNCE_AWAY_RETURN; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
429 else if (!strcmp(data->event_type, "idle")) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
430 data->events |= GAIM_POUNCE_IDLE; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
431 else if (!strcmp(data->event_type, "return-from-idle")) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
432 data->events |= GAIM_POUNCE_IDLE_RETURN; |
6444
601c2a52d74a
[gaim-migrate @ 6953]
Christian Hammond <chipx86@chipx86.com>
parents:
6271
diff
changeset
|
433 else if (!strcmp(data->event_type, "start-typing")) |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
434 data->events |= GAIM_POUNCE_TYPING; |
13842 | 435 else if (!strcmp(data->event_type, "typed")) |
436 data->events |= GAIM_POUNCE_TYPED; | |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
437 else if (!strcmp(data->event_type, "stop-typing")) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
438 data->events |= GAIM_POUNCE_TYPING_STOPPED; |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
439 else if (!strcmp(data->event_type, "message-received")) |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
440 data->events |= GAIM_POUNCE_MESSAGE_RECEIVED; |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
441 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
442 g_free(data->event_type); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
443 data->event_type = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
444 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
445 else if (!strcmp(element_name, "action")) { |
9598 | 446 if (data->pounce != NULL) { |
447 gaim_pounce_action_register(data->pounce, data->action_name); | |
448 gaim_pounce_action_set_enabled(data->pounce, data->action_name, TRUE); | |
449 } | |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
450 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
451 g_free(data->action_name); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
452 data->action_name = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
453 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
454 else if (!strcmp(element_name, "param")) { |
9598 | 455 if (data->pounce != NULL) { |
456 gaim_pounce_action_set_attribute(data->pounce, data->action_name, | |
457 data->param_name, buffer); | |
458 } | |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
459 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
460 g_free(data->param_name); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
461 data->param_name = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
462 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
463 else if (!strcmp(element_name, "events")) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
464 GaimAccount *account; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
465 |
7132 | 466 account = gaim_accounts_find(data->account_name, data->protocol_id); |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
467 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
468 g_free(data->account_name); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
469 g_free(data->protocol_id); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
470 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
471 data->account_name = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
472 data->protocol_id = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
473 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
474 if (account == NULL) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
475 gaim_debug(GAIM_DEBUG_ERROR, "pounce", |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
476 "Account for pounce not found!\n"); |
12002 | 477 /* |
478 * This pounce has effectively been removed, so make | |
479 * sure that we save the changes to pounces.xml | |
480 */ | |
481 schedule_pounces_save(); | |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
482 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
483 else { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
484 gaim_debug(GAIM_DEBUG_INFO, "pounce", |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
485 "Creating pounce: %s, %s\n", data->ui_name, |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
486 data->pouncee); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
487 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
488 data->pounce = gaim_pounce_new(data->ui_name, account, |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
489 data->pouncee, data->events, |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
490 data->options); |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
491 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
492 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
493 g_free(data->pouncee); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
494 data->pouncee = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
495 } |
5878
9e54bb2ee3b5
[gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents:
5875
diff
changeset
|
496 else if (!strcmp(element_name, "save")) { |
12002 | 497 if (data->pounce != NULL) |
498 gaim_pounce_set_save(data->pounce, TRUE); | |
5878
9e54bb2ee3b5
[gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents:
5875
diff
changeset
|
499 } |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
500 else if (!strcmp(element_name, "pounce")) { |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
501 data->pounce = NULL; |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
502 data->events = 0; |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
503 data->options = 0; |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
504 |
13228
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
505 g_free(data->ui_name); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
506 g_free(data->pouncee); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
507 g_free(data->protocol_id); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
508 g_free(data->event_type); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
509 g_free(data->option_type); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
510 g_free(data->action_name); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
511 g_free(data->param_name); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
512 g_free(data->account_name); |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
513 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
514 data->ui_name = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
515 data->pounce = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
516 data->protocol_id = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
517 data->event_type = NULL; |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
518 data->option_type = NULL; |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
519 data->action_name = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
520 data->param_name = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
521 data->account_name = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
522 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
523 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
524 if (buffer != NULL) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
525 g_free(buffer); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
526 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
527 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
528 static void |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
529 text_handler(GMarkupParseContext *context, const gchar *text, |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
530 gsize text_len, gpointer user_data, GError **error) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
531 { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
532 PounceParserData *data = user_data; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
533 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
534 if (data->buffer == NULL) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
535 data->buffer = g_string_new_len(text, text_len); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
536 else |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
537 g_string_append_len(data->buffer, text, text_len); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
538 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
539 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
540 static GMarkupParser pounces_parser = |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
541 { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
542 start_element_handler, |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
543 end_element_handler, |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
544 text_handler, |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
545 NULL, |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
546 NULL |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
547 }; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
548 |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
549 gboolean |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
550 gaim_pounces_load(void) |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
551 { |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
552 gchar *filename = g_build_filename(gaim_user_dir(), "pounces.xml", NULL); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
553 gchar *contents = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
554 gsize length; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
555 GMarkupParseContext *context; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
556 GError *error = NULL; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
557 PounceParserData *parser_data; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
558 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
559 if (filename == NULL) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
560 pounces_loaded = TRUE; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
561 return FALSE; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
562 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
563 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
564 if (!g_file_get_contents(filename, &contents, &length, &error)) { |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10432
diff
changeset
|
565 gaim_debug(GAIM_DEBUG_ERROR, "pounce", |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
566 "Error reading pounces: %s\n", error->message); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
567 |
5940 | 568 g_free(filename); |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
569 g_error_free(error); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
570 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
571 pounces_loaded = TRUE; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
572 return FALSE; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
573 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
574 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
575 parser_data = g_new0(PounceParserData, 1); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
576 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
577 context = g_markup_parse_context_new(&pounces_parser, 0, |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
578 parser_data, free_parser_data); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
579 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
580 if (!g_markup_parse_context_parse(context, contents, length, NULL)) { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
581 g_markup_parse_context_free(context); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
582 g_free(contents); |
5940 | 583 g_free(filename); |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
584 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
585 pounces_loaded = TRUE; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
586 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
587 return FALSE; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
588 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
589 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
590 if (!g_markup_parse_context_end_parse(context, NULL)) { |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10432
diff
changeset
|
591 gaim_debug(GAIM_DEBUG_ERROR, "pounce", "Error parsing %s\n", |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
592 filename); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
593 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
594 g_markup_parse_context_free(context); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
595 g_free(contents); |
5940 | 596 g_free(filename); |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
597 pounces_loaded = TRUE; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
598 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
599 return FALSE; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
600 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
601 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
602 g_markup_parse_context_free(context); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
603 g_free(contents); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
604 g_free(filename); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
605 |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
606 pounces_loaded = TRUE; |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
607 |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
608 return TRUE; |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
609 } |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
610 |
10432 | 611 |
612 GaimPounce * | |
613 gaim_pounce_new(const char *ui_type, GaimAccount *pouncer, | |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
614 const char *pouncee, GaimPounceEvent event, |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
615 GaimPounceOption option) |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
616 { |
10432 | 617 GaimPounce *pounce; |
618 GaimPounceHandler *handler; | |
619 | |
620 g_return_val_if_fail(ui_type != NULL, NULL); | |
621 g_return_val_if_fail(pouncer != NULL, NULL); | |
622 g_return_val_if_fail(pouncee != NULL, NULL); | |
623 g_return_val_if_fail(event != 0, NULL); | |
624 | |
625 pounce = g_new0(GaimPounce, 1); | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
626 |
10432 | 627 pounce->ui_type = g_strdup(ui_type); |
628 pounce->pouncer = pouncer; | |
629 pounce->pouncee = g_strdup(pouncee); | |
630 pounce->events = event; | |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
631 pounce->options = option; |
10432 | 632 |
633 pounce->actions = g_hash_table_new_full(g_str_hash, g_str_equal, | |
634 g_free, free_action_data); | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
635 |
10432 | 636 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type); |
637 | |
638 if (handler != NULL && handler->new_pounce != NULL) | |
639 handler->new_pounce(pounce); | |
640 | |
641 pounces = g_list_append(pounces, pounce); | |
642 | |
643 schedule_pounces_save(); | |
644 | |
645 return pounce; | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
646 } |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
647 |
10432 | 648 void |
649 gaim_pounce_destroy(GaimPounce *pounce) | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
650 { |
10432 | 651 GaimPounceHandler *handler; |
652 | |
653 g_return_if_fail(pounce != NULL); | |
654 | |
655 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type); | |
656 | |
657 pounces = g_list_remove(pounces, pounce); | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
658 |
13228
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
659 g_free(pounce->ui_type); |
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
660 g_free(pounce->pouncee); |
10432 | 661 |
662 g_hash_table_destroy(pounce->actions); | |
663 | |
664 if (handler != NULL && handler->free_pounce != NULL) | |
665 handler->free_pounce(pounce); | |
666 | |
667 g_free(pounce); | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
668 |
10432 | 669 schedule_pounces_save(); |
670 } | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
671 |
10432 | 672 void |
673 gaim_pounce_destroy_all_by_account(GaimAccount *account) | |
674 { | |
675 GaimAccount *pouncer; | |
676 GaimPounce *pounce; | |
677 GList *l, *l_next; | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
678 |
10432 | 679 g_return_if_fail(account != NULL); |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
680 |
10432 | 681 for (l = gaim_pounces_get_all(); l != NULL; l = l_next) |
682 { | |
683 pounce = (GaimPounce *)l->data; | |
684 l_next = l->next; | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
685 |
10432 | 686 pouncer = gaim_pounce_get_pouncer(pounce); |
687 if (pouncer == account) | |
688 gaim_pounce_destroy(pounce); | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
689 } |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
690 } |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
691 |
10432 | 692 void |
693 gaim_pounce_set_events(GaimPounce *pounce, GaimPounceEvent events) | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
694 { |
10432 | 695 g_return_if_fail(pounce != NULL); |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
696 g_return_if_fail(events != GAIM_POUNCE_NONE); |
10432 | 697 |
698 pounce->events = events; | |
699 | |
700 schedule_pounces_save(); | |
701 } | |
702 | |
703 void | |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
704 gaim_pounce_set_options(GaimPounce *pounce, GaimPounceOption options) |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
705 { |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
706 g_return_if_fail(pounce != NULL); |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
707 |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
708 pounce->options = options; |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
709 |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
710 schedule_pounces_save(); |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
711 } |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
712 |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
713 void |
10432 | 714 gaim_pounce_set_pouncer(GaimPounce *pounce, GaimAccount *pouncer) |
715 { | |
716 g_return_if_fail(pounce != NULL); | |
717 g_return_if_fail(pouncer != NULL); | |
718 | |
719 pounce->pouncer = pouncer; | |
720 | |
721 schedule_pounces_save(); | |
722 } | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
723 |
10432 | 724 void |
725 gaim_pounce_set_pouncee(GaimPounce *pounce, const char *pouncee) | |
726 { | |
727 g_return_if_fail(pounce != NULL); | |
728 g_return_if_fail(pouncee != NULL); | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
729 |
13228
dd1996c9f3b6
[gaim-migrate @ 15593]
Richard Laager <rlaager@wiktel.com>
parents:
12694
diff
changeset
|
730 g_free(pounce->pouncee); |
10432 | 731 |
732 pounce->pouncee = (pouncee == NULL ? NULL : g_strdup(pouncee)); | |
733 | |
734 schedule_pounces_save(); | |
735 } | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
736 |
10432 | 737 void |
738 gaim_pounce_set_save(GaimPounce *pounce, gboolean save) | |
739 { | |
740 g_return_if_fail(pounce != NULL); | |
741 | |
742 pounce->save = save; | |
743 | |
744 schedule_pounces_save(); | |
745 } | |
746 | |
747 void | |
748 gaim_pounce_action_register(GaimPounce *pounce, const char *name) | |
749 { | |
750 GaimPounceActionData *action_data; | |
751 | |
752 g_return_if_fail(pounce != NULL); | |
753 g_return_if_fail(name != NULL); | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
754 |
10432 | 755 if (g_hash_table_lookup(pounce->actions, name) != NULL) |
756 return; | |
757 | |
758 action_data = g_new0(GaimPounceActionData, 1); | |
759 | |
760 action_data->name = g_strdup(name); | |
761 action_data->enabled = FALSE; | |
762 action_data->atts = g_hash_table_new_full(g_str_hash, g_str_equal, | |
763 g_free, g_free); | |
764 | |
765 g_hash_table_insert(pounce->actions, g_strdup(name), action_data); | |
766 | |
767 schedule_pounces_save(); | |
768 } | |
769 | |
770 void | |
771 gaim_pounce_action_set_enabled(GaimPounce *pounce, const char *action, | |
772 gboolean enabled) | |
773 { | |
774 GaimPounceActionData *action_data; | |
775 | |
776 g_return_if_fail(pounce != NULL); | |
777 g_return_if_fail(action != NULL); | |
778 | |
779 action_data = find_action_data(pounce, action); | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
780 |
10432 | 781 g_return_if_fail(action_data != NULL); |
782 | |
783 action_data->enabled = enabled; | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
784 |
10432 | 785 schedule_pounces_save(); |
786 } | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
787 |
10432 | 788 void |
789 gaim_pounce_action_set_attribute(GaimPounce *pounce, const char *action, | |
790 const char *attr, const char *value) | |
791 { | |
792 GaimPounceActionData *action_data; | |
5878
9e54bb2ee3b5
[gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents:
5875
diff
changeset
|
793 |
10432 | 794 g_return_if_fail(pounce != NULL); |
795 g_return_if_fail(action != NULL); | |
796 g_return_if_fail(attr != NULL); | |
797 | |
798 action_data = find_action_data(pounce, action); | |
799 | |
800 g_return_if_fail(action_data != NULL); | |
5878
9e54bb2ee3b5
[gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents:
5875
diff
changeset
|
801 |
10432 | 802 if (value == NULL) |
803 g_hash_table_remove(action_data->atts, attr); | |
804 else | |
805 g_hash_table_insert(action_data->atts, g_strdup(attr), | |
806 g_strdup(value)); | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
807 |
10432 | 808 schedule_pounces_save(); |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
809 } |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
810 |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
811 void |
10432 | 812 gaim_pounce_set_data(GaimPounce *pounce, void *data) |
813 { | |
814 g_return_if_fail(pounce != NULL); | |
815 | |
816 pounce->data = data; | |
817 | |
818 schedule_pounces_save(); | |
819 } | |
820 | |
821 GaimPounceEvent | |
822 gaim_pounce_get_events(const GaimPounce *pounce) | |
823 { | |
824 g_return_val_if_fail(pounce != NULL, GAIM_POUNCE_NONE); | |
825 | |
826 return pounce->events; | |
827 } | |
828 | |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
829 GaimPounceOption |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
830 gaim_pounce_get_options(const GaimPounce *pounce) |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
831 { |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
832 g_return_val_if_fail(pounce != NULL, GAIM_POUNCE_OPTION_NONE); |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
833 |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
834 return pounce->options; |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
835 } |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
836 |
10432 | 837 GaimAccount * |
838 gaim_pounce_get_pouncer(const GaimPounce *pounce) | |
839 { | |
840 g_return_val_if_fail(pounce != NULL, NULL); | |
841 | |
842 return pounce->pouncer; | |
843 } | |
844 | |
845 const char * | |
846 gaim_pounce_get_pouncee(const GaimPounce *pounce) | |
847 { | |
848 g_return_val_if_fail(pounce != NULL, NULL); | |
849 | |
850 return pounce->pouncee; | |
851 } | |
852 | |
853 gboolean | |
854 gaim_pounce_get_save(const GaimPounce *pounce) | |
855 { | |
856 g_return_val_if_fail(pounce != NULL, FALSE); | |
857 | |
858 return pounce->save; | |
859 } | |
860 | |
861 gboolean | |
862 gaim_pounce_action_is_enabled(const GaimPounce *pounce, const char *action) | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
863 { |
10432 | 864 GaimPounceActionData *action_data; |
865 | |
866 g_return_val_if_fail(pounce != NULL, FALSE); | |
867 g_return_val_if_fail(action != NULL, FALSE); | |
868 | |
869 action_data = find_action_data(pounce, action); | |
870 | |
871 g_return_val_if_fail(action_data != NULL, FALSE); | |
872 | |
873 return action_data->enabled; | |
874 } | |
875 | |
876 const char * | |
877 gaim_pounce_action_get_attribute(const GaimPounce *pounce, | |
878 const char *action, const char *attr) | |
879 { | |
880 GaimPounceActionData *action_data; | |
881 | |
882 g_return_val_if_fail(pounce != NULL, NULL); | |
883 g_return_val_if_fail(action != NULL, NULL); | |
884 g_return_val_if_fail(attr != NULL, NULL); | |
885 | |
886 action_data = find_action_data(pounce, action); | |
887 | |
888 g_return_val_if_fail(action_data != NULL, NULL); | |
889 | |
890 return g_hash_table_lookup(action_data->atts, attr); | |
891 } | |
892 | |
893 void * | |
894 gaim_pounce_get_data(const GaimPounce *pounce) | |
895 { | |
896 g_return_val_if_fail(pounce != NULL, NULL); | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
897 |
10432 | 898 return pounce->data; |
899 } | |
900 | |
901 void | |
902 gaim_pounce_execute(const GaimAccount *pouncer, const char *pouncee, | |
903 GaimPounceEvent events) | |
904 { | |
905 GaimPounce *pounce; | |
906 GaimPounceHandler *handler; | |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
907 GaimPresence *presence; |
10432 | 908 GList *l, *l_next; |
909 char *norm_pouncee; | |
910 | |
911 g_return_if_fail(pouncer != NULL); | |
912 g_return_if_fail(pouncee != NULL); | |
913 g_return_if_fail(events != GAIM_POUNCE_NONE); | |
914 | |
915 norm_pouncee = g_strdup(gaim_normalize(pouncer, pouncee)); | |
916 | |
917 for (l = gaim_pounces_get_all(); l != NULL; l = l_next) | |
918 { | |
919 pounce = (GaimPounce *)l->data; | |
920 l_next = l->next; | |
921 | |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
922 presence = gaim_account_get_presence(pouncer); |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
923 |
10432 | 924 if ((gaim_pounce_get_events(pounce) & events) && |
925 (gaim_pounce_get_pouncer(pounce) == pouncer) && | |
926 !gaim_utf8_strcasecmp(gaim_normalize(pouncer, gaim_pounce_get_pouncee(pounce)), | |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
927 norm_pouncee) && |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
928 (pounce->options == GAIM_POUNCE_OPTION_NONE || |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
929 (pounce->options & GAIM_POUNCE_OPTION_AWAY && |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
930 !gaim_presence_is_available(presence)))) |
10432 | 931 { |
932 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type); | |
933 | |
934 if (handler != NULL && handler->cb != NULL) | |
935 { | |
936 handler->cb(pounce, events, gaim_pounce_get_data(pounce)); | |
937 | |
938 if (!gaim_pounce_get_save(pounce)) | |
939 gaim_pounce_destroy(pounce); | |
940 } | |
941 } | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
942 } |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
943 |
10432 | 944 g_free(norm_pouncee); |
945 } | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
946 |
10432 | 947 GaimPounce * |
948 gaim_find_pounce(const GaimAccount *pouncer, const char *pouncee, | |
949 GaimPounceEvent events) | |
950 { | |
951 GaimPounce *pounce = NULL; | |
952 GList *l; | |
953 char *norm_pouncee; | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
954 |
10432 | 955 g_return_val_if_fail(pouncer != NULL, NULL); |
956 g_return_val_if_fail(pouncee != NULL, NULL); | |
957 g_return_val_if_fail(events != GAIM_POUNCE_NONE, NULL); | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
958 |
10432 | 959 norm_pouncee = g_strdup(gaim_normalize(pouncer, pouncee)); |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
960 |
10432 | 961 for (l = gaim_pounces_get_all(); l != NULL; l = l->next) |
962 { | |
963 pounce = (GaimPounce *)l->data; | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
964 |
10432 | 965 if ((gaim_pounce_get_events(pounce) & events) && |
966 (gaim_pounce_get_pouncer(pounce) == pouncer) && | |
967 !gaim_utf8_strcasecmp(gaim_normalize(pouncer, gaim_pounce_get_pouncee(pounce)), | |
968 norm_pouncee)) | |
969 { | |
970 break; | |
971 } | |
972 | |
973 pounce = NULL; | |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
974 } |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
975 |
10432 | 976 g_free(norm_pouncee); |
10399 | 977 |
10432 | 978 return pounce; |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
979 } |
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
980 |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
981 void |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
982 gaim_pounces_register_handler(const char *ui, GaimPounceCb cb, |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
983 void (*new_pounce)(GaimPounce *pounce), |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
984 void (*free_pounce)(GaimPounce *pounce)) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
985 { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
986 GaimPounceHandler *handler; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
987 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
988 g_return_if_fail(ui != NULL); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
989 g_return_if_fail(cb != NULL); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
990 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
991 handler = g_new0(GaimPounceHandler, 1); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
992 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
993 handler->ui = g_strdup(ui); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
994 handler->cb = cb; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
995 handler->new_pounce = new_pounce; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
996 handler->free_pounce = free_pounce; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
997 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
998 g_hash_table_insert(pounce_handlers, g_strdup(ui), handler); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
999 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1000 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1001 void |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1002 gaim_pounces_unregister_handler(const char *ui) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1003 { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1004 g_return_if_fail(ui != NULL); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1005 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1006 g_hash_table_remove(pounce_handlers, ui); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1007 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1008 |
5032
cb700c07ee07
[gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1009 GList * |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
1010 gaim_pounces_get_all(void) |
5032
cb700c07ee07
[gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1011 { |
cb700c07ee07
[gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1012 return pounces; |
cb700c07ee07
[gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1013 } |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1014 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1015 static void |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1016 free_pounce_handler(gpointer user_data) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1017 { |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1018 GaimPounceHandler *handler = (GaimPounceHandler *)user_data; |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1019 |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1020 g_free(handler->ui); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1021 g_free(handler); |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1022 } |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1023 |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1024 static void |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1025 buddy_state_cb(GaimBuddy *buddy, GaimPounceEvent event) |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1026 { |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1027 gaim_pounce_execute(buddy->account, buddy->name, event); |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1028 } |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1029 |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1030 static void |
11935
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1031 buddy_status_changed_cb(GaimBuddy *buddy, GaimStatus *old_status, |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1032 GaimStatus *status) |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1033 { |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1034 gboolean old_available, available; |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1035 |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1036 available = gaim_status_is_available(status); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1037 old_available = gaim_status_is_available(old_status); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1038 |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1039 if (available && !old_available) |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1040 gaim_pounce_execute(buddy->account, buddy->name, |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1041 GAIM_POUNCE_AWAY_RETURN); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1042 else if (!available && old_available) |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1043 gaim_pounce_execute(buddy->account, buddy->name, |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1044 GAIM_POUNCE_AWAY); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1045 } |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1046 |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1047 static void |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1048 buddy_idle_changed_cb(GaimBuddy *buddy, gboolean old_idle, gboolean idle) |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1049 { |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1050 if (idle && !old_idle) |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1051 gaim_pounce_execute(buddy->account, buddy->name, |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1052 GAIM_POUNCE_IDLE); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1053 else if (!idle && old_idle) |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1054 gaim_pounce_execute(buddy->account, buddy->name, |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1055 GAIM_POUNCE_IDLE_RETURN); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1056 } |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1057 |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1058 static void |
11706
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11256
diff
changeset
|
1059 buddy_typing_cb(GaimAccount *account, const char *name, void *data) |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1060 { |
11710
c9bd6decdec4
[gaim-migrate @ 14001]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11708
diff
changeset
|
1061 GaimConversation *conv; |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1062 |
11710
c9bd6decdec4
[gaim-migrate @ 14001]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11708
diff
changeset
|
1063 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, account); |
11706
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11256
diff
changeset
|
1064 if (conv != NULL) |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1065 { |
13842 | 1066 GaimTypingState state; |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1067 GaimPounceEvent event; |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1068 |
13842 | 1069 state = gaim_conv_im_get_typing_state(GAIM_CONV_IM(conv)); |
1070 if (state == GAIM_TYPED) | |
1071 event = GAIM_POUNCE_TYPED; | |
1072 else if (state == GAIM_NOT_TYPING) | |
1073 event = GAIM_POUNCE_TYPING_STOPPED; | |
1074 else | |
1075 event = GAIM_POUNCE_TYPING; | |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1076 |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1077 gaim_pounce_execute(account, name, event); |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1078 } |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1079 } |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1080 |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
1081 static void |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
1082 received_message_cb(GaimAccount *account, const char *name, void *data) |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
1083 { |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
1084 gaim_pounce_execute(account, name, GAIM_POUNCE_MESSAGE_RECEIVED); |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
1085 } |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
1086 |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1087 void * |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1088 gaim_pounces_get_handle(void) |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1089 { |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1090 static int pounce_handle; |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1091 |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1092 return &pounce_handle; |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1093 } |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1094 |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1095 void |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1096 gaim_pounces_init(void) |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1097 { |
10432 | 1098 void *handle = gaim_pounces_get_handle(); |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1099 void *blist_handle = gaim_blist_get_handle(); |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1100 void *conv_handle = gaim_conversations_get_handle(); |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1101 |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1102 pounce_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, |
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1103 g_free, free_pounce_handler); |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1104 |
11935
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1105 gaim_signal_connect(blist_handle, "buddy-idle-changed", |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1106 handle, GAIM_CALLBACK(buddy_idle_changed_cb), NULL); |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1107 gaim_signal_connect(blist_handle, "buddy-status-changed", |
cb73483c9f63
[gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11710
diff
changeset
|
1108 handle, GAIM_CALLBACK(buddy_status_changed_cb), NULL); |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1109 gaim_signal_connect(blist_handle, "buddy-signed-on", |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1110 handle, GAIM_CALLBACK(buddy_state_cb), |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1111 GINT_TO_POINTER(GAIM_POUNCE_SIGNON)); |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1112 gaim_signal_connect(blist_handle, "buddy-signed-off", |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1113 handle, GAIM_CALLBACK(buddy_state_cb), |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1114 GINT_TO_POINTER(GAIM_POUNCE_SIGNOFF)); |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1115 |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1116 gaim_signal_connect(conv_handle, "buddy-typing", |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1117 handle, GAIM_CALLBACK(buddy_typing_cb), NULL); |
13842 | 1118 gaim_signal_connect(conv_handle, "buddy-typed", |
1119 handle, GAIM_CALLBACK(buddy_typing_cb), NULL); | |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1120 gaim_signal_connect(conv_handle, "buddy-typing-stopped", |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1121 handle, GAIM_CALLBACK(buddy_typing_cb), NULL); |
12694
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
1122 |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
1123 gaim_signal_connect(conv_handle, "received-im-msg", |
ebed1bbedb04
[gaim-migrate @ 15037]
Richard Laager <rlaager@wiktel.com>
parents:
12002
diff
changeset
|
1124 handle, GAIM_CALLBACK(received_message_cb), NULL); |
5875
448f2f4ca3ec
[gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1125 } |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1126 |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1127 void |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1128 gaim_pounces_uninit() |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1129 { |
10432 | 1130 if (save_timer != 0) |
1131 { | |
1132 gaim_timeout_remove(save_timer); | |
1133 save_timer = 0; | |
1134 sync_pounces(); | |
8235 | 1135 } |
1136 | |
6837
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1137 gaim_signals_disconnect_by_handle(gaim_pounces_get_handle()); |
f098765ac919
[gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents:
6719
diff
changeset
|
1138 } |