Mercurial > pidgin
annotate libgaim/prpl.h @ 15284:e8f8749e6182
[gaim-migrate @ 18074]
Fix a crash when adding a buddy to the deny list on a Google Talk account when that buddy doesnot have a resource name, and changed a printf() to a gaim_debug().
committer: Tailor Script <tailor@pidgin.im>
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Thu, 04 Jan 2007 23:38:43 +0000 |
parents | 4bf7801a2539 |
children |
rev | line source |
---|---|
14192 | 1 /** |
2 * @file prpl.h Protocol Plugin functions | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
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. | |
10 * | |
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 | |
26 /* this file should be all that prpls need to include. therefore, by including | |
27 * this file, they should get glib, proxy, gaim_connection, prpl, etc. */ | |
28 | |
29 #ifndef _GAIM_PRPL_H_ | |
30 #define _GAIM_PRPL_H_ | |
31 | |
32 typedef struct _GaimPluginProtocolInfo GaimPluginProtocolInfo; | |
33 | |
34 /**************************************************************************/ | |
35 /** @name Basic Protocol Information */ | |
36 /**************************************************************************/ | |
37 | |
38 typedef enum { | |
39 GAIM_ICON_SCALE_DISPLAY = 0x01, /**< We scale the icon when we display it */ | |
40 GAIM_ICON_SCALE_SEND = 0x02 /**< We scale the icon before we send it to the server */ | |
41 } GaimIconScaleRules; | |
42 | |
43 | |
44 /** | |
45 * A description of a Buddy Icon specification. This tells Gaim what kind of image file | |
46 * it should give this prpl, and what kind of image file it should expect back. | |
47 * Dimensions less than 1 should be ignored and the image not scaled. | |
48 */ | |
15219 | 49 typedef struct _GaimBuddyIconSpec GaimBuddyIconSpec; |
14192 | 50 |
51 /** | |
52 * This \#define exists just to make it easier to fill out the buddy icon | |
53 * field in the prpl info struct for protocols that couldn't care less. | |
54 */ | |
15219 | 55 #define NO_BUDDY_ICONS {NULL, 0, 0, 0, 0, 0, 0} |
56 | |
57 #include <unistd.h> | |
14192 | 58 |
59 #include "blist.h" | |
60 #include "conversation.h" | |
61 #include "ft.h" | |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15123
diff
changeset
|
62 #include "notify.h" |
14192 | 63 #include "proxy.h" |
64 #include "plugin.h" | |
65 #include "roomlist.h" | |
66 #include "status.h" | |
67 #include "whiteboard.h" | |
68 | |
15219 | 69 struct _GaimBuddyIconSpec { |
70 char *format; /**< This is a comma-delimited list of image formats or NULL if icons are not supported. | |
71 * Neither the core nor the prpl will actually check to see if the data it's given matches this; it's | |
72 * entirely up to the UI to do what it wants */ | |
73 int min_width; /**< The minimum width of this icon */ | |
74 int min_height; /**< The minimum height of this icon */ | |
75 int max_width; /**< The maximum width of this icon */ | |
76 int max_height; /**< The maximum height of this icon */ | |
77 size_t max_filesize; /**< The maximum number of bytes */ | |
78 GaimIconScaleRules scale_rules; /**< How to stretch this icon */ | |
79 }; | |
80 | |
14192 | 81 struct proto_chat_entry { |
82 const char *label; | |
83 const char *identifier; | |
84 gboolean required; | |
85 gboolean is_int; | |
86 int min; | |
87 int max; | |
88 gboolean secret; | |
89 }; | |
90 | |
91 /** | |
92 * Protocol options | |
93 * | |
94 * These should all be stuff that some plugins can do and others can't. | |
95 */ | |
96 typedef enum | |
97 { | |
98 /** | |
99 * Use a unique name, not an alias, for chat rooms. | |
100 * | |
101 * Jabber lets you choose what name you want for chat. | |
102 * So it shouldn't be pulling the alias for when you're in chat; | |
103 * it gets annoying. | |
104 */ | |
105 OPT_PROTO_UNIQUE_CHATNAME = 0x00000004, | |
106 | |
107 /** | |
108 * Chat rooms have topics. | |
109 * | |
110 * IRC and Jabber support this. | |
111 */ | |
112 OPT_PROTO_CHAT_TOPIC = 0x00000008, | |
113 | |
114 /** | |
115 * Don't require passwords for sign-in. | |
116 * | |
117 * Zephyr doesn't require passwords, so there's no | |
118 * need for a password prompt. | |
119 */ | |
120 OPT_PROTO_NO_PASSWORD = 0x00000010, | |
121 | |
122 /** | |
123 * Notify on new mail. | |
124 * | |
125 * MSN and Yahoo notify you when you have new mail. | |
126 */ | |
127 OPT_PROTO_MAIL_CHECK = 0x00000020, | |
128 | |
129 /** | |
130 * Images in IMs. | |
131 * | |
132 * Oscar lets you send images in direct IMs. | |
133 */ | |
134 OPT_PROTO_IM_IMAGE = 0x00000040, | |
135 | |
136 /** | |
137 * Allow passwords to be optional. | |
138 * | |
139 * Passwords in IRC are optional, and are needed for certain | |
140 * functionality. | |
141 */ | |
142 OPT_PROTO_PASSWORD_OPTIONAL = 0x00000080, | |
143 | |
144 /** | |
145 * Allows font size to be specified in sane point size | |
146 * | |
147 * Probably just Jabber and Y!M | |
148 */ | |
149 OPT_PROTO_USE_POINTSIZE = 0x00000100, | |
150 | |
151 /** | |
152 * Set the Register button active when screenname is not given. | |
153 * | |
154 * Gadu-Gadu doesn't need a screenname to register new account. | |
155 */ | |
156 OPT_PROTO_REGISTER_NOSCREENNAME = 0x00000200, | |
157 | |
158 } GaimProtocolOptions; | |
159 | |
160 /** | |
161 * A protocol plugin information structure. | |
162 * | |
163 * Every protocol plugin initializes this structure. It is the gateway | |
164 * between gaim and the protocol plugin. Many of this callbacks can be | |
165 * NULL. If a callback must be implemented, it has a comment indicating so. | |
166 */ | |
167 struct _GaimPluginProtocolInfo | |
168 { | |
169 GaimProtocolOptions options; /**< Protocol options. */ | |
170 | |
171 GList *user_splits; /* A GList of GaimAccountUserSplit */ | |
172 GList *protocol_options; /* A GList of GaimAccountOption */ | |
173 | |
174 GaimBuddyIconSpec icon_spec; /* The icon spec. */ | |
175 | |
176 /** | |
177 * Returns the base icon name for the given buddy and account. | |
178 * If buddy is NULL, it will return the name to use for the account's | |
179 * icon. This must be implemented. | |
180 */ | |
181 const char *(*list_icon)(GaimAccount *account, GaimBuddy *buddy); | |
182 | |
183 /** | |
184 * Fills the four char**'s with string identifiers for "emblems" | |
185 * that the UI will interpret and display as relevant | |
186 */ | |
187 void (*list_emblems)(GaimBuddy *buddy, const char **se, const char **sw, | |
188 const char **nw, const char **ne); | |
189 | |
190 /** | |
191 * Gets a short string representing this buddy's status. This will | |
192 * be shown on the buddy list. | |
193 */ | |
194 char *(*status_text)(GaimBuddy *buddy); | |
195 | |
196 /** | |
197 * Allows the prpl to add text to a buddy's tooltip. | |
198 */ | |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15123
diff
changeset
|
199 void (*tooltip_text)(GaimBuddy *buddy, GaimNotifyUserInfo *user_info, gboolean full); |
14192 | 200 |
201 /** | |
202 * This must be implemented, and must add at least the offline | |
203 * and online states. | |
204 */ | |
205 GList *(*status_types)(GaimAccount *account); | |
206 | |
207 GList *(*blist_node_menu)(GaimBlistNode *node); | |
208 GList *(*chat_info)(GaimConnection *); | |
209 GHashTable *(*chat_info_defaults)(GaimConnection *, const char *chat_name); | |
210 | |
211 /* All the server-related functions */ | |
212 | |
213 /** This must be implemented. */ | |
214 void (*login)(GaimAccount *); | |
215 | |
216 /** This must be implemented. */ | |
217 void (*close)(GaimConnection *); | |
218 | |
219 /** | |
220 * This PRPL function should return a positive value on success. | |
221 * If the message is too big to be sent, return -E2BIG. If | |
222 * the account is not connected, return -ENOTCONN. If the | |
223 * PRPL is unable to send the message for another reason, return | |
224 * some other negative value. You can use one of the valid | |
225 * errno values, or just big something. If the message should | |
226 * not be echoed to the conversation window, return 0. | |
227 */ | |
228 int (*send_im)(GaimConnection *, const char *who, | |
229 const char *message, | |
230 GaimMessageFlags flags); | |
231 | |
232 void (*set_info)(GaimConnection *, const char *info); | |
233 unsigned int (*send_typing)(GaimConnection *, const char *name, GaimTypingState state); | |
234 void (*get_info)(GaimConnection *, const char *who); | |
235 void (*set_status)(GaimAccount *account, GaimStatus *status); | |
236 | |
237 void (*set_idle)(GaimConnection *, int idletime); | |
238 void (*change_passwd)(GaimConnection *, const char *old_pass, | |
239 const char *new_pass); | |
240 void (*add_buddy)(GaimConnection *, GaimBuddy *buddy, GaimGroup *group); | |
241 void (*add_buddies)(GaimConnection *, GList *buddies, GList *groups); | |
242 void (*remove_buddy)(GaimConnection *, GaimBuddy *buddy, GaimGroup *group); | |
243 void (*remove_buddies)(GaimConnection *, GList *buddies, GList *groups); | |
244 void (*add_permit)(GaimConnection *, const char *name); | |
245 void (*add_deny)(GaimConnection *, const char *name); | |
246 void (*rem_permit)(GaimConnection *, const char *name); | |
247 void (*rem_deny)(GaimConnection *, const char *name); | |
248 void (*set_permit_deny)(GaimConnection *); | |
249 void (*join_chat)(GaimConnection *, GHashTable *components); | |
250 void (*reject_chat)(GaimConnection *, GHashTable *components); | |
251 char *(*get_chat_name)(GHashTable *components); | |
252 void (*chat_invite)(GaimConnection *, int id, | |
14974
c0d6f960675b
[gaim-migrate @ 17753]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14940
diff
changeset
|
253 const char *message, const char *who); |
14192 | 254 void (*chat_leave)(GaimConnection *, int id); |
255 void (*chat_whisper)(GaimConnection *, int id, | |
256 const char *who, const char *message); | |
257 int (*chat_send)(GaimConnection *, int id, const char *message, GaimMessageFlags flags); | |
258 void (*keepalive)(GaimConnection *); | |
259 | |
260 /* new user registration */ | |
261 void (*register_user)(GaimAccount *); | |
262 | |
263 /* get "chat buddy" info and away message */ | |
264 void (*get_cb_info)(GaimConnection *, int, const char *who); | |
265 void (*get_cb_away)(GaimConnection *, int, const char *who); | |
266 | |
267 /* save/store buddy's alias on server list/roster */ | |
268 void (*alias_buddy)(GaimConnection *, const char *who, | |
269 const char *alias); | |
270 | |
271 /* change a buddy's group on a server list/roster */ | |
272 void (*group_buddy)(GaimConnection *, const char *who, | |
273 const char *old_group, const char *new_group); | |
274 | |
275 /* rename a group on a server list/roster */ | |
276 void (*rename_group)(GaimConnection *, const char *old_name, | |
277 GaimGroup *group, GList *moved_buddies); | |
278 | |
279 void (*buddy_free)(GaimBuddy *); | |
280 | |
281 void (*convo_closed)(GaimConnection *, const char *who); | |
282 | |
283 const char *(*normalize)(const GaimAccount *, const char *); | |
284 | |
15070 | 285 void (*set_buddy_icon)(GaimConnection *, const char *cached_path); |
14192 | 286 |
287 void (*remove_group)(GaimConnection *gc, GaimGroup *group); | |
288 | |
289 char *(*get_cb_real_name)(GaimConnection *gc, int id, const char *who); | |
290 | |
291 void (*set_chat_topic)(GaimConnection *gc, int id, const char *topic); | |
292 | |
293 GaimChat *(*find_blist_chat)(GaimAccount *account, const char *name); | |
294 | |
295 /* room listing prpl callbacks */ | |
296 GaimRoomlist *(*roomlist_get_list)(GaimConnection *gc); | |
297 void (*roomlist_cancel)(GaimRoomlist *list); | |
298 void (*roomlist_expand_category)(GaimRoomlist *list, GaimRoomlistRoom *category); | |
299 | |
300 /* file transfer callbacks */ | |
301 gboolean (*can_receive_file)(GaimConnection *, const char *who); | |
302 void (*send_file)(GaimConnection *, const char *who, const char *filename); | |
303 GaimXfer *(*new_xfer)(GaimConnection *, const char *who); | |
304 gboolean (*offline_message)(const GaimBuddy *buddy); | |
305 | |
306 GaimWhiteboardPrplOps *whiteboard_prpl_ops; | |
14542 | 307 |
308 /* For use in plugins that may understand the underlying protocol */ | |
309 int (*send_raw)(GaimConnection *gc, const char *buf, int len); | |
15123 | 310 |
311 /* room list serialize */ | |
312 char *(*roomlist_room_serialize)(GaimRoomlistRoom *room); | |
14192 | 313 }; |
314 | |
315 #define GAIM_IS_PROTOCOL_PLUGIN(plugin) \ | |
316 ((plugin)->info->type == GAIM_PLUGIN_PROTOCOL) | |
317 | |
318 #define GAIM_PLUGIN_PROTOCOL_INFO(plugin) \ | |
319 ((GaimPluginProtocolInfo *)(plugin)->info->extra_info) | |
320 | |
321 #ifdef __cplusplus | |
322 extern "C" { | |
323 #endif | |
324 | |
325 /**************************************************************************/ | |
326 /** @name Protocol Plugin API */ | |
327 /**************************************************************************/ | |
328 /*@{*/ | |
329 | |
330 /** | |
331 * Notifies Gaim that an account's idle state and time have changed. | |
332 * | |
333 * This is meant to be called from protocol plugins. | |
334 * | |
335 * @param account The account. | |
336 * @param idle The user's idle state. | |
337 * @param idle_time The user's idle time. | |
338 */ | |
339 void gaim_prpl_got_account_idle(GaimAccount *account, gboolean idle, | |
340 time_t idle_time); | |
341 | |
342 /** | |
343 * Notifies Gaim of an account's log-in time. | |
344 * | |
345 * This is meant to be called from protocol plugins. | |
346 * | |
347 * @param account The account the user is on. | |
348 * @param login_time The user's log-in time. | |
349 */ | |
350 void gaim_prpl_got_account_login_time(GaimAccount *account, time_t login_time); | |
351 | |
352 /** | |
353 * Notifies Gaim that an account's status has changed. | |
354 * | |
355 * This is meant to be called from protocol plugins. | |
356 * | |
357 * @param account The account the user is on. | |
358 * @param status_id The status ID. | |
359 * @param ... A NULL-terminated list of attribute IDs and values, | |
360 * beginning with the value for @a attr_id. | |
361 */ | |
362 void gaim_prpl_got_account_status(GaimAccount *account, | |
363 const char *status_id, ...); | |
364 /** | |
365 * Notifies Gaim that a user's idle state and time have changed. | |
366 * | |
367 * This is meant to be called from protocol plugins. | |
368 * | |
369 * @param account The account the user is on. | |
370 * @param name The screen name of the user. | |
371 * @param idle The user's idle state. | |
372 * @param idle_time The user's idle time. This is the time at | |
373 * which the user became idle, in seconds since | |
374 * the epoch. | |
375 */ | |
376 void gaim_prpl_got_user_idle(GaimAccount *account, const char *name, | |
377 gboolean idle, time_t idle_time); | |
378 | |
379 /** | |
380 * Notifies Gaim of a user's log-in time. | |
381 * | |
382 * This is meant to be called from protocol plugins. | |
383 * | |
384 * @param account The account the user is on. | |
385 * @param name The screen name of the user. | |
386 * @param login_time The user's log-in time. | |
387 */ | |
388 void gaim_prpl_got_user_login_time(GaimAccount *account, const char *name, | |
389 time_t login_time); | |
390 | |
391 /** | |
392 * Notifies Gaim that a user's status has changed. | |
393 * | |
394 * This is meant to be called from protocol plugins. | |
395 * | |
396 * @param account The account the user is on. | |
397 * @param name The screen name of the user. | |
398 * @param status_id The status ID. | |
399 * @param ... A NULL-terminated list of attribute IDs and values, | |
400 * beginning with the value for @a attr_id. | |
401 */ | |
402 void gaim_prpl_got_user_status(GaimAccount *account, const char *name, | |
403 const char *status_id, ...); | |
404 /** | |
405 * Informs the server that an account's status changed. | |
406 * | |
407 * @param account The account the user is on. | |
408 * @param old_status The previous status. | |
409 * @param new_status The status that was activated, or deactivated | |
410 * (in the case of independent statuses). | |
411 */ | |
412 void gaim_prpl_change_account_status(GaimAccount *account, | |
413 GaimStatus *old_status, | |
414 GaimStatus *new_status); | |
415 | |
416 /** | |
417 * Retrieves the list of stock status types from a prpl. | |
418 * | |
419 * @param account The account the user is on. | |
420 * @param presence The presence for which we're going to get statuses | |
421 * | |
422 * @return List of statuses | |
423 */ | |
424 GList *gaim_prpl_get_statuses(GaimAccount *account, GaimPresence *presence); | |
425 | |
426 /*@}*/ | |
427 | |
428 /**************************************************************************/ | |
429 /** @name Protocol Plugin Subsystem API */ | |
430 /**************************************************************************/ | |
431 /*@{*/ | |
432 | |
433 /** | |
434 * Finds a protocol plugin structure of the specified type. | |
435 * | |
436 * @param id The protocol plugin; | |
437 */ | |
438 GaimPlugin *gaim_find_prpl(const char *id); | |
439 | |
440 /*@}*/ | |
441 | |
442 #ifdef __cplusplus | |
443 } | |
444 #endif | |
445 | |
446 #endif /* _PRPL_H_ */ |