connection.h

Go to the documentation of this file.
00001 
00027 #ifndef _PURPLE_CONNECTION_H_
00028 #define _PURPLE_CONNECTION_H_
00029 
00030 typedef struct _PurpleConnection PurpleConnection;
00031 
00035 typedef enum
00036 {
00037     PURPLE_CONNECTION_HTML       = 0x0001, 
00038     PURPLE_CONNECTION_NO_BGCOLOR = 0x0002, 
00040     PURPLE_CONNECTION_AUTO_RESP  = 0x0004,  
00041     PURPLE_CONNECTION_FORMATTING_WBFO = 0x0008, 
00042     PURPLE_CONNECTION_NO_NEWLINES = 0x0010, 
00043     PURPLE_CONNECTION_NO_FONTSIZE = 0x0020, 
00044     PURPLE_CONNECTION_NO_URLDESC = 0x0040,  
00045     PURPLE_CONNECTION_NO_IMAGES = 0x0080,  
00047 } PurpleConnectionFlags;
00048 
00049 typedef enum
00050 {
00051     PURPLE_DISCONNECTED = 0, 
00052     PURPLE_CONNECTED,        
00053     PURPLE_CONNECTING        
00055 } PurpleConnectionState;
00056 
00057 #include <time.h>
00058 
00059 #include "account.h"
00060 #include "plugin.h"
00061 #include "status.h"
00062 
00070 typedef struct
00071 {
00077     void (*connect_progress)(PurpleConnection *gc,
00078                              const char *text,
00079                              size_t step,
00080                              size_t step_count);
00084     void (*connected)(PurpleConnection *gc);
00088     void (*disconnected)(PurpleConnection *gc);
00094     void (*notice)(PurpleConnection *gc, const char *text);
00099     void (*report_disconnect)(PurpleConnection *gc, const char *text);
00105     void (*network_connected)();
00109     void (*network_disconnected)();
00110 
00111     void (*_purple_reserved1)(void);
00112     void (*_purple_reserved2)(void);
00113     void (*_purple_reserved3)(void);
00114     void (*_purple_reserved4)(void);
00115 } PurpleConnectionUiOps;
00116 
00117 struct _PurpleConnection
00118 {
00119     PurplePlugin *prpl;            
00120     PurpleConnectionFlags flags;   
00122     PurpleConnectionState state;   
00124     PurpleAccount *account;        
00125     char *password;              
00126     int inpa;                    
00128     GSList *buddy_chats;         
00129     void *proto_data;            
00131     char *display_name;          
00132     guint keepalive;             
00135     gboolean wants_to_die;       
00141     guint disconnect_timeout;    
00142 };
00143 
00144 #ifdef __cplusplus
00145 extern "C" {
00146 #endif
00147 
00148 /**************************************************************************/
00150 /**************************************************************************/
00170 void purple_connection_new(PurpleAccount *account, gboolean regist,
00171                                     const char *password);
00172 
00182 void purple_connection_destroy(PurpleConnection *gc);
00183 
00194 void purple_connection_set_state(PurpleConnection *gc, PurpleConnectionState state);
00195 
00202 void purple_connection_set_account(PurpleConnection *gc, PurpleAccount *account);
00203 
00210 void purple_connection_set_display_name(PurpleConnection *gc, const char *name);
00211 
00219 PurpleConnectionState purple_connection_get_state(const PurpleConnection *gc);
00220 
00226 #define PURPLE_CONNECTION_IS_CONNECTED(gc) \
00227     (gc->state == PURPLE_CONNECTED)
00228 
00236 PurpleAccount *purple_connection_get_account(const PurpleConnection *gc);
00237 
00245 const char *purple_connection_get_password(const PurpleConnection *gc);
00246 
00254 const char *purple_connection_get_display_name(const PurpleConnection *gc);
00255 
00264 void purple_connection_update_progress(PurpleConnection *gc, const char *text,
00265                                      size_t step, size_t count);
00266 
00273 void purple_connection_notice(PurpleConnection *gc, const char *text);
00274 
00281 void purple_connection_error(PurpleConnection *gc, const char *reason);
00282 
00285 /**************************************************************************/
00287 /**************************************************************************/
00293 void purple_connections_disconnect_all(void);
00294 
00301 GList *purple_connections_get_all(void);
00302 
00308 GList *purple_connections_get_connecting(void);
00309 
00315 /*
00316  * TODO: Eventually this bad boy will be removed, because it is
00317  *       a gross fix for a crashy problem.
00318  */
00319 #define PURPLE_CONNECTION_IS_VALID(gc) (g_list_find(purple_connections_get_all(), (gc)) != NULL)
00320 
00323 /**************************************************************************/
00325 /**************************************************************************/
00333 void purple_connections_set_ui_ops(PurpleConnectionUiOps *ops);
00334 
00340 PurpleConnectionUiOps *purple_connections_get_ui_ops(void);
00341 
00344 /**************************************************************************/
00346 /**************************************************************************/
00352 void purple_connections_init(void);
00353 
00357 void purple_connections_uninit(void);
00358 
00364 void *purple_connections_get_handle(void);
00365 
00369 #ifdef __cplusplus
00370 }
00371 #endif
00372 
00373 #endif /* _PURPLE_CONNECTION_H_ */