src/prpl.h

changeset 5205
242b8aa81328
parent 5148
44e45957485f
child 5234
8320a1cb0274
equal deleted inserted replaced
5204:deed98aa3181 5205:242b8aa81328
25 * this file, they should get glib, proxy, gaim_connection, prpl, etc. */ 25 * this file, they should get glib, proxy, gaim_connection, prpl, etc. */
26 26
27 #ifndef _GAIM_PRPL_H_ 27 #ifndef _GAIM_PRPL_H_
28 #define _GAIM_PRPL_H_ 28 #define _GAIM_PRPL_H_
29 29
30 typedef struct _GaimPluginProtocolInfo GaimPluginProtocolInfo;
31
30 #include "core.h" 32 #include "core.h"
31 #include "proxy.h" 33 #include "proxy.h"
32 #include "multi.h" 34 #include "multi.h"
33 35
34 /**************************************************************************/ 36 /**************************************************************************/
42 * Do not assume a new protocol number without talking to 44 * Do not assume a new protocol number without talking to
43 * Rob Flynn or Sean Egan first! 45 * Rob Flynn or Sean Egan first!
44 */ 46 */
45 typedef enum 47 typedef enum
46 { 48 {
47 PROTO_TOC = 0, /**< AIM TOC protocol */ 49 GAIM_PROTO_TOC = 0, /**< AIM TOC protocol */
48 PROTO_OSCAR, /**< AIM OSCAR protocol */ 50 GAIM_PROTO_OSCAR, /**< AIM OSCAR protocol */
49 PROTO_YAHOO, /**< Yahoo Messenger protocol */ 51 GAIM_PROTO_YAHOO, /**< Yahoo Messenger protocol */
50 PROTO_ICQ, /**< Outdated ICQ protocol */ 52 GAIM_PROTO_ICQ, /**< Outdated ICQ protocol */
51 PROTO_MSN, /**< MSN Messenger protocol */ 53 GAIM_PROTO_MSN, /**< MSN Messenger protocol */
52 PROTO_IRC, /**< IRC protocol */ 54 GAIM_PROTO_IRC, /**< IRC protocol */
53 PROTO_FTP, /**< FTP protocol */ 55 GAIM_PROTO_FTP, /**< FTP protocol */
54 PROTO_VGATE, /**< VGATE protocol */ 56 GAIM_PROTO_VGATE, /**< VGATE protocol */
55 PROTO_JABBER, /**< Jabber protocol */ 57 GAIM_PROTO_JABBER, /**< Jabber protocol */
56 PROTO_NAPSTER, /**< Napster/OpenNAP protocol */ 58 GAIM_PROTO_NAPSTER, /**< Napster/OpenNAP protocol */
57 PROTO_ZEPHYR, /**< MIT Zephyr protocol */ 59 GAIM_PROTO_ZEPHYR, /**< MIT Zephyr protocol */
58 PROTO_GADUGADU, /**< Gadu-Gadu protocol */ 60 GAIM_PROTO_GADUGADU, /**< Gadu-Gadu protocol */
59 PROTO_SAMETIME, /**< SameTime protocol */ 61 GAIM_PROTO_SAMETIME, /**< SameTime protocol */
60 PROTO_TLEN, /**< TLEN protocol */ 62 GAIM_PROTO_TLEN, /**< TLEN protocol */
61 PROTO_RVP, /**< RVP protocol */ 63 GAIM_PROTO_RVP, /**< RVP protocol */
62 PROTO_BACKRUB, /**< Instant Massager protocol */ 64 GAIM_PROTO_BACKRUB, /**< Instant Massager protocol */
63 PROTO_MOO, /**< MOO protocol */ 65 GAIM_PROTO_MOO, /**< MOO protocol */
64 PROTO_UNTAKEN /**< Untaken protocol number */ 66 GAIM_PROTO_UNTAKEN /**< Untaken protocol number */
65 67
66 } GaimProtocol; 68 } GaimProtocol;
67 69
68 /** Default protocol plugin description */ 70 /** Default protocol plugin description */
69 #define PRPL_DESC(x) \ 71 #define GAIM_PRPL_DESC(x) \
70 "Allows gaim to use the " x " protocol.\n\n" \ 72 "Allows gaim to use the " (x) " protocol.\n\n" \
71 "Now that you have loaded this protocol, use the " \ 73 "Now that you have loaded this protocol, use the " \
72 "Account Editor to add an account that uses this " \ 74 "Account Editor to add an account that uses this " \
73 "protocol. You can access the Account Editor from " \ 75 "protocol. You can access the Account Editor from " \
74 "the \"Accounts\" button on the login window or " \ 76 "the \"Accounts\" button on the login window or " \
75 "in the \"Tools\" menu in the buddy list window." 77 "in the \"Tools\" menu in the buddy list window."
76 78
77 /** Default protocol */ 79 /** Default protocol */
78 #define DEFAULT_PROTO PROTO_OSCAR 80 #define GAIM_PROTO_DEFAULT GAIM_PROTO_OSCAR
79 81
80 /*@}*/ 82 /*@}*/
81 83
82 /** 84 /**
83 * Protocol options 85 * Protocol options
161 163
162 /** Custom away message. */ 164 /** Custom away message. */
163 #define GAIM_AWAY_CUSTOM _("Custom") 165 #define GAIM_AWAY_CUSTOM _("Custom")
164 166
165 /** 167 /**
166 * Protocol plugin initialization function. 168 * A protocol plugin information structure.
167 */
168 typedef void (*proto_init)(struct prpl *);
169
170 /**
171 * A protocol plugin structure.
172 * 169 *
173 * Every protocol plugin initializes this structure. It is the gateway 170 * Every protocol plugin initializes this structure. It is the gateway
174 * between gaim and the protocol plugin. 171 * between gaim and the protocol plugin.
175 */ 172 */
176 struct prpl 173 struct _GaimPluginProtocolInfo
177 { 174 {
178 GaimProtocol protocol; /**< The protocol type. */ 175 GaimProtocol protocol; /**< The protocol type. */
179 GaimProtocolOptions options; /**< Protocol options. */ 176 GaimProtocolOptions options; /**< Protocol options. */
180 struct gaim_plugin *plug; /**< The base plugin structure. */ 177
181 char *name;
182
183 /**
184 * Returns the base icon name for the given buddy and account.
185 * If buddy is NULL, it will return the name to use for the account's icon
186 */
187 const char *(* list_icon)(struct gaim_account *account, struct buddy *buddy);
188
189 /**
190 * Fills the four char**'s with string identifiers for "emblems" that the UI will
191 * interpret and display as relevant
192 */
193 void (* list_emblems)(struct buddy *buddy, char **se, char **sw, char **nw, char **ne);
194
195 /**
196 * Gets a short string representing this buddy's status. This will be shown
197 * on the buddy list.
198 */
199 char *(* status_text)(struct buddy *buddy);
200
201 /**
202 * Gets a string to put in the buddy list tooltip.
203 */
204 char *(* tooltip_text)(struct buddy *buddy);
205
206 GList *(* away_states)(struct gaim_connection *gc);
207 GList *(* actions)(struct gaim_connection *gc);
208 /* user_splits is a GList of g_malloc'd struct proto_user_split */ 178 /* user_splits is a GList of g_malloc'd struct proto_user_split */
209 GList *user_splits; 179 GList *user_splits;
210 /* user_opts is a GList* of g_malloc'd struct proto_user_opts */ 180 /* user_opts is a GList* of g_malloc'd struct proto_user_opts */
211 GList *user_opts; 181 GList *user_opts;
212 GList *(* buddy_menu)(struct gaim_connection *, const char *); 182
213 GList *(* chat_info)(struct gaim_connection *); 183 /**
184 * Returns the base icon name for the given buddy and account.
185 * If buddy is NULL, it will return the name to use for the account's icon
186 */
187 const char *(*list_icon)(struct gaim_account *account, struct buddy *buddy);
188
189 /**
190 * Fills the four char**'s with string identifiers for "emblems"
191 * that the UI will interpret and display as relevant
192 */
193 void (*list_emblems)(struct buddy *buddy, char **se, char **sw,
194 char **nw, char **ne);
195
196 /**
197 * Gets a short string representing this buddy's status. This will
198 * be shown on the buddy list.
199 */
200 char *(*status_text)(struct buddy *buddy);
201
202 /**
203 * Gets a string to put in the buddy list tooltip.
204 */
205 char *(*tooltip_text)(struct buddy *buddy);
206
207 GList *(*away_states)(struct gaim_connection *gc);
208 GList *(*actions)(struct gaim_connection *gc);
209
210 GList *(*buddy_menu)(struct gaim_connection *, const char *);
211 GList *(*chat_info)(struct gaim_connection *);
214 212
215 /* All the server-related functions */ 213 /* All the server-related functions */
216 214
217 /* 215 /*
218 * A lot of these (like get_dir) are protocol-dependent and should 216 * A lot of these (like get_dir) are protocol-dependent and should
219 * be removed. ones like set_dir (which is also protocol-dependent) 217 * be removed. ones like set_dir (which is also protocol-dependent)
220 * can stay though because there's a dialog (i.e. the prpl says you 218 * can stay though because there's a dialog (i.e. the prpl says you
221 * can set your dir info, the ui shows a dialog and needs to call 219 * can set your dir info, the ui shows a dialog and needs to call
222 * set_dir in order to set it) 220 * set_dir in order to set it)
223 */ 221 */
224 void (* login) (struct gaim_account *); 222 void (*login)(struct gaim_account *);
225 void (* close) (struct gaim_connection *); 223 void (*close)(struct gaim_connection *);
226 int (* send_im) (struct gaim_connection *, const char *who, const char *message, 224 int (*send_im)(struct gaim_connection *, const char *who,
227 int len, int away); 225 const char *message, int len, int away);
228 void (* set_info) (struct gaim_connection *, char *info); 226 void (*set_info)(struct gaim_connection *, char *info);
229 int (* send_typing) (struct gaim_connection *, char *name, int typing); 227 int (*send_typing)(struct gaim_connection *, char *name, int typing);
230 void (* get_info) (struct gaim_connection *, const char *who); 228 void (*get_info)(struct gaim_connection *, const char *who);
231 void (* set_away) (struct gaim_connection *, char *state, char *message); 229 void (*set_away)(struct gaim_connection *, char *state, char *message);
232 void (* get_away) (struct gaim_connection *, const char *who); 230 void (*get_away)(struct gaim_connection *, const char *who);
233 void (* set_dir) (struct gaim_connection *, const char *first, 231 void (*set_dir)(struct gaim_connection *, const char *first,
234 const char *middle, 232 const char *middle, const char *last,
235 const char *last, 233 const char *maiden, const char *city,
236 const char *maiden, 234 const char *state, const char *country, int web);
237 const char *city, 235 void (*get_dir)(struct gaim_connection *, const char *who);
238 const char *state, 236 void (*dir_search)(struct gaim_connection *, const char *first,
239 const char *country, 237 const char *middle, const char *last,
240 int web); 238 const char *maiden, const char *city,
241 void (* get_dir) (struct gaim_connection *, const char *who); 239 const char *state, const char *country,
242 void (* dir_search) (struct gaim_connection *, const char *first, 240 const char *email);
243 const char *middle, 241 void (*set_idle)(struct gaim_connection *, int idletime);
244 const char *last, 242 void (*change_passwd)(struct gaim_connection *, const char *old,
245 const char *maiden, 243 const char *new);
246 const char *city, 244 void (*add_buddy)(struct gaim_connection *, const char *name);
247 const char *state, 245 void (*add_buddies)(struct gaim_connection *, GList *buddies);
248 const char *country, 246 void (*remove_buddy)(struct gaim_connection *, char *name, char *group);
249 const char *email); 247 void (*remove_buddies)(struct gaim_connection *, GList *buddies,
250 void (* set_idle) (struct gaim_connection *, int idletime); 248 const char *group);
251 void (* change_passwd) (struct gaim_connection *, const char *old, 249 void (*add_permit)(struct gaim_connection *, const char *name);
252 const char *new); 250 void (*add_deny)(struct gaim_connection *, const char *name);
253 void (* add_buddy) (struct gaim_connection *, const char *name); 251 void (*rem_permit)(struct gaim_connection *, const char *name);
254 void (* add_buddies) (struct gaim_connection *, GList *buddies); 252 void (*rem_deny)(struct gaim_connection *, const char *name);
255 void (* remove_buddy) (struct gaim_connection *, char *name, char *group); 253 void (*set_permit_deny)(struct gaim_connection *);
256 void (* remove_buddies) (struct gaim_connection *, GList *buddies, 254 void (*warn)(struct gaim_connection *, char *who, int anonymous);
257 const char *group); 255 void (*join_chat)(struct gaim_connection *, GList *data);
258 void (* add_permit) (struct gaim_connection *, const char *name); 256 void (*chat_invite)(struct gaim_connection *, int id,
259 void (* add_deny) (struct gaim_connection *, const char *name); 257 const char *who, const char *message);
260 void (* rem_permit) (struct gaim_connection *, const char *name); 258 void (*chat_leave)(struct gaim_connection *, int id);
261 void (* rem_deny) (struct gaim_connection *, const char *name); 259 void (*chat_whisper)(struct gaim_connection *, int id,
262 void (* set_permit_deny)(struct gaim_connection *); 260 char *who, char *message);
263 void (* warn) (struct gaim_connection *, char *who, int anonymous); 261 int (*chat_send)(struct gaim_connection *, int id, char *message);
264 void (* join_chat) (struct gaim_connection *, GList *data); 262 void (*keepalive)(struct gaim_connection *);
265 void (* chat_invite) (struct gaim_connection *, int id,
266 const char *who, const char *message);
267 void (* chat_leave) (struct gaim_connection *, int id);
268 void (* chat_whisper) (struct gaim_connection *, int id,
269 char *who, char *message);
270 int (* chat_send) (struct gaim_connection *, int id, char *message);
271 void (* keepalive) (struct gaim_connection *);
272 263
273 /* new user registration */ 264 /* new user registration */
274 void (* register_user) (struct gaim_account *); 265 void (*register_user)(struct gaim_account *);
275 266
276 /* get "chat buddy" info and away message */ 267 /* get "chat buddy" info and away message */
277 void (* get_cb_info) (struct gaim_connection *, int, char *who); 268 void (*get_cb_info)(struct gaim_connection *, int, char *who);
278 void (* get_cb_away) (struct gaim_connection *, int, char *who); 269 void (*get_cb_away)(struct gaim_connection *, int, char *who);
279 270
280 /* save/store buddy's alias on server list/roster */ 271 /* save/store buddy's alias on server list/roster */
281 void (* alias_buddy) (struct gaim_connection *, const char *who, 272 void (*alias_buddy)(struct gaim_connection *, const char *who,
282 const char *alias); 273 const char *alias);
283 274
284 /* change a buddy's group on a server list/roster */ 275 /* change a buddy's group on a server list/roster */
285 void (* group_buddy) (struct gaim_connection *, const char *who, 276 void (*group_buddy)(struct gaim_connection *, const char *who,
286 const char *old_group, const char *new_group); 277 const char *old_group, const char *new_group);
287 278
288 /* rename a group on a server list/roster */ 279 /* rename a group on a server list/roster */
289 void (* rename_group) (struct gaim_connection *, const char *old_group, 280 void (*rename_group)(struct gaim_connection *, const char *old_group,
290 const char *new_group, GList *members); 281 const char *new_group, GList *members);
291 282
292 void (* buddy_free) (struct buddy *); 283 void (*buddy_free)(struct buddy *);
293 284
294 /* this is really bad. */ 285 /* this is really bad. */
295 void (* convo_closed) (struct gaim_connection *, char *who); 286 void (*convo_closed)(struct gaim_connection *, char *who);
296 287
297 char *(* normalize)(const char *); 288 char *(*normalize)(const char *);
298 }; 289 };
290
291 #define GAIM_IS_PROTOCOL_PLUGIN(plugin) \
292 ((plugin)->info->type == GAIM_PLUGIN_PROTOCOL)
293
294 #define GAIM_PLUGIN_PROTOCOL_INFO(plugin) \
295 ((GaimPluginProtocolInfo *)(plugin)->info->extra_info)
299 296
300 /** A list of all loaded protocol plugins. */ 297 /** A list of all loaded protocol plugins. */
301 extern GSList *protocols; 298 extern GSList *protocols;
302
303 /** The number of accounts using a given protocol plugin. */
304 extern int prpl_accounts[];
305
306 /**
307 * Initializes static protocols.
308 *
309 * This is mostly just for main.c, when it initializes the protocols.
310 */
311 void static_proto_init();
312
313 /**
314 * Loads a protocol plugin.
315 *
316 * @param prpl The initial protocol plugin structure.
317 *
318 * @return @c TRUE if the protocol was loaded, or @c FALSE otherwise.
319 */
320 gboolean load_prpl(struct prpl *prpl);
321
322 /**
323 * Loads a statically compiled protocol plugin.
324 *
325 * @param pi The initialization function.
326 */
327 void load_protocol(proto_init pi);
328
329 /**
330 * Unloads a protocol plugin.
331 *
332 * @param prpl The protocol plugin to unload.
333 */
334 extern void unload_protocol(struct prpl *prpl);
335 299
336 /** 300 /**
337 * Compares two protocol plugins, based off their protocol plugin number. 301 * Compares two protocol plugins, based off their protocol plugin number.
338 * 302 *
339 * @param a The first protocol plugin. 303 * @param a The first protocol plugin.
341 * 305 *
342 * @return <= 1 if the first plugin's number is smaller than the second; 306 * @return <= 1 if the first plugin's number is smaller than the second;
343 * 0 if the first plugin's number is equal to the second; or 307 * 0 if the first plugin's number is equal to the second; or
344 * >= 1 if the first plugin's number is greater than the second. 308 * >= 1 if the first plugin's number is greater than the second.
345 */ 309 */
346 gint proto_compare(struct prpl *a, struct prpl *b); 310 gint gaim_prpl_compare(GaimPlugin *a, GaimPlugin *b);
347 311
348 /** 312 /**
349 * Finds a protocol plugin structure of the specified type. 313 * Finds a protocol plugin structure of the specified type.
350 * 314 *
351 * @param type The protocol plugin type. 315 * @param type The protocol plugin;
352 */ 316 */
353 struct prpl *find_prpl(GaimProtocol type); 317 GaimPlugin *gaim_find_prpl(GaimProtocol type);
354 318
355 /** 319 /**
356 * Creates a menu of all protocol plugins and their protocol-specific 320 * Creates a menu of all protocol plugins and their protocol-specific
357 * actions. 321 * actions.
358 * 322 *
359 * @note This should be UI-specific code, or rewritten in such a way as to 323 * @note This should be UI-specific code, or rewritten in such a way as to
360 * not use any any GTK code. 324 * not use any any GTK code.
361 */ 325 */
362 void do_proto_menu(); 326 void do_proto_menu(void);
363 327
364 /** 328 /**
365 * Shows a message saying that somebody added you as a buddy, and asks 329 * Shows a message saying that somebody added you as a buddy, and asks
366 * if you would like to do the same. 330 * if you would like to do the same.
367 * 331 *
375 const char *who, const char *alias, const char *msg); 339 const char *who, const char *alias, const char *msg);
376 340
377 /** 341 /**
378 * Closes do_ask_dialogs when the associated plugin is unloaded. 342 * Closes do_ask_dialogs when the associated plugin is unloaded.
379 * 343 *
380 * @param module The module. 344 * @param handle The handle.
381 */ 345 */
382 void do_ask_cancel_by_handle(GModule *module); 346 void do_ask_cancel_by_handle(void *handle);
383 347
384 /** 348 /**
385 * Asks the user a question and acts on the response. 349 * Asks the user a question and acts on the response.
386 * 350 *
387 * @param prim The primary question. 351 * @param prim The primary question.
446 * 410 *
447 * @return The buddy icon data. 411 * @return The buddy icon data.
448 */ 412 */
449 void *get_icon_data(struct gaim_connection *gc, const char *who, int *len); 413 void *get_icon_data(struct gaim_connection *gc, const char *who, int *len);
450 414
451 /* stuff to load/unload PRPLs as necessary */
452
453 /**
454 * Increments the reference count on a protocol plugin.
455 *
456 * @param prpl The protocol plugin.
457 *
458 * @return @c TRUE if the protocol plugin is loaded, or @c FALSE otherwise.
459 */
460 gboolean ref_protocol(struct prpl *prpl);
461
462 /**
463 * Decrements the reference count on a protocol plugin.
464 *
465 * When the reference count hits 0, the protocol plugin is unloaded.
466 */
467 void unref_protocol(struct prpl *prpl);
468
469 #endif /* _PRPL_H_ */ 415 #endif /* _PRPL_H_ */

mercurial