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 
00063 typedef struct
00064 {
00065     void (*connect_progress)(PurpleConnection *gc, const char *text,
00066                              size_t step, size_t step_count);
00067     void (*connected)(PurpleConnection *gc);
00068     void (*disconnected)(PurpleConnection *gc);
00069     void (*notice)(PurpleConnection *gc, const char *text);
00070     void (*report_disconnect)(PurpleConnection *gc, const char *text);
00071     void (*network_connected)();
00072     void (*network_disconnected)();
00073 
00074     void (*_purple_reserved1)(void);
00075     void (*_purple_reserved2)(void);
00076     void (*_purple_reserved3)(void);
00077     void (*_purple_reserved4)(void);
00078 } PurpleConnectionUiOps;
00079 
00080 struct _PurpleConnection
00081 {
00082     PurplePlugin *prpl;            
00083     PurpleConnectionFlags flags;   
00085     PurpleConnectionState state;   
00087     PurpleAccount *account;        
00088     char *password;              
00089     int inpa;                    
00091     GSList *buddy_chats;         
00092     void *proto_data;            
00094     char *display_name;          
00095     guint keepalive;             
00098     gboolean wants_to_die;       
00104     guint disconnect_timeout;    
00105 };
00106 
00107 #ifdef __cplusplus
00108 extern "C" {
00109 #endif
00110 
00111 /**************************************************************************/
00113 /**************************************************************************/
00133 void purple_connection_new(PurpleAccount *account, gboolean regist,
00134                                     const char *password);
00135 
00145 void purple_connection_destroy(PurpleConnection *gc);
00146 
00157 void purple_connection_set_state(PurpleConnection *gc, PurpleConnectionState state);
00158 
00165 void purple_connection_set_account(PurpleConnection *gc, PurpleAccount *account);
00166 
00173 void purple_connection_set_display_name(PurpleConnection *gc, const char *name);
00174 
00182 PurpleConnectionState purple_connection_get_state(const PurpleConnection *gc);
00183 
00189 #define PURPLE_CONNECTION_IS_CONNECTED(gc) \
00190     (gc->state == PURPLE_CONNECTED)
00191 
00199 PurpleAccount *purple_connection_get_account(const PurpleConnection *gc);
00200 
00208 const char *purple_connection_get_password(const PurpleConnection *gc);
00209 
00217 const char *purple_connection_get_display_name(const PurpleConnection *gc);
00218 
00227 void purple_connection_update_progress(PurpleConnection *gc, const char *text,
00228                                      size_t step, size_t count);
00229 
00236 void purple_connection_notice(PurpleConnection *gc, const char *text);
00237 
00244 void purple_connection_error(PurpleConnection *gc, const char *reason);
00245 
00248 /**************************************************************************/
00250 /**************************************************************************/
00256 void purple_connections_disconnect_all(void);
00257 
00264 GList *purple_connections_get_all(void);
00265 
00271 GList *purple_connections_get_connecting(void);
00272 
00278 /*
00279  * TODO: Eventually this bad boy will be removed, because it is
00280  *       a gross fix for a crashy problem.
00281  */
00282 #define PURPLE_CONNECTION_IS_VALID(gc) (g_list_find(purple_connections_get_all(), (gc)) != NULL)
00283 
00286 /**************************************************************************/
00288 /**************************************************************************/
00296 void purple_connections_set_ui_ops(PurpleConnectionUiOps *ops);
00297 
00303 PurpleConnectionUiOps *purple_connections_get_ui_ops(void);
00304 
00307 /**************************************************************************/
00309 /**************************************************************************/
00315 void purple_connections_init(void);
00316 
00320 void purple_connections_uninit(void);
00321 
00327 void *purple_connections_get_handle(void);
00328 
00332 #ifdef __cplusplus
00333 }
00334 #endif
00335 
00336 #endif /* _PURPLE_CONNECTION_H_ */