prpl.h

Go to the documentation of this file.
00001 
00006 /* purple
00007  *
00008  * Purple is the legal property of its developers, whose names are too numerous
00009  * to list here.  Please refer to the COPYRIGHT file distributed with this
00010  * source distribution.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00025  */
00026 
00027 /* this file should be all that prpls need to include. therefore, by including
00028  * this file, they should get glib, proxy, purple_connection, prpl, etc. */
00029 
00030 #ifndef _PURPLE_PRPL_H_
00031 #define _PURPLE_PRPL_H_
00032 
00033 typedef struct _PurplePluginProtocolInfo PurplePluginProtocolInfo;
00035 typedef struct _PurpleAttentionType PurpleAttentionType;
00036 
00037 /**************************************************************************/
00039 /**************************************************************************/
00040 
00041 typedef enum {
00042     PURPLE_ICON_SCALE_DISPLAY = 0x01,       
00043     PURPLE_ICON_SCALE_SEND = 0x02           
00044 } PurpleIconScaleRules;
00045 
00046 
00052 typedef struct _PurpleBuddyIconSpec PurpleBuddyIconSpec;
00053 
00058 #define NO_BUDDY_ICONS {NULL, 0, 0, 0, 0, 0, 0}
00059 
00060 #ifdef HAVE_UNISTD_H
00061 #include <unistd.h>
00062 #endif
00063 
00064 #include "blist.h"
00065 #include "conversation.h"
00066 #include "ft.h"
00067 #include "imgstore.h"
00068 #include "media.h"
00069 #include "notify.h"
00070 #include "proxy.h"
00071 #include "plugin.h"
00072 #include "roomlist.h"
00073 #include "status.h"
00074 #include "whiteboard.h"
00075 
00076 
00078 struct _PurpleBuddyIconSpec {
00084     char *format;
00085 
00086     int min_width;                     
00087     int min_height;                    
00088     int max_width;                     
00089     int max_height;                    
00090     size_t max_filesize;               
00091     PurpleIconScaleRules scale_rules;  
00092 };
00093 
00094 struct proto_chat_entry {
00095     const char *label;
00096     const char *identifier;
00097     gboolean required;
00098     gboolean is_int;
00099     int min;
00100     int max;
00101     gboolean secret;
00102 };
00103 
00107 struct _PurpleAttentionType
00108 {
00109     const char *name;                  
00110     const char *incoming_description;  
00111     const char *outgoing_description;  
00112     const char *icon_name;             
00113     const char *unlocalized_name;      
00115     /* Reserved fields for future purposes */
00116     gpointer _reserved2;
00117     gpointer _reserved3;
00118     gpointer _reserved4;
00119 };
00120 
00126 typedef enum
00127 {
00135     OPT_PROTO_UNIQUE_CHATNAME = 0x00000004,
00136 
00142     OPT_PROTO_CHAT_TOPIC = 0x00000008,
00143 
00150     OPT_PROTO_NO_PASSWORD = 0x00000010,
00151 
00157     OPT_PROTO_MAIL_CHECK = 0x00000020,
00158 
00164     OPT_PROTO_IM_IMAGE = 0x00000040,
00165 
00172     OPT_PROTO_PASSWORD_OPTIONAL = 0x00000080,
00173 
00179     OPT_PROTO_USE_POINTSIZE = 0x00000100,
00180 
00188     OPT_PROTO_REGISTER_NOSCREENNAME = 0x00000200,
00189 
00195     OPT_PROTO_SLASH_COMMANDS_NATIVE = 0x00000400
00196 
00197 } PurpleProtocolOptions;
00198 
00206 struct _PurplePluginProtocolInfo
00207 {
00208     PurpleProtocolOptions options;  
00210     GList *user_splits;      
00211     GList *protocol_options; 
00213     PurpleBuddyIconSpec icon_spec; 
00223     const char *(*list_icon)(PurpleAccount *account, PurpleBuddy *buddy);
00224 
00229     const char *(*list_emblem)(PurpleBuddy *buddy);
00230 
00235     char *(*status_text)(PurpleBuddy *buddy);
00236 
00240     void (*tooltip_text)(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full);
00241 
00247     GList *(*status_types)(PurpleAccount *account);
00248 
00254     GList *(*blist_node_menu)(PurpleBlistNode *node);
00255     GList *(*chat_info)(PurpleConnection *);
00256     GHashTable *(*chat_info_defaults)(PurpleConnection *, const char *chat_name);
00257 
00258     /* All the server-related functions */
00259 
00261     void (*login)(PurpleAccount *);
00262 
00264     void (*close)(PurpleConnection *);
00265 
00275     int  (*send_im)(PurpleConnection *, const char *who,
00276                     const char *message,
00277                     PurpleMessageFlags flags);
00278 
00279     void (*set_info)(PurpleConnection *, const char *info);
00280 
00288     unsigned int (*send_typing)(PurpleConnection *, const char *name, PurpleTypingState state);
00289 
00294     void (*get_info)(PurpleConnection *, const char *who);
00295     void (*set_status)(PurpleAccount *account, PurpleStatus *status);
00296 
00297     void (*set_idle)(PurpleConnection *, int idletime);
00298     void (*change_passwd)(PurpleConnection *, const char *old_pass,
00299                           const char *new_pass);
00308     void (*add_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
00309     void (*add_buddies)(PurpleConnection *, GList *buddies, GList *groups);
00310     void (*remove_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
00311     void (*remove_buddies)(PurpleConnection *, GList *buddies, GList *groups);
00312     void (*add_permit)(PurpleConnection *, const char *name);
00313     void (*add_deny)(PurpleConnection *, const char *name);
00314     void (*rem_permit)(PurpleConnection *, const char *name);
00315     void (*rem_deny)(PurpleConnection *, const char *name);
00316     void (*set_permit_deny)(PurpleConnection *);
00317     void (*join_chat)(PurpleConnection *, GHashTable *components);
00318     void (*reject_chat)(PurpleConnection *, GHashTable *components);
00319     char *(*get_chat_name)(GHashTable *components);
00320     void (*chat_invite)(PurpleConnection *, int id,
00321                         const char *message, const char *who);
00322     void (*chat_leave)(PurpleConnection *, int id);
00323     void (*chat_whisper)(PurpleConnection *, int id,
00324                          const char *who, const char *message);
00325     int  (*chat_send)(PurpleConnection *, int id, const char *message, PurpleMessageFlags flags);
00326 
00333     void (*keepalive)(PurpleConnection *);
00334 
00336     void (*register_user)(PurpleAccount *);
00337 
00341     void (*get_cb_info)(PurpleConnection *, int, const char *who);
00346     void (*get_cb_away)(PurpleConnection *, int, const char *who);
00347 
00349     void (*alias_buddy)(PurpleConnection *, const char *who,
00350                         const char *alias);
00351 
00353     void (*group_buddy)(PurpleConnection *, const char *who,
00354                         const char *old_group, const char *new_group);
00355 
00357     void (*rename_group)(PurpleConnection *, const char *old_name,
00358                          PurpleGroup *group, GList *moved_buddies);
00359 
00360     void (*buddy_free)(PurpleBuddy *);
00361 
00362     void (*convo_closed)(PurpleConnection *, const char *who);
00363 
00369     const char *(*normalize)(const PurpleAccount *, const char *who);
00370 
00376     void (*set_buddy_icon)(PurpleConnection *, PurpleStoredImage *img);
00377 
00378     void (*remove_group)(PurpleConnection *gc, PurpleGroup *group);
00379 
00389     char *(*get_cb_real_name)(PurpleConnection *gc, int id, const char *who);
00390 
00391     void (*set_chat_topic)(PurpleConnection *gc, int id, const char *topic);
00392 
00393     PurpleChat *(*find_blist_chat)(PurpleAccount *account, const char *name);
00394 
00395     /* room listing prpl callbacks */
00396     PurpleRoomlist *(*roomlist_get_list)(PurpleConnection *gc);
00397     void (*roomlist_cancel)(PurpleRoomlist *list);
00398     void (*roomlist_expand_category)(PurpleRoomlist *list, PurpleRoomlistRoom *category);
00399 
00400     /* file transfer callbacks */
00401     gboolean (*can_receive_file)(PurpleConnection *, const char *who);
00402     void (*send_file)(PurpleConnection *, const char *who, const char *filename);
00403     PurpleXfer *(*new_xfer)(PurpleConnection *, const char *who);
00404 
00409     gboolean (*offline_message)(const PurpleBuddy *buddy);
00410 
00411     PurpleWhiteboardPrplOps *whiteboard_prpl_ops;
00412 
00414     int (*send_raw)(PurpleConnection *gc, const char *buf, int len);
00415 
00416     /* room list serialize */
00417     char *(*roomlist_room_serialize)(PurpleRoomlistRoom *room);
00418 
00423     /* This is here rather than next to register_user for API compatibility
00424      * reasons.
00425      */
00426     void (*unregister_user)(PurpleAccount *, PurpleAccountUnregistrationCb cb, void *user_data);
00427 
00428     /* Attention API for sending & receiving zaps/nudges/buzzes etc. */
00429     gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type);
00430     GList *(*get_attention_types)(PurpleAccount *acct);
00431 
00436     unsigned long struct_size;
00437 
00438     /* NOTE:
00439      * If more functions are added, they should accessed using the following syntax:
00440      *
00441      *      if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, new_function))
00442      *          prpl->new_function(...);
00443      *
00444      * instead of
00445      *
00446      *      if (prpl->new_function != NULL)
00447      *          prpl->new_function(...);
00448      *
00449      * The PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro can be used for the older member
00450      * functions (e.g. login, send_im etc.) too.
00451      */
00452 
00462     GHashTable *(*get_account_text_table)(PurpleAccount *account);
00463 
00472     gboolean (*initiate_media)(PurpleAccount *account, const char *who,
00473                     PurpleMediaSessionType type);
00474 
00482     PurpleMediaCaps (*get_media_caps)(PurpleAccount *account,
00483                       const char *who);
00484 };
00485 
00486 #define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \
00487     (((G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < G_STRUCT_OFFSET(PurplePluginProtocolInfo, struct_size)) \
00488       || (G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < prpl->struct_size)) && \
00489      prpl->member != NULL)
00490 
00491 
00492 #define PURPLE_IS_PROTOCOL_PLUGIN(plugin) \
00493     ((plugin)->info->type == PURPLE_PLUGIN_PROTOCOL)
00494 
00495 #define PURPLE_PLUGIN_PROTOCOL_INFO(plugin) \
00496     ((PurplePluginProtocolInfo *)(plugin)->info->extra_info)
00497 
00498 #ifdef __cplusplus
00499 extern "C" {
00500 #endif
00501 
00502 /**************************************************************************/
00504 /**************************************************************************/
00520 PurpleAttentionType *purple_attention_type_new(const char *ulname, const char *name,
00521                                 const char *inc_desc, const char *out_desc);
00522 
00532 void purple_attention_type_set_name(PurpleAttentionType *type, const char *name);
00533 
00542 void purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const char *desc);
00543 
00552 void purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const char *desc);
00553 
00562 void purple_attention_type_set_icon_name(PurpleAttentionType *type, const char *name);
00563 
00573 void purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const char *ulname);
00574 
00582 const char *purple_attention_type_get_name(const PurpleAttentionType *type);
00583 
00591 const char *purple_attention_type_get_incoming_desc(const PurpleAttentionType *type);
00592 
00600 const char *purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type);
00601 
00610 const char *purple_attention_type_get_icon_name(const PurpleAttentionType *type);
00611 
00619 const char *purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type);
00620 
00623 /**************************************************************************/
00625 /**************************************************************************/
00637 void purple_prpl_got_account_idle(PurpleAccount *account, gboolean idle,
00638                                 time_t idle_time);
00639 
00648 void purple_prpl_got_account_login_time(PurpleAccount *account, time_t login_time);
00649 
00660 void purple_prpl_got_account_status(PurpleAccount *account,
00661                                   const char *status_id, ...) G_GNUC_NULL_TERMINATED;
00662 
00675 void purple_prpl_got_account_actions(PurpleAccount *account);
00676 
00690 void purple_prpl_got_user_idle(PurpleAccount *account, const char *name,
00691                              gboolean idle, time_t idle_time);
00692 
00702 void purple_prpl_got_user_login_time(PurpleAccount *account, const char *name,
00703                                    time_t login_time);
00704 
00716 void purple_prpl_got_user_status(PurpleAccount *account, const char *name,
00717                                const char *status_id, ...) G_GNUC_NULL_TERMINATED;
00718 
00728 void purple_prpl_got_user_status_deactive(PurpleAccount *account, const char *name,
00729                     const char *status_id);
00730 
00739 void purple_prpl_change_account_status(PurpleAccount *account,
00740                                      PurpleStatus *old_status,
00741                                      PurpleStatus *new_status);
00742 
00751 GList *purple_prpl_get_statuses(PurpleAccount *account, PurplePresence *presence);
00752 
00767 void purple_prpl_send_attention(PurpleConnection *gc, const char *who, guint type_code);
00768 
00779 void purple_prpl_got_attention(PurpleConnection *gc, const char *who, guint type_code);
00780 
00792 void purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code);
00793 
00802 PurpleMediaCaps purple_prpl_get_media_caps(PurpleAccount *account,
00803                   const char *who);
00804 
00814 gboolean purple_prpl_initiate_media(PurpleAccount *account,
00815                     const char *who,
00816                     PurpleMediaSessionType type);
00817 
00820 /**************************************************************************/
00822 /**************************************************************************/
00830 PurplePlugin *purple_find_prpl(const char *id);
00831 
00834 #ifdef __cplusplus
00835 }
00836 #endif
00837 
00838 #endif /* _PRPL_H_ */

Generated on Wed Oct 14 21:58:20 2009 for pidgin by  doxygen 1.6.1