Thu, 01 Dec 2005 21:13:48 +0000
[gaim-migrate @ 14590]
Mostly whitespace, but a couple small typo fixes, and an A;B -> B;A; swap to
be consistent in plugins/notify.c
| 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
bd201d637ff4
[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
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
34 | void *ui_handle; |
|
12242
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
35 | GaimNotifyCloseCallback cb; |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
36 | gpointer cb_user_data; |
| 5437 | 37 | } GaimNotifyInfo; |
| 38 | ||
| 39 | void * | |
|
6356
27990c4f9a9f
[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
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
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
76bca80cd91d
[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
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
53 | info = g_new0(GaimNotifyInfo, 1); |
|
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
54 | info->type = GAIM_NOTIFY_MESSAGE; |
|
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
55 | info->handle = handle; |
|
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
56 | info->ui_handle = ops->notify_message(type, title, primary, |
|
12242
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
57 | secondary); |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
58 | info->cb = cb; |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
59 | info->cb_user_data = user_data; |
| 5437 | 60 | |
| 61 | handles = g_list_append(handles, info); | |
| 62 | ||
|
5476
6f863ea68018
[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
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
71 | const char *to, const char *url, GaimNotifyCloseCallback cb, |
| 12220 | 72 | gpointer user_data) |
| 5437 | 73 | { |
| 74 | GaimNotifyUiOps *ops; | |
| 75 | ||
|
7035
76bca80cd91d
[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
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
81 | info = g_new0(GaimNotifyInfo, 1); |
|
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
82 | info->type = GAIM_NOTIFY_EMAIL; |
|
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
83 | info->handle = handle; |
|
12242
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
84 | info->ui_handle = ops->notify_email(subject, from, to, url); |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
85 | info->cb = cb; |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
86 | info->cb_user_data = user_data; |
| 5437 | 87 | |
| 88 | handles = g_list_append(handles, info); | |
| 89 | ||
|
5476
6f863ea68018
[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
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
97 | gaim_notify_emails(void *handle, size_t count, gboolean detailed, |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
98 | const char **subjects, const char **froms, |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
99 | const char **tos, const char **urls, |
|
12242
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
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
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
106 | if (count == 1) { |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
107 | return gaim_notify_email(handle, |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
108 | (subjects == NULL ? NULL : *subjects), |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
109 | (froms == NULL ? NULL : *froms), |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
110 | (tos == NULL ? NULL : *tos), |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
111 | (urls == NULL ? NULL : *urls), |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
112 | cb, user_data); |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
113 | } |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
114 | |
|
7035
76bca80cd91d
[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
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
120 | info = g_new0(GaimNotifyInfo, 1); |
|
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
121 | info->type = GAIM_NOTIFY_EMAILS; |
|
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
122 | info->handle = handle; |
|
5522
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5476
diff
changeset
|
123 | info->ui_handle = ops->notify_emails(count, detailed, subjects, |
|
12242
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
124 | froms, tos, urls); |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
125 | info->cb = cb; |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
126 | info->cb_user_data = user_data; |
| 5437 | 127 | |
| 128 | handles = g_list_append(handles, info); | |
| 129 | ||
|
5476
6f863ea68018
[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
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
136 | void * |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
137 | gaim_notify_formatted(void *handle, const char *title, const char *primary, |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
138 | const char *secondary, const char *text, |
|
12242
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
139 | GaimNotifyCloseCallback cb, gpointer user_data) |
|
6381
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
140 | { |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
141 | GaimNotifyUiOps *ops; |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
142 | |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
143 | g_return_val_if_fail(primary != NULL, NULL); |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
144 | |
|
7035
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
145 | ops = gaim_notify_get_ui_ops(); |
|
6381
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
146 | |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
147 | if (ops != NULL && ops->notify_formatted != NULL) { |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
148 | GaimNotifyInfo *info; |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
149 | |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
150 | info = g_new0(GaimNotifyInfo, 1); |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
151 | info->type = GAIM_NOTIFY_FORMATTED; |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
152 | info->handle = handle; |
|
12242
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
153 | info->ui_handle = ops->notify_formatted(title, primary, secondary, text); |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
154 | info->cb = cb; |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
155 | info->cb_user_data = user_data; |
|
6381
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
156 | |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
157 | handles = g_list_append(handles, info); |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
158 | |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
159 | return info->ui_handle; |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
160 | } |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
161 | |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
162 | return NULL; |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
163 | } |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
164 | |
|
10439
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
165 | void * |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
166 | gaim_notify_searchresults(GaimConnection *gc, const char *title, |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
167 | const char *primary, const char *secondary, |
|
12242
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
168 | GaimNotifySearchResults *results, GaimNotifyCloseCallback cb, gpointer user_data) |
|
10439
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
169 | { |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
170 | GaimNotifyUiOps *ops; |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
171 | |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
172 | ops = gaim_notify_get_ui_ops(); |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
173 | |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
174 | if (ops != NULL && ops->notify_searchresults != NULL) { |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
175 | GaimNotifyInfo *info; |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
176 | |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
177 | info = g_new0(GaimNotifyInfo, 1); |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
178 | info->type = GAIM_NOTIFY_SEARCHRESULTS; |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
179 | info->handle = gc; |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
180 | info->ui_handle = ops->notify_searchresults(gc, title, primary, |
|
12242
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
181 | secondary, results); |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
182 | info->cb = cb; |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
183 | info->cb_user_data = user_data; |
|
10439
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
184 | |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
185 | handles = g_list_append(handles, info); |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
186 | |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
187 | return info->ui_handle; |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
188 | } |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
189 | |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
190 | return NULL; |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
191 | } |
|
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
192 | |
| 11359 | 193 | void |
| 194 | gaim_notify_searchresults_free(GaimNotifySearchResults *results) | |
| 195 | { | |
| 196 | GList *l, *m; | |
| 197 | ||
| 198 | g_return_if_fail(results != NULL); | |
| 199 | ||
| 200 | for (l = results->buttons; l != NULL; l = l->next) { | |
| 201 | GaimNotifySearchButton *button = l->data; | |
| 202 | ||
| 203 | results->buttons = g_list_remove(results->buttons, button); | |
| 204 | g_free(button); | |
| 205 | } | |
| 206 | g_list_free(results->buttons); | |
| 207 | ||
| 208 | for (l = results->rows; l != NULL; l = l->next) { | |
| 209 | GList *row = l->data; | |
| 210 | ||
| 211 | for (m = row; m != NULL; m = m->next) { | |
| 212 | gchar *str = m->data; | |
| 213 | ||
| 214 | m = g_list_remove(m, str); | |
| 215 | g_free(str); | |
| 216 | } | |
| 217 | ||
| 218 | results->rows = g_list_remove(results->rows, row); | |
| 219 | g_list_free(row); | |
| 220 | } | |
| 221 | g_list_free(results->rows); | |
| 222 | ||
| 223 | for (l = results->columns; l != NULL; l = l->next) { | |
| 224 | GaimNotifySearchColumn *column = l->data; | |
| 225 | ||
| 226 | results->columns = g_list_remove(results->columns, column); | |
| 227 | g_free(column->title); | |
| 228 | g_free(column); | |
| 229 | } | |
| 230 | g_list_free(results->columns); | |
| 231 | } | |
| 232 | ||
| 233 | void | |
| 234 | gaim_notify_searchresults_new_rows(GaimConnection *gc, | |
| 235 | GaimNotifySearchResults *results, | |
| 12220 | 236 | void *data, gpointer user_data) |
| 11359 | 237 | { |
| 238 | GaimNotifyUiOps *ops; | |
| 239 | ||
| 240 | ops = gaim_notify_get_ui_ops(); | |
| 241 | ||
| 242 | if (ops != NULL && ops->notify_searchresults != NULL) { | |
| 243 | ops->notify_searchresults_new_rows(gc, results, data, user_data); | |
| 244 | } | |
| 245 | } | |
| 246 | ||
| 247 | void | |
| 248 | gaim_notify_searchresults_button_add(GaimNotifySearchResults *results, | |
| 249 | GaimNotifySearchButtonType type, | |
| 250 | GaimNotifySearchResultsCallback cb) | |
| 251 | { | |
| 252 | GaimNotifySearchButton *button; | |
| 253 | ||
| 254 | g_return_if_fail(results != NULL); | |
| 255 | g_return_if_fail(cb != NULL); | |
| 256 | ||
| 257 | button = g_new0(GaimNotifySearchButton, 1); | |
| 258 | button->callback = cb; | |
| 259 | button->type = type; | |
| 260 | ||
| 261 | results->buttons = g_list_append(results->buttons, button); | |
| 262 | } | |
| 263 | ||
| 264 | GaimNotifySearchResults * | |
| 265 | gaim_notify_searchresults_new() | |
| 266 | { | |
| 267 | GaimNotifySearchResults *rs = g_new0(GaimNotifySearchResults, 1); | |
| 268 | ||
| 269 | return rs; | |
| 270 | } | |
| 271 | ||
| 272 | void | |
| 273 | gaim_notify_searchresults_column_add(GaimNotifySearchResults *results, | |
| 274 | GaimNotifySearchColumn *column) | |
| 275 | { | |
| 276 | g_return_if_fail(results != NULL); | |
| 277 | g_return_if_fail(column != NULL); | |
| 278 | ||
| 279 | results->columns = g_list_append(results->columns, column); | |
| 280 | } | |
| 281 | ||
| 282 | void gaim_notify_searchresults_row_add(GaimNotifySearchResults *results, | |
| 283 | GList *row) | |
| 284 | { | |
| 285 | g_return_if_fail(results != NULL); | |
| 286 | g_return_if_fail(row != NULL); | |
| 287 | ||
| 288 | results->rows = g_list_append(results->rows, row); | |
| 289 | } | |
| 290 | ||
| 291 | GaimNotifySearchColumn * | |
| 292 | gaim_notify_searchresults_column_new(const char *title) | |
| 293 | { | |
| 294 | GaimNotifySearchColumn *sc; | |
| 295 | ||
| 296 | g_return_val_if_fail(title != NULL, NULL); | |
| 297 | ||
| 298 | sc = g_new0(GaimNotifySearchColumn, 1); | |
| 299 | sc->title = g_strdup(title); | |
| 300 | ||
| 301 | return sc; | |
| 302 | } | |
| 303 | ||
| 12257 | 304 | guint |
| 11359 | 305 | gaim_notify_searchresults_get_columns_count(GaimNotifySearchResults *results) |
| 306 | { | |
| 12257 | 307 | g_return_val_if_fail(results != NULL, 0); |
| 11359 | 308 | |
| 309 | return g_list_length(results->columns); | |
| 310 | } | |
| 311 | ||
| 12257 | 312 | guint |
| 11359 | 313 | gaim_notify_searchresults_get_rows_count(GaimNotifySearchResults *results) |
| 314 | { | |
| 12257 | 315 | g_return_val_if_fail(results != NULL, 0); |
| 11359 | 316 | |
| 317 | return g_list_length(results->rows); | |
| 318 | } | |
| 319 | ||
| 320 | char * | |
| 321 | gaim_notify_searchresults_column_get_title(GaimNotifySearchResults *results, | |
| 322 | unsigned int column_id) | |
| 323 | { | |
| 324 | g_return_val_if_fail(results != NULL, NULL); | |
| 325 | ||
| 326 | return ((GaimNotifySearchColumn *)g_list_nth_data(results->columns, column_id))->title; | |
| 327 | } | |
| 328 | ||
| 329 | GList * | |
| 330 | gaim_notify_searchresults_row_get(GaimNotifySearchResults *results, | |
| 331 | unsigned int row_id) | |
| 332 | { | |
| 333 | g_return_val_if_fail(results != NULL, NULL); | |
| 334 | ||
| 335 | return g_list_nth_data(results->rows, row_id); | |
| 336 | } | |
| 337 | ||
|
10439
5868d8f55fb1
[gaim-migrate @ 11697]
Alex Converse <alex.converse@gmail.com>
parents:
10240
diff
changeset
|
338 | void * |
|
11531
63c017cfd8d2
[gaim-migrate @ 13780]
Luke Schierer <lschiere@pidgin.im>
parents:
11359
diff
changeset
|
339 | gaim_notify_userinfo(GaimConnection *gc, const char *who, |
|
12242
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
340 | const char *text, GaimNotifyCloseCallback cb, gpointer user_data) |
| 9797 | 341 | { |
| 342 | GaimNotifyUiOps *ops; | |
|
11531
63c017cfd8d2
[gaim-migrate @ 13780]
Luke Schierer <lschiere@pidgin.im>
parents:
11359
diff
changeset
|
343 | |
|
11533
f58436975d44
[gaim-migrate @ 13782]
Richard Laager <rlaager@pidgin.im>
parents:
11531
diff
changeset
|
344 | g_return_val_if_fail(who != NULL, NULL); |
| 9797 | 345 | |
| 346 | ops = gaim_notify_get_ui_ops(); | |
| 347 | ||
| 348 | if (ops != NULL && ops->notify_userinfo != NULL) { | |
| 349 | GaimNotifyInfo *info; | |
| 12129 | 350 | char *infotext = g_strdup(text); |
| 9797 | 351 | |
| 352 | info = g_new0(GaimNotifyInfo, 1); | |
| 353 | info->type = GAIM_NOTIFY_USERINFO; | |
| 354 | info->handle = gc; | |
| 12129 | 355 | |
| 356 | gaim_signal_emit(gaim_notify_get_handle(), "displaying-userinfo", | |
| 357 | gaim_connection_get_account(gc), who, &infotext); | |
| 358 | ||
|
12242
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
359 | info->ui_handle = ops->notify_userinfo(gc, who, infotext); |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
360 | info->cb = cb; |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
361 | info->cb_user_data = user_data; |
| 9797 | 362 | |
| 363 | handles = g_list_append(handles, info); | |
| 364 | ||
| 12129 | 365 | g_free(infotext); |
| 9797 | 366 | return info->ui_handle; |
| 367 | } | |
| 368 | ||
| 369 | return NULL; | |
| 370 | } | |
| 371 | ||
|
6465
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
372 | void * |
|
10240
09342bc554d9
[gaim-migrate @ 11377]
Herman Bloggs <herman@bluedigits.com>
parents:
10209
diff
changeset
|
373 | gaim_notify_uri(void *handle, const char *uri) |
|
6465
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
374 | { |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
375 | GaimNotifyUiOps *ops; |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
376 | |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
377 | g_return_val_if_fail(uri != NULL, NULL); |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
378 | |
|
7035
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
379 | ops = gaim_notify_get_ui_ops(); |
|
6465
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
380 | |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
381 | if (ops != NULL && ops->notify_uri != NULL) { |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
382 | GaimNotifyInfo *info; |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
383 | |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
384 | info = g_new0(GaimNotifyInfo, 1); |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
385 | info->type = GAIM_NOTIFY_URI; |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
386 | info->handle = handle; |
|
10240
09342bc554d9
[gaim-migrate @ 11377]
Herman Bloggs <herman@bluedigits.com>
parents:
10209
diff
changeset
|
387 | info->ui_handle = ops->notify_uri(uri); |
|
6465
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
388 | |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
389 | handles = g_list_append(handles, info); |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
390 | |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
391 | return info->ui_handle; |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
392 | } |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
393 | |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
394 | return NULL; |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
395 | } |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
396 | |
| 5437 | 397 | void |
|
5476
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
398 | gaim_notify_close(GaimNotifyType type, void *ui_handle) |
| 5437 | 399 | { |
| 400 | GList *l; | |
| 401 | GaimNotifyUiOps *ops; | |
| 402 | ||
|
5476
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
403 | g_return_if_fail(ui_handle != NULL); |
| 5437 | 404 | |
|
7035
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
405 | ops = gaim_notify_get_ui_ops(); |
| 5437 | 406 | |
| 407 | for (l = handles; l != NULL; l = l->next) { | |
| 408 | GaimNotifyInfo *info = l->data; | |
| 409 | ||
|
5476
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
410 | if (info->ui_handle == ui_handle) { |
| 5437 | 411 | handles = g_list_remove(handles, info); |
| 412 | ||
| 413 | if (ops != NULL && ops->close_notify != NULL) | |
|
5476
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
414 | ops->close_notify(info->type, ui_handle); |
| 5437 | 415 | |
|
12242
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
416 | if (info->cb != NULL) |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
417 | info->cb(info->cb_user_data); |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
418 | |
| 5437 | 419 | g_free(info); |
| 420 | ||
| 421 | break; | |
| 422 | } | |
| 423 | } | |
| 424 | } | |
| 425 | ||
| 426 | void | |
| 427 | gaim_notify_close_with_handle(void *handle) | |
| 428 | { | |
| 429 | GList *l, *l_next; | |
| 430 | GaimNotifyUiOps *ops; | |
| 431 | ||
| 432 | g_return_if_fail(handle != NULL); | |
| 433 | ||
|
7035
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
434 | ops = gaim_notify_get_ui_ops(); |
| 5437 | 435 | |
| 436 | for (l = handles; l != NULL; l = l_next) { | |
| 437 | GaimNotifyInfo *info = l->data; | |
| 438 | ||
| 439 | l_next = l->next; | |
| 440 | ||
| 441 | if (info->handle == handle) { | |
| 442 | handles = g_list_remove(handles, info); | |
| 443 | ||
| 444 | if (ops != NULL && ops->close_notify != NULL) | |
|
5476
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
445 | ops->close_notify(info->type, info->ui_handle); |
| 5437 | 446 | |
|
12242
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
447 | if (info->cb != NULL) |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
448 | info->cb(info->cb_user_data); |
|
e7fc1748eb56
[gaim-migrate @ 14544]
Richard Laager <rlaager@pidgin.im>
parents:
12220
diff
changeset
|
449 | |
| 5437 | 450 | g_free(info); |
| 451 | } | |
| 452 | } | |
| 453 | } | |
| 454 | ||
| 455 | void | |
|
7035
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
456 | gaim_notify_set_ui_ops(GaimNotifyUiOps *ops) |
| 5437 | 457 | { |
| 458 | notify_ui_ops = ops; | |
| 459 | } | |
| 460 | ||
| 461 | GaimNotifyUiOps * | |
|
7035
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
462 | gaim_notify_get_ui_ops(void) |
| 5437 | 463 | { |
| 464 | return notify_ui_ops; | |
| 465 | } | |
| 12129 | 466 | |
| 467 | void * | |
| 468 | gaim_notify_get_handle(void) | |
| 469 | { | |
| 470 | static int handle; | |
| 471 | ||
| 472 | return &handle; | |
| 473 | } | |
| 474 | ||
| 475 | void | |
| 476 | gaim_notify_init(void) | |
| 477 | { | |
| 478 | gpointer handle = gaim_notify_get_handle(); | |
| 479 | ||
| 480 | gaim_signal_register(handle, "displaying-userinfo", | |
| 481 | gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3, | |
| 482 | gaim_value_new(GAIM_TYPE_SUBTYPE, | |
| 483 | GAIM_SUBTYPE_ACCOUNT), | |
| 484 | gaim_value_new(GAIM_TYPE_STRING), | |
| 485 | gaim_value_new_outgoing(GAIM_TYPE_STRING)); | |
| 486 | } | |
| 487 | ||
| 488 | void | |
| 489 | gaim_notify_uninit(void) | |
| 490 | { | |
| 491 | gaim_signals_unregister_by_instance(gaim_notify_get_handle()); | |
| 492 | } |