Sun, 23 May 2004 22:17:38 +0000
[gaim-migrate @ 9821]
nosnilmot wrote:
" This patch prevents turning strings with '@' in them
into mailto: links if they are not valid email addresses.
An example would be copying from a shell something like:
[user@host dir]$ thing
would create a mailto link to "[user@host"
It adds a gaim_email_is_valid function to util.c which
could also be used elsewhere :)
Thanks to Alver on #gaim for reporting this buglet."
And also said:
"Updated patch attached, tested against 86,171 valid email
addresses and as many invalid addresses as I could make up"
committer: Tim Ringenbach <marv@pidgin.im>
| 5437 | 1 | /** |
| 2 | * @file notify.h 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 | #ifndef _GAIM_NOTIFY_H_ | |
| 26 | #define _GAIM_NOTIFY_H_ | |
| 27 | ||
| 28 | #include <stdlib.h> | |
| 29 | #include <glib-object.h> | |
| 30 | #include <glib.h> | |
| 31 | ||
| 32 | /** | |
| 33 | * Notification types. | |
| 34 | */ | |
| 35 | typedef enum | |
| 36 | { | |
| 37 | GAIM_NOTIFY_MESSAGE = 0, /**< Message notification. */ | |
| 38 | GAIM_NOTIFY_EMAIL, /**< Single e-mail notification. */ | |
|
6381
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
39 | GAIM_NOTIFY_EMAILS, /**< Multiple e-mail notification. */ |
|
6465
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
40 | GAIM_NOTIFY_FORMATTED, /**< Formatted text. */ |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
41 | GAIM_NOTIFY_URI /**< URI notification or display. */ |
| 5437 | 42 | |
| 43 | } GaimNotifyType; | |
| 44 | ||
| 45 | /** | |
| 46 | * Notification message types. | |
| 47 | */ | |
| 48 | typedef enum | |
| 49 | { | |
| 50 | GAIM_NOTIFY_MSG_ERROR = 0, /**< Error notification. */ | |
| 51 | GAIM_NOTIFY_MSG_WARNING, /**< Warning notification. */ | |
| 52 | GAIM_NOTIFY_MSG_INFO /**< Information notification. */ | |
| 53 | ||
| 54 | } GaimNotifyMsgType; | |
| 55 | ||
| 56 | /** | |
| 57 | * Notification UI operations. | |
| 58 | */ | |
| 59 | typedef struct | |
| 60 | { | |
| 61 | void *(*notify_message)(GaimNotifyMsgType type, const char *title, | |
| 62 | const char *primary, const char *secondary, | |
| 63 | GCallback cb, void *user_data); | |
| 64 | void *(*notify_email)(const char *subject, const char *from, | |
| 65 | const char *to, const char *url, | |
| 66 | GCallback cb, void *user_data); | |
|
5522
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
67 | void *(*notify_emails)(size_t count, gboolean detailed, |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
68 | const char **subjects, const char **froms, |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
69 | const char **tos, const char **urls, |
|
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
70 | GCallback cb, void *user_data); |
|
6381
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
71 | void *(*notify_formatted)(const char *title, const char *primary, |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
72 | const char *secondary, const char *text, |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
73 | GCallback cb, void *user_data); |
|
6465
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
74 | void *(*notify_uri)(const char *uri); |
| 5437 | 75 | |
|
5476
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
76 | void (*close_notify)(GaimNotifyType type, void *ui_handle); |
| 5437 | 77 | |
| 78 | } GaimNotifyUiOps; | |
| 79 | ||
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
80 | |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
81 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
82 | extern "C" { |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
83 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
84 | |
| 5437 | 85 | /**************************************************************************/ |
| 86 | /** @name Notification API */ | |
| 87 | /**************************************************************************/ | |
| 88 | /*@{*/ | |
| 89 | ||
| 90 | /** | |
| 91 | * Displays a notification message to the user. | |
| 92 | * | |
| 93 | * @param handle The plugin or connection handle. | |
| 94 | * @param type The notification type. | |
| 95 | * @param title The title of the message. | |
| 96 | * @param primary The main point of the message. | |
| 97 | * @param secondary The secondary information. | |
| 98 | * @param cb The callback to call when the user closes | |
| 99 | * the notification. | |
| 100 | * @param user_data The data to pass to the callback. | |
| 101 | * | |
| 102 | * @return A UI-specific handle. | |
| 103 | */ | |
|
6356
27990c4f9a9f
[gaim-migrate @ 6855]
Christian Hammond <chipx86@chipx86.com>
parents:
5944
diff
changeset
|
104 | void *gaim_notify_message(void *handle, GaimNotifyMsgType type, |
| 5437 | 105 | const char *title, const char *primary, |
| 106 | const char *secondary, GCallback cb, | |
| 107 | void *user_data); | |
| 108 | ||
| 109 | /** | |
| 110 | * Displays a single e-mail notification to the user. | |
| 111 | * | |
| 112 | * @param handle The plugin or connection handle. | |
| 113 | * @param subject The subject of the e-mail. | |
| 114 | * @param from The from address. | |
| 115 | * @param to The destination address. | |
| 116 | * @param url The URL where the message can be read. | |
| 117 | * @param cb The callback to call when the user closes | |
| 118 | * the notification. | |
| 119 | * @param user_data The data to pass to the callback. | |
| 120 | * | |
| 121 | * @return A UI-specific handle. | |
| 122 | */ | |
| 123 | void *gaim_notify_email(void *handle, const char *subject, | |
| 124 | const char *from, const char *to, | |
| 125 | const char *url, GCallback cb, | |
| 126 | void *user_data); | |
| 127 | ||
| 128 | /** | |
| 129 | * Displays a notification for multiple e-mails to the user. | |
| 130 | * | |
| 131 | * @param handle The plugin or connection handle. | |
| 132 | * @param count The number of e-mails. | |
|
5522
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
133 | * @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
|
134 | * arrays. |
| 5437 | 135 | * @param subjects The array of subjects. |
| 136 | * @param froms The array of from addresses. | |
| 137 | * @param tos The array of destination addresses. | |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6467
diff
changeset
|
138 | * @param urls The URLs where the messages can be read. |
| 5437 | 139 | * @param cb The callback to call when the user closes |
| 140 | * the notification. | |
| 141 | * @param user_data The data to pass to the callback. | |
| 142 | * | |
| 143 | * @return A UI-specific handle. | |
| 144 | */ | |
|
5522
faa69c8f503d
[gaim-migrate @ 5922]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
145 | void *gaim_notify_emails(void *handle, size_t count, gboolean detailed, |
| 5437 | 146 | const char **subjects, const char **froms, |
| 147 | const char **tos, const char **urls, | |
| 148 | GCallback cb, void *user_data); | |
| 149 | ||
| 150 | /** | |
|
6381
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
151 | * Displays a notification with formatted text. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
152 | * |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
153 | * 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
|
154 | * IMs may send. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
155 | * |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
156 | * @param handle The plugin or connection handle. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
157 | * @param title The title of the message. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
158 | * @param primary The main point of the message. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
159 | * @param secondary The secondary information. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
160 | * @param text The formatted text. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
161 | * @param cb The callback to call when the user closes |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
162 | * the notification. |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6467
diff
changeset
|
163 | * @param user_data The data to pass to the callback. |
|
6381
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
164 | * |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
165 | * @return A UI-specific handle. |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
166 | */ |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
167 | void *gaim_notify_formatted(void *handle, const char *title, |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
168 | const char *primary, const char *secondary, |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
169 | const char *text, GCallback cb, void *user_data); |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
170 | |
|
53203c44c731
[gaim-migrate @ 6886]
Christian Hammond <chipx86@chipx86.com>
parents:
6356
diff
changeset
|
171 | /** |
|
6465
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
172 | * Opens a URI or somehow presents it to the user. |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
173 | * |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
174 | * @param handle The plugin or connection handle. |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6467
diff
changeset
|
175 | * @param uri The URI to display or go to. |
|
6465
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
176 | * |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
177 | * @return A UI-specific handle, if any. This may only be presented if |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
178 | * the UI code displays a dialog instead of a webpage, or something |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
179 | * similar. |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
180 | */ |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
181 | void *gaim_notify_uri(void *handle, const char *uri); |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
182 | |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6381
diff
changeset
|
183 | /** |
| 5437 | 184 | * Closes a notification. |
| 185 | * | |
| 186 | * This should be used only by the UI operation functions and part of the | |
| 187 | * core. | |
| 188 | * | |
|
5476
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
189 | * @param type The notification type. |
|
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
190 | * @param ui_handle The notification UI handle. |
| 5437 | 191 | */ |
|
5476
6f863ea68018
[gaim-migrate @ 5872]
Christian Hammond <chipx86@chipx86.com>
parents:
5437
diff
changeset
|
192 | void gaim_notify_close(GaimNotifyType type, void *ui_handle); |
| 5437 | 193 | |
| 194 | /** | |
| 195 | * Closes all notifications registered with the specified handle. | |
| 196 | * | |
| 197 | * @param handle The handle. | |
| 198 | */ | |
| 199 | void gaim_notify_close_with_handle(void *handle); | |
| 200 | ||
| 201 | /** | |
| 202 | * A wrapper for gaim_notify_message that displays an information message. | |
| 203 | */ | |
| 204 | #define gaim_notify_info(handle, title, primary, secondary) \ | |
| 205 | gaim_notify_message((handle), GAIM_NOTIFY_MSG_INFO, (title), \ | |
| 206 | (primary), (secondary), NULL, NULL) | |
| 207 | ||
| 208 | /** | |
| 209 | * A wrapper for gaim_notify_message that displays a warning message. | |
| 210 | */ | |
| 211 | #define gaim_notify_warning(handle, title, primary, secondary) \ | |
| 212 | gaim_notify_message((handle), GAIM_NOTIFY_MSG_WARNING, (title), \ | |
| 213 | (primary), (secondary), NULL, NULL) | |
| 214 | ||
| 215 | /** | |
| 216 | * A wrapper for gaim_notify_message that displays an error message. | |
| 217 | */ | |
| 218 | #define gaim_notify_error(handle, title, primary, secondary) \ | |
| 219 | gaim_notify_message((handle), GAIM_NOTIFY_MSG_ERROR, (title), \ | |
| 220 | (primary), (secondary), NULL, NULL) | |
| 221 | ||
| 222 | /*@}*/ | |
| 223 | ||
| 224 | /**************************************************************************/ | |
| 225 | /** @name UI Operations API */ | |
| 226 | /**************************************************************************/ | |
| 227 | /*@{*/ | |
| 228 | ||
| 229 | /** | |
| 230 | * Sets the UI operations structure to be used when displaying a | |
| 231 | * notification. | |
| 232 | * | |
| 233 | * @param ops The UI operations structure. | |
| 234 | */ | |
|
7035
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
235 | void gaim_notify_set_ui_ops(GaimNotifyUiOps *ops); |
| 5437 | 236 | |
| 237 | /** | |
| 238 | * Returns the UI operations structure to be used when displaying a | |
| 239 | * notification. | |
| 240 | * | |
|
6467
754d318cac4a
[gaim-migrate @ 6976]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
241 | * @return The UI operations structure. |
| 5437 | 242 | */ |
|
7035
76bca80cd91d
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
243 | GaimNotifyUiOps *gaim_notify_get_ui_ops(void); |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
244 | |
|
5497
da3c08f3af25
[gaim-migrate @ 5893]
Mark Doliner <markdoliner@pidgin.im>
parents:
5476
diff
changeset
|
245 | /*@}*/ |
| 5437 | 246 | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
247 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
248 | } |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
249 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5522
diff
changeset
|
250 | |
| 5437 | 251 | #endif /* _GAIM_NOTIFY_H_ */ |