Mercurial > pidgin.yaz
annotate src/connection.h @ 8677:cc2ce209cc46
[gaim-migrate @ 9430]
marv's patch for GtkIMHtml.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sat, 17 Apr 2004 13:58:29 +0000 |
parents | 87bd4d4ff499 |
children | 0eb5161ef333 |
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. */ | |
8677 | 43 GAIM_CONNECTION_AUTO_RESP = 0x0004, /**< Send auto responses when away. */ |
44 GAIM_CONNECTION_FORMATTING_WBFO = 0x0008, /**< The text buffer must be formatted as a whole */ | |
45 GAIM_CONNECTION_NO_NEWLINES = 0x0010 /**< No new lines are allowed in outgoing messages */ | |
6622 | 46 } GaimConnectionFlags; |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5733
diff
changeset
|
47 |
5563 | 48 typedef enum |
49 { | |
50 GAIM_DISCONNECTED = 0, /**< Disconnected. */ | |
51 GAIM_CONNECTED, /**< Connected. */ | |
52 GAIM_CONNECTING /**< Connecting. */ | |
53 | |
54 } GaimConnectionState; | |
55 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
56 #include "account.h" |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
57 #include "plugin.h" |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
58 |
5563 | 59 typedef struct |
60 { | |
61 void (*connect_progress)(GaimConnection *gc, const char *text, | |
62 size_t step, size_t step_count); | |
63 void (*connected)(GaimConnection *gc); | |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6393
diff
changeset
|
64 void (*disconnected)(GaimConnection *gc); |
5571
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
65 void (*notice)(GaimConnection *gc, const char *text); |
6460
ff4551719cc7
[gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents:
6393
diff
changeset
|
66 void (*report_disconnect)(GaimConnection *gc, const char *text); |
5563 | 67 |
68 } GaimConnectionUiOps; | |
69 | |
70 struct _GaimConnection | |
71 { | |
72 GaimPlugin *prpl; /**< The protocol plugin. */ | |
6622 | 73 GaimConnectionFlags flags; /**< Connection flags. */ |
5563 | 74 |
75 GaimConnectionState state; /**< The connection state. */ | |
76 | |
77 GaimAccount *account; /**< The account being connected to. */ | |
78 int inpa; /**< The input watcher. */ | |
79 | |
80 GSList *buddy_chats; /**< A list of active chats. */ | |
81 void *proto_data; /**< Protocol-specific data. */ | |
82 | |
83 char *display_name; /**< The name displayed. */ | |
84 guint keep_alive; /**< Keep-alive. */ | |
85 | |
86 guint idle_timer; /**< The idle timer. */ | |
87 time_t login_time; /**< Time of login. */ | |
88 time_t login_time_official; /**< Official time of login. */ | |
89 time_t last_sent_time; /**< The time something was last sent. */ | |
90 int is_idle; /**< Idle state of the connection. */ | |
91 | |
92 char *away; /**< The current away message, or NULL */ | |
93 char *away_state; /**< The last away type. */ | |
94 gboolean is_auto_away; /**< Whether or not it's auto-away. */ | |
95 | |
96 int evil; /**< Warning level for AIM (why is | |
97 this here?) */ | |
98 | |
8430 | 99 gboolean wants_to_die; /**< Wants to Die state. This is set |
100 when the user chooses to sign off, | |
101 or when the protocol is | |
102 disconnected and should not be | |
103 automatically reconnected | |
104 (incorrect password, etc.) */ | |
6393 | 105 guint disconnect_timeout; /**< Timer used for nasty stack tricks */ |
5563 | 106 }; |
107 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
108 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
109 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
110 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
111 |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
112 /**************************************************************************/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
113 /** @name Connection API */ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
114 /**************************************************************************/ |
6488
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
115 /*@{*/ |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
116 |
5563 | 117 /** |
118 * Creates a connection to the specified account. | |
119 * | |
120 * @param account The account the connection should be connecting to. | |
121 * | |
122 * @return The gaim connection. | |
123 */ | |
124 GaimConnection *gaim_connection_new(GaimAccount *account); | |
125 | |
126 /** | |
127 * Destroys and closes a gaim connection. | |
128 * | |
129 * @param gc The gaim connection to destroy. | |
130 */ | |
131 void gaim_connection_destroy(GaimConnection *gc); | |
132 | |
133 /** | |
134 * Signs a connection on. | |
135 * | |
136 * @param gc The connection to sign on. | |
137 * | |
138 * @see gaim_connection_disconnect() | |
139 */ | |
140 void gaim_connection_connect(GaimConnection *gc); | |
141 | |
142 /** | |
6581 | 143 * Registers a connection. |
144 * | |
145 * @param gc The connection to register. | |
146 */ | |
147 void gaim_connection_register(GaimConnection *gc); | |
148 | |
149 /** | |
5563 | 150 * Signs a connection off. |
6583
e07c66073b6d
[gaim-migrate @ 7105]
Christian Hammond <chipx86@chipx86.com>
parents:
6581
diff
changeset
|
151 * |
5563 | 152 * @param gc The connection to sign off. |
153 * | |
154 * @see gaim_connection_connect() | |
155 */ | |
156 void gaim_connection_disconnect(GaimConnection *gc); | |
157 | |
158 /** | |
159 * Sets the connection state. | |
160 * | |
161 * @param gc The connection. | |
162 * @param state The connection state. | |
163 */ | |
164 void gaim_connection_set_state(GaimConnection *gc, GaimConnectionState state); | |
165 | |
166 /** | |
167 * Sets the connection's account. | |
168 * | |
169 * @param gc The connection. | |
170 * @param account The account. | |
171 */ | |
172 void gaim_connection_set_account(GaimConnection *gc, GaimAccount *account); | |
173 | |
174 /** | |
175 * Sets the connection's displayed name. | |
176 * | |
177 * @param gc The connection. | |
178 * @param name The displayed name. | |
179 */ | |
180 void gaim_connection_set_display_name(GaimConnection *gc, const char *name); | |
181 | |
182 /** | |
183 * Returns the connection state. | |
184 * | |
185 * @param gc The connection. | |
186 * | |
187 * @return The connection state. | |
188 */ | |
189 GaimConnectionState gaim_connection_get_state(const GaimConnection *gc); | |
190 | |
191 /** | |
192 * Returns the connection's account. | |
193 * | |
194 * @param gc The connection. | |
195 * | |
196 * @return The connection's account. | |
197 */ | |
198 GaimAccount *gaim_connection_get_account(const GaimConnection *gc); | |
199 | |
200 /** | |
201 * Returns the connection's displayed name. | |
202 * | |
203 * @param gc The connection. | |
204 * | |
205 * @return The connection's displayed name. | |
206 */ | |
207 const char *gaim_connection_get_display_name(const GaimConnection *gc); | |
208 | |
209 /** | |
210 * Updates the connection progress. | |
211 * | |
212 * @param gc The connection. | |
213 * @param text Information on the current step. | |
214 * @param step The current step. | |
215 * @param count The total number of steps. | |
216 */ | |
217 void gaim_connection_update_progress(GaimConnection *gc, const char *text, | |
218 size_t step, size_t count); | |
219 | |
220 /** | |
5571
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
221 * Displays a connection-specific notice. |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
222 * |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
223 * @param gc The connection. |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
224 * @param text The notice text. |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
225 */ |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
226 void gaim_connection_notice(GaimConnection *gc, const char *text); |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
227 |
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
228 /** |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
229 * Closes a connection with an error. |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
230 * |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
231 * @param gc The connection. |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
232 * @param reason The error text. |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
233 */ |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
234 void gaim_connection_error(GaimConnection *gc, const char *reason); |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
235 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
236 /*@}*/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
237 |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
238 /**************************************************************************/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
239 /** @name Connections API */ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
240 /**************************************************************************/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
241 /*@{*/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
242 |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
243 /** |
5563 | 244 * Disconnects from all connections. |
245 */ | |
246 void gaim_connections_disconnect_all(void); | |
247 | |
248 /** | |
249 * Returns a list of all active connections. | |
250 * | |
251 * @return A list of all active connections. | |
252 */ | |
253 GList *gaim_connections_get_all(void); | |
254 | |
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
255 /** |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
256 * Returns a list of all connections in the process of connecting. |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
257 * |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
258 * @return A list of connecting connections. |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
259 */ |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
260 GList *gaim_connections_get_connecting(void); |
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
261 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
262 /*@}*/ |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
263 |
5563 | 264 /**************************************************************************/ |
7122
b90c94620d1c
[gaim-migrate @ 7689]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
265 /** @name UI Registration Functions */ |
5563 | 266 /**************************************************************************/ |
267 /*@{*/ | |
268 | |
269 /** | |
270 * Sets the UI operations structure to be used for connections. | |
271 * | |
272 * @param ops The UI operations structure. | |
273 */ | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
274 void gaim_connections_set_ui_ops(GaimConnectionUiOps *ops); |
5563 | 275 |
276 /** | |
277 * Returns the UI operations structure used for connections. | |
278 * | |
279 * @return The UI operations structure in use. | |
280 */ | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
281 GaimConnectionUiOps *gaim_connections_get_ui_ops(void); |
5563 | 282 |
283 /*@}*/ | |
284 | |
6488
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 /** @name Connections Subsystem */ |
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 |
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 * Initializes the connections subsystem. |
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 void gaim_connections_init(void); |
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 * Uninitializes the connections subsystem. |
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_uninit(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 * Returns the handle to the connections subsystem. |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
302 * |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
303 * @return The connections subsystem handle. |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
304 */ |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
305 void *gaim_connections_get_handle(void); |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
306 |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
307 /*@}*/ |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
308 |
e5e8d21bd4d8
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
309 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
310 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
311 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
312 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
313 |
5563 | 314 #endif /* _GAIM_CONNECTION_H_ */ |