Mercurial > pidgin.yaz
annotate src/notify.c @ 11531:bf763a1b2454
[gaim-migrate @ 13780]
(13:57:11) rlaager: LSchiere2: Should we just change gaim_notify_userinfo
to take a screenname and eliminate all the duplication of "Buddy
Information" and "Info for %s"?
(13:57:18) LSchiere2: sounds good
This breaks perl, I could not figure out how to fix that.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 12 Sep 2005 18:46:15 +0000 |
parents | 9480e0d0f563 |
children | c9b815aeddc1 |
rev | line source |
---|---|
5437 | 1 /** |
2 * @file notify.c Notification API | |
3 * @ingroup core | |
4 * | |
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. | |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
10 * |
5437 | 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 */ | |
11531
bf763a1b2454
[gaim-migrate @ 13780]
Luke Schierer <lschiere@pidgin.im>
parents:
11359
diff
changeset
|
25 #include "internal.h" |
5437 | 26 #include "notify.h" |
27 | |
28 static GaimNotifyUiOps *notify_ui_ops = NULL; | |
29 static GList *handles = NULL; | |
30 | |
31 typedef struct | |
32 { | |
33 GaimNotifyType type; | |
34 void *handle; | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
35 void *ui_handle; |
5437 | 36 |
37 } GaimNotifyInfo; | |
38 | |
39 void * | |
6356
ee0044f3e377
[gaim-migrate @ 6855]
Christian Hammond <chipx86@chipx86.com>
parents:
6106
diff
changeset
|
40 gaim_notify_message(void *handle, GaimNotifyMsgType type, |
5437 | 41 const char *title, const char *primary, |
42 const char *secondary, GCallback cb, void *user_data) | |
43 { | |
44 GaimNotifyUiOps *ops; | |
45 | |
46 g_return_val_if_fail(primary != NULL, NULL); | |
47 | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
48 ops = gaim_notify_get_ui_ops(); |
5437 | 49 |
50 if (ops != NULL && ops->notify_message != NULL) { | |
51 GaimNotifyInfo *info; | |
52 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
53 info = g_new0(GaimNotifyInfo, 1); |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
54 info->type = GAIM_NOTIFY_MESSAGE; |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
55 info->handle = handle; |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
56 info->ui_handle = ops->notify_message(type, title, primary, |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
57 secondary, cb, user_data); |
5437 | 58 |
59 handles = g_list_append(handles, info); | |
60 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
61 return info->ui_handle; |
5437 | 62 } |
63 | |
64 return NULL; | |
65 } | |
66 | |
67 void * | |
68 gaim_notify_email(void *handle, const char *subject, const char *from, | |
69 const char *to, const char *url, GCallback cb, | |
70 void *user_data) | |
71 { | |
72 GaimNotifyUiOps *ops; | |
73 | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
74 ops = gaim_notify_get_ui_ops(); |
5437 | 75 |
76 if (ops != NULL && ops->notify_email != NULL) { | |
77 GaimNotifyInfo *info; | |
78 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
79 info = g_new0(GaimNotifyInfo, 1); |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
80 info->type = GAIM_NOTIFY_EMAIL; |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
81 info->handle = handle; |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
82 info->ui_handle = ops->notify_email(subject, from, to, url, cb, |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
83 user_data); |
5437 | 84 |
85 handles = g_list_append(handles, info); | |
86 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
87 return info->ui_handle; |
5437 | 88 } |
89 | |
90 return NULL; | |
91 } | |
92 | |
93 void * | |
5522
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
94 gaim_notify_emails(void *handle, size_t count, gboolean detailed, |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
95 const char **subjects, const char **froms, |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
96 const char **tos, const char **urls, |
5437 | 97 GCallback cb, void *user_data) |
98 { | |
99 GaimNotifyUiOps *ops; | |
100 | |
101 g_return_val_if_fail(count != 0, NULL); | |
102 | |
5522
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
103 if (count == 1) { |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
104 return gaim_notify_email(handle, |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
105 (subjects == NULL ? NULL : *subjects), |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
106 (froms == NULL ? NULL : *froms), |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
107 (tos == NULL ? NULL : *tos), |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
108 (urls == NULL ? NULL : *urls), |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
109 cb, user_data); |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
110 } |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
111 |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
112 ops = gaim_notify_get_ui_ops(); |
5437 | 113 |
114 if (ops != NULL && ops->notify_emails != NULL) { | |
115 GaimNotifyInfo *info; | |
116 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
117 info = g_new0(GaimNotifyInfo, 1); |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
118 info->type = GAIM_NOTIFY_EMAILS; |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
119 info->handle = handle; |
5522
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
120 info->ui_handle = ops->notify_emails(count, detailed, subjects, |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
121 froms, tos, urls, cb, user_data); |
5437 | 122 |
123 handles = g_list_append(handles, info); | |
124 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
125 return info->ui_handle; |
5437 | 126 } |
127 | |
128 return NULL; | |
129 } | |
130 | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
131 void * |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
132 gaim_notify_formatted(void *handle, const char *title, const char *primary, |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
133 const char *secondary, const char *text, |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
134 GCallback cb, void *user_data) |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
135 { |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
136 GaimNotifyUiOps *ops; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
137 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
138 g_return_val_if_fail(primary != NULL, NULL); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
139 |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
140 ops = gaim_notify_get_ui_ops(); |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
141 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
142 if (ops != NULL && ops->notify_formatted != NULL) { |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
143 GaimNotifyInfo *info; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
144 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
145 info = g_new0(GaimNotifyInfo, 1); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
146 info->type = GAIM_NOTIFY_FORMATTED; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
147 info->handle = handle; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
148 info->ui_handle = ops->notify_formatted(title, primary, secondary, |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
149 text, cb, user_data); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
150 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
151 handles = g_list_append(handles, info); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
152 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
153 return info->ui_handle; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
154 } |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
155 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
156 return NULL; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
157 } |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
158 |
10439 | 159 void * |
160 gaim_notify_searchresults(GaimConnection *gc, const char *title, | |
161 const char *primary, const char *secondary, | |
11359 | 162 GaimNotifySearchResults *results, GCallback cb, void *user_data) |
10439 | 163 { |
164 GaimNotifyUiOps *ops; | |
165 | |
166 ops = gaim_notify_get_ui_ops(); | |
167 | |
168 if (ops != NULL && ops->notify_searchresults != NULL) { | |
169 GaimNotifyInfo *info; | |
170 | |
171 info = g_new0(GaimNotifyInfo, 1); | |
172 info->type = GAIM_NOTIFY_SEARCHRESULTS; | |
173 info->handle = gc; | |
174 info->ui_handle = ops->notify_searchresults(gc, title, primary, | |
175 secondary, results, | |
176 cb, user_data); | |
177 | |
178 handles = g_list_append(handles, info); | |
179 | |
180 return info->ui_handle; | |
181 } | |
182 | |
183 return NULL; | |
184 } | |
185 | |
11359 | 186 void |
187 gaim_notify_searchresults_free(GaimNotifySearchResults *results) | |
188 { | |
189 GList *l, *m; | |
190 | |
191 g_return_if_fail(results != NULL); | |
192 | |
193 for (l = results->buttons; l != NULL; l = l->next) { | |
194 GaimNotifySearchButton *button = l->data; | |
195 | |
196 results->buttons = g_list_remove(results->buttons, button); | |
197 g_free(button); | |
198 } | |
199 g_list_free(results->buttons); | |
200 | |
201 for (l = results->rows; l != NULL; l = l->next) { | |
202 GList *row = l->data; | |
203 | |
204 for (m = row; m != NULL; m = m->next) { | |
205 gchar *str = m->data; | |
206 | |
207 m = g_list_remove(m, str); | |
208 g_free(str); | |
209 } | |
210 | |
211 results->rows = g_list_remove(results->rows, row); | |
212 g_list_free(row); | |
213 } | |
214 g_list_free(results->rows); | |
215 | |
216 for (l = results->columns; l != NULL; l = l->next) { | |
217 GaimNotifySearchColumn *column = l->data; | |
218 | |
219 results->columns = g_list_remove(results->columns, column); | |
220 g_free(column->title); | |
221 g_free(column); | |
222 } | |
223 g_list_free(results->columns); | |
224 } | |
225 | |
226 void | |
227 gaim_notify_searchresults_new_rows(GaimConnection *gc, | |
228 GaimNotifySearchResults *results, | |
229 void *data, void *user_data) | |
230 { | |
231 GaimNotifyUiOps *ops; | |
232 | |
233 ops = gaim_notify_get_ui_ops(); | |
234 | |
235 if (ops != NULL && ops->notify_searchresults != NULL) { | |
236 ops->notify_searchresults_new_rows(gc, results, data, user_data); | |
237 } | |
238 } | |
239 | |
240 void | |
241 gaim_notify_searchresults_button_add(GaimNotifySearchResults *results, | |
242 GaimNotifySearchButtonType type, | |
243 GaimNotifySearchResultsCallback cb) | |
244 { | |
245 GaimNotifySearchButton *button; | |
246 | |
247 g_return_if_fail(results != NULL); | |
248 g_return_if_fail(cb != NULL); | |
249 | |
250 button = g_new0(GaimNotifySearchButton, 1); | |
251 button->callback = cb; | |
252 button->type = type; | |
253 | |
254 results->buttons = g_list_append(results->buttons, button); | |
255 } | |
256 | |
257 GaimNotifySearchResults * | |
258 gaim_notify_searchresults_new() | |
259 { | |
260 GaimNotifySearchResults *rs = g_new0(GaimNotifySearchResults, 1); | |
261 | |
262 return rs; | |
263 } | |
264 | |
265 void | |
266 gaim_notify_searchresults_column_add(GaimNotifySearchResults *results, | |
267 GaimNotifySearchColumn *column) | |
268 { | |
269 g_return_if_fail(results != NULL); | |
270 g_return_if_fail(column != NULL); | |
271 | |
272 results->columns = g_list_append(results->columns, column); | |
273 } | |
274 | |
275 void gaim_notify_searchresults_row_add(GaimNotifySearchResults *results, | |
276 GList *row) | |
277 { | |
278 g_return_if_fail(results != NULL); | |
279 g_return_if_fail(row != NULL); | |
280 | |
281 results->rows = g_list_append(results->rows, row); | |
282 } | |
283 | |
284 GaimNotifySearchColumn * | |
285 gaim_notify_searchresults_column_new(const char *title) | |
286 { | |
287 GaimNotifySearchColumn *sc; | |
288 | |
289 g_return_val_if_fail(title != NULL, NULL); | |
290 | |
291 sc = g_new0(GaimNotifySearchColumn, 1); | |
292 sc->title = g_strdup(title); | |
293 | |
294 return sc; | |
295 } | |
296 | |
297 int | |
298 gaim_notify_searchresults_get_columns_count(GaimNotifySearchResults *results) | |
299 { | |
300 g_return_val_if_fail(results != NULL, -1); | |
301 | |
302 return g_list_length(results->columns); | |
303 } | |
304 | |
305 int | |
306 gaim_notify_searchresults_get_rows_count(GaimNotifySearchResults *results) | |
307 { | |
308 g_return_val_if_fail(results != NULL, -1); | |
309 | |
310 return g_list_length(results->rows); | |
311 } | |
312 | |
313 char * | |
314 gaim_notify_searchresults_column_get_title(GaimNotifySearchResults *results, | |
315 unsigned int column_id) | |
316 { | |
317 g_return_val_if_fail(results != NULL, NULL); | |
318 | |
319 return ((GaimNotifySearchColumn *)g_list_nth_data(results->columns, column_id))->title; | |
320 } | |
321 | |
322 GList * | |
323 gaim_notify_searchresults_row_get(GaimNotifySearchResults *results, | |
324 unsigned int row_id) | |
325 { | |
326 g_return_val_if_fail(results != NULL, NULL); | |
327 | |
328 return g_list_nth_data(results->rows, row_id); | |
329 } | |
330 | |
10439 | 331 void * |
11531
bf763a1b2454
[gaim-migrate @ 13780]
Luke Schierer <lschiere@pidgin.im>
parents:
11359
diff
changeset
|
332 gaim_notify_userinfo(GaimConnection *gc, const char *who, |
10439 | 333 const char *primary, const char *secondary, |
9797 | 334 const char *text, GCallback cb, void *user_data) |
335 { | |
336 GaimNotifyUiOps *ops; | |
11531
bf763a1b2454
[gaim-migrate @ 13780]
Luke Schierer <lschiere@pidgin.im>
parents:
11359
diff
changeset
|
337 char title[256]; |
bf763a1b2454
[gaim-migrate @ 13780]
Luke Schierer <lschiere@pidgin.im>
parents:
11359
diff
changeset
|
338 |
bf763a1b2454
[gaim-migrate @ 13780]
Luke Schierer <lschiere@pidgin.im>
parents:
11359
diff
changeset
|
339 g_snprintf(title, sizeof(title), _("Info for %s"), who); |
9797 | 340 |
341 g_return_val_if_fail(primary != NULL, NULL); | |
342 | |
343 ops = gaim_notify_get_ui_ops(); | |
344 | |
345 if (ops != NULL && ops->notify_userinfo != NULL) { | |
346 GaimNotifyInfo *info; | |
347 | |
348 info = g_new0(GaimNotifyInfo, 1); | |
349 info->type = GAIM_NOTIFY_USERINFO; | |
350 info->handle = gc; | |
351 info->ui_handle = ops->notify_userinfo(gc, who, title, primary, | |
352 secondary, text, cb, user_data); | |
353 | |
354 handles = g_list_append(handles, info); | |
355 | |
356 return info->ui_handle; | |
357 } | |
358 | |
359 return NULL; | |
360 } | |
361 | |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
362 void * |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
363 gaim_notify_uri(void *handle, const char *uri) |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
364 { |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
365 GaimNotifyUiOps *ops; |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
366 |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
367 g_return_val_if_fail(uri != NULL, NULL); |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
368 |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
369 ops = gaim_notify_get_ui_ops(); |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
370 |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
371 if (ops != NULL && ops->notify_uri != NULL) { |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
372 GaimNotifyInfo *info; |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
373 |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
374 info = g_new0(GaimNotifyInfo, 1); |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
375 info->type = GAIM_NOTIFY_URI; |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
376 info->handle = handle; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
377 info->ui_handle = ops->notify_uri(uri); |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
378 |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
379 handles = g_list_append(handles, info); |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
380 |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
381 return info->ui_handle; |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
382 } |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
383 |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
384 return NULL; |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
385 } |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
386 |
5437 | 387 void |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
388 gaim_notify_close(GaimNotifyType type, void *ui_handle) |
5437 | 389 { |
390 GList *l; | |
391 GaimNotifyUiOps *ops; | |
392 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
393 g_return_if_fail(ui_handle != NULL); |
5437 | 394 |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
395 ops = gaim_notify_get_ui_ops(); |
5437 | 396 |
397 for (l = handles; l != NULL; l = l->next) { | |
398 GaimNotifyInfo *info = l->data; | |
399 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
400 if (info->ui_handle == ui_handle) { |
5437 | 401 handles = g_list_remove(handles, info); |
402 | |
403 if (ops != NULL && ops->close_notify != NULL) | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
404 ops->close_notify(info->type, ui_handle); |
5437 | 405 |
406 g_free(info); | |
407 | |
408 break; | |
409 } | |
410 } | |
411 } | |
412 | |
413 void | |
414 gaim_notify_close_with_handle(void *handle) | |
415 { | |
416 GList *l, *l_next; | |
417 GaimNotifyUiOps *ops; | |
418 | |
419 g_return_if_fail(handle != NULL); | |
420 | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
421 ops = gaim_notify_get_ui_ops(); |
5437 | 422 |
423 for (l = handles; l != NULL; l = l_next) { | |
424 GaimNotifyInfo *info = l->data; | |
425 | |
426 l_next = l->next; | |
427 | |
428 if (info->handle == handle) { | |
429 handles = g_list_remove(handles, info); | |
430 | |
431 if (ops != NULL && ops->close_notify != NULL) | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
432 ops->close_notify(info->type, info->ui_handle); |
5437 | 433 |
434 g_free(info); | |
435 } | |
436 } | |
437 } | |
438 | |
439 void | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
440 gaim_notify_set_ui_ops(GaimNotifyUiOps *ops) |
5437 | 441 { |
442 notify_ui_ops = ops; | |
443 } | |
444 | |
445 GaimNotifyUiOps * | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
446 gaim_notify_get_ui_ops(void) |
5437 | 447 { |
448 return notify_ui_ops; | |
449 } |