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;
00034 typedef struct _PurpleAttentionType PurpleAttentionType;
00035 
00036 /**************************************************************************/
00038 /**************************************************************************/
00039 
00040 typedef enum {
00041     PURPLE_ICON_SCALE_DISPLAY = 0x01,       
00042     PURPLE_ICON_SCALE_SEND = 0x02           
00043 } PurpleIconScaleRules;
00044 
00045 
00051 typedef struct _PurpleBuddyIconSpec PurpleBuddyIconSpec;
00052 
00057 #define NO_BUDDY_ICONS {NULL, 0, 0, 0, 0, 0, 0}
00058 
00059 #ifdef HAVE_UNISTD_H
00060 #include <unistd.h>
00061 #endif
00062 
00063 #include "blist.h"
00064 #include "conversation.h"
00065 #include "ft.h"
00066 #include "imgstore.h"
00067 #include "notify.h"
00068 #include "proxy.h"
00069 #include "plugin.h"
00070 #include "roomlist.h"
00071 #include "status.h"
00072 #include "whiteboard.h"
00073 
00074 struct _PurpleBuddyIconSpec {
00075     char *format;                       
00078     int min_width;                          
00079     int min_height;                         
00080     int max_width;                          
00081     int max_height;                         
00082     size_t max_filesize;                     
00083     PurpleIconScaleRules scale_rules;       
00084 };
00085 
00086 struct proto_chat_entry {
00087     const char *label;
00088     const char *identifier;
00089     gboolean required;
00090     gboolean is_int;
00091     int min;
00092     int max;
00093     gboolean secret;
00094 };
00095 
00096 struct _PurpleAttentionType
00097 {
00098     const char *name;                  
00099     const char *incoming_description;  
00100     const char *outgoing_description;  
00101     const char *icon_name;             
00103     /* Reserved fields for future purposes */
00104     gpointer _reserved1;
00105     gpointer _reserved2;
00106     gpointer _reserved3;
00107     gpointer _reserved4;
00108 };
00109 
00115 typedef enum
00116 {
00124     OPT_PROTO_UNIQUE_CHATNAME = 0x00000004,
00125 
00131     OPT_PROTO_CHAT_TOPIC = 0x00000008,
00132 
00139     OPT_PROTO_NO_PASSWORD = 0x00000010,
00140 
00146     OPT_PROTO_MAIL_CHECK = 0x00000020,
00147 
00153     OPT_PROTO_IM_IMAGE = 0x00000040,
00154 
00161     OPT_PROTO_PASSWORD_OPTIONAL = 0x00000080,
00162 
00168     OPT_PROTO_USE_POINTSIZE = 0x00000100,
00169 
00175     OPT_PROTO_REGISTER_NOSCREENNAME = 0x00000200,
00176 
00181     OPT_PROTO_SLASH_COMMANDS_NATIVE = 0x00000400,
00182 
00183 } PurpleProtocolOptions;
00184 
00192 struct _PurplePluginProtocolInfo
00193 {
00194     PurpleProtocolOptions options;  
00196     GList *user_splits;      
00197     GList *protocol_options; 
00199     PurpleBuddyIconSpec icon_spec; 
00209     const char *(*list_icon)(PurpleAccount *account, PurpleBuddy *buddy);
00210 
00215     const char *(*list_emblem)(PurpleBuddy *buddy);
00216 
00221     char *(*status_text)(PurpleBuddy *buddy);
00222 
00226     void (*tooltip_text)(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full);
00227 
00232     GList *(*status_types)(PurpleAccount *account);
00233 
00234     GList *(*blist_node_menu)(PurpleBlistNode *node);
00235     GList *(*chat_info)(PurpleConnection *);
00236     GHashTable *(*chat_info_defaults)(PurpleConnection *, const char *chat_name);
00237 
00238     /* All the server-related functions */
00239 
00241     void (*login)(PurpleAccount *);
00242 
00244     void (*close)(PurpleConnection *);
00245 
00255     int  (*send_im)(PurpleConnection *, const char *who,
00256                     const char *message,
00257                     PurpleMessageFlags flags);
00258 
00259     void (*set_info)(PurpleConnection *, const char *info);
00260     unsigned int (*send_typing)(PurpleConnection *, const char *name, PurpleTypingState state);
00261     void (*get_info)(PurpleConnection *, const char *who);
00262     void (*set_status)(PurpleAccount *account, PurpleStatus *status);
00263 
00264     void (*set_idle)(PurpleConnection *, int idletime);
00265     void (*change_passwd)(PurpleConnection *, const char *old_pass,
00266                           const char *new_pass);
00267     void (*add_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
00268     void (*add_buddies)(PurpleConnection *, GList *buddies, GList *groups);
00269     void (*remove_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
00270     void (*remove_buddies)(PurpleConnection *, GList *buddies, GList *groups);
00271     void (*add_permit)(PurpleConnection *, const char *name);
00272     void (*add_deny)(PurpleConnection *, const char *name);
00273     void (*rem_permit)(PurpleConnection *, const char *name);
00274     void (*rem_deny)(PurpleConnection *, const char *name);
00275     void (*set_permit_deny)(PurpleConnection *);
00276     void (*join_chat)(PurpleConnection *, GHashTable *components);
00277     void (*reject_chat)(PurpleConnection *, GHashTable *components);
00278     char *(*get_chat_name)(GHashTable *components);
00279     void (*chat_invite)(PurpleConnection *, int id,
00280                         const char *message, const char *who);
00281     void (*chat_leave)(PurpleConnection *, int id);
00282     void (*chat_whisper)(PurpleConnection *, int id,
00283                          const char *who, const char *message);
00284     int  (*chat_send)(PurpleConnection *, int id, const char *message, PurpleMessageFlags flags);
00285     void (*keepalive)(PurpleConnection *);
00286 
00288     void (*register_user)(PurpleAccount *);
00289 
00290     /* get "chat buddy" info and away message */
00291     void (*get_cb_info)(PurpleConnection *, int, const char *who);
00292     void (*get_cb_away)(PurpleConnection *, int, const char *who);
00293 
00295     void (*alias_buddy)(PurpleConnection *, const char *who,
00296                         const char *alias);
00297 
00299     void (*group_buddy)(PurpleConnection *, const char *who,
00300                         const char *old_group, const char *new_group);
00301 
00303     void (*rename_group)(PurpleConnection *, const char *old_name,
00304                          PurpleGroup *group, GList *moved_buddies);
00305 
00306     void (*buddy_free)(PurpleBuddy *);
00307 
00308     void (*convo_closed)(PurpleConnection *, const char *who);
00309 
00315     const char *(*normalize)(const PurpleAccount *, const char *who);
00316 
00322     void (*set_buddy_icon)(PurpleConnection *, PurpleStoredImage *img);
00323 
00324     void (*remove_group)(PurpleConnection *gc, PurpleGroup *group);
00325 
00326     char *(*get_cb_real_name)(PurpleConnection *gc, int id, const char *who);
00327 
00328     void (*set_chat_topic)(PurpleConnection *gc, int id, const char *topic);
00329 
00330     PurpleChat *(*find_blist_chat)(PurpleAccount *account, const char *name);
00331 
00332     /* room listing prpl callbacks */
00333     PurpleRoomlist *(*roomlist_get_list)(PurpleConnection *gc);
00334     void (*roomlist_cancel)(PurpleRoomlist *list);
00335     void (*roomlist_expand_category)(PurpleRoomlist *list, PurpleRoomlistRoom *category);
00336 
00337     /* file transfer callbacks */
00338     gboolean (*can_receive_file)(PurpleConnection *, const char *who);
00339     void (*send_file)(PurpleConnection *, const char *who, const char *filename);
00340     PurpleXfer *(*new_xfer)(PurpleConnection *, const char *who);
00341     gboolean (*offline_message)(const PurpleBuddy *buddy);
00342 
00343     PurpleWhiteboardPrplOps *whiteboard_prpl_ops;
00344 
00346     int (*send_raw)(PurpleConnection *gc, const char *buf, int len);
00347 
00348     /* room list serialize */
00349     char *(*roomlist_room_serialize)(PurpleRoomlistRoom *room);
00350 
00351     /* Remove the user from the server. (This is only at the bottom to keep binary compatibility.)
00352      * The account can either be connected or disconnected. After the removal is finished,
00353      * the connection will stay open and has to be closed!
00354      */
00355     void (*unregister_user)(PurpleAccount *, PurpleAccountUnregistrationCb cb, void *user_data);
00356     
00357     /* Attention API for sending & receiving zaps/nudges/buzzes etc. */
00358     gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type);
00359     GList *(*get_attention_types)(PurpleAccount *acct);
00360 
00361     void (*_purple_reserved4)(void);
00362 };
00363 
00364 #define PURPLE_IS_PROTOCOL_PLUGIN(plugin) \
00365     ((plugin)->info->type == PURPLE_PLUGIN_PROTOCOL)
00366 
00367 #define PURPLE_PLUGIN_PROTOCOL_INFO(plugin) \
00368     ((PurplePluginProtocolInfo *)(plugin)->info->extra_info)
00369 
00370 #ifdef __cplusplus
00371 extern "C" {
00372 #endif
00373 
00374 /**************************************************************************/
00376 /**************************************************************************/
00388 void purple_prpl_got_account_idle(PurpleAccount *account, gboolean idle,
00389                                 time_t idle_time);
00390 
00399 void purple_prpl_got_account_login_time(PurpleAccount *account, time_t login_time);
00400 
00411 void purple_prpl_got_account_status(PurpleAccount *account,
00412                                   const char *status_id, ...) G_GNUC_NULL_TERMINATED;
00425 void purple_prpl_got_user_idle(PurpleAccount *account, const char *name,
00426                              gboolean idle, time_t idle_time);
00427 
00437 void purple_prpl_got_user_login_time(PurpleAccount *account, const char *name,
00438                                    time_t login_time);
00439 
00451 void purple_prpl_got_user_status(PurpleAccount *account, const char *name,
00452                                const char *status_id, ...) G_GNUC_NULL_TERMINATED;
00453 
00463 void purple_prpl_got_user_status_deactive(PurpleAccount *account, const char *name,
00464                     const char *status_id);
00465  
00474 void purple_prpl_change_account_status(PurpleAccount *account,
00475                                      PurpleStatus *old_status,
00476                                      PurpleStatus *new_status);
00477 
00486 GList *purple_prpl_get_statuses(PurpleAccount *account, PurplePresence *presence);
00487 
00490 /**************************************************************************/
00492 /**************************************************************************/
00500 PurplePlugin *purple_find_prpl(const char *id);
00501 
00504 #ifdef __cplusplus
00505 }
00506 #endif
00507 
00508 #endif /* _PRPL_H_ */