Mercurial > pidgin
annotate src/connection.h @ 8191:90a1fbd2493d
[gaim-migrate @ 8912]
Badabigwiffa!
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 31 Jan 2004 04:40:24 +0000 |
parents | fa6395637e2c |
children | 87bd4d4ff499 |
rev | line source |
---|---|
5563 | 1 /** |
2 * @file connection.h Connection API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6393
diff
changeset
|
10 * |
5563 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
6724
aca39e77db85
[gaim-migrate @ 7251]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
24 * |
aca39e77db85
[gaim-migrate @ 7251]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
25 * @see @ref connection-signals |
5563 | 26 */ |
27 #ifndef _GAIM_CONNECTION_H_ | |
28 #define _GAIM_CONNECTION_H_ | |
29 | |
30 #include <stdlib.h> | |
5733
4350b62bac45
[gaim-migrate @ 6157]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
31 #include <time.h> |
5563 | 32 |
33 typedef struct _GaimConnection GaimConnection; | |
34 | |
6622 | 35 /** |
36 * Flags to change behavior of the client for a given connection. | |
37 */ | |
38 typedef enum | |
39 { | |
6982 | 40 GAIM_CONNECTION_HTML = 0x0001, /**< Connection sends/receives in 'HTML'. */ |
41 GAIM_CONNECTION_NO_BGCOLOR = 0x0002, /**< Connection does not send/recieve | |
42 background colors. */ | |
43 GAIM_CONNECTION_AUTO_RESP = 0x0004 /**< Send auto responses when away. */ | |
6622 | 44 } GaimConnectionFlags; |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5733
diff
changeset
|
45 |
5563 | 46 typedef enum |
47 { | |
48 GAIM_DISCONNECTED = 0, /**< Disconnected. */ | |
49 GAIM_CONNECTED, /**< Connected. */ | |
50 GAIM_CONNECTING /**< Connecting. */ | |
51 | |
52 } GaimConnectionState; | |
53 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
54 #include "account.h" |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
55 #include "plugin.h" |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
56 |
5563 | 57 typedef struct |
58 { | |
59 void (*connect_progress)(GaimConnection *gc, const char *text, | |
60 size_t step, size_t step_count); | |
61 void (*connected)(GaimConnection *gc); | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6393
diff
changeset
|
62 void (*disconnected)(GaimConnection *gc); |
5571
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
63 void (*notice)(GaimConnection *gc, const char *text); |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6393
diff
changeset
|
64 void (*report_disconnect)(GaimConnection *gc, const char *text); |
5563 | 65 |
66 } GaimConnectionUiOps; | |
67 | |
68 struct _GaimConnection | |
69 { | |
70 GaimPlugin *prpl; /**< The protocol plugin. */ | |
6622 | 71 GaimConnectionFlags flags; /**< Connection flags. */ |
5563 | 72 |
73 GaimConnectionState state; /**< The connection state. */ | |
74 | |
75 GaimAccount *account; /**< The account being connected to. */ | |
76 int inpa; /**< The input watcher. */ | |
77 | |
78 GSList *buddy_chats; /**< A list of active chats. */ | |
79 void *proto_data; /**< Protocol-specific data. */ | |
80 | |
81 char *display_name; /**< The name displayed. */ | |
82 guint keep_alive; /**< Keep-alive. */ | |
83 | |
84 guint idle_timer; /**< The idle timer. */ | |
85 time_t login_time; /**< Time of login. */ | |
86 time_t login_time_official; /**< Official time of login. */ | |
87 time_t last_sent_time; /**< The time something was last sent. */ | |
88 int is_idle; /**< Idle state of the connection. */ | |
89 | |
90 char *away; /**< The current away message, or NULL */ | |
91 char *away_state; /**< The last away type. */ | |
92 gboolean is_auto_away; /**< Whether or not it's auto-away. */ | |
93 | |
94 int evil; /**< Warning level for AIM (why is | |
95 this here?) */ | |
96 | |
97 gboolean wants_to_die; /**< Wants to Die state. */ | |
6393 | 98 guint disconnect_timeout; /**< Timer used for nasty stack tricks */ |
5563 | 99 }; |
100 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
101 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
102 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
103 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
104 |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
105 /**************************************************************************/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
106 /** @name Connection API */ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
107 /**************************************************************************/ |
6488
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
108 /*@{*/ |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
109 |
5563 | 110 /** |
111 * Creates a connection to the specified account. | |
112 * | |
113 * @param account The account the connection should be connecting to. | |
114 * | |
115 * @return The gaim connection. | |
116 */ | |
117 GaimConnection *gaim_connection_new(GaimAccount *account); | |
118 | |
119 /** | |
120 * Destroys and closes a gaim connection. | |
121 * | |
122 * @param gc The gaim connection to destroy. | |
123 */ | |
124 void gaim_connection_destroy(GaimConnection *gc); | |
125 | |
126 /** | |
127 * Signs a connection on. | |
128 * | |
129 * @param gc The connection to sign on. | |
130 * | |
131 * @see gaim_connection_disconnect() | |
132 */ | |
133 void gaim_connection_connect(GaimConnection *gc); | |
134 | |
135 /** | |
6581 | 136 * Registers a connection. |
137 * | |
138 * @param gc The connection to register. | |
139 */ | |
140 void gaim_connection_register(GaimConnection *gc); | |
141 | |
142 /** | |
5563 | 143 * Signs a connection off. |
6583
e07c66073b6d
[gaim-migrate @ 7105]
Christian Hammond <chipx86@chipx86.com>
parents:
6581
diff
changeset
|
144 * |
5563 | 145 * @param gc The connection to sign off. |
146 * | |
147 * @see gaim_connection_connect() | |
148 */ | |
149 void gaim_connection_disconnect(GaimConnection *gc); | |
150 | |
151 /** | |
152 * Sets the connection state. | |
153 * | |
154 * @param gc The connection. | |
155 * @param state The connection state. | |
156 */ | |
157 void gaim_connection_set_state(GaimConnection *gc, GaimConnectionState state); | |
158 | |
159 /** | |
160 * Sets the connection's account. | |
161 * | |
162 * @param gc The connection. | |
163 * @param account The account. | |
164 */ | |
165 void gaim_connection_set_account(GaimConnection *gc, GaimAccount *account); | |
166 | |
167 /** | |
168 * Sets the connection's displayed name. | |
169 * | |
170 * @param gc The connection. | |
171 * @param name The displayed name. | |
172 */ | |
173 void gaim_connection_set_display_name(GaimConnection *gc, const char *name); | |
174 | |
175 /** | |
176 * Returns the connection state. | |
177 * | |
178 * @param gc The connection. | |
179 * | |
180 * @return The connection state. | |
181 */ | |
182 GaimConnectionState gaim_connection_get_state(const GaimConnection *gc); | |
183 | |
184 /** | |
185 * Returns the connection's account. | |
186 * | |
187 * @param gc The connection. | |
188 * | |
189 * @return The connection's account. | |
190 */ | |
191 GaimAccount *gaim_connection_get_account(const GaimConnection *gc); | |
192 | |
193 /** | |
194 * Returns the connection's displayed name. | |
195 * | |
196 * @param gc The connection. | |
197 * | |
198 * @return The connection's displayed name. | |
199 */ | |
200 const char *gaim_connection_get_display_name(const GaimConnection *gc); | |
201 | |
202 /** | |
203 * Updates the connection progress. | |
204 * | |
205 * @param gc The connection. | |
206 * @param text Information on the current step. | |
207 * @param step The current step. | |
208 * @param count The total number of steps. | |
209 */ | |
210 void gaim_connection_update_progress(GaimConnection *gc, const char *text, | |
211 size_t step, size_t count); | |
212 | |
213 /** | |
5571
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
214 * Displays a connection-specific notice. |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
215 * |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
216 * @param gc The connection. |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
217 * @param text The notice text. |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
218 */ |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
219 void gaim_connection_notice(GaimConnection *gc, const char *text); |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
220 |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
221 /** |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
222 * Closes a connection with an error. |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
223 * |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
224 * @param gc The connection. |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
225 * @param reason The error text. |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
226 */ |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
227 void gaim_connection_error(GaimConnection *gc, const char *reason); |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
228 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
229 /*@}*/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
230 |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
231 /**************************************************************************/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
232 /** @name Connections API */ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
233 /**************************************************************************/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
234 /*@{*/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
235 |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
236 /** |
5563 | 237 * Disconnects from all connections. |
238 */ | |
239 void gaim_connections_disconnect_all(void); | |
240 | |
241 /** | |
242 * Returns a list of all active connections. | |
243 * | |
244 * @return A list of all active connections. | |
245 */ | |
246 GList *gaim_connections_get_all(void); | |
247 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
248 /** |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
249 * Returns a list of all connections in the process of connecting. |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
250 * |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
251 * @return A list of connecting connections. |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
252 */ |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
253 GList *gaim_connections_get_connecting(void); |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
254 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
255 /*@}*/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
256 |
5563 | 257 /**************************************************************************/ |
7122
b90c94620d1c
[gaim-migrate @ 7689]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
258 /** @name UI Registration Functions */ |
5563 | 259 /**************************************************************************/ |
260 /*@{*/ | |
261 | |
262 /** | |
263 * Sets the UI operations structure to be used for connections. | |
264 * | |
265 * @param ops The UI operations structure. | |
266 */ | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
267 void gaim_connections_set_ui_ops(GaimConnectionUiOps *ops); |
5563 | 268 |
269 /** | |
270 * Returns the UI operations structure used for connections. | |
271 * | |
272 * @return The UI operations structure in use. | |
273 */ | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
274 GaimConnectionUiOps *gaim_connections_get_ui_ops(void); |
5563 | 275 |
276 /*@}*/ | |
277 | |
6488
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
278 /**************************************************************************/ |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
279 /** @name Connections Subsystem */ |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
280 /**************************************************************************/ |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
281 /*@{*/ |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
282 |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
283 /** |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
284 * Initializes the connections subsystem. |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
285 */ |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
286 void gaim_connections_init(void); |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
287 |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
288 /** |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
289 * Uninitializes the connections subsystem. |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
290 */ |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
291 void gaim_connections_uninit(void); |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
292 |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
293 /** |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
294 * Returns the handle to the connections subsystem. |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
295 * |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
296 * @return The connections subsystem handle. |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
297 */ |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
298 void *gaim_connections_get_handle(void); |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
299 |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
300 /*@}*/ |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
301 |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
302 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
303 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
304 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
305 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
306 |
5563 | 307 #endif /* _GAIM_CONNECTION_H_ */ |