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