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 
00059 typedef struct _PurpleThumbnailSpec PurpleThumbnailSpec;
00060 
00065 #define NO_BUDDY_ICONS {NULL, 0, 0, 0, 0, 0, 0}
00066 
00067 #ifdef HAVE_UNISTD_H
00068 #include <unistd.h>
00069 #endif
00070 
00071 #include "blist.h"
00072 #include "conversation.h"
00073 #include "ft.h"
00074 #include "imgstore.h"
00075 #include "media.h"
00076 #include "notify.h"
00077 #include "proxy.h"
00078 #include "plugin.h"
00079 #include "roomlist.h"
00080 #include "status.h"
00081 #include "whiteboard.h"
00082 
00083 
00085 struct _PurpleBuddyIconSpec {
00091     char *format;
00092 
00093     int min_width;                     
00094     int min_height;                    
00095     int max_width;                     
00096     int max_height;                    
00097     size_t max_filesize;               
00098     PurpleIconScaleRules scale_rules;  
00099 };
00100 
00104 struct proto_chat_entry {
00105     const char *label;       
00106     const char *identifier;  
00107     gboolean required;       
00108     gboolean is_int;         
00109     int min;                 
00110     int max;                 
00111     gboolean secret;         
00112 };
00113 
00117 struct _PurpleAttentionType
00118 {
00119     const char *name;                  
00120     const char *incoming_description;  
00121     const char *outgoing_description;  
00122     const char *icon_name;             
00123     const char *unlocalized_name;      
00125     /* Reserved fields for future purposes */
00126     gpointer _reserved2;
00127     gpointer _reserved3;
00128     gpointer _reserved4;
00129 };
00130 
00136 typedef enum
00137 {
00145     OPT_PROTO_UNIQUE_CHATNAME = 0x00000004,
00146 
00152     OPT_PROTO_CHAT_TOPIC = 0x00000008,
00153 
00160     OPT_PROTO_NO_PASSWORD = 0x00000010,
00161 
00167     OPT_PROTO_MAIL_CHECK = 0x00000020,
00168 
00174     OPT_PROTO_IM_IMAGE = 0x00000040,
00175 
00182     OPT_PROTO_PASSWORD_OPTIONAL = 0x00000080,
00183 
00189     OPT_PROTO_USE_POINTSIZE = 0x00000100,
00190 
00198     OPT_PROTO_REGISTER_NOSCREENNAME = 0x00000200,
00199 
00205     OPT_PROTO_SLASH_COMMANDS_NATIVE = 0x00000400
00206 
00207 } PurpleProtocolOptions;
00208 
00216 struct _PurplePluginProtocolInfo
00217 {
00218     PurpleProtocolOptions options;  
00220     GList *user_splits;      
00221     GList *protocol_options; 
00223     PurpleBuddyIconSpec icon_spec; 
00233     const char *(*list_icon)(PurpleAccount *account, PurpleBuddy *buddy);
00234 
00239     const char *(*list_emblem)(PurpleBuddy *buddy);
00240 
00245     char *(*status_text)(PurpleBuddy *buddy);
00246 
00250     void (*tooltip_text)(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full);
00251 
00257     GList *(*status_types)(PurpleAccount *account);
00258 
00264     GList *(*blist_node_menu)(PurpleBlistNode *node);
00265 
00273     GList *(*chat_info)(PurpleConnection *);
00274 
00285     GHashTable *(*chat_info_defaults)(PurpleConnection *, const char *chat_name);
00286 
00287     /* All the server-related functions */
00288 
00290     void (*login)(PurpleAccount *);
00291 
00293     void (*close)(PurpleConnection *);
00294 
00304     int  (*send_im)(PurpleConnection *, const char *who,
00305                     const char *message,
00306                     PurpleMessageFlags flags);
00307 
00308     void (*set_info)(PurpleConnection *, const char *info);
00309 
00317     unsigned int (*send_typing)(PurpleConnection *, const char *name, PurpleTypingState state);
00318 
00323     void (*get_info)(PurpleConnection *, const char *who);
00324     void (*set_status)(PurpleAccount *account, PurpleStatus *status);
00325 
00326     void (*set_idle)(PurpleConnection *, int idletime);
00327     void (*change_passwd)(PurpleConnection *, const char *old_pass,
00328                           const char *new_pass);
00337     void (*add_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
00338     void (*add_buddies)(PurpleConnection *, GList *buddies, GList *groups);
00339     void (*remove_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
00340     void (*remove_buddies)(PurpleConnection *, GList *buddies, GList *groups);
00341     void (*add_permit)(PurpleConnection *, const char *name);
00342     void (*add_deny)(PurpleConnection *, const char *name);
00343     void (*rem_permit)(PurpleConnection *, const char *name);
00344     void (*rem_deny)(PurpleConnection *, const char *name);
00345     void (*set_permit_deny)(PurpleConnection *);
00346 
00357     void (*join_chat)(PurpleConnection *, GHashTable *components);
00358 
00365     void (*reject_chat)(PurpleConnection *, GHashTable *components);
00366 
00374     char *(*get_chat_name)(GHashTable *components);
00375 
00384     void (*chat_invite)(PurpleConnection *, int id,
00385                         const char *message, const char *who);
00391     void (*chat_leave)(PurpleConnection *, int id);
00392 
00400     void (*chat_whisper)(PurpleConnection *, int id,
00401                          const char *who, const char *message);
00402 
00420     int  (*chat_send)(PurpleConnection *, int id, const char *message, PurpleMessageFlags flags);
00421 
00428     void (*keepalive)(PurpleConnection *);
00429 
00431     void (*register_user)(PurpleAccount *);
00432 
00436     void (*get_cb_info)(PurpleConnection *, int, const char *who);
00441     void (*get_cb_away)(PurpleConnection *, int, const char *who);
00442 
00444     void (*alias_buddy)(PurpleConnection *, const char *who,
00445                         const char *alias);
00446 
00448     void (*group_buddy)(PurpleConnection *, const char *who,
00449                         const char *old_group, const char *new_group);
00450 
00452     void (*rename_group)(PurpleConnection *, const char *old_name,
00453                          PurpleGroup *group, GList *moved_buddies);
00454 
00455     void (*buddy_free)(PurpleBuddy *);
00456 
00457     void (*convo_closed)(PurpleConnection *, const char *who);
00458 
00464     const char *(*normalize)(const PurpleAccount *, const char *who);
00465 
00471     void (*set_buddy_icon)(PurpleConnection *, PurpleStoredImage *img);
00472 
00473     void (*remove_group)(PurpleConnection *gc, PurpleGroup *group);
00474 
00484     char *(*get_cb_real_name)(PurpleConnection *gc, int id, const char *who);
00485 
00486     void (*set_chat_topic)(PurpleConnection *gc, int id, const char *topic);
00487 
00488     PurpleChat *(*find_blist_chat)(PurpleAccount *account, const char *name);
00489 
00490     /* room listing prpl callbacks */
00491     PurpleRoomlist *(*roomlist_get_list)(PurpleConnection *gc);
00492     void (*roomlist_cancel)(PurpleRoomlist *list);
00493     void (*roomlist_expand_category)(PurpleRoomlist *list, PurpleRoomlistRoom *category);
00494 
00495     /* file transfer callbacks */
00496     gboolean (*can_receive_file)(PurpleConnection *, const char *who);
00497     void (*send_file)(PurpleConnection *, const char *who, const char *filename);
00498     PurpleXfer *(*new_xfer)(PurpleConnection *, const char *who);
00499 
00504     gboolean (*offline_message)(const PurpleBuddy *buddy);
00505 
00506     PurpleWhiteboardPrplOps *whiteboard_prpl_ops;
00507 
00509     int (*send_raw)(PurpleConnection *gc, const char *buf, int len);
00510 
00511     /* room list serialize */
00512     char *(*roomlist_room_serialize)(PurpleRoomlistRoom *room);
00513 
00518     /* This is here rather than next to register_user for API compatibility
00519      * reasons.
00520      */
00521     void (*unregister_user)(PurpleAccount *, PurpleAccountUnregistrationCb cb, void *user_data);
00522 
00523     /* Attention API for sending & receiving zaps/nudges/buzzes etc. */
00524     gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type);
00525     GList *(*get_attention_types)(PurpleAccount *acct);
00526 
00531     unsigned long struct_size;
00532 
00533     /* NOTE:
00534      * If more functions are added, they should accessed using the following syntax:
00535      *
00536      *      if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, new_function))
00537      *          prpl->new_function(...);
00538      *
00539      * instead of
00540      *
00541      *      if (prpl->new_function != NULL)
00542      *          prpl->new_function(...);
00543      *
00544      * The PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro can be used for the older member
00545      * functions (e.g. login, send_im etc.) too.
00546      */
00547 
00557     GHashTable *(*get_account_text_table)(PurpleAccount *account);
00558 
00567     gboolean (*initiate_media)(PurpleAccount *account, const char *who,
00568                     PurpleMediaSessionType type);
00569 
00577     PurpleMediaCaps (*get_media_caps)(PurpleAccount *account,
00578                       const char *who);
00579 
00585     PurpleMood *(*get_moods)(PurpleAccount *account);
00586 
00605     void (*set_public_alias)(PurpleConnection *gc, const char *alias,
00606                              PurpleSetPublicAliasSuccessCallback success_cb,
00607                              PurpleSetPublicAliasFailureCallback failure_cb);
00622     void (*get_public_alias)(PurpleConnection *gc,
00623                              PurpleGetPublicAliasSuccessCallback success_cb,
00624                              PurpleGetPublicAliasFailureCallback failure_cb);
00625 };
00626 
00627 #define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \
00628     (((G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < G_STRUCT_OFFSET(PurplePluginProtocolInfo, struct_size)) \
00629       || (G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < prpl->struct_size)) && \
00630      prpl->member != NULL)
00631 
00632 
00633 #define PURPLE_IS_PROTOCOL_PLUGIN(plugin) \
00634     ((plugin)->info->type == PURPLE_PLUGIN_PROTOCOL)
00635 
00636 #define PURPLE_PLUGIN_PROTOCOL_INFO(plugin) \
00637     ((PurplePluginProtocolInfo *)(plugin)->info->extra_info)
00638 
00639 #ifdef __cplusplus
00640 extern "C" {
00641 #endif
00642 
00643 /**************************************************************************/
00645 /**************************************************************************/
00661 PurpleAttentionType *purple_attention_type_new(const char *ulname, const char *name,
00662                                 const char *inc_desc, const char *out_desc);
00663 
00673 void purple_attention_type_set_name(PurpleAttentionType *type, const char *name);
00674 
00683 void purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const char *desc);
00684 
00693 void purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const char *desc);
00694 
00703 void purple_attention_type_set_icon_name(PurpleAttentionType *type, const char *name);
00704 
00714 void purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const char *ulname);
00715 
00723 const char *purple_attention_type_get_name(const PurpleAttentionType *type);
00724 
00732 const char *purple_attention_type_get_incoming_desc(const PurpleAttentionType *type);
00733 
00741 const char *purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type);
00742 
00751 const char *purple_attention_type_get_icon_name(const PurpleAttentionType *type);
00752 
00760 const char *purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type);
00761 
00764 /**************************************************************************/
00766 /**************************************************************************/
00778 void purple_prpl_got_account_idle(PurpleAccount *account, gboolean idle,
00779                                 time_t idle_time);
00780 
00789 void purple_prpl_got_account_login_time(PurpleAccount *account, time_t login_time);
00790 
00801 void purple_prpl_got_account_status(PurpleAccount *account,
00802                                   const char *status_id, ...) G_GNUC_NULL_TERMINATED;
00803 
00816 void purple_prpl_got_account_actions(PurpleAccount *account);
00817 
00831 void purple_prpl_got_user_idle(PurpleAccount *account, const char *name,
00832                              gboolean idle, time_t idle_time);
00833 
00843 void purple_prpl_got_user_login_time(PurpleAccount *account, const char *name,
00844                                    time_t login_time);
00845 
00857 void purple_prpl_got_user_status(PurpleAccount *account, const char *name,
00858                                const char *status_id, ...) G_GNUC_NULL_TERMINATED;
00859 
00869 void purple_prpl_got_user_status_deactive(PurpleAccount *account, const char *name,
00870                     const char *status_id);
00871 
00880 void purple_prpl_change_account_status(PurpleAccount *account,
00881                                      PurpleStatus *old_status,
00882                                      PurpleStatus *new_status);
00883 
00892 GList *purple_prpl_get_statuses(PurpleAccount *account, PurplePresence *presence);
00893 
00908 void purple_prpl_send_attention(PurpleConnection *gc, const char *who, guint type_code);
00909 
00920 void purple_prpl_got_attention(PurpleConnection *gc, const char *who, guint type_code);
00921 
00933 void purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code);
00934 
00943 PurpleMediaCaps purple_prpl_get_media_caps(PurpleAccount *account,
00944                   const char *who);
00945 
00955 gboolean purple_prpl_initiate_media(PurpleAccount *account,
00956                     const char *who,
00957                     PurpleMediaSessionType type);
00958 
00968 void purple_prpl_got_media_caps(PurpleAccount *account, const char *who);
00969 
00972 /**************************************************************************/
00974 /**************************************************************************/
00982 PurplePlugin *purple_find_prpl(const char *id);
00983 
00986 #ifdef __cplusplus
00987 }
00988 #endif
00989 
00990 #endif /* _PRPL_H_ */