comparison src/notify.c @ 12242:976677e67239

[gaim-migrate @ 14544] Rework the notify API close callbacks. They are now called by the core, instead of the UI. Prior to a couple days ago, they weren't actually implemented in the UI at all. As a side note, if anyone knows why gpointer is declared as a T_GaimObj instead of a T_PTR, please let me know. That seems wrong, especially since void * is a T_PTR and gconstpointer is a T_PTR. This may or may not cause problems for the notify change (void * -> gpointer) to user_data. NOTE: I did not change this, even though I think it's wrong. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 28 Nov 2005 01:50:56 +0000
parents 64254fbabc7b
children ca27de274225
comparison
equal deleted inserted replaced
12241:4777c5912068 12242:976677e67239
30 typedef struct 30 typedef struct
31 { 31 {
32 GaimNotifyType type; 32 GaimNotifyType type;
33 void *handle; 33 void *handle;
34 void *ui_handle; 34 void *ui_handle;
35 35 GaimNotifyCloseCallback cb;
36 gpointer cb_user_data;
36 } GaimNotifyInfo; 37 } GaimNotifyInfo;
37 38
38 void * 39 void *
39 gaim_notify_message(void *handle, GaimNotifyMsgType type, 40 gaim_notify_message(void *handle, GaimNotifyMsgType type,
40 const char *title, const char *primary, 41 const char *title, const char *primary,
41 const char *secondary, GHookFunc cb, gpointer user_data) 42 const char *secondary, GaimNotifyCloseCallback cb, gpointer user_data)
42 { 43 {
43 GaimNotifyUiOps *ops; 44 GaimNotifyUiOps *ops;
44 45
45 g_return_val_if_fail(primary != NULL, NULL); 46 g_return_val_if_fail(primary != NULL, NULL);
46 47
51 52
52 info = g_new0(GaimNotifyInfo, 1); 53 info = g_new0(GaimNotifyInfo, 1);
53 info->type = GAIM_NOTIFY_MESSAGE; 54 info->type = GAIM_NOTIFY_MESSAGE;
54 info->handle = handle; 55 info->handle = handle;
55 info->ui_handle = ops->notify_message(type, title, primary, 56 info->ui_handle = ops->notify_message(type, title, primary,
56 secondary, cb, user_data); 57 secondary);
58 info->cb = cb;
59 info->cb_user_data = user_data;
57 60
58 handles = g_list_append(handles, info); 61 handles = g_list_append(handles, info);
59 62
60 return info->ui_handle; 63 return info->ui_handle;
61 } 64 }
63 return NULL; 66 return NULL;
64 } 67 }
65 68
66 void * 69 void *
67 gaim_notify_email(void *handle, const char *subject, const char *from, 70 gaim_notify_email(void *handle, const char *subject, const char *from,
68 const char *to, const char *url, GHookFunc cb, 71 const char *to, const char *url, GaimNotifyCloseCallback cb,
69 gpointer user_data) 72 gpointer user_data)
70 { 73 {
71 GaimNotifyUiOps *ops; 74 GaimNotifyUiOps *ops;
72 75
73 ops = gaim_notify_get_ui_ops(); 76 ops = gaim_notify_get_ui_ops();
76 GaimNotifyInfo *info; 79 GaimNotifyInfo *info;
77 80
78 info = g_new0(GaimNotifyInfo, 1); 81 info = g_new0(GaimNotifyInfo, 1);
79 info->type = GAIM_NOTIFY_EMAIL; 82 info->type = GAIM_NOTIFY_EMAIL;
80 info->handle = handle; 83 info->handle = handle;
81 info->ui_handle = ops->notify_email(subject, from, to, url, cb, 84 info->ui_handle = ops->notify_email(subject, from, to, url);
82 user_data); 85 info->cb = cb;
86 info->cb_user_data = user_data;
83 87
84 handles = g_list_append(handles, info); 88 handles = g_list_append(handles, info);
85 89
86 return info->ui_handle; 90 return info->ui_handle;
87 } 91 }
91 95
92 void * 96 void *
93 gaim_notify_emails(void *handle, size_t count, gboolean detailed, 97 gaim_notify_emails(void *handle, size_t count, gboolean detailed,
94 const char **subjects, const char **froms, 98 const char **subjects, const char **froms,
95 const char **tos, const char **urls, 99 const char **tos, const char **urls,
96 GHookFunc cb, gpointer user_data) 100 GaimNotifyCloseCallback cb, gpointer user_data)
97 { 101 {
98 GaimNotifyUiOps *ops; 102 GaimNotifyUiOps *ops;
99 103
100 g_return_val_if_fail(count != 0, NULL); 104 g_return_val_if_fail(count != 0, NULL);
101 105
115 119
116 info = g_new0(GaimNotifyInfo, 1); 120 info = g_new0(GaimNotifyInfo, 1);
117 info->type = GAIM_NOTIFY_EMAILS; 121 info->type = GAIM_NOTIFY_EMAILS;
118 info->handle = handle; 122 info->handle = handle;
119 info->ui_handle = ops->notify_emails(count, detailed, subjects, 123 info->ui_handle = ops->notify_emails(count, detailed, subjects,
120 froms, tos, urls, cb, user_data); 124 froms, tos, urls);
125 info->cb = cb;
126 info->cb_user_data = user_data;
121 127
122 handles = g_list_append(handles, info); 128 handles = g_list_append(handles, info);
123 129
124 return info->ui_handle; 130 return info->ui_handle;
125 } 131 }
128 } 134 }
129 135
130 void * 136 void *
131 gaim_notify_formatted(void *handle, const char *title, const char *primary, 137 gaim_notify_formatted(void *handle, const char *title, const char *primary,
132 const char *secondary, const char *text, 138 const char *secondary, const char *text,
133 GHookFunc cb, gpointer user_data) 139 GaimNotifyCloseCallback cb, gpointer user_data)
134 { 140 {
135 GaimNotifyUiOps *ops; 141 GaimNotifyUiOps *ops;
136 142
137 g_return_val_if_fail(primary != NULL, NULL); 143 g_return_val_if_fail(primary != NULL, NULL);
138 144
142 GaimNotifyInfo *info; 148 GaimNotifyInfo *info;
143 149
144 info = g_new0(GaimNotifyInfo, 1); 150 info = g_new0(GaimNotifyInfo, 1);
145 info->type = GAIM_NOTIFY_FORMATTED; 151 info->type = GAIM_NOTIFY_FORMATTED;
146 info->handle = handle; 152 info->handle = handle;
147 info->ui_handle = ops->notify_formatted(title, primary, secondary, 153 info->ui_handle = ops->notify_formatted(title, primary, secondary, text);
148 text, cb, user_data); 154 info->cb = cb;
155 info->cb_user_data = user_data;
149 156
150 handles = g_list_append(handles, info); 157 handles = g_list_append(handles, info);
151 158
152 return info->ui_handle; 159 return info->ui_handle;
153 } 160 }
156 } 163 }
157 164
158 void * 165 void *
159 gaim_notify_searchresults(GaimConnection *gc, const char *title, 166 gaim_notify_searchresults(GaimConnection *gc, const char *title,
160 const char *primary, const char *secondary, 167 const char *primary, const char *secondary,
161 GaimNotifySearchResults *results, GHookFunc cb, gpointer user_data) 168 GaimNotifySearchResults *results, GaimNotifyCloseCallback cb, gpointer user_data)
162 { 169 {
163 GaimNotifyUiOps *ops; 170 GaimNotifyUiOps *ops;
164 171
165 ops = gaim_notify_get_ui_ops(); 172 ops = gaim_notify_get_ui_ops();
166 173
169 176
170 info = g_new0(GaimNotifyInfo, 1); 177 info = g_new0(GaimNotifyInfo, 1);
171 info->type = GAIM_NOTIFY_SEARCHRESULTS; 178 info->type = GAIM_NOTIFY_SEARCHRESULTS;
172 info->handle = gc; 179 info->handle = gc;
173 info->ui_handle = ops->notify_searchresults(gc, title, primary, 180 info->ui_handle = ops->notify_searchresults(gc, title, primary,
174 secondary, results, 181 secondary, results);
175 cb, user_data); 182 info->cb = cb;
183 info->cb_user_data = user_data;
176 184
177 handles = g_list_append(handles, info); 185 handles = g_list_append(handles, info);
178 186
179 return info->ui_handle; 187 return info->ui_handle;
180 } 188 }
327 return g_list_nth_data(results->rows, row_id); 335 return g_list_nth_data(results->rows, row_id);
328 } 336 }
329 337
330 void * 338 void *
331 gaim_notify_userinfo(GaimConnection *gc, const char *who, 339 gaim_notify_userinfo(GaimConnection *gc, const char *who,
332 const char *text, GHookFunc cb, gpointer user_data) 340 const char *text, GaimNotifyCloseCallback cb, gpointer user_data)
333 { 341 {
334 GaimNotifyUiOps *ops; 342 GaimNotifyUiOps *ops;
335 343
336 g_return_val_if_fail(who != NULL, NULL); 344 g_return_val_if_fail(who != NULL, NULL);
337 345
346 info->handle = gc; 354 info->handle = gc;
347 355
348 gaim_signal_emit(gaim_notify_get_handle(), "displaying-userinfo", 356 gaim_signal_emit(gaim_notify_get_handle(), "displaying-userinfo",
349 gaim_connection_get_account(gc), who, &infotext); 357 gaim_connection_get_account(gc), who, &infotext);
350 358
351 info->ui_handle = ops->notify_userinfo(gc, who, 359 info->ui_handle = ops->notify_userinfo(gc, who, infotext);
352 infotext, cb, user_data); 360 info->cb = cb;
361 info->cb_user_data = user_data;
353 362
354 handles = g_list_append(handles, info); 363 handles = g_list_append(handles, info);
355 364
356 g_free(infotext); 365 g_free(infotext);
357 return info->ui_handle; 366 return info->ui_handle;
402 handles = g_list_remove(handles, info); 411 handles = g_list_remove(handles, info);
403 412
404 if (ops != NULL && ops->close_notify != NULL) 413 if (ops != NULL && ops->close_notify != NULL)
405 ops->close_notify(info->type, ui_handle); 414 ops->close_notify(info->type, ui_handle);
406 415
416 if (info->cb != NULL)
417 info->cb(info->cb_user_data);
418
407 g_free(info); 419 g_free(info);
408 420
409 break; 421 break;
410 } 422 }
411 } 423 }
429 if (info->handle == handle) { 441 if (info->handle == handle) {
430 handles = g_list_remove(handles, info); 442 handles = g_list_remove(handles, info);
431 443
432 if (ops != NULL && ops->close_notify != NULL) 444 if (ops != NULL && ops->close_notify != NULL)
433 ops->close_notify(info->type, info->ui_handle); 445 ops->close_notify(info->type, info->ui_handle);
446
447 if (info->cb != NULL)
448 info->cb(info->cb_user_data);
434 449
435 g_free(info); 450 g_free(info);
436 } 451 }
437 } 452 }
438 } 453 }