Mercurial > pidgin.yaz
annotate src/connection.h @ 6628:31b39f6c2142
[gaim-migrate @ 7152]
Ambrose C. LI (acli) detected some misspellings
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 25 Aug 2003 23:17:01 +0000 |
parents | a4622f1fb5a1 |
children | bdc448cf4cb6 |
rev | line source |
---|---|
5563 | 1 /** |
2 * @file connection.h Connection API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6393
diff
changeset
|
8 * |
5563 | 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 | |
6488
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
22 * |
6605
943b03bcecf5
[gaim-migrate @ 7129]
Christian Hammond <chipx86@chipx86.com>
parents:
6583
diff
changeset
|
23 * @see @ref connection-signals |
5563 | 24 */ |
25 #ifndef _GAIM_CONNECTION_H_ | |
26 #define _GAIM_CONNECTION_H_ | |
27 | |
28 #include <stdlib.h> | |
5733
4350b62bac45
[gaim-migrate @ 6157]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
29 #include <time.h> |
5563 | 30 |
31 typedef struct _GaimConnection GaimConnection; | |
32 | |
6622 | 33 /** |
34 * Flags to change behavior of the client for a given connection. | |
35 */ | |
36 typedef enum | |
37 { | |
38 GAIM_CONNECTION_HTML = 0x0001, /**< Connection sends/receives in 'HTML'. */ | |
39 GAIM_CONNECTION_AUTO_RESP = 0x0002 /**< Send auto responses when away. */ | |
40 } GaimConnectionFlags; | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5733
diff
changeset
|
41 |
5563 | 42 typedef enum |
43 { | |
44 GAIM_DISCONNECTED = 0, /**< Disconnected. */ | |
45 GAIM_CONNECTED, /**< Connected. */ | |
46 GAIM_CONNECTING /**< Connecting. */ | |
47 | |
48 } GaimConnectionState; | |
49 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
50 #include "account.h" |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
51 #include "plugin.h" |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
52 |
5563 | 53 typedef struct |
54 { | |
55 void (*connect_progress)(GaimConnection *gc, const char *text, | |
56 size_t step, size_t step_count); | |
57 void (*connected)(GaimConnection *gc); | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6393
diff
changeset
|
58 void (*disconnected)(GaimConnection *gc); |
5571
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
59 void (*notice)(GaimConnection *gc, const char *text); |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6393
diff
changeset
|
60 void (*report_disconnect)(GaimConnection *gc, const char *text); |
5563 | 61 |
62 } GaimConnectionUiOps; | |
63 | |
64 struct _GaimConnection | |
65 { | |
66 GaimPlugin *prpl; /**< The protocol plugin. */ | |
6622 | 67 GaimConnectionFlags flags; /**< Connection flags. */ |
5563 | 68 |
69 GaimConnectionState state; /**< The connection state. */ | |
70 | |
71 GaimAccount *account; /**< The account being connected to. */ | |
72 int inpa; /**< The input watcher. */ | |
73 | |
74 GSList *buddy_chats; /**< A list of active chats. */ | |
75 void *proto_data; /**< Protocol-specific data. */ | |
76 | |
77 char *display_name; /**< The name displayed. */ | |
78 guint keep_alive; /**< Keep-alive. */ | |
79 | |
80 guint idle_timer; /**< The idle timer. */ | |
81 time_t login_time; /**< Time of login. */ | |
82 time_t login_time_official; /**< Official time of login. */ | |
83 time_t last_sent_time; /**< The time something was last sent. */ | |
84 int is_idle; /**< Idle state of the connection. */ | |
85 | |
86 char *away; /**< The current away message, or NULL */ | |
87 char *away_state; /**< The last away type. */ | |
88 gboolean is_auto_away; /**< Whether or not it's auto-away. */ | |
89 | |
90 int evil; /**< Warning level for AIM (why is | |
91 this here?) */ | |
92 | |
93 gboolean wants_to_die; /**< Wants to Die state. */ | |
6393 | 94 guint disconnect_timeout; /**< Timer used for nasty stack tricks */ |
5563 | 95 }; |
96 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
97 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
98 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
99 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
100 |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
101 /**************************************************************************/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
102 /** @name Connection API */ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
103 /**************************************************************************/ |
6488
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
104 /*@{*/ |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
105 |
5563 | 106 /** |
107 * Creates a connection to the specified account. | |
108 * | |
109 * @param account The account the connection should be connecting to. | |
110 * | |
111 * @return The gaim connection. | |
112 */ | |
113 GaimConnection *gaim_connection_new(GaimAccount *account); | |
114 | |
115 /** | |
116 * Destroys and closes a gaim connection. | |
117 * | |
118 * @param gc The gaim connection to destroy. | |
119 */ | |
120 void gaim_connection_destroy(GaimConnection *gc); | |
121 | |
122 /** | |
123 * Signs a connection on. | |
124 * | |
125 * @param gc The connection to sign on. | |
126 * | |
127 * @see gaim_connection_disconnect() | |
128 */ | |
129 void gaim_connection_connect(GaimConnection *gc); | |
130 | |
131 /** | |
6581 | 132 * Registers a connection. |
133 * | |
134 * @param gc The connection to register. | |
135 */ | |
136 void gaim_connection_register(GaimConnection *gc); | |
137 | |
138 /** | |
5563 | 139 * Signs a connection off. |
6583
e07c66073b6d
[gaim-migrate @ 7105]
Christian Hammond <chipx86@chipx86.com>
parents:
6581
diff
changeset
|
140 * |
5563 | 141 * @param gc The connection to sign off. |
142 * | |
143 * @see gaim_connection_connect() | |
144 */ | |
145 void gaim_connection_disconnect(GaimConnection *gc); | |
146 | |
147 /** | |
148 * Sets the connection state. | |
149 * | |
150 * @param gc The connection. | |
151 * @param state The connection state. | |
152 */ | |
153 void gaim_connection_set_state(GaimConnection *gc, GaimConnectionState state); | |
154 | |
155 /** | |
156 * Sets the connection's account. | |
157 * | |
158 * @param gc The connection. | |
159 * @param account The account. | |
160 */ | |
161 void gaim_connection_set_account(GaimConnection *gc, GaimAccount *account); | |
162 | |
163 /** | |
164 * Sets the connection's displayed name. | |
165 * | |
166 * @param gc The connection. | |
167 * @param name The displayed name. | |
168 */ | |
169 void gaim_connection_set_display_name(GaimConnection *gc, const char *name); | |
170 | |
171 /** | |
172 * Returns the connection state. | |
173 * | |
174 * @param gc The connection. | |
175 * | |
176 * @return The connection state. | |
177 */ | |
178 GaimConnectionState gaim_connection_get_state(const GaimConnection *gc); | |
179 | |
180 /** | |
181 * Returns the connection's account. | |
182 * | |
183 * @param gc The connection. | |
184 * | |
185 * @return The connection's account. | |
186 */ | |
187 GaimAccount *gaim_connection_get_account(const GaimConnection *gc); | |
188 | |
189 /** | |
190 * Returns the connection's displayed name. | |
191 * | |
192 * @param gc The connection. | |
193 * | |
194 * @return The connection's displayed name. | |
195 */ | |
196 const char *gaim_connection_get_display_name(const GaimConnection *gc); | |
197 | |
198 /** | |
199 * Updates the connection progress. | |
200 * | |
201 * @param gc The connection. | |
202 * @param text Information on the current step. | |
203 * @param step The current step. | |
204 * @param count The total number of steps. | |
205 */ | |
206 void gaim_connection_update_progress(GaimConnection *gc, const char *text, | |
207 size_t step, size_t count); | |
208 | |
209 /** | |
5571
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
210 * Displays a connection-specific notice. |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
211 * |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
212 * @param gc The connection. |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
213 * @param text The notice text. |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
214 */ |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
215 void gaim_connection_notice(GaimConnection *gc, const char *text); |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
216 |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
217 /** |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
218 * Closes a connection with an error. |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
219 * |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
220 * @param gc The connection. |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
221 * @param reason The error text. |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
222 */ |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
223 void gaim_connection_error(GaimConnection *gc, const char *reason); |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
224 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
225 /*@}*/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
226 |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
227 /**************************************************************************/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
228 /** @name Connections API */ |
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 |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
232 /** |
5563 | 233 * Disconnects from all connections. |
234 */ | |
235 void gaim_connections_disconnect_all(void); | |
236 | |
237 /** | |
238 * Returns a list of all active connections. | |
239 * | |
240 * @return A list of all active connections. | |
241 */ | |
242 GList *gaim_connections_get_all(void); | |
243 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
244 /** |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
245 * Returns a list of all connections in the process of connecting. |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
246 * |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
247 * @return A list of connecting connections. |
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 GList *gaim_connections_get_connecting(void); |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
250 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
251 /*@}*/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
252 |
5563 | 253 /**************************************************************************/ |
254 /** @name UI Operations API */ | |
255 /**************************************************************************/ | |
256 /*@{*/ | |
257 | |
258 /** | |
259 * Sets the UI operations structure to be used for connections. | |
260 * | |
261 * @param ops The UI operations structure. | |
262 */ | |
263 void gaim_set_connection_ui_ops(GaimConnectionUiOps *ops); | |
264 | |
265 /** | |
266 * Returns the UI operations structure used for connections. | |
267 * | |
268 * @return The UI operations structure in use. | |
269 */ | |
270 GaimConnectionUiOps *gaim_get_connection_ui_ops(void); | |
271 | |
272 /*@}*/ | |
273 | |
6488
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
274 /**************************************************************************/ |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
275 /** @name Connections Subsystem */ |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
276 /**************************************************************************/ |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
277 /*@{*/ |
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 /** |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
280 * Initializes the connections subsystem. |
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 void gaim_connections_init(void); |
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 /** |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
285 * Uninitializes the connections subsystem. |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
286 */ |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
287 void gaim_connections_uninit(void); |
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 /** |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
290 * Returns the handle to the connections subsystem. |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
291 * |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
292 * @return The connections subsystem handle. |
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 void *gaim_connections_get_handle(void); |
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 /*@}*/ |
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 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
299 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
300 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
301 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
302 |
5563 | 303 #endif /* _GAIM_CONNECTION_H_ */ |