00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
00060 typedef enum
00061 {
00066 PURPLE_CONNECTION_ERROR_NETWORK_ERROR = 0,
00068 PURPLE_CONNECTION_ERROR_INVALID_USERNAME = 1,
00073 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED = 2,
00077 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE = 3,
00081 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT = 4,
00086 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR = 5,
00090 PURPLE_CONNECTION_ERROR_NAME_IN_USE = 6,
00091
00101 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS = 7,
00102
00104 PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED = 8,
00106 PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED = 9,
00108 PURPLE_CONNECTION_ERROR_CERT_EXPIRED = 10,
00110 PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED = 11,
00112 PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH = 12,
00116 PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH = 13,
00118 PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED = 14,
00121 PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR = 15,
00122
00126
00127
00128
00129
00130 PURPLE_CONNECTION_ERROR_OTHER_ERROR = 16
00131 } PurpleConnectionError;
00132
00134 typedef struct
00135 {
00137 PurpleConnectionError type;
00139 char *description;
00140 } PurpleConnectionErrorInfo;
00141
00142 #include <time.h>
00143
00144 #include "account.h"
00145 #include "plugin.h"
00146 #include "status.h"
00147 #include "sslconn.h"
00148
00156 typedef struct
00157 {
00164 void (*connect_progress)(PurpleConnection *gc,
00165 const char *text,
00166 size_t step,
00167 size_t step_count);
00168
00172 void (*connected)(PurpleConnection *gc);
00176 void (*disconnected)(PurpleConnection *gc);
00177
00183 void (*notice)(PurpleConnection *gc, const char *text);
00184
00192 void (*report_disconnect)(PurpleConnection *gc, const char *text);
00193
00199 void (*network_connected)(void);
00203 void (*network_disconnected)(void);
00204
00216 void (*report_disconnect_reason)(PurpleConnection *gc,
00217 PurpleConnectionError reason,
00218 const char *text);
00219
00220 void (*_purple_reserved1)(void);
00221 void (*_purple_reserved2)(void);
00222 void (*_purple_reserved3)(void);
00223 } PurpleConnectionUiOps;
00224
00225 struct _PurpleConnection
00226 {
00227 PurplePlugin *prpl;
00228 PurpleConnectionFlags flags;
00230 PurpleConnectionState state;
00232 PurpleAccount *account;
00233 char *password;
00234 int inpa;
00236 GSList *buddy_chats;
00239 void *proto_data;
00241 char *display_name;
00242 guint keepalive;
00251 gboolean wants_to_die;
00252
00253 guint disconnect_timeout;
00254 time_t last_received;
00256 };
00257
00258 #ifdef __cplusplus
00259 extern "C" {
00260 #endif
00261
00262
00264
00267 #ifndef PURPLE_DISABLE_DEPRECATED
00268
00287 void purple_connection_new(PurpleAccount *account, gboolean regist,
00288 const char *password);
00289 #endif
00290
00291 #ifndef PURPLE_DISABLE_DEPRECATED
00292
00306 void purple_connection_new_unregister(PurpleAccount *account, const char *password, PurpleAccountUnregistrationCb cb, void *user_data);
00307 #endif
00308
00309 #ifndef PURPLE_DISABLE_DEPRECATED
00310
00321 void purple_connection_destroy(PurpleConnection *gc);
00322 #endif
00323
00334 void purple_connection_set_state(PurpleConnection *gc, PurpleConnectionState state);
00335
00342 void purple_connection_set_account(PurpleConnection *gc, PurpleAccount *account);
00343
00350 void purple_connection_set_display_name(PurpleConnection *gc, const char *name);
00351
00359 PurpleConnectionState purple_connection_get_state(const PurpleConnection *gc);
00360
00366 #define PURPLE_CONNECTION_IS_CONNECTED(gc) \
00367 (purple_connection_get_state(gc) == PURPLE_CONNECTED)
00368
00376 PurpleAccount *purple_connection_get_account(const PurpleConnection *gc);
00377
00386 PurplePlugin * purple_connection_get_prpl(const PurpleConnection *gc);
00387
00395 const char *purple_connection_get_password(const PurpleConnection *gc);
00396
00404 const char *purple_connection_get_display_name(const PurpleConnection *gc);
00405
00414 void purple_connection_update_progress(PurpleConnection *gc, const char *text,
00415 size_t step, size_t count);
00416
00423 void purple_connection_notice(PurpleConnection *gc, const char *text);
00424
00438 void purple_connection_error(PurpleConnection *gc, const char *reason);
00439
00451 void
00452 purple_connection_error_reason (PurpleConnection *gc,
00453 PurpleConnectionError reason,
00454 const char *description);
00455
00462 void
00463 purple_connection_ssl_error (PurpleConnection *gc,
00464 PurpleSslErrorType ssl_error);
00465
00485 gboolean
00486 purple_connection_error_is_fatal (PurpleConnectionError reason);
00487
00490
00492
00498 void purple_connections_disconnect_all(void);
00499
00506 GList *purple_connections_get_all(void);
00507
00513 GList *purple_connections_get_connecting(void);
00514
00520
00521
00522
00523
00524 #define PURPLE_CONNECTION_IS_VALID(gc) (g_list_find(purple_connections_get_all(), (gc)) != NULL)
00525
00528
00530
00538 void purple_connections_set_ui_ops(PurpleConnectionUiOps *ops);
00539
00545 PurpleConnectionUiOps *purple_connections_get_ui_ops(void);
00546
00549
00551
00557 void purple_connections_init(void);
00558
00562 void purple_connections_uninit(void);
00563
00569 void *purple_connections_get_handle(void);
00570
00574 #ifdef __cplusplus
00575 }
00576 #endif
00577
00578 #endif