Wed, 13 Aug 2003 16:31:57 +0000
[gaim-migrate @ 6959]
MMaking a comment about a check that, imho, is a bit ugly. We don't want to
have protocol-specific checks in core code if we can help it.
| 5437 | 1 | /** |
| 2 | * @file notify.h Notification API | |
| 3 | * @ingroup core | |
| 4 | * | |
| 5 | * gaim | |
| 6 | * | |
| 7 | * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
| 8 | * | |
| 9 | * This program is free software; you can redistribute it and/or modify | |
| 10 | * it under the terms of the GNU General Public License as published by | |
| 11 | * the Free Software Foundation; either version 2 of the License, or | |
| 12 | * (at your option) any later version. | |
| 13 | * | |
| 14 | * This program is distributed in the hope that it will be useful, | |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | * GNU General Public License for more details. | |
| 18 | * | |
| 19 | * You should have received a copy of the GNU General Public License | |
| 20 | * along with this program; if not, write to the Free Software | |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 | */ | |
| 23 | #ifndef _GAIM_NOTIFY_H_ | |
| 24 | #define _GAIM_NOTIFY_H_ | |
| 25 | ||
| 26 | #include <stdlib.h> | |
| 27 | #include <glib-object.h> | |
| 28 | #include <glib.h> | |
| 29 | ||
| 30 | /** | |
| 31 | * Notification types. | |
| 32 | */ | |
| 33 | typedef enum | |
| 34 | { | |
| 35 | GAIM_NOTIFY_MESSAGE = 0, /**< Message notification. */ | |
| 36 | GAIM_NOTIFY_EMAIL, /**< Single e-mail notification. */ | |
|
6381
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
37 | GAIM_NOTIFY_EMAILS, /**< Multiple e-mail notification. */ |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
38 | GAIM_NOTIFY_FORMATTED /**< Formatted text. */ |
| 5437 | 39 | |
| 40 | } GaimNotifyType; | |
| 41 | ||
| 42 | /** | |
| 43 | * Notification message types. | |
| 44 | */ | |
| 45 | typedef enum | |
| 46 | { | |
| 47 | GAIM_NOTIFY_MSG_ERROR = 0, /**< Error notification. */ | |
| 48 | GAIM_NOTIFY_MSG_WARNING, /**< Warning notification. */ | |
| 49 | GAIM_NOTIFY_MSG_INFO /**< Information notification. */ | |
| 50 | ||
| 51 | } GaimNotifyMsgType; | |
| 52 | ||
| 53 | /** | |
| 54 | * Notification UI operations. | |
| 55 | */ | |
| 56 | typedef struct | |
| 57 | { | |
| 58 | void *(*notify_message)(GaimNotifyMsgType type, const char *title, | |
| 59 | const char *primary, const char *secondary, | |
| 60 | GCallback cb, void *user_data); | |
| 61 | void *(*notify_email)(const char *subject, const char *from, | |
| 62 | const char *to, const char *url, | |
| 63 | GCallback cb, void *user_data); | |
|
5522
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
64 | void *(*notify_emails)(size_t count, gboolean detailed, |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
65 | const char **subjects, const char **froms, |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
66 | const char **tos, const char **urls, |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
67 | GCallback cb, void *user_data); |
|
6381
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
68 | void *(*notify_formatted)(const char *title, const char *primary, |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
69 | const char *secondary, const char *text, |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
70 | GCallback cb, void *user_data); |
| 5437 | 71 | |
|
5476
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
72 | void (*close_notify)(GaimNotifyType type, void *ui_handle); |
| 5437 | 73 | |
| 74 | } GaimNotifyUiOps; | |
| 75 | ||
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
76 | |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
77 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
78 | extern "C" { |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
79 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
80 | |
| 5437 | 81 | /**************************************************************************/ |
| 82 | /** @name Notification API */ | |
| 83 | /**************************************************************************/ | |
| 84 | /*@{*/ | |
| 85 | ||
| 86 | /** | |
| 87 | * Displays a notification message to the user. | |
| 88 | * | |
| 89 | * @param handle The plugin or connection handle. | |
| 90 | * @param type The notification type. | |
| 91 | * @param title The title of the message. | |
| 92 | * @param primary The main point of the message. | |
| 93 | * @param secondary The secondary information. | |
| 94 | * @param cb The callback to call when the user closes | |
| 95 | * the notification. | |
| 96 | * @param user_data The data to pass to the callback. | |
| 97 | * | |
| 98 | * @return A UI-specific handle. | |
| 99 | */ | |
|
6356
27990c4f9a9f
[gaim-migrate @ 6855]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
100 | void *gaim_notify_message(void *handle, GaimNotifyMsgType type, |
| 5437 | 101 | const char *title, const char *primary, |
| 102 | const char *secondary, GCallback cb, | |
| 103 | void *user_data); | |
| 104 | ||
| 105 | /** | |
| 106 | * Displays a single e-mail notification to the user. | |
| 107 | * | |
| 108 | * @param handle The plugin or connection handle. | |
| 109 | * @param subject The subject of the e-mail. | |
| 110 | * @param from The from address. | |
| 111 | * @param to The destination address. | |
| 112 | * @param url The URL where the message can be read. | |
| 113 | * @param cb The callback to call when the user closes | |
| 114 | * the notification. | |
| 115 | * @param user_data The data to pass to the callback. | |
| 116 | * | |
| 117 | * @return A UI-specific handle. | |
| 118 | */ | |
| 119 | void *gaim_notify_email(void *handle, const char *subject, | |
| 120 | const char *from, const char *to, | |
| 121 | const char *url, GCallback cb, | |
| 122 | void *user_data); | |
| 123 | ||
| 124 | /** | |
| 125 | * Displays a notification for multiple e-mails to the user. | |
| 126 | * | |
| 127 | * @param handle The plugin or connection handle. | |
| 128 | * @param count The number of e-mails. | |
|
5522
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
129 | * @param detailed @c TRUE if there is information for each e-mail in the |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
130 | * arrays. |
| 5437 | 131 | * @param subjects The array of subjects. |
| 132 | * @param froms The array of from addresses. | |
| 133 | * @param tos The array of destination addresses. | |
| 134 | * @param url The URLs where the messages can be read. | |
| 135 | * @param cb The callback to call when the user closes | |
| 136 | * the notification. | |
| 137 | * @param user_data The data to pass to the callback. | |
| 138 | * | |
| 139 | * @return A UI-specific handle. | |
| 140 | */ | |
|
5522
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
141 | void *gaim_notify_emails(void *handle, size_t count, gboolean detailed, |
| 5437 | 142 | const char **subjects, const char **froms, |
| 143 | const char **tos, const char **urls, | |
| 144 | GCallback cb, void *user_data); | |
| 145 | ||
| 146 | /** | |
|
6381
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
147 | * Displays a notification with formatted text. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
148 | * |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
149 | * The text is essentially a stripped-down format of HTML, the same that |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
150 | * IMs may send. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
151 | * |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
152 | * @param handle The plugin or connection handle. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
153 | * @param title The title of the message. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
154 | * @param primary The main point of the message. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
155 | * @param secondary The secondary information. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
156 | * @param text The formatted text. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
157 | * @param cb The callback to call when the user closes |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
158 | * the notification. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
159 | * |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
160 | * @return A UI-specific handle. |
|
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 | void *gaim_notify_formatted(void *handle, const char *title, |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
163 | const char *primary, const char *secondary, |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
164 | const char *text, GCallback cb, void *user_data); |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
165 | |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
166 | /** |
| 5437 | 167 | * Closes a notification. |
| 168 | * | |
| 169 | * This should be used only by the UI operation functions and part of the | |
| 170 | * core. | |
| 171 | * | |
|
5476
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
172 | * @param type The notification type. |
|
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
173 | * @param ui_handle The notification UI handle. |
| 5437 | 174 | */ |
|
5476
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
175 | void gaim_notify_close(GaimNotifyType type, void *ui_handle); |
| 5437 | 176 | |
| 177 | /** | |
| 178 | * Closes all notifications registered with the specified handle. | |
| 179 | * | |
| 180 | * @param handle The handle. | |
| 181 | */ | |
| 182 | void gaim_notify_close_with_handle(void *handle); | |
| 183 | ||
| 184 | /** | |
| 185 | * A wrapper for gaim_notify_message that displays an information message. | |
| 186 | */ | |
| 187 | #define gaim_notify_info(handle, title, primary, secondary) \ | |
| 188 | gaim_notify_message((handle), GAIM_NOTIFY_MSG_INFO, (title), \ | |
| 189 | (primary), (secondary), NULL, NULL) | |
| 190 | ||
| 191 | /** | |
| 192 | * A wrapper for gaim_notify_message that displays a warning message. | |
| 193 | */ | |
| 194 | #define gaim_notify_warning(handle, title, primary, secondary) \ | |
| 195 | gaim_notify_message((handle), GAIM_NOTIFY_MSG_WARNING, (title), \ | |
| 196 | (primary), (secondary), NULL, NULL) | |
| 197 | ||
| 198 | /** | |
| 199 | * A wrapper for gaim_notify_message that displays an error message. | |
| 200 | */ | |
| 201 | #define gaim_notify_error(handle, title, primary, secondary) \ | |
| 202 | gaim_notify_message((handle), GAIM_NOTIFY_MSG_ERROR, (title), \ | |
| 203 | (primary), (secondary), NULL, NULL) | |
| 204 | ||
| 205 | /*@}*/ | |
| 206 | ||
| 207 | /**************************************************************************/ | |
| 208 | /** @name UI Operations API */ | |
| 209 | /**************************************************************************/ | |
| 210 | /*@{*/ | |
| 211 | ||
| 212 | /** | |
| 213 | * Sets the UI operations structure to be used when displaying a | |
| 214 | * notification. | |
| 215 | * | |
| 216 | * @param ops The UI operations structure. | |
| 217 | */ | |
| 218 | void gaim_set_notify_ui_ops(GaimNotifyUiOps *ops); | |
| 219 | ||
| 220 | /** | |
| 221 | * Returns the UI operations structure to be used when displaying a | |
| 222 | * notification. | |
| 223 | * | |
| 224 | * @param ops The UI operations structure. | |
| 225 | */ | |
| 226 | GaimNotifyUiOps *gaim_get_notify_ui_ops(void); | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
227 | |
|
5497
da3c08f3af25
[gaim-migrate @ 5893]
Mark Doliner <markdoliner@pidgin.im>
parents:
5476
diff
changeset
|
228 | /*@}*/ |
| 5437 | 229 | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
230 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
231 | } |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
232 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
233 | |
| 5437 | 234 | #endif /* _GAIM_NOTIFY_H_ */ |