5563
|
1 /**
|
|
2 * @file connection.h Connection API
|
|
3 * @ingroup core
|
|
4 *
|
|
5 * gaim
|
|
6 *
|
|
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
|
|
8 *
|
|
9 * This program is free software; you can redistribute it and/or modify
|
|
10 * it under the terms of the GNU General Public License as published by
|
|
11 * the Free Software Foundation; either version 2 of the License, or
|
|
12 * (at your option) any later version.
|
|
13 *
|
|
14 * This program is distributed in the hope that it will be useful,
|
|
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 * GNU General Public License for more details.
|
|
18 *
|
|
19 * You should have received a copy of the GNU General Public License
|
|
20 * along with this program; if not, write to the Free Software
|
|
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
22 */
|
|
23 #ifndef _GAIM_CONNECTION_H_
|
|
24 #define _GAIM_CONNECTION_H_
|
|
25
|
|
26 #include <stdlib.h>
|
|
27
|
|
28 typedef struct _GaimConnection GaimConnection;
|
|
29
|
|
30 #include "account.h"
|
|
31 #include "plugin.h"
|
|
32 #include "multi.h"
|
|
33
|
|
34 typedef enum
|
|
35 {
|
|
36 GAIM_DISCONNECTED = 0, /**< Disconnected. */
|
|
37 GAIM_CONNECTED, /**< Connected. */
|
|
38 GAIM_CONNECTING /**< Connecting. */
|
|
39
|
|
40 } GaimConnectionState;
|
|
41
|
|
42 typedef struct
|
|
43 {
|
|
44 void (*connect_progress)(GaimConnection *gc, const char *text,
|
|
45 size_t step, size_t step_count);
|
|
46 void (*connected)(GaimConnection *gc);
|
|
47 void (*request_pass)(GaimConnection *gc);
|
|
48 void (*disconnected)(GaimConnection *gc, const char *reason);
|
|
49
|
|
50 } GaimConnectionUiOps;
|
|
51
|
|
52 struct _GaimConnection
|
|
53 {
|
|
54 GaimPlugin *prpl; /**< The protocol plugin. */
|
|
55 guint32 flags; /**< Connection flags. */
|
|
56
|
|
57 GaimConnectionState state; /**< The connection state. */
|
|
58
|
|
59 GaimAccount *account; /**< The account being connected to. */
|
|
60 int inpa; /**< The input watcher. */
|
|
61
|
|
62 GSList *buddy_chats; /**< A list of active chats. */
|
|
63 void *proto_data; /**< Protocol-specific data. */
|
|
64
|
|
65 char *display_name; /**< The name displayed. */
|
|
66 guint keep_alive; /**< Keep-alive. */
|
|
67
|
|
68 guint idle_timer; /**< The idle timer. */
|
|
69 time_t login_time; /**< Time of login. */
|
|
70 time_t login_time_official; /**< Official time of login. */
|
|
71 time_t last_sent_time; /**< The time something was last sent. */
|
|
72 int is_idle; /**< Idle state of the connection. */
|
|
73
|
|
74 char *away; /**< The current away message, or NULL */
|
|
75 char *away_state; /**< The last away type. */
|
|
76 gboolean is_auto_away; /**< Whether or not it's auto-away. */
|
|
77
|
|
78 int evil; /**< Warning level for AIM (why is
|
|
79 this here?) */
|
|
80
|
|
81 gboolean wants_to_die; /**< Wants to Die state. */
|
|
82 };
|
|
83
|
|
84 /**
|
|
85 * Creates a connection to the specified account.
|
|
86 *
|
|
87 * @param account The account the connection should be connecting to.
|
|
88 *
|
|
89 * @return The gaim connection.
|
|
90 */
|
|
91 GaimConnection *gaim_connection_new(GaimAccount *account);
|
|
92
|
|
93 /**
|
|
94 * Destroys and closes a gaim connection.
|
|
95 *
|
|
96 * @param gc The gaim connection to destroy.
|
|
97 */
|
|
98 void gaim_connection_destroy(GaimConnection *gc);
|
|
99
|
|
100 /**
|
|
101 * Signs a connection on.
|
|
102 *
|
|
103 * @param gc The connection to sign on.
|
|
104 *
|
|
105 * @see gaim_connection_disconnect()
|
|
106 */
|
|
107 void gaim_connection_connect(GaimConnection *gc);
|
|
108
|
|
109 /**
|
|
110 * Signs a connection off.
|
|
111 *
|
|
112 * @param gc The connection to sign off.
|
|
113 *
|
|
114 * @see gaim_connection_connect()
|
|
115 */
|
|
116 void gaim_connection_disconnect(GaimConnection *gc);
|
|
117
|
|
118 /**
|
|
119 * Sets the connection state.
|
|
120 *
|
|
121 * @param gc The connection.
|
|
122 * @param state The connection state.
|
|
123 */
|
|
124 void gaim_connection_set_state(GaimConnection *gc, GaimConnectionState state);
|
|
125
|
|
126 /**
|
|
127 * Sets the connection's account.
|
|
128 *
|
|
129 * @param gc The connection.
|
|
130 * @param account The account.
|
|
131 */
|
|
132 void gaim_connection_set_account(GaimConnection *gc, GaimAccount *account);
|
|
133
|
|
134 /**
|
|
135 * Sets the connection's displayed name.
|
|
136 *
|
|
137 * @param gc The connection.
|
|
138 * @param name The displayed name.
|
|
139 */
|
|
140 void gaim_connection_set_display_name(GaimConnection *gc, const char *name);
|
|
141
|
|
142 /**
|
|
143 * Returns the connection state.
|
|
144 *
|
|
145 * @param gc The connection.
|
|
146 *
|
|
147 * @return The connection state.
|
|
148 */
|
|
149 GaimConnectionState gaim_connection_get_state(const GaimConnection *gc);
|
|
150
|
|
151 /**
|
|
152 * Returns the connection's account.
|
|
153 *
|
|
154 * @param gc The connection.
|
|
155 *
|
|
156 * @return The connection's account.
|
|
157 */
|
|
158 GaimAccount *gaim_connection_get_account(const GaimConnection *gc);
|
|
159
|
|
160 /**
|
|
161 * Returns the connection's displayed name.
|
|
162 *
|
|
163 * @param gc The connection.
|
|
164 *
|
|
165 * @return The connection's displayed name.
|
|
166 */
|
|
167 const char *gaim_connection_get_display_name(const GaimConnection *gc);
|
|
168
|
|
169 /**
|
|
170 * Updates the connection progress.
|
|
171 *
|
|
172 * @param gc The connection.
|
|
173 * @param text Information on the current step.
|
|
174 * @param step The current step.
|
|
175 * @param count The total number of steps.
|
|
176 */
|
|
177 void gaim_connection_update_progress(GaimConnection *gc, const char *text,
|
|
178 size_t step, size_t count);
|
|
179
|
|
180 /**
|
|
181 * Disconnects from all connections.
|
|
182 */
|
|
183 void gaim_connections_disconnect_all(void);
|
|
184
|
|
185 /**
|
|
186 * Returns a list of all active connections.
|
|
187 *
|
|
188 * @return A list of all active connections.
|
|
189 */
|
|
190 GList *gaim_connections_get_all(void);
|
|
191
|
|
192 /**************************************************************************/
|
|
193 /** @name UI Operations API */
|
|
194 /**************************************************************************/
|
|
195 /*@{*/
|
|
196
|
|
197 /**
|
|
198 * Sets the UI operations structure to be used for connections.
|
|
199 *
|
|
200 * @param ops The UI operations structure.
|
|
201 */
|
|
202 void gaim_set_connection_ui_ops(GaimConnectionUiOps *ops);
|
|
203
|
|
204 /**
|
|
205 * Returns the UI operations structure used for connections.
|
|
206 *
|
|
207 * @return The UI operations structure in use.
|
|
208 */
|
|
209 GaimConnectionUiOps *gaim_get_connection_ui_ops(void);
|
|
210
|
|
211 /*@}*/
|
|
212
|
|
213 #endif /* _GAIM_CONNECTION_H_ */
|