comparison libpurple/prpl.h @ 28598:e37f85160784

Documented chat API. References #10605
author sttwister@gmail.com
date Sun, 22 Nov 2009 21:13:20 +0000
parents cda10ae89918
children 45a94940c122 a538cb73f897
comparison
equal deleted inserted replaced
28385:d5ff2cd6064a 28598:e37f85160784
89 int max_height; /**< Maximum height of this icon */ 89 int max_height; /**< Maximum height of this icon */
90 size_t max_filesize; /**< Maximum size in bytes */ 90 size_t max_filesize; /**< Maximum size in bytes */
91 PurpleIconScaleRules scale_rules; /**< How to stretch this icon */ 91 PurpleIconScaleRules scale_rules; /**< How to stretch this icon */
92 }; 92 };
93 93
94 /** Represents an entry containing information that must be supplied by the
95 * user when joining a chat.
96 */
94 struct proto_chat_entry { 97 struct proto_chat_entry {
95 const char *label; 98 const char *label; /**< User-friendly name of the entry */
96 const char *identifier; 99 const char *identifier; /**< Used by the PRPL to identify the option */
97 gboolean required; 100 gboolean required; /**< True if it's required */
98 gboolean is_int; 101 gboolean is_int; /**< True if the entry expects an integer */
99 int min; 102 int min; /**< Minimum value in case of integer */
100 int max; 103 int max; /**< Maximum value in case of integer */
101 gboolean secret; 104 gboolean secret; /**< True if the entry is secret (password) */
102 }; 105 };
103 106
104 /** Represents "nudges" and "buzzes" that you may send to a buddy to attract 107 /** Represents "nudges" and "buzzes" that you may send to a buddy to attract
105 * their attention (or vice-versa). 108 * their attention (or vice-versa).
106 */ 109 */
250 * Returns a list of #PurpleMenuAction structs, which represent extra 253 * Returns a list of #PurpleMenuAction structs, which represent extra
251 * actions to be shown in (for example) the right-click menu for @a 254 * actions to be shown in (for example) the right-click menu for @a
252 * node. 255 * node.
253 */ 256 */
254 GList *(*blist_node_menu)(PurpleBlistNode *node); 257 GList *(*blist_node_menu)(PurpleBlistNode *node);
258
259 /**
260 * Returns a list of #proto_chat_entry structs, which represent
261 * information required by the PRPL to join a chat. libpurple will
262 * call join_chat along with the information filled by the user.
263 *
264 * @return A list of #proto_chat_entry structs
265 */
255 GList *(*chat_info)(PurpleConnection *); 266 GList *(*chat_info)(PurpleConnection *);
267
268 /**
269 * Returns a hashtable which maps #proto_chat_entry struct identifiers
270 * to default options as strings based on chat_name. The resulting
271 * hashtable should be created with g_hash_table_new_full(g_str_hash,
272 * g_str_equal, NULL, g_free);. Use #get_chat_name if you instead need
273 * to extract a chat name from a hashtable.
274 *
275 * @param chat_name The chat name to be turned into components
276 * @return Hashtable containing the information extracted from chat_name
277 */
256 GHashTable *(*chat_info_defaults)(PurpleConnection *, const char *chat_name); 278 GHashTable *(*chat_info_defaults)(PurpleConnection *, const char *chat_name);
257 279
258 /* All the server-related functions */ 280 /* All the server-related functions */
259 281
260 /** This must be implemented. */ 282 /** This must be implemented. */
312 void (*add_permit)(PurpleConnection *, const char *name); 334 void (*add_permit)(PurpleConnection *, const char *name);
313 void (*add_deny)(PurpleConnection *, const char *name); 335 void (*add_deny)(PurpleConnection *, const char *name);
314 void (*rem_permit)(PurpleConnection *, const char *name); 336 void (*rem_permit)(PurpleConnection *, const char *name);
315 void (*rem_deny)(PurpleConnection *, const char *name); 337 void (*rem_deny)(PurpleConnection *, const char *name);
316 void (*set_permit_deny)(PurpleConnection *); 338 void (*set_permit_deny)(PurpleConnection *);
339
340 /**
341 * Called when the user requests joining a chat. Should arrange for
342 * #serv_got_joined_chat to be called.
343 *
344 * @param components A hashtable containing information required to
345 * join the chat as described by the entries returned
346 * by #chat_info. It may also be called when accepting
347 * an invitation, in which case this matches the
348 * data parameter passed to #serv_got_chat_invite.
349 */
317 void (*join_chat)(PurpleConnection *, GHashTable *components); 350 void (*join_chat)(PurpleConnection *, GHashTable *components);
351
352 /**
353 * Called when the user refuses a chat invitation.
354 *
355 * @param components A hashtable containing information required to
356 * join the chat as passed to #serv_got_chat_invite.
357 */
318 void (*reject_chat)(PurpleConnection *, GHashTable *components); 358 void (*reject_chat)(PurpleConnection *, GHashTable *components);
359
360 /**
361 * Returns a chat name based on the information in components. Use
362 * #chat_info_defaults if you instead need to generate a hashtable
363 * from a chat name.
364 *
365 * @param components A hashtable containing information about the chat.
366 */
319 char *(*get_chat_name)(GHashTable *components); 367 char *(*get_chat_name)(GHashTable *components);
368
369 /**
370 * Invite a user to join a chat.
371 *
372 * @param id The id of the chat to invite the user to.
373 * @param message A message displayed to the user when the invitation
374 * is received.
375 * @param who The name of the user to send the invation to.
376 */
320 void (*chat_invite)(PurpleConnection *, int id, 377 void (*chat_invite)(PurpleConnection *, int id,
321 const char *message, const char *who); 378 const char *message, const char *who);
379 /**
380 * Called when the user requests leaving a chat.
381 *
382 * @param id The id of the chat to leave
383 */
322 void (*chat_leave)(PurpleConnection *, int id); 384 void (*chat_leave)(PurpleConnection *, int id);
385
386 /**
387 * Send a whisper to a user in a chat.
388 *
389 * @param id The id of the chat.
390 * @param who The name of the user to send the whisper to.
391 * @param message The message of the whisper.
392 */
323 void (*chat_whisper)(PurpleConnection *, int id, 393 void (*chat_whisper)(PurpleConnection *, int id,
324 const char *who, const char *message); 394 const char *who, const char *message);
395
396 /**
397 * Send a message to a chat.
398 * This PRPL function should return a positive value on success.
399 * If the message is too big to be sent, return -E2BIG. If
400 * the account is not connected, return -ENOTCONN. If the
401 * PRPL is unable to send the message for another reason, return
402 * some other negative value. You can use one of the valid
403 * errno values, or just big something. If the message should
404 * not be echoed to the conversation window, return 0.
405 *
406 * @param id The id of the chat to send the message to.
407 * @param message The message to send to the chat.
408 * @param flags A bitwise OR of #PurpleMessageFlags representing
409 * message flags.
410 * @return A positive number or 0 in case of succes,
411 * a negative error number in case of failure.
412 */
325 int (*chat_send)(PurpleConnection *, int id, const char *message, PurpleMessageFlags flags); 413 int (*chat_send)(PurpleConnection *, int id, const char *message, PurpleMessageFlags flags);
326 414
327 /** If implemented, this will be called regularly for this prpl's 415 /** If implemented, this will be called regularly for this prpl's
328 * active connections. You'd want to do this if you need to repeatedly 416 * active connections. You'd want to do this if you need to repeatedly
329 * send some kind of keepalive packet to the server to avoid being 417 * send some kind of keepalive packet to the server to avoid being