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
00097 struct proto_chat_entry {
00098     const char *label;
00099     const char *identifier;
00100     gboolean required;
00101     gboolean is_int;
00102     int min;
00103     int max;
00104     gboolean secret;
00105 };
00106
00110 struct _PurpleAttentionType
00111 {
00112     const char *name;
00113     const char *incoming_description;
00114     const char *outgoing_description;
00115     const char *icon_name;
00116     const char *unlocalized_name;
00118     /* Reserved fields for future purposes */
00119     gpointer _reserved2;
00120     gpointer _reserved3;
00121     gpointer _reserved4;
00122 };
00123
00129 typedef enum
00130 {
00138     OPT_PROTO_UNIQUE_CHATNAME = 0x00000004,
00139
00145     OPT_PROTO_CHAT_TOPIC = 0x00000008,
00146
00153     OPT_PROTO_NO_PASSWORD = 0x00000010,
00154
00160     OPT_PROTO_MAIL_CHECK = 0x00000020,
00161
00167     OPT_PROTO_IM_IMAGE = 0x00000040,
00168
00175     OPT_PROTO_PASSWORD_OPTIONAL = 0x00000080,
00176
00182     OPT_PROTO_USE_POINTSIZE = 0x00000100,
00183
00191     OPT_PROTO_REGISTER_NOSCREENNAME = 0x00000200,
00192
00198     OPT_PROTO_SLASH_COMMANDS_NATIVE = 0x00000400
00199
00200 } PurpleProtocolOptions;
00201
00209 struct _PurplePluginProtocolInfo
00210 {
00211     PurpleProtocolOptions options;
00213     GList *user_splits;
00214     GList *protocol_options;
00216     PurpleBuddyIconSpec icon_spec;
00226     const char *(*list_icon)(PurpleAccount *account, PurpleBuddy *buddy);
00227
00232     const char *(*list_emblem)(PurpleBuddy *buddy);
00233
00238     char *(*status_text)(PurpleBuddy *buddy);
00239
00243     void (*tooltip_text)(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full);
00244
00250     GList *(*status_types)(PurpleAccount *account);
00251
00257     GList *(*blist_node_menu)(PurpleBlistNode *node);
00258
00266     GList *(*chat_info)(PurpleConnection *);
00267
00278     GHashTable *(*chat_info_defaults)(PurpleConnection *, const char *chat_name);
00279
00280     /* All the server-related functions */
00281
00283     void (*login)(PurpleAccount *);
00284
00286     void (*close)(PurpleConnection *);
00287
00297     int  (*send_im)(PurpleConnection *, const char *who,
00298                     const char *message,
00299                     PurpleMessageFlags flags);
00300
00301     void (*set_info)(PurpleConnection *, const char *info);
00302
00310     unsigned int (*send_typing)(PurpleConnection *, const char *name, PurpleTypingState state);
00311
00316     void (*get_info)(PurpleConnection *, const char *who);
00317     void (*set_status)(PurpleAccount *account, PurpleStatus *status);
00318
00319     void (*set_idle)(PurpleConnection *, int idletime);
00320     void (*change_passwd)(PurpleConnection *, const char *old_pass,
00321                           const char *new_pass);
00330     void (*add_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
00331     void (*add_buddies)(PurpleConnection *, GList *buddies, GList *groups);
00332     void (*remove_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
00333     void (*remove_buddies)(PurpleConnection *, GList *buddies, GList *groups);
00334     void (*add_permit)(PurpleConnection *, const char *name);
00335     void (*add_deny)(PurpleConnection *, const char *name);
00336     void (*rem_permit)(PurpleConnection *, const char *name);
00337     void (*rem_deny)(PurpleConnection *, const char *name);
00338     void (*set_permit_deny)(PurpleConnection *);
00339
00350     void (*join_chat)(PurpleConnection *, GHashTable *components);
00351
00358     void (*reject_chat)(PurpleConnection *, GHashTable *components);
00359
00367     char *(*get_chat_name)(GHashTable *components);
00368
00377     void (*chat_invite)(PurpleConnection *, int id,
00378                         const char *message, const char *who);
00384     void (*chat_leave)(PurpleConnection *, int id);
00385
00393     void (*chat_whisper)(PurpleConnection *, int id,
00394                          const char *who, const char *message);
00395
00413     int  (*chat_send)(PurpleConnection *, int id, const char *message, PurpleMessageFlags flags);
00414
00421     void (*keepalive)(PurpleConnection *);
00422
00424     void (*register_user)(PurpleAccount *);
00425
00429     void (*get_cb_info)(PurpleConnection *, int, const char *who);
00434     void (*get_cb_away)(PurpleConnection *, int, const char *who);
00435
00437     void (*alias_buddy)(PurpleConnection *, const char *who,
00438                         const char *alias);
00439
00441     void (*group_buddy)(PurpleConnection *, const char *who,
00442                         const char *old_group, const char *new_group);
00443
00445     void (*rename_group)(PurpleConnection *, const char *old_name,
00446                          PurpleGroup *group, GList *moved_buddies);
00447
00448     void (*buddy_free)(PurpleBuddy *);
00449
00450     void (*convo_closed)(PurpleConnection *, const char *who);
00451
00457     const char *(*normalize)(const PurpleAccount *, const char *who);
00458
00464     void (*set_buddy_icon)(PurpleConnection *, PurpleStoredImage *img);
00465
00466     void (*remove_group)(PurpleConnection *gc, PurpleGroup *group);
00467
00477     char *(*get_cb_real_name)(PurpleConnection *gc, int id, const char *who);
00478
00479     void (*set_chat_topic)(PurpleConnection *gc, int id, const char *topic);
00480
00481     PurpleChat *(*find_blist_chat)(PurpleAccount *account, const char *name);
00482
00483     /* room listing prpl callbacks */
00484     PurpleRoomlist *(*roomlist_get_list)(PurpleConnection *gc);
00485     void (*roomlist_cancel)(PurpleRoomlist *list);
00486     void (*roomlist_expand_category)(PurpleRoomlist *list, PurpleRoomlistRoom *category);
00487
00488     /* file transfer callbacks */
00489     gboolean (*can_receive_file)(PurpleConnection *, const char *who);
00490     void (*send_file)(PurpleConnection *, const char *who, const char *filename);
00491     PurpleXfer *(*new_xfer)(PurpleConnection *, const char *who);
00492
00497     gboolean (*offline_message)(const PurpleBuddy *buddy);
00498
00499     PurpleWhiteboardPrplOps *whiteboard_prpl_ops;
00500
00502     int (*send_raw)(PurpleConnection *gc, const char *buf, int len);
00503
00504     /* room list serialize */
00505     char *(*roomlist_room_serialize)(PurpleRoomlistRoom *room);
00506
00511     /* This is here rather than next to register_user for API compatibility
00512      * reasons.
00513      */
00514     void (*unregister_user)(PurpleAccount *, PurpleAccountUnregistrationCb cb, void *user_data);
00515
00516     /* Attention API for sending & receiving zaps/nudges/buzzes etc. */
00517     gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type);
00518     GList *(*get_attention_types)(PurpleAccount *acct);
00519
00524     unsigned long struct_size;
00525
00526     /* NOTE:
00527      * If more functions are added, they should accessed using the following syntax:
00528      *
00529      *      if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, new_function))
00530      *          prpl->new_function(...);
00531      *
00532      * instead of
00533      *
00534      *      if (prpl->new_function != NULL)
00535      *          prpl->new_function(...);
00536      *
00537      * The PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro can be used for the older member
00538      * functions (e.g. login, send_im etc.) too.
00539      */
00540
00550     GHashTable *(*get_account_text_table)(PurpleAccount *account);
00551
00560     gboolean (*initiate_media)(PurpleAccount *account, const char *who,
00561                     PurpleMediaSessionType type);
00562
00570     PurpleMediaCaps (*get_media_caps)(PurpleAccount *account,
00571                       const char *who);
00572
00577     PurpleMood *(*get_moods)(PurpleAccount *account);
00578 };
00579
00580 #define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \
00581     (((G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < G_STRUCT_OFFSET(PurplePluginProtocolInfo, struct_size)) \
00582       || (G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < prpl->struct_size)) && \
00583      prpl->member != NULL)
00584 
00585
00586 #define PURPLE_IS_PROTOCOL_PLUGIN(plugin) \
00587     ((plugin)->info->type == PURPLE_PLUGIN_PROTOCOL)
00588 
00589 #define PURPLE_PLUGIN_PROTOCOL_INFO(plugin) \
00590     ((PurplePluginProtocolInfo *)(plugin)->info->extra_info)
00591 
00592 #ifdef __cplusplus
00593 extern "C" {
00594 #endif
00595 
00596 /**************************************************************************/
00598 /**************************************************************************/
00614 PurpleAttentionType *purple_attention_type_new(const char *ulname, const char *name,
00615                                 const char *inc_desc, const char *out_desc);
00616
00626 void purple_attention_type_set_name(PurpleAttentionType *type, const char *name);
00627
00636 void purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const char *desc);
00637
00646 void purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const char *desc);
00647
00656 void purple_attention_type_set_icon_name(PurpleAttentionType *type, const char *name);
00657
00667 void purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const char *ulname);
00668
00676 const char *purple_attention_type_get_name(const PurpleAttentionType *type);
00677
00685 const char *purple_attention_type_get_incoming_desc(const PurpleAttentionType *type);
00686
00694 const char *purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type);
00695
00704 const char *purple_attention_type_get_icon_name(const PurpleAttentionType *type);
00705
00713 const char *purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type);
00714
00717 /**************************************************************************/
00719 /**************************************************************************/
00731 void purple_prpl_got_account_idle(PurpleAccount *account, gboolean idle,
00732                                 time_t idle_time);
00733
00742 void purple_prpl_got_account_login_time(PurpleAccount *account, time_t login_time);
00743
00754 void purple_prpl_got_account_status(PurpleAccount *account,
00755                                   const char *status_id, ...) G_GNUC_NULL_TERMINATED;
00756
00769 void purple_prpl_got_account_actions(PurpleAccount *account);
00770
00784 void purple_prpl_got_user_idle(PurpleAccount *account, const char *name,
00785                              gboolean idle, time_t idle_time);
00786
00796 void purple_prpl_got_user_login_time(PurpleAccount *account, const char *name,
00797                                    time_t login_time);
00798
00810 void purple_prpl_got_user_status(PurpleAccount *account, const char *name,
00811                                const char *status_id, ...) G_GNUC_NULL_TERMINATED;
00812
00822 void purple_prpl_got_user_status_deactive(PurpleAccount *account, const char *name,
00823                     const char *status_id);
00824
00833 void purple_prpl_change_account_status(PurpleAccount *account,
00834                                      PurpleStatus *old_status,
00835                                      PurpleStatus *new_status);
00836
00845 GList *purple_prpl_get_statuses(PurpleAccount *account, PurplePresence *presence);
00846
00861 void purple_prpl_send_attention(PurpleConnection *gc, const char *who, guint type_code);
00862
00873 void purple_prpl_got_attention(PurpleConnection *gc, const char *who, guint type_code);
00874
00886 void purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code);
00887
00896 PurpleMediaCaps purple_prpl_get_media_caps(PurpleAccount *account,
00897                   const char *who);
00898
00908 gboolean purple_prpl_initiate_media(PurpleAccount *account,
00909                     const char *who,
00910                     PurpleMediaSessionType type);
00911
00921 void purple_prpl_got_media_caps(PurpleAccount *account, const char *who);
00922
00925 /**************************************************************************/
00927 /**************************************************************************/
00935 PurplePlugin *purple_find_prpl(const char *id);
00936
00939 #ifdef __cplusplus
00940 }
00941 #endif
00942 
00943 #endif /* _PRPL_H_ */