connection.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  * @see @ref connection-signals
00027  */
00028 #ifndef _PURPLE_CONNECTION_H_
00029 #define _PURPLE_CONNECTION_H_
00030 
00031 typedef struct _PurpleConnection PurpleConnection;
00032 
00036 typedef enum
00037 {
00038     PURPLE_CONNECTION_HTML       = 0x0001, 
00039     PURPLE_CONNECTION_NO_BGCOLOR = 0x0002, 
00041     PURPLE_CONNECTION_AUTO_RESP  = 0x0004,  
00042     PURPLE_CONNECTION_FORMATTING_WBFO = 0x0008, 
00043     PURPLE_CONNECTION_NO_NEWLINES = 0x0010, 
00044     PURPLE_CONNECTION_NO_FONTSIZE = 0x0020, 
00045     PURPLE_CONNECTION_NO_URLDESC = 0x0040,  
00046     PURPLE_CONNECTION_NO_IMAGES = 0x0080,  
00048 } PurpleConnectionFlags;
00049 
00050 typedef enum
00051 {
00052     PURPLE_DISCONNECTED = 0, 
00053     PURPLE_CONNECTED,        
00054     PURPLE_CONNECTING        
00056 } PurpleConnectionState;
00057 
00058 #include <time.h>
00059 
00060 #include "account.h"
00061 #include "plugin.h"
00062 #include "status.h"
00063 
00071 typedef struct
00072 {
00078     void (*connect_progress)(PurpleConnection *gc,
00079                              const char *text,
00080                              size_t step,
00081                              size_t step_count);
00085     void (*connected)(PurpleConnection *gc);
00089     void (*disconnected)(PurpleConnection *gc);
00095     void (*notice)(PurpleConnection *gc, const char *text);
00100     void (*report_disconnect)(PurpleConnection *gc, const char *text);
00106     void (*network_connected)();
00110     void (*network_disconnected)();
00111 
00112     void (*_purple_reserved1)(void);
00113     void (*_purple_reserved2)(void);
00114     void (*_purple_reserved3)(void);
00115     void (*_purple_reserved4)(void);
00116 } PurpleConnectionUiOps;
00117 
00118 struct _PurpleConnection
00119 {
00120     PurplePlugin *prpl;            
00121     PurpleConnectionFlags flags;   
00123     PurpleConnectionState state;   
00125     PurpleAccount *account;        
00126     char *password;              
00127     int inpa;                    
00129     GSList *buddy_chats;         
00130     void *proto_data;            
00132     char *display_name;          
00133     guint keepalive;             
00136     gboolean wants_to_die;       
00142     guint disconnect_timeout;    
00143 };
00144 
00145 #ifdef __cplusplus
00146 extern "C" {
00147 #endif
00148 
00149 /**************************************************************************/
00151 /**************************************************************************/
00171 void purple_connection_new(PurpleAccount *account, gboolean regist,
00172                                     const char *password);
00173 
00184 void purple_connection_new_unregister(PurpleAccount *account, const char *password, PurpleAccountUnregistrationCb cb, void *user_data);
00185 
00195 void purple_connection_destroy(PurpleConnection *gc);
00196 
00207 void purple_connection_set_state(PurpleConnection *gc, PurpleConnectionState state);
00208 
00215 void purple_connection_set_account(PurpleConnection *gc, PurpleAccount *account);
00216 
00223 void purple_connection_set_display_name(PurpleConnection *gc, const char *name);
00224 
00232 PurpleConnectionState purple_connection_get_state(const PurpleConnection *gc);
00233 
00239 #define PURPLE_CONNECTION_IS_CONNECTED(gc) \
00240     (gc->state == PURPLE_CONNECTED)
00241 
00249 PurpleAccount *purple_connection_get_account(const PurpleConnection *gc);
00250 
00258 const char *purple_connection_get_password(const PurpleConnection *gc);
00259 
00267 const char *purple_connection_get_display_name(const PurpleConnection *gc);
00268 
00277 void purple_connection_update_progress(PurpleConnection *gc, const char *text,
00278                                      size_t step, size_t count);
00279 
00286 void purple_connection_notice(PurpleConnection *gc, const char *text);
00287 
00294 void purple_connection_error(PurpleConnection *gc, const char *reason);
00295 
00298 /**************************************************************************/
00300 /**************************************************************************/
00306 void purple_connections_disconnect_all(void);
00307 
00314 GList *purple_connections_get_all(void);
00315 
00321 GList *purple_connections_get_connecting(void);
00322 
00328 /*
00329  * TODO: Eventually this bad boy will be removed, because it is
00330  *       a gross fix for a crashy problem.
00331  */
00332 #define PURPLE_CONNECTION_IS_VALID(gc) (g_list_find(purple_connections_get_all(), (gc)) != NULL)
00333 
00336 /**************************************************************************/
00338 /**************************************************************************/
00346 void purple_connections_set_ui_ops(PurpleConnectionUiOps *ops);
00347 
00353 PurpleConnectionUiOps *purple_connections_get_ui_ops(void);
00354 
00357 /**************************************************************************/
00359 /**************************************************************************/
00365 void purple_connections_init(void);
00366 
00370 void purple_connections_uninit(void);
00371 
00377 void *purple_connections_get_handle(void);
00378 
00382 #ifdef __cplusplus
00383 }
00384 #endif
00385 
00386 #endif /* _PURPLE_CONNECTION_H_ */