comparison src/prpl.h @ 4557:53ce3af93edb

[gaim-migrate @ 4837] - Documented prpl.h. - Moved #defines into enums. Sean likes it. You should too! committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 08 Feb 2003 00:26:16 +0000
parents 7521e29658bc
children 7e1591c6d0d8
comparison
equal deleted inserted replaced
4556:f7f0c7fef6be 4557:53ce3af93edb
1 /* 1 /**
2 * @file prpl.h Protocol Plugin functions
3 *
2 * gaim 4 * gaim
3 * 5 *
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> 6 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
5 * 7 *
6 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
20 */ 22 */
21 23
22 /* this file should be all that prpls need to include. therefore, by including 24 /* this file should be all that prpls need to include. therefore, by including
23 * this file, they should get glib, proxy, gaim_connection, prpl, etc. */ 25 * this file, they should get glib, proxy, gaim_connection, prpl, etc. */
24 26
25 #ifndef _PRPL_H_ 27 #ifndef _GAIM_PRPL_H_
26 #define _PRPL_H_ 28 #define _GAIM_PRPL_H_
27 29
28 #include "core.h" 30 #include "core.h"
29 #include "proxy.h" 31 #include "proxy.h"
30 #include "multi.h" 32 #include "multi.h"
31 33
32 #define PROTO_TOC 0 34 /**************************************************************************/
33 #define PROTO_OSCAR 1 35 /** @name Basic Protocol Information */
34 #define PROTO_YAHOO 2 36 /**************************************************************************/
35 #define PROTO_ICQ 3 37 /*@{*/
36 #define PROTO_MSN 4 38
37 #define PROTO_IRC 5 39 /**
38 #define PROTO_FTP 6 40 * Protocol types and numbers.
39 #define PROTO_VGATE 7 41 *
40 #define PROTO_JABBER 8 42 * Do not assume a new protocol number without talking to
41 #define PROTO_NAPSTER 9 43 * Rob Flynn or Sean Egan first!
42 #define PROTO_ZEPHYR 10 44 */
43 #define PROTO_GADUGADU 11 45 typedef enum
44 #define PROTO_SAMETIME 12 46 {
45 #define PROTO_TLEN 13 47 PROTO_TOC = 0, /**< AIM TOC protocol */
46 #define PROTO_RVP 14 48 PROTO_OSCAR, /**< AIM OSCAR protocol */
47 #define PROTO_BACKRUB 15 49 PROTO_YAHOO, /**< Yahoo Messenger protocol */
48 #define PROTO_UNTAKEN 16 50 PROTO_ICQ, /**< Outdated ICQ protocol */
49 51 PROTO_MSN, /**< MSN Messenger protocol */
50 /* DON'T TAKE AN UNASSIGNED NUMBER! Talk to Rob or Sean if you'd like 52 PROTO_IRC, /**< IRC protocol */
51 * to create a new PRPL. */ 53 PROTO_FTP, /**< FTP protocol */
52 54 PROTO_VGATE, /**< VGATE protocol */
53 #define PRPL_DESC(x) "Allows gaim to use the " x " protocol.\n\n" \ 55 PROTO_JABBER, /**< Jabber protocol */
54 "Now that you have loaded this protocol, use the " \ 56 PROTO_NAPSTER, /**< Napster/OpenNAP protocol */
55 "Account Editor to add an account that uses this " \ 57 PROTO_ZEPHYR, /**< MIT Zephyr protocol */
56 "protocol. You can access the Account Editor from " \ 58 PROTO_GADUGADU, /**< Gadu-Gadu protocol */
57 "the \"Accounts\" button on the login window or " \ 59 PROTO_SAMETIME, /**< SameTime protocol */
58 "in the \"Tools\" menu in the buddy list window." 60 PROTO_TLEN, /**< TLEN protocol */
59 61 PROTO_RVP, /**< RVP protocol */
62 PROTO_BACKRUB, /**< Instant Massager protocol */
63 PROTO_UNTAKEN /**< Untaken protocol number */
64
65 } GaimProtocol;
66
67 /** Default protocol plugin description */
68 #define PRPL_DESC(x) \
69 "Allows gaim to use the " x " protocol.\n\n" \
70 "Now that you have loaded this protocol, use the " \
71 "Account Editor to add an account that uses this " \
72 "protocol. You can access the Account Editor from " \
73 "the \"Accounts\" button on the login window or " \
74 "in the \"Tools\" menu in the buddy list window."
75
76 /** Default protocol */
60 #define DEFAULT_PROTO PROTO_OSCAR 77 #define DEFAULT_PROTO PROTO_OSCAR
61 78
62 /* These should all be stuff that some plugins can do and others can't */ 79 /*@}*/
63 /* TOC/Oscar send HTML-encoded messages; most other protocols don't */ 80
64 /* #define OPT_PROTO_HTML 0x00000001 this should be per-connection */ 81 /**
65 /* TOC/Oscar have signon time, and the server's time needs to be adjusted to match 82 * Protocol options
66 * your computer's time. We wouldn't need this if everyone used NTP. */ 83 *
67 #define OPT_PROTO_CORRECT_TIME 0x00000002 84 * These should all be stuff that some plugins can do and others can't.
68 /* Jabber lets you choose what name you want for chat. So it shouldn't be pulling 85 */
69 * the alias for when you're in chat; it gets annoying. */ 86 typedef enum
70 #define OPT_PROTO_UNIQUE_CHATNAME 0x00000004 87 {
71 /* IRC, Jabber let you have chat room topics */ 88 /**
72 #define OPT_PROTO_CHAT_TOPIC 0x00000008 89 * TOC and Oscar send HTML-encoded messages;
73 /* Zephyr doesn't require passwords, so there's no need for a password prompt */ 90 * most other protocols don't.
74 #define OPT_PROTO_NO_PASSWORD 0x00000010 91 */
75 /* MSN and Yahoo notify you when you have new mail */ 92 // #define OPT_PROTO_HTML 0x00000001 this should be per-connection */
76 #define OPT_PROTO_MAIL_CHECK 0x00000020 93
77 /* Oscar and Jabber have buddy icons */ 94 /**
78 #define OPT_PROTO_BUDDY_ICON 0x00000040 95 * Synchronize the time between the local computer and the server.
79 /* Oscar lets you send images in direct IMs */ 96 *
80 #define OPT_PROTO_IM_IMAGE 0x00000080 97 * TOC and Oscar have signon time, and the server's time needs
81 /* Passwords in IRC are optional, and are needed for certain functionality. */ 98 * to be adjusted to match your computer's time.
82 #define OPT_PROTO_PASSWORD_OPTIONAL 0x00000100 99 *
83 100 * We wouldn't need this if everyone used NTP.
101 */
102 OPT_PROTO_CORRECT_TIME = 0x00000002,
103
104 /**
105 * Use a unique name, not an alias, for chat rooms.
106 *
107 * Jabber lets you choose what name you want for chat.
108 * So it shouldn't be pulling the alias for when you're in chat;
109 * it gets annoying.
110 */
111 OPT_PROTO_UNIQUE_CHATNAME = 0x00000004,
112
113 /**
114 * Chat rooms have topics.
115 *
116 * IRC and Jabber support this.
117 */
118 OPT_PROTO_CHAT_TOPIC = 0x00000008,
119
120 /**
121 * Don't require passwords for sign-in.
122 *
123 * Zephyr doesn't require passwords, so there's no need for
124 * a password prompt.
125 */
126 OPT_PROTO_NO_PASSWORD = 0x00000010,
127
128 /**
129 * Notify on new mail.
130 *
131 * MSN and Yahoo notify you when you have new mail.
132 */
133 OPT_PROTO_MAIL_CHECK = 0x00000020,
134
135 /**
136 * Buddy icon support.
137 *
138 * Oscar and Jabber have buddy icons.
139 */
140 OPT_PROTO_BUDDY_ICON = 0x00000040,
141
142 /**
143 * Images in IMs.
144 *
145 * Oscar lets you send images in direct IMs.
146 */
147 OPT_PROTO_IM_IMAGE = 0x00000080,
148
149 /**
150 * Allow passwords to be optional.
151 *
152 * Passwords in IRC are optional, and are needed for certain
153 * functionality.
154 */
155 OPT_PROTO_PASSWORD_OPTIONAL = 0x00000100,
156
157 } GaimProtocolOptions;
158
159 /** Custom away message. */
84 #define GAIM_AWAY_CUSTOM "Custom" 160 #define GAIM_AWAY_CUSTOM "Custom"
85 161
162 /**
163 * Protocol plugin initialization function.
164 */
86 typedef void (*proto_init)(struct prpl *); 165 typedef void (*proto_init)(struct prpl *);
87 166
88 struct prpl { 167 /**
89 int protocol; 168 * A protocol plugin structure.
90 int options; 169 *
91 struct gaim_plugin *plug; 170 * Every protocol plugin initializes this structure. It is the gateway
171 * between gaim and the protocol plugin.
172 */
173 struct prpl
174 {
175 GaimProtocol protocol; /**< The protocol type. */
176 GaimProtocolOptions options; /**< Protocol options. */
177 struct gaim_plugin *plug; /**< The base plugin structure. */
92 char *name; 178 char *name;
93 179
94 /* for ICQ and Yahoo, who have off/on per-conversation options */ 180 /** Returns the XPM associated with the given user class. */
95 /* char *checkbox; this should be per-connection */
96
97 /* returns the XPM associated with the given user class */
98 char **(* list_icon)(int); 181 char **(* list_icon)(int);
99 GList *(* away_states)(struct gaim_connection *gc); 182 GList *(* away_states)(struct gaim_connection *gc);
100 GList *(* actions)(struct gaim_connection *gc); 183 GList *(* actions)(struct gaim_connection *gc);
101 /* user_opts is a GList* of g_malloc'd struct proto_user_opts */ 184 /* user_opts is a GList* of g_malloc'd struct proto_user_opts */
102 GList *user_opts; 185 GList *user_opts;
103 GList *(* buddy_menu)(struct gaim_connection *, char *); 186 GList *(* buddy_menu)(struct gaim_connection *, char *);
104 GList *(* edit_buddy_menu)(struct gaim_connection *, char *); 187 GList *(* edit_buddy_menu)(struct gaim_connection *, char *);
105 GList *(* chat_info)(struct gaim_connection *); 188 GList *(* chat_info)(struct gaim_connection *);
106 189
107 /* all the server-related functions */ 190 /* All the server-related functions */
108 191
109 /* a lot of these (like get_dir) are protocol-dependent and should be removed. ones like 192 /*
110 * set_dir (which is also protocol-dependent) can stay though because there's a dialog 193 * A lot of these (like get_dir) are protocol-dependent and should
111 * (i.e. the prpl says you can set your dir info, the ui shows a dialog and needs to call 194 * be removed. ones like set_dir (which is also protocol-dependent)
112 * set_dir in order to set it) */ 195 * can stay though because there's a dialog (i.e. the prpl says you
113 196 * can set your dir info, the ui shows a dialog and needs to call
197 * set_dir in order to set it)
198 */
114 void (* login) (struct gaim_account *); 199 void (* login) (struct gaim_account *);
115 void (* close) (struct gaim_connection *); 200 void (* close) (struct gaim_connection *);
116 int (* send_im) (struct gaim_connection *, char *who, char *message, int len, int away); 201 int (* send_im) (struct gaim_connection *, char *who, char *message,
202 int len, int away);
117 void (* set_info) (struct gaim_connection *, char *info); 203 void (* set_info) (struct gaim_connection *, char *info);
118 int (* send_typing) (struct gaim_connection *, char *name, int typing); 204 int (* send_typing) (struct gaim_connection *, char *name, int typing);
119 void (* get_info) (struct gaim_connection *, char *who); 205 void (* get_info) (struct gaim_connection *, char *who);
120 void (* set_away) (struct gaim_connection *, char *state, char *message); 206 void (* set_away) (struct gaim_connection *, char *state, char *message);
121 void (* get_away) (struct gaim_connection *, char *who); 207 void (* get_away) (struct gaim_connection *, char *who);
135 const char *city, 221 const char *city,
136 const char *state, 222 const char *state,
137 const char *country, 223 const char *country,
138 const char *email); 224 const char *email);
139 void (* set_idle) (struct gaim_connection *, int idletime); 225 void (* set_idle) (struct gaim_connection *, int idletime);
140 void (* change_passwd) (struct gaim_connection *, const char *old, const char *new); 226 void (* change_passwd) (struct gaim_connection *, const char *old,
227 const char *new);
141 void (* add_buddy) (struct gaim_connection *, const char *name); 228 void (* add_buddy) (struct gaim_connection *, const char *name);
142 void (* add_buddies) (struct gaim_connection *, GList *buddies); 229 void (* add_buddies) (struct gaim_connection *, GList *buddies);
143 void (* remove_buddy) (struct gaim_connection *, char *name, char *group); 230 void (* remove_buddy) (struct gaim_connection *, char *name, char *group);
144 void (* remove_buddies) (struct gaim_connection *, GList *buddies, const char *group); 231 void (* remove_buddies) (struct gaim_connection *, GList *buddies,
232 const char *group);
145 void (* add_permit) (struct gaim_connection *, const char *name); 233 void (* add_permit) (struct gaim_connection *, const char *name);
146 void (* add_deny) (struct gaim_connection *, const char *name); 234 void (* add_deny) (struct gaim_connection *, const char *name);
147 void (* rem_permit) (struct gaim_connection *, const char *name); 235 void (* rem_permit) (struct gaim_connection *, const char *name);
148 void (* rem_deny) (struct gaim_connection *, const char *name); 236 void (* rem_deny) (struct gaim_connection *, const char *name);
149 void (* set_permit_deny)(struct gaim_connection *); 237 void (* set_permit_deny)(struct gaim_connection *);
150 void (* warn) (struct gaim_connection *, char *who, int anonymous); 238 void (* warn) (struct gaim_connection *, char *who, int anonymous);
151 void (* join_chat) (struct gaim_connection *, GList *data); 239 void (* join_chat) (struct gaim_connection *, GList *data);
152 void (* chat_invite) (struct gaim_connection *, int id, const char *who, const char *message); 240 void (* chat_invite) (struct gaim_connection *, int id,
241 const char *who, const char *message);
153 void (* chat_leave) (struct gaim_connection *, int id); 242 void (* chat_leave) (struct gaim_connection *, int id);
154 void (* chat_whisper) (struct gaim_connection *, int id, char *who, char *message); 243 void (* chat_whisper) (struct gaim_connection *, int id,
244 char *who, char *message);
155 int (* chat_send) (struct gaim_connection *, int id, char *message); 245 int (* chat_send) (struct gaim_connection *, int id, char *message);
156 void (* keepalive) (struct gaim_connection *); 246 void (* keepalive) (struct gaim_connection *);
157 247
158 /* new user registration */ 248 /* new user registration */
159 void (* register_user) (struct gaim_account *); 249 void (* register_user) (struct gaim_account *);
161 /* get "chat buddy" info and away message */ 251 /* get "chat buddy" info and away message */
162 void (* get_cb_info) (struct gaim_connection *, int, char *who); 252 void (* get_cb_info) (struct gaim_connection *, int, char *who);
163 void (* get_cb_away) (struct gaim_connection *, int, char *who); 253 void (* get_cb_away) (struct gaim_connection *, int, char *who);
164 254
165 /* save/store buddy's alias on server list/roster */ 255 /* save/store buddy's alias on server list/roster */
166 void (* alias_buddy) (struct gaim_connection *, const char *who, const char *alias); 256 void (* alias_buddy) (struct gaim_connection *, const char *who,
257 const char *alias);
167 258
168 /* change a buddy's group on a server list/roster */ 259 /* change a buddy's group on a server list/roster */
169 void (* group_buddy) (struct gaim_connection *, const char *who, const char *old_group, const char *new_group); 260 void (* group_buddy) (struct gaim_connection *, const char *who,
261 const char *old_group, const char *new_group);
170 262
171 /* rename a group on a server list/roster */ 263 /* rename a group on a server list/roster */
172 void (* rename_group) (struct gaim_connection *, const char *old_group, const char *new_group, GList *members); 264 void (* rename_group) (struct gaim_connection *, const char *old_group,
265 const char *new_group, GList *members);
173 266
174 void (* buddy_free) (struct buddy *); 267 void (* buddy_free) (struct buddy *);
175 268
176 /* this is really bad. */ 269 /* this is really bad. */
177 void (* convo_closed) (struct gaim_connection *, char *who); 270 void (* convo_closed) (struct gaim_connection *, char *who);
178 271
179 char *(* normalize)(const char *); 272 char *(* normalize)(const char *);
180 }; 273 };
181 274
275 /** A list of all loaded protocol plugins. */
182 extern GSList *protocols; 276 extern GSList *protocols;
277
278 /** The number of accounts using a given protocol plugin. */
183 extern int prpl_accounts[]; 279 extern int prpl_accounts[];
184 280
185 /* this is mostly just for aim.c, when it initializes the protocols */ 281 /**
186 extern void static_proto_init(); 282 * Initializes static protocols.
187 283 *
188 /* this is what should actually load the protocol. pass it the protocol's initializer */ 284 * This is mostly just for main.c, when it initializes the protocols.
189 extern gboolean load_prpl(struct prpl *); 285 */
190 extern void load_protocol(proto_init); 286 void static_proto_init();
191 extern void unload_protocol(struct prpl *); 287
192 extern gint proto_compare(struct prpl *, struct prpl *); 288 /**
193 289 * Loads a protocol plugin.
194 extern struct prpl *find_prpl(int); 290 *
195 extern void do_proto_menu(); 291 * @param prpl The initial protocol plugin structure.
196 292 *
197 extern void show_got_added(struct gaim_connection *, const char *, 293 * @return @c TRUE if the protocol was loaded, or @c FALSE otherwise.
198 const char *, const char *, const char *); 294 */
199 295 gboolean load_prpl(struct prpl *prpl);
200 extern void do_ask_cancel_by_handle(GModule *); 296
201 extern void do_ask_dialog(const char *, const char *, void *, char*, void *, char *, void *, GModule *, gboolean); 297 /**
202 extern void do_prompt_dialog(const char *, const char *, void *, void *, void *); 298 * Loads a statically compiled protocol plugin.
203 299 *
204 extern void connection_has_mail(struct gaim_connection *, int, const char *, const char *, const char *); 300 * @param pi The initialization function.
205 301 */
206 extern void set_icon_data(struct gaim_connection *, char *, void *, int); 302 void load_protocol(proto_init pi);
207 extern void *get_icon_data(struct gaim_connection *, char *, int *); 303
304 /**
305 * Unloads a protocol plugin.
306 *
307 * @param prpl The protocol plugin to unload.
308 */
309 extern void unload_protocol(struct prpl *prpl);
310
311 /**
312 * Compares two protocol plugins, based off their protocol plugin number.
313 *
314 * @param a The first protocol plugin.
315 * @param b The second protocol plugin.
316 *
317 * @return <= 1 if the first plugin's number is smaller than the second;
318 * 0 if the first plugin's number is equal to the second; or
319 * >= 1 if the first plugin's number is greater than the second.
320 */
321 gint proto_compare(struct prpl *a, struct prpl *b);
322
323 /**
324 * Finds a protocol plugin structure of the specified type.
325 *
326 * @param type The protocol plugin type.
327 */
328 struct prpl *find_prpl(GaimProtocol type);
329
330 /**
331 * Creates a menu of all protocol plugins and their protocol-specific
332 * actions.
333 *
334 * @note This should be UI-specific code, or rewritten in such a way as to
335 * not use any any GTK code.
336 */
337 void do_proto_menu();
338
339 /**
340 * Shows a message saying that somebody added you as a buddy, and asks
341 * if you would like to do the same.
342 *
343 * @param gc The gaim connection.
344 * @param id The ID of the user.
345 * @param who The username.
346 * @param alias The user's alias.
347 * @param msg The message to go along with the request.
348 */
349 void show_got_added(struct gaim_connection *gc, const char *id,
350 const char *who, const char *alias, const char *msg);
351
352 /**
353 * Closes do_ask_dialogs when the associated plugin is unloaded.
354 *
355 * @param module The module.
356 */
357 void do_ask_cancel_by_handle(GModule *module);
358
359 /**
360 * Asks the user a question and acts on the response.
361 *
362 * @param prim The primary question.
363 * @param sec The secondary question.
364 * @param data The data to be passed to a callback.
365 * @param yestext The text for the Yes button.
366 * @param doit The callback function to call when the Yes button is clicked.
367 * @param notext The text for the No button.
368 * @param dont The callback function to call when the No button is clicked.
369 * @param handle The module handle to associate with this dialog, or @c NULL.
370 * @param modal @c TRUE if the dialog should be modal; @c FALSE otherwise.
371 */
372 void do_ask_dialog(const char *prim, const char *sec, void *data,
373 char *yestext, void *doit, char *notext, void *dont,
374 GModule *handle, gboolean modal);
375
376 /**
377 * Prompts the user for data.
378 *
379 * @param text The text to present to the user.
380 * @param def The default data, or @c NULL.
381 * @param data The data to be passed to the callback.
382 * @param doit The callback function to call when the Accept button is clicked.
383 * @param dont The callback function to call when the Cancel button is clicked.
384 */
385 void do_prompt_dialog(const char *text, const char *sdef, void *data,
386 void *doit, void *dont);
387
388 /**
389 * Called to notify the user that the account has new mail.
390 *
391 * If @a count is less than 0, the dialog will display the the sender
392 * and the subject, if available. If @a count is greater than 0, it will
393 * display how many messages the user has.
394 *
395 * @param gc The gaim connection.
396 * @param count The number of new e-mails.
397 * @param from The sender, or @c NULL.
398 * @param subject The subject, or @c NULL.
399 * @param url The URL to go to to read the new mail.
400 */
401 void connection_has_mail(struct gaim_connection *gc, int count,
402 const char *from, const char *subject,
403 const char *url);
404
405 /**
406 * Retrieves and sets the new buddy icon for a user.
407 *
408 * @param gc The gaim connection.
409 * @param who The user.
410 * @param data The icon data.
411 * @param len The length of @a data.
412 */
413 void set_icon_data(struct gaim_connection *gc, char *who, void *data, int len);
414
415 /**
416 * Retrieves the buddy icon data for a user.
417 *
418 * @param gc The gaim connection.
419 * @param who The user.
420 * @param len The returned length of the data.
421 *
422 * @return The buddy icon data.
423 */
424 void *get_icon_data(struct gaim_connection *gc, char *who, int *len);
208 425
209 /* stuff to load/unload PRPLs as necessary */ 426 /* stuff to load/unload PRPLs as necessary */
210 extern gboolean ref_protocol(struct prpl *p); 427
211 extern void unref_protocol(struct prpl *p); 428 /**
429 * Increments the reference count on a protocol plugin.
430 *
431 * @param prpl The protocol plugin.
432 *
433 * @return @c TRUE if the protocol plugin is loaded, or @c FALSE otherwise.
434 */
435 gboolean ref_protocol(struct prpl *prpl);
436
437 /**
438 * Decrements the reference count on a protocol plugin.
439 *
440 * When the reference count hits 0, the protocol plugin is unloaded.
441 */
442 void unref_protocol(struct prpl *prpl);
212 443
213 #endif /* _PRPL_H_ */ 444 #endif /* _PRPL_H_ */