Mercurial > pidgin
comparison libgaim/connection.h @ 14192:60b1bc8dbf37
[gaim-migrate @ 16863]
Renamed 'core' to 'libgaim'
committer: Tailor Script <tailor@pidgin.im>
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Sat, 19 Aug 2006 01:50:10 +0000 |
parents | |
children | c590ec448bc3 |
comparison
equal
deleted
inserted
replaced
14191:009db0b357b5 | 14192:60b1bc8dbf37 |
---|---|
1 /** | |
2 * @file connection.h Connection API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
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. | |
10 * | |
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 | |
24 * | |
25 * @see @ref connection-signals | |
26 */ | |
27 #ifndef _GAIM_CONNECTION_H_ | |
28 #define _GAIM_CONNECTION_H_ | |
29 | |
30 typedef struct _GaimConnection GaimConnection; | |
31 | |
32 /** | |
33 * Flags to change behavior of the client for a given connection. | |
34 */ | |
35 typedef enum | |
36 { | |
37 GAIM_CONNECTION_HTML = 0x0001, /**< Connection sends/receives in 'HTML'. */ | |
38 GAIM_CONNECTION_NO_BGCOLOR = 0x0002, /**< Connection does not send/receive | |
39 background colors. */ | |
40 GAIM_CONNECTION_AUTO_RESP = 0x0004, /**< Send auto responses when away. */ | |
41 GAIM_CONNECTION_FORMATTING_WBFO = 0x0008, /**< The text buffer must be formatted as a whole */ | |
42 GAIM_CONNECTION_NO_NEWLINES = 0x0010, /**< No new lines are allowed in outgoing messages */ | |
43 GAIM_CONNECTION_NO_FONTSIZE = 0x0020, /**< Connection does not send/receive font sizes */ | |
44 GAIM_CONNECTION_NO_URLDESC = 0x0040, /**< Connection does not support descriptions with links */ | |
45 GAIM_CONNECTION_NO_IMAGES = 0x0080, /**< Connection does not support sending of images */ | |
46 | |
47 } GaimConnectionFlags; | |
48 | |
49 typedef enum | |
50 { | |
51 GAIM_DISCONNECTED = 0, /**< Disconnected. */ | |
52 GAIM_CONNECTED, /**< Connected. */ | |
53 GAIM_CONNECTING /**< Connecting. */ | |
54 | |
55 } GaimConnectionState; | |
56 | |
57 #include <time.h> | |
58 | |
59 #include "account.h" | |
60 #include "plugin.h" | |
61 #include "status.h" | |
62 | |
63 typedef struct | |
64 { | |
65 void (*connect_progress)(GaimConnection *gc, const char *text, | |
66 size_t step, size_t step_count); | |
67 void (*connected)(GaimConnection *gc); | |
68 void (*disconnected)(GaimConnection *gc); | |
69 void (*notice)(GaimConnection *gc, const char *text); | |
70 void (*report_disconnect)(GaimConnection *gc, const char *text); | |
71 | |
72 } GaimConnectionUiOps; | |
73 | |
74 struct _GaimConnection | |
75 { | |
76 GaimPlugin *prpl; /**< The protocol plugin. */ | |
77 GaimConnectionFlags flags; /**< Connection flags. */ | |
78 | |
79 GaimConnectionState state; /**< The connection state. */ | |
80 | |
81 GaimAccount *account; /**< The account being connected to. */ | |
82 char *password; /**< The password used. */ | |
83 int inpa; /**< The input watcher. */ | |
84 | |
85 GSList *buddy_chats; /**< A list of active chats. */ | |
86 void *proto_data; /**< Protocol-specific data. */ | |
87 | |
88 char *display_name; /**< The name displayed. */ | |
89 guint keepalive; /**< Keep-alive. */ | |
90 | |
91 | |
92 gboolean wants_to_die; /**< Wants to Die state. This is set | |
93 when the user chooses to log out, | |
94 or when the protocol is | |
95 disconnected and should not be | |
96 automatically reconnected | |
97 (incorrect password, etc.) */ | |
98 guint disconnect_timeout; /**< Timer used for nasty stack tricks */ | |
99 }; | |
100 | |
101 #ifdef __cplusplus | |
102 extern "C" { | |
103 #endif | |
104 | |
105 /**************************************************************************/ | |
106 /** @name Connection API */ | |
107 /**************************************************************************/ | |
108 /*@{*/ | |
109 | |
110 /** | |
111 * This function should only be called by gaim_account_connect() | |
112 * in account.c. If you're trying to sign on an account, use that | |
113 * function instead. | |
114 * | |
115 * Creates a connection to the specified account and either connects | |
116 * or attempts to register a new account. If you are logging in, | |
117 * the connection uses the current active status for this account. | |
118 * So if you want to sign on as "away," for example, you need to | |
119 * have called gaim_account_set_status(account, "away"). | |
120 * (And this will call gaim_account_connect() automatically). | |
121 * | |
122 * @param account The account the connection should be connecting to. | |
123 * @param regist Whether we are registering a new account or just | |
124 * trying to do a normal signon. | |
125 * @param password The password to use. | |
126 */ | |
127 void gaim_connection_new(GaimAccount *account, gboolean regist, | |
128 const char *password); | |
129 | |
130 /** | |
131 * Disconnects and destroys a GaimConnection. | |
132 * | |
133 * This function should only be called by gaim_account_disconnect() | |
134 * in account.c. If you're trying to sign off an account, use that | |
135 * function instead. | |
136 * | |
137 * @param gc The gaim connection to destroy. | |
138 */ | |
139 void gaim_connection_destroy(GaimConnection *gc); | |
140 | |
141 /** | |
142 * Sets the connection state. PRPLs should call this and pass in | |
143 * the state "GAIM_CONNECTED" when the account is completely | |
144 * signed on. What does it mean to be completely signed on? If | |
145 * the core can call prpl->set_status, and it successfully changes | |
146 * your status, then the account is online. | |
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 TRUE if the account is connected, otherwise returns FALSE. | |
180 * | |
181 * @return TRUE if the account is connected, otherwise returns FALSE. | |
182 */ | |
183 #define GAIM_CONNECTION_IS_CONNECTED(gc) \ | |
184 (gc->state == GAIM_CONNECTED) | |
185 | |
186 /** | |
187 * Returns the connection's account. | |
188 * | |
189 * @param gc The connection. | |
190 * | |
191 * @return The connection's account. | |
192 */ | |
193 GaimAccount *gaim_connection_get_account(const GaimConnection *gc); | |
194 | |
195 /** | |
196 * Returns the connection's password. | |
197 * | |
198 * @param gc The connection. | |
199 * | |
200 * @return The connection's password. | |
201 */ | |
202 const char *gaim_connection_get_password(const GaimConnection *gc); | |
203 | |
204 /** | |
205 * Returns the connection's displayed name. | |
206 * | |
207 * @param gc The connection. | |
208 * | |
209 * @return The connection's displayed name. | |
210 */ | |
211 const char *gaim_connection_get_display_name(const GaimConnection *gc); | |
212 | |
213 /** | |
214 * Updates the connection progress. | |
215 * | |
216 * @param gc The connection. | |
217 * @param text Information on the current step. | |
218 * @param step The current step. | |
219 * @param count The total number of steps. | |
220 */ | |
221 void gaim_connection_update_progress(GaimConnection *gc, const char *text, | |
222 size_t step, size_t count); | |
223 | |
224 /** | |
225 * Displays a connection-specific notice. | |
226 * | |
227 * @param gc The connection. | |
228 * @param text The notice text. | |
229 */ | |
230 void gaim_connection_notice(GaimConnection *gc, const char *text); | |
231 | |
232 /** | |
233 * Closes a connection with an error. | |
234 * | |
235 * @param gc The connection. | |
236 * @param reason The error text. | |
237 */ | |
238 void gaim_connection_error(GaimConnection *gc, const char *reason); | |
239 | |
240 /*@}*/ | |
241 | |
242 /**************************************************************************/ | |
243 /** @name Connections API */ | |
244 /**************************************************************************/ | |
245 /*@{*/ | |
246 | |
247 /** | |
248 * Disconnects from all connections. | |
249 */ | |
250 void gaim_connections_disconnect_all(void); | |
251 | |
252 /** | |
253 * Returns a list of all active connections. This does not | |
254 * include connections that are in the process of connecting. | |
255 * | |
256 * @return A list of all active connections. | |
257 */ | |
258 GList *gaim_connections_get_all(void); | |
259 | |
260 /** | |
261 * Returns a list of all connections in the process of connecting. | |
262 * | |
263 * @return A list of connecting connections. | |
264 */ | |
265 GList *gaim_connections_get_connecting(void); | |
266 | |
267 /** | |
268 * Checks if gc is still a valid pointer to a gc. | |
269 * | |
270 * @return @c TRUE if gc is valid. | |
271 */ | |
272 /* | |
273 * TODO: Eventually this bad boy will be removed, because it is | |
274 * a gross fix for a crashy problem. | |
275 */ | |
276 #define GAIM_CONNECTION_IS_VALID(gc) (g_list_find(gaim_connections_get_all(), (gc))) | |
277 | |
278 /*@}*/ | |
279 | |
280 /**************************************************************************/ | |
281 /** @name UI Registration Functions */ | |
282 /**************************************************************************/ | |
283 /*@{*/ | |
284 | |
285 /** | |
286 * Sets the UI operations structure to be used for connections. | |
287 * | |
288 * @param ops The UI operations structure. | |
289 */ | |
290 void gaim_connections_set_ui_ops(GaimConnectionUiOps *ops); | |
291 | |
292 /** | |
293 * Returns the UI operations structure used for connections. | |
294 * | |
295 * @return The UI operations structure in use. | |
296 */ | |
297 GaimConnectionUiOps *gaim_connections_get_ui_ops(void); | |
298 | |
299 /*@}*/ | |
300 | |
301 /**************************************************************************/ | |
302 /** @name Connections Subsystem */ | |
303 /**************************************************************************/ | |
304 /*@{*/ | |
305 | |
306 /** | |
307 * Initializes the connections subsystem. | |
308 */ | |
309 void gaim_connections_init(void); | |
310 | |
311 /** | |
312 * Uninitializes the connections subsystem. | |
313 */ | |
314 void gaim_connections_uninit(void); | |
315 | |
316 /** | |
317 * Returns the handle to the connections subsystem. | |
318 * | |
319 * @return The connections subsystem handle. | |
320 */ | |
321 void *gaim_connections_get_handle(void); | |
322 | |
323 /*@}*/ | |
324 | |
325 | |
326 #ifdef __cplusplus | |
327 } | |
328 #endif | |
329 | |
330 #endif /* _GAIM_CONNECTION_H_ */ |