Mercurial > pidgin.yaz
annotate src/notify.c @ 19789:d99e36279d41
[gaim-migrate @ 17181]
add PSM in tooltips
fix oim bug in windows
committed by MaYuan<mayuan2006@gmail.com>
committer: Ethan Blanton <elb@pidgin.im>
author | Ma Yuan <mayuan2006@gmail.com> |
---|---|
date | Wed, 06 Sep 2006 16:14:22 +0000 |
parents | d12bbe6da705 |
children | 6a5aaf46bd52 |
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 */ | |
25 #include "notify.h" | |
26 | |
27 static GaimNotifyUiOps *notify_ui_ops = NULL; | |
28 static GList *handles = NULL; | |
29 | |
30 typedef struct | |
31 { | |
32 GaimNotifyType type; | |
33 void *handle; | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
34 void *ui_handle; |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
35 GaimNotifyCloseCallback cb; |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
36 gpointer cb_user_data; |
5437 | 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, |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
42 const char *secondary, GaimNotifyCloseCallback cb, gpointer user_data) |
5437 | 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, |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
57 secondary); |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
58 info->cb = cb; |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
59 info->cb_user_data = user_data; |
5437 | 60 |
61 handles = g_list_append(handles, info); | |
62 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
63 return info->ui_handle; |
5437 | 64 } |
65 | |
66 return NULL; | |
67 } | |
68 | |
69 void * | |
70 gaim_notify_email(void *handle, const char *subject, const char *from, | |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
71 const char *to, const char *url, GaimNotifyCloseCallback cb, |
12220
64254fbabc7b
[gaim-migrate @ 14522]
Richard Laager <rlaager@wiktel.com>
parents:
12129
diff
changeset
|
72 gpointer user_data) |
5437 | 73 { |
74 GaimNotifyUiOps *ops; | |
75 | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
76 ops = gaim_notify_get_ui_ops(); |
5437 | 77 |
78 if (ops != NULL && ops->notify_email != NULL) { | |
79 GaimNotifyInfo *info; | |
80 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
81 info = g_new0(GaimNotifyInfo, 1); |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
82 info->type = GAIM_NOTIFY_EMAIL; |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
83 info->handle = handle; |
12647
852df2d9d4f8
[gaim-migrate @ 14985]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
84 info->ui_handle = ops->notify_email(handle, subject, from, to, url); |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
85 info->cb = cb; |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
86 info->cb_user_data = user_data; |
5437 | 87 |
88 handles = g_list_append(handles, info); | |
89 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
90 return info->ui_handle; |
5437 | 91 } |
92 | |
93 return NULL; | |
94 } | |
95 | |
96 void * | |
5522
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
97 gaim_notify_emails(void *handle, size_t count, gboolean detailed, |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
98 const char **subjects, const char **froms, |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
99 const char **tos, const char **urls, |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
100 GaimNotifyCloseCallback cb, gpointer user_data) |
5437 | 101 { |
102 GaimNotifyUiOps *ops; | |
103 | |
104 g_return_val_if_fail(count != 0, NULL); | |
105 | |
5522
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
106 if (count == 1) { |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
107 return gaim_notify_email(handle, |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
108 (subjects == NULL ? NULL : *subjects), |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
109 (froms == NULL ? NULL : *froms), |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
110 (tos == NULL ? NULL : *tos), |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
111 (urls == NULL ? NULL : *urls), |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
112 cb, user_data); |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
113 } |
a3e6a5ef49b5
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
114 |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
115 ops = gaim_notify_get_ui_ops(); |
5437 | 116 |
117 if (ops != NULL && ops->notify_emails != NULL) { | |
118 GaimNotifyInfo *info; | |
119 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
120 info = g_new0(GaimNotifyInfo, 1); |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
121 info->type = GAIM_NOTIFY_EMAILS; |
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
122 info->handle = handle; |
12647
852df2d9d4f8
[gaim-migrate @ 14985]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
123 info->ui_handle = ops->notify_emails(handle, count, detailed, subjects, |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
124 froms, tos, urls); |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
125 info->cb = cb; |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
126 info->cb_user_data = user_data; |
5437 | 127 |
128 handles = g_list_append(handles, info); | |
129 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
130 return info->ui_handle; |
5437 | 131 } |
132 | |
133 return NULL; | |
134 } | |
135 | |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
136 void * |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
137 gaim_notify_formatted(void *handle, const char *title, const char *primary, |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
138 const char *secondary, const char *text, |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
139 GaimNotifyCloseCallback cb, gpointer user_data) |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
140 { |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
141 GaimNotifyUiOps *ops; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
142 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
143 g_return_val_if_fail(primary != NULL, NULL); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
144 |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
145 ops = gaim_notify_get_ui_ops(); |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
146 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
147 if (ops != NULL && ops->notify_formatted != NULL) { |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
148 GaimNotifyInfo *info; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
149 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
150 info = g_new0(GaimNotifyInfo, 1); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
151 info->type = GAIM_NOTIFY_FORMATTED; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
152 info->handle = handle; |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
153 info->ui_handle = ops->notify_formatted(title, primary, secondary, text); |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
154 info->cb = cb; |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
155 info->cb_user_data = user_data; |
6381
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
156 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
157 handles = g_list_append(handles, info); |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
158 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
159 return info->ui_handle; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
160 } |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
161 |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
162 return NULL; |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
163 } |
e006685f75aa
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
164 |
10439 | 165 void * |
166 gaim_notify_searchresults(GaimConnection *gc, const char *title, | |
167 const char *primary, const char *secondary, | |
13640 | 168 GaimNotifySearchResults *results, GaimNotifyCloseCallback cb, |
169 gpointer user_data) | |
10439 | 170 { |
171 GaimNotifyUiOps *ops; | |
172 | |
173 ops = gaim_notify_get_ui_ops(); | |
174 | |
175 if (ops != NULL && ops->notify_searchresults != NULL) { | |
176 GaimNotifyInfo *info; | |
177 | |
178 info = g_new0(GaimNotifyInfo, 1); | |
179 info->type = GAIM_NOTIFY_SEARCHRESULTS; | |
180 info->handle = gc; | |
181 info->ui_handle = ops->notify_searchresults(gc, title, primary, | |
13640 | 182 secondary, results, user_data); |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
183 info->cb = cb; |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
184 info->cb_user_data = user_data; |
10439 | 185 |
186 handles = g_list_append(handles, info); | |
187 | |
188 return info->ui_handle; | |
189 } | |
190 | |
191 return NULL; | |
192 } | |
193 | |
11359 | 194 void |
195 gaim_notify_searchresults_free(GaimNotifySearchResults *results) | |
196 { | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
197 GList *l; |
11359 | 198 |
199 g_return_if_fail(results != NULL); | |
200 | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
201 for (l = results->buttons; l; l = g_list_delete_link(l, l)) { |
11359 | 202 GaimNotifySearchButton *button = l->data; |
203 g_free(button); | |
204 } | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
205 results->buttons = NULL; |
11359 | 206 |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
207 for (l = results->rows; l; l = g_list_delete_link(l, l)) { |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
208 GList *row = l->data; |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
209 for (; row; row = g_list_delete_link(row, row)) { |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
210 gchar *str = row->data; |
11359 | 211 g_free(str); |
212 } | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
213 } |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
214 results->rows = NULL; |
11359 | 215 |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
216 for (l = results->columns; l; l = g_list_delete_link(l, l)) { |
11359 | 217 GaimNotifySearchColumn *column = l->data; |
218 g_free(column->title); | |
219 g_free(column); | |
220 } | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
221 results->columns = NULL; |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
222 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
223 g_free(results); |
11359 | 224 } |
225 | |
226 void | |
227 gaim_notify_searchresults_new_rows(GaimConnection *gc, | |
228 GaimNotifySearchResults *results, | |
13640 | 229 void *data) |
11359 | 230 { |
231 GaimNotifyUiOps *ops; | |
232 | |
233 ops = gaim_notify_get_ui_ops(); | |
234 | |
235 if (ops != NULL && ops->notify_searchresults != NULL) { | |
13640 | 236 ops->notify_searchresults_new_rows(gc, results, data); |
11359 | 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 | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
257 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
258 void |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
259 gaim_notify_searchresults_button_add_labeled(GaimNotifySearchResults *results, |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
260 const char *label, |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
261 GaimNotifySearchResultsCallback cb) { |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
262 GaimNotifySearchButton *button; |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
263 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
264 g_return_if_fail(results != NULL); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
265 g_return_if_fail(cb != NULL); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
266 g_return_if_fail(label != NULL); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
267 g_return_if_fail(*label != '\0'); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
268 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
269 button = g_new0(GaimNotifySearchButton, 1); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
270 button->callback = cb; |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
271 button->type = GAIM_NOTIFY_BUTTON_LABELED; |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
272 button->label = g_strdup(label); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
273 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
274 results->buttons = g_list_append(results->buttons, button); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
275 } |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
276 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12257
diff
changeset
|
277 |
11359 | 278 GaimNotifySearchResults * |
279 gaim_notify_searchresults_new() | |
280 { | |
281 GaimNotifySearchResults *rs = g_new0(GaimNotifySearchResults, 1); | |
282 | |
283 return rs; | |
284 } | |
285 | |
286 void | |
287 gaim_notify_searchresults_column_add(GaimNotifySearchResults *results, | |
288 GaimNotifySearchColumn *column) | |
289 { | |
290 g_return_if_fail(results != NULL); | |
291 g_return_if_fail(column != NULL); | |
292 | |
293 results->columns = g_list_append(results->columns, column); | |
294 } | |
295 | |
296 void gaim_notify_searchresults_row_add(GaimNotifySearchResults *results, | |
297 GList *row) | |
298 { | |
299 g_return_if_fail(results != NULL); | |
300 g_return_if_fail(row != NULL); | |
301 | |
302 results->rows = g_list_append(results->rows, row); | |
303 } | |
304 | |
305 GaimNotifySearchColumn * | |
306 gaim_notify_searchresults_column_new(const char *title) | |
307 { | |
308 GaimNotifySearchColumn *sc; | |
309 | |
310 g_return_val_if_fail(title != NULL, NULL); | |
311 | |
312 sc = g_new0(GaimNotifySearchColumn, 1); | |
313 sc->title = g_strdup(title); | |
314 | |
315 return sc; | |
316 } | |
317 | |
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
318 guint |
11359 | 319 gaim_notify_searchresults_get_columns_count(GaimNotifySearchResults *results) |
320 { | |
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
321 g_return_val_if_fail(results != NULL, 0); |
11359 | 322 |
323 return g_list_length(results->columns); | |
324 } | |
325 | |
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
326 guint |
11359 | 327 gaim_notify_searchresults_get_rows_count(GaimNotifySearchResults *results) |
328 { | |
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12242
diff
changeset
|
329 g_return_val_if_fail(results != NULL, 0); |
11359 | 330 |
331 return g_list_length(results->rows); | |
332 } | |
333 | |
334 char * | |
335 gaim_notify_searchresults_column_get_title(GaimNotifySearchResults *results, | |
336 unsigned int column_id) | |
337 { | |
338 g_return_val_if_fail(results != NULL, NULL); | |
339 | |
340 return ((GaimNotifySearchColumn *)g_list_nth_data(results->columns, column_id))->title; | |
341 } | |
342 | |
343 GList * | |
344 gaim_notify_searchresults_row_get(GaimNotifySearchResults *results, | |
345 unsigned int row_id) | |
346 { | |
347 g_return_val_if_fail(results != NULL, NULL); | |
348 | |
349 return g_list_nth_data(results->rows, row_id); | |
350 } | |
351 | |
10439 | 352 void * |
11531
bf763a1b2454
[gaim-migrate @ 13780]
Luke Schierer <lschiere@pidgin.im>
parents:
11359
diff
changeset
|
353 gaim_notify_userinfo(GaimConnection *gc, const char *who, |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
354 const char *text, GaimNotifyCloseCallback cb, gpointer user_data) |
9797 | 355 { |
356 GaimNotifyUiOps *ops; | |
11531
bf763a1b2454
[gaim-migrate @ 13780]
Luke Schierer <lschiere@pidgin.im>
parents:
11359
diff
changeset
|
357 |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11531
diff
changeset
|
358 g_return_val_if_fail(who != NULL, NULL); |
9797 | 359 |
360 ops = gaim_notify_get_ui_ops(); | |
361 | |
362 if (ops != NULL && ops->notify_userinfo != NULL) { | |
363 GaimNotifyInfo *info; | |
12129
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
364 char *infotext = g_strdup(text); |
9797 | 365 |
366 info = g_new0(GaimNotifyInfo, 1); | |
367 info->type = GAIM_NOTIFY_USERINFO; | |
368 info->handle = gc; | |
12129
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
369 |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
370 gaim_signal_emit(gaim_notify_get_handle(), "displaying-userinfo", |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
371 gaim_connection_get_account(gc), who, &infotext); |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
372 |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
373 info->ui_handle = ops->notify_userinfo(gc, who, infotext); |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
374 info->cb = cb; |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
375 info->cb_user_data = user_data; |
9797 | 376 |
377 handles = g_list_append(handles, info); | |
378 | |
12129
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
379 g_free(infotext); |
9797 | 380 return info->ui_handle; |
381 } | |
382 | |
383 return NULL; | |
384 } | |
385 | |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
386 void * |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
387 gaim_notify_uri(void *handle, const char *uri) |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
388 { |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
389 GaimNotifyUiOps *ops; |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
390 |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
391 g_return_val_if_fail(uri != NULL, NULL); |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
392 |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
393 ops = gaim_notify_get_ui_ops(); |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
394 |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
395 if (ops != NULL && ops->notify_uri != NULL) { |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
396 GaimNotifyInfo *info; |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
397 |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
398 info = g_new0(GaimNotifyInfo, 1); |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
399 info->type = GAIM_NOTIFY_URI; |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
400 info->handle = handle; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
401 info->ui_handle = ops->notify_uri(uri); |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
402 |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
403 handles = g_list_append(handles, info); |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
404 |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
405 return info->ui_handle; |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
406 } |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
407 |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
408 return NULL; |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
409 } |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
410 |
5437 | 411 void |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
412 gaim_notify_close(GaimNotifyType type, void *ui_handle) |
5437 | 413 { |
414 GList *l; | |
415 GaimNotifyUiOps *ops; | |
416 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
417 g_return_if_fail(ui_handle != NULL); |
5437 | 418 |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
419 ops = gaim_notify_get_ui_ops(); |
5437 | 420 |
421 for (l = handles; l != NULL; l = l->next) { | |
422 GaimNotifyInfo *info = l->data; | |
423 | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
424 if (info->ui_handle == ui_handle) { |
5437 | 425 handles = g_list_remove(handles, info); |
426 | |
427 if (ops != NULL && ops->close_notify != NULL) | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
428 ops->close_notify(info->type, ui_handle); |
5437 | 429 |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
430 if (info->cb != NULL) |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
431 info->cb(info->cb_user_data); |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
432 |
5437 | 433 g_free(info); |
434 | |
435 break; | |
436 } | |
437 } | |
438 } | |
439 | |
440 void | |
441 gaim_notify_close_with_handle(void *handle) | |
442 { | |
443 GList *l, *l_next; | |
444 GaimNotifyUiOps *ops; | |
445 | |
446 g_return_if_fail(handle != NULL); | |
447 | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
448 ops = gaim_notify_get_ui_ops(); |
5437 | 449 |
450 for (l = handles; l != NULL; l = l_next) { | |
451 GaimNotifyInfo *info = l->data; | |
452 | |
453 l_next = l->next; | |
454 | |
455 if (info->handle == handle) { | |
456 handles = g_list_remove(handles, info); | |
457 | |
458 if (ops != NULL && ops->close_notify != NULL) | |
5476
9bcd8cd625ae
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
459 ops->close_notify(info->type, info->ui_handle); |
5437 | 460 |
12242
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
461 if (info->cb != NULL) |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
462 info->cb(info->cb_user_data); |
976677e67239
[gaim-migrate @ 14544]
Richard Laager <rlaager@wiktel.com>
parents:
12220
diff
changeset
|
463 |
5437 | 464 g_free(info); |
465 } | |
466 } | |
467 } | |
468 | |
469 void | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
470 gaim_notify_set_ui_ops(GaimNotifyUiOps *ops) |
5437 | 471 { |
472 notify_ui_ops = ops; | |
473 } | |
474 | |
475 GaimNotifyUiOps * | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
476 gaim_notify_get_ui_ops(void) |
5437 | 477 { |
478 return notify_ui_ops; | |
479 } | |
12129
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
480 |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
481 void * |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
482 gaim_notify_get_handle(void) |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
483 { |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
484 static int handle; |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
485 |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
486 return &handle; |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
487 } |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
488 |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
489 void |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
490 gaim_notify_init(void) |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
491 { |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
492 gpointer handle = gaim_notify_get_handle(); |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
493 |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
494 gaim_signal_register(handle, "displaying-userinfo", |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
495 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3, |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
496 gaim_value_new(GAIM_TYPE_SUBTYPE, |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
497 GAIM_SUBTYPE_ACCOUNT), |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
498 gaim_value_new(GAIM_TYPE_STRING), |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
499 gaim_value_new_outgoing(GAIM_TYPE_STRING)); |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
500 } |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
501 |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
502 void |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
503 gaim_notify_uninit(void) |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
504 { |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
505 gaim_signals_unregister_by_instance(gaim_notify_get_handle()); |
216988c717da
[gaim-migrate @ 14429]
Richard Laager <rlaager@wiktel.com>
parents:
11533
diff
changeset
|
506 } |