Mercurial > pidgin
comparison libpurple/connection.h @ 32819:2c6510167895 default tip
propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24)
to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 02 Jun 2012 02:30:49 +0000 |
parents | 98520ee78f12 |
children |
comparison
equal
deleted
inserted
replaced
32818:01ff09d4a463 | 32819:2c6510167895 |
---|---|
57 | 57 |
58 } PurpleConnectionState; | 58 } PurpleConnectionState; |
59 | 59 |
60 /** | 60 /** |
61 * Possible errors that can cause a connection to be closed. | 61 * Possible errors that can cause a connection to be closed. |
62 * | |
63 * @since 2.3.0 | |
64 */ | 62 */ |
65 typedef enum | 63 typedef enum |
66 { | 64 { |
67 /** There was an error sending or receiving on the network socket, or | 65 /** There was an error sending or receiving on the network socket, or |
68 * there was some protocol error (such as the server sending malformed | 66 * there was some protocol error (such as the server sending malformed |
126 PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR = 15, | 124 PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR = 15, |
127 | 125 |
128 /** Some other error occurred which fits into none of the other | 126 /** Some other error occurred which fits into none of the other |
129 * categories. | 127 * categories. |
130 */ | 128 */ |
131 /* purple_connection_error_reason() in connection.c uses the fact that | 129 /* purple_connection_error() in connection.c uses the fact that |
132 * this is the last member of the enum when sanity-checking; if other | 130 * this is the last member of the enum when sanity-checking; if other |
133 * reasons are added after it, the check must be updated. | 131 * reasons are added after it, the check must be updated. |
134 */ | 132 */ |
135 PURPLE_CONNECTION_ERROR_OTHER_ERROR = 16 | 133 PURPLE_CONNECTION_ERROR_OTHER_ERROR = 16 |
136 } PurpleConnectionError; | 134 } PurpleConnectionError; |
192 * shipped with libpurple.) | 190 * shipped with libpurple.) |
193 */ | 191 */ |
194 void (*notice)(PurpleConnection *gc, const char *text); | 192 void (*notice)(PurpleConnection *gc, const char *text); |
195 | 193 |
196 /** | 194 /** |
197 * Called when an error causes a connection to be disconnected. | |
198 * Called before #disconnected. | |
199 * @param text a localized error message. | |
200 * @see #purple_connection_error | |
201 * @deprecated in favour of | |
202 * #PurpleConnectionUiOps.report_disconnect_reason. | |
203 */ | |
204 void (*report_disconnect)(PurpleConnection *gc, const char *text); | |
205 | |
206 /** | |
207 * Called when libpurple discovers that the computer's network | 195 * Called when libpurple discovers that the computer's network |
208 * connection is active. On Linux, this uses Network Manager if | 196 * connection is active. On Linux, this uses Network Manager if |
209 * available; on Windows, it uses Win32's network change notification | 197 * available; on Windows, it uses Win32's network change notification |
210 * infrastructure. | 198 * infrastructure. |
211 */ | 199 */ |
217 */ | 205 */ |
218 void (*network_disconnected)(void); | 206 void (*network_disconnected)(void); |
219 | 207 |
220 /** | 208 /** |
221 * Called when an error causes a connection to be disconnected. | 209 * Called when an error causes a connection to be disconnected. |
222 * Called before #disconnected. This op is intended to replace | 210 * Called before #disconnected. |
223 * #report_disconnect. If both are implemented, this will be called | |
224 * first; however, there's no real reason to implement both. | |
225 * | 211 * |
226 * @param reason why the connection ended, if known, or | 212 * @param reason why the connection ended, if known, or |
227 * #PURPLE_CONNECTION_ERROR_OTHER_ERROR, if not. | 213 * #PURPLE_CONNECTION_ERROR_OTHER_ERROR, if not. |
228 * @param text a localized message describing the disconnection | 214 * @param text a localized message describing the disconnection |
229 * in more detail to the user. | 215 * in more detail to the user. |
230 * @see #purple_connection_error_reason | 216 * @see #purple_connection_error |
231 * | 217 */ |
232 * @since 2.3.0 | 218 void (*report_disconnect)(PurpleConnection *gc, |
233 */ | 219 PurpleConnectionError reason, |
234 void (*report_disconnect_reason)(PurpleConnection *gc, | 220 const char *text); |
235 PurpleConnectionError reason, | |
236 const char *text); | |
237 | 221 |
238 void (*_purple_reserved1)(void); | 222 void (*_purple_reserved1)(void); |
239 void (*_purple_reserved2)(void); | 223 void (*_purple_reserved2)(void); |
240 void (*_purple_reserved3)(void); | 224 void (*_purple_reserved3)(void); |
241 } PurpleConnectionUiOps; | 225 } PurpleConnectionUiOps; |
249 | 233 |
250 PurpleConnectionState state; /**< The connection state. */ | 234 PurpleConnectionState state; /**< The connection state. */ |
251 | 235 |
252 PurpleAccount *account; /**< The account being connected to. */ | 236 PurpleAccount *account; /**< The account being connected to. */ |
253 char *password; /**< The password used. */ | 237 char *password; /**< The password used. */ |
254 int inpa; /**< The input watcher. */ | |
255 | 238 |
256 GSList *buddy_chats; /**< A list of active chats | 239 GSList *buddy_chats; /**< A list of active chats |
257 (#PurpleConversation structs of type | 240 (#PurpleConversation structs of type |
258 #PURPLE_CONV_TYPE_CHAT). */ | 241 #PURPLE_CONV_TYPE_CHAT). */ |
259 void *proto_data; /**< Protocol-specific data. */ | 242 void *proto_data; /**< Protocol-specific data. */ |
262 guint keepalive; /**< Keep-alive. */ | 245 guint keepalive; /**< Keep-alive. */ |
263 | 246 |
264 /** Wants to Die state. This is set when the user chooses to log out, or | 247 /** Wants to Die state. This is set when the user chooses to log out, or |
265 * when the protocol is disconnected and should not be automatically | 248 * when the protocol is disconnected and should not be automatically |
266 * reconnected (incorrect password, etc.). prpls should rely on | 249 * reconnected (incorrect password, etc.). prpls should rely on |
267 * purple_connection_error_reason() to set this for them rather than | 250 * purple_connection_error() to set this for them rather than |
268 * setting it themselves. | 251 * setting it themselves. |
269 * @see purple_connection_error_is_fatal | 252 * @see purple_connection_error_is_fatal |
270 */ | 253 */ |
271 gboolean wants_to_die; | 254 gboolean wants_to_die; |
272 | 255 |
273 guint disconnect_timeout; /**< Timer used for nasty stack tricks */ | 256 guint disconnect_timeout; /**< Timer used for nasty stack tricks */ |
274 time_t last_received; /**< When we last received a packet. Set by the | 257 time_t last_received; /**< When we last received a packet. Set by the |
275 prpl to avoid sending unneeded keepalives */ | 258 prpl to avoid sending unneeded keepalives */ |
276 }; | 259 }; |
277 | 260 |
278 #ifdef __cplusplus | 261 G_BEGIN_DECLS |
279 extern "C" { | |
280 #endif | |
281 | 262 |
282 /**************************************************************************/ | 263 /**************************************************************************/ |
283 /** @name Connection API */ | 264 /** @name Connection API */ |
284 /**************************************************************************/ | 265 /**************************************************************************/ |
285 /*@{*/ | 266 /*@{*/ |
286 | |
287 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_CONNECTION_C_) | |
288 /** | |
289 * This function should only be called by purple_account_connect() | |
290 * in account.c. If you're trying to sign on an account, use that | |
291 * function instead. | |
292 * | |
293 * Creates a connection to the specified account and either connects | |
294 * or attempts to register a new account. If you are logging in, | |
295 * the connection uses the current active status for this account. | |
296 * So if you want to sign on as "away," for example, you need to | |
297 * have called purple_account_set_status(account, "away"). | |
298 * (And this will call purple_account_connect() automatically). | |
299 * | |
300 * @param account The account the connection should be connecting to. | |
301 * @param regist Whether we are registering a new account or just | |
302 * trying to do a normal signon. | |
303 * @param password The password to use. | |
304 * | |
305 * @deprecated As this is internal, we should make it private in 3.0.0. | |
306 */ | |
307 void purple_connection_new(PurpleAccount *account, gboolean regist, | |
308 const char *password); | |
309 #endif | |
310 | |
311 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_CONNECTION_C_) | |
312 /** | |
313 * This function should only be called by purple_account_unregister() | |
314 * in account.c. | |
315 * | |
316 * Tries to unregister the account on the server. If the account is not | |
317 * connected, also creates a new connection. | |
318 * | |
319 * @param account The account to unregister | |
320 * @param password The password to use. | |
321 * @param cb Optional callback to be called when unregistration is complete | |
322 * @param user_data user data to pass to the callback | |
323 * | |
324 * @deprecated As this is internal, we should make it private in 3.0.0. | |
325 */ | |
326 void purple_connection_new_unregister(PurpleAccount *account, const char *password, PurpleAccountUnregistrationCb cb, void *user_data); | |
327 #endif | |
328 | |
329 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_CONNECTION_C_) | |
330 /** | |
331 * Disconnects and destroys a PurpleConnection. | |
332 * | |
333 * This function should only be called by purple_account_disconnect() | |
334 * in account.c. If you're trying to sign off an account, use that | |
335 * function instead. | |
336 * | |
337 * @param gc The purple connection to destroy. | |
338 * | |
339 * @deprecated As this is internal, we should make it private in 3.0.0. | |
340 */ | |
341 void purple_connection_destroy(PurpleConnection *gc); | |
342 #endif | |
343 | 267 |
344 /** | 268 /** |
345 * Sets the connection state. PRPLs should call this and pass in | 269 * Sets the connection state. PRPLs should call this and pass in |
346 * the state #PURPLE_CONNECTED when the account is completely | 270 * the state #PURPLE_CONNECTED when the account is completely |
347 * signed on. What does it mean to be completely signed on? If | 271 * signed on. What does it mean to be completely signed on? If |
352 * @param state The connection state. | 276 * @param state The connection state. |
353 */ | 277 */ |
354 void purple_connection_set_state(PurpleConnection *gc, PurpleConnectionState state); | 278 void purple_connection_set_state(PurpleConnection *gc, PurpleConnectionState state); |
355 | 279 |
356 /** | 280 /** |
281 * Sets the connection flags. | |
282 * | |
283 * @param gc The connection. | |
284 * @param flags The flags. | |
285 */ | |
286 void purple_connection_set_flags(PurpleConnection *gc, PurpleConnectionFlags flags); | |
287 | |
288 /** | |
357 * Sets the connection's account. | 289 * Sets the connection's account. |
358 * | 290 * |
359 * @param gc The connection. | 291 * @param gc The connection. |
360 * @param account The account. | 292 * @param account The account. |
361 */ | 293 */ |
372 /** | 304 /** |
373 * Sets the protocol data for a connection. | 305 * Sets the protocol data for a connection. |
374 * | 306 * |
375 * @param connection The PurpleConnection. | 307 * @param connection The PurpleConnection. |
376 * @param proto_data The protocol data to set for the connection. | 308 * @param proto_data The protocol data to set for the connection. |
377 * | |
378 * @since 2.6.0 | |
379 */ | 309 */ |
380 void purple_connection_set_protocol_data(PurpleConnection *connection, void *proto_data); | 310 void purple_connection_set_protocol_data(PurpleConnection *connection, void *proto_data); |
381 | 311 |
382 /** | 312 /** |
383 * Returns the connection state. | 313 * Returns the connection state. |
385 * @param gc The connection. | 315 * @param gc The connection. |
386 * | 316 * |
387 * @return The connection state. | 317 * @return The connection state. |
388 */ | 318 */ |
389 PurpleConnectionState purple_connection_get_state(const PurpleConnection *gc); | 319 PurpleConnectionState purple_connection_get_state(const PurpleConnection *gc); |
320 | |
321 /** | |
322 * Returns the connection flags. | |
323 * | |
324 * @param gc The connection. | |
325 * | |
326 * @return The connection flags. | |
327 */ | |
328 PurpleConnectionFlags purple_connection_get_flags(const PurpleConnection *gc); | |
390 | 329 |
391 /** | 330 /** |
392 * Returns TRUE if the account is connected, otherwise returns FALSE. | 331 * Returns TRUE if the account is connected, otherwise returns FALSE. |
393 * | 332 * |
394 * @return TRUE if the account is connected, otherwise returns FALSE. | 333 * @return TRUE if the account is connected, otherwise returns FALSE. |
409 * Returns the protocol plugin managing a connection. | 348 * Returns the protocol plugin managing a connection. |
410 * | 349 * |
411 * @param gc The connection. | 350 * @param gc The connection. |
412 * | 351 * |
413 * @return The protocol plugin. | 352 * @return The protocol plugin. |
414 * | |
415 * @since 2.4.0 | |
416 */ | 353 */ |
417 PurplePlugin * purple_connection_get_prpl(const PurpleConnection *gc); | 354 PurplePlugin * purple_connection_get_prpl(const PurpleConnection *gc); |
418 | 355 |
419 /** | 356 /** |
420 * Returns the connection's password. | 357 * Returns the connection's password. |
438 * Gets the protocol data from a connection. | 375 * Gets the protocol data from a connection. |
439 * | 376 * |
440 * @param connection The PurpleConnection. | 377 * @param connection The PurpleConnection. |
441 * | 378 * |
442 * @return The protocol data for the connection. | 379 * @return The protocol data for the connection. |
443 * | |
444 * @since 2.6.0 | |
445 */ | 380 */ |
446 void *purple_connection_get_protocol_data(const PurpleConnection *connection); | 381 void *purple_connection_get_protocol_data(const PurpleConnection *connection); |
447 | 382 |
448 /** | 383 /** |
449 * Updates the connection progress. | 384 * Updates the connection progress. |
463 * @param text The notice text. | 398 * @param text The notice text. |
464 */ | 399 */ |
465 void purple_connection_notice(PurpleConnection *gc, const char *text); | 400 void purple_connection_notice(PurpleConnection *gc, const char *text); |
466 | 401 |
467 /** | 402 /** |
468 * Closes a connection with an error. | |
469 * | |
470 * @param gc The connection. | |
471 * @param reason The error text, which may not be @c NULL. | |
472 * @deprecated in favour of #purple_connection_error_reason. Calling | |
473 * @c purple_connection_error(gc, text) is equivalent to calling | |
474 * @c purple_connection_error_reason(gc, reason, text) where @c reason is | |
475 * #PURPLE_CONNECTION_ERROR_OTHER_ERROR if @c gc->wants_to_die is @c TRUE, and | |
476 * #PURPLE_CONNECTION_ERROR_NETWORK_ERROR if not. (This is to keep | |
477 * auto-reconnection behaviour the same when using old prpls which don't use | |
478 * reasons yet.) | |
479 */ | |
480 void purple_connection_error(PurpleConnection *gc, const char *reason); | |
481 | |
482 /** | |
483 * Closes a connection with an error and a human-readable description of the | 403 * Closes a connection with an error and a human-readable description of the |
484 * error. It also sets @c gc->wants_to_die to the value of | 404 * error. It also sets @c gc->wants_to_die to the value of |
485 * #purple_connection_error_is_fatal(@a reason), mainly for | 405 * #purple_connection_error_is_fatal(@a reason), mainly for |
486 * backwards-compatibility. | 406 * backwards-compatibility. |
487 * | 407 * |
488 * @param gc the connection which is closing. | 408 * @param gc the connection which is closing. |
489 * @param reason why the connection is closing. | 409 * @param reason why the connection is closing. |
490 * @param description a non-@c NULL localized description of the error. | 410 * @param description a non-@c NULL localized description of the error. |
491 * | |
492 * @since 2.3.0 | |
493 */ | 411 */ |
494 void | 412 void |
495 purple_connection_error_reason (PurpleConnection *gc, | 413 purple_connection_error(PurpleConnection *gc, |
496 PurpleConnectionError reason, | 414 PurpleConnectionError reason, |
497 const char *description); | 415 const char *description); |
498 | 416 |
499 /** | 417 /** |
500 * Closes a connection due to an SSL error; this is basically a shortcut to | 418 * Closes a connection due to an SSL error; this is basically a shortcut to |
501 * turning the #PurpleSslErrorType into a #PurpleConnectionError and a | 419 * turning the #PurpleSslErrorType into a #PurpleConnectionError and a |
502 * human-readable string and then calling purple_connection_error_reason(). | 420 * human-readable string and then calling purple_connection_error(). |
503 * | |
504 * @since 2.3.0 | |
505 */ | 421 */ |
506 void | 422 void |
507 purple_connection_ssl_error (PurpleConnection *gc, | 423 purple_connection_ssl_error (PurpleConnection *gc, |
508 PurpleSslErrorType ssl_error); | 424 PurpleSslErrorType ssl_error); |
509 | 425 |
522 * | 438 * |
523 * (This function is meant to replace checking PurpleConnection.wants_to_die.) | 439 * (This function is meant to replace checking PurpleConnection.wants_to_die.) |
524 * | 440 * |
525 * @return @c TRUE if the account should not be automatically reconnected, and | 441 * @return @c TRUE if the account should not be automatically reconnected, and |
526 * @c FALSE otherwise. | 442 * @c FALSE otherwise. |
527 * | |
528 * @since 2.3.0 | |
529 */ | 443 */ |
530 gboolean | 444 gboolean |
531 purple_connection_error_is_fatal (PurpleConnectionError reason); | 445 purple_connection_error_is_fatal (PurpleConnectionError reason); |
446 | |
447 /** | |
448 * Indicate that a packet was received on the connection. | |
449 * Set by the prpl to avoid sending unneeded keepalives. | |
450 * | |
451 * @param gc The connection. | |
452 */ | |
453 void purple_connection_update_last_received(PurpleConnection *gc); | |
532 | 454 |
533 /*@}*/ | 455 /*@}*/ |
534 | 456 |
535 /**************************************************************************/ | 457 /**************************************************************************/ |
536 /** @name Connections API */ | 458 /** @name Connections API */ |
617 void *purple_connections_get_handle(void); | 539 void *purple_connections_get_handle(void); |
618 | 540 |
619 /*@}*/ | 541 /*@}*/ |
620 | 542 |
621 | 543 |
622 #ifdef __cplusplus | 544 G_END_DECLS |
623 } | |
624 #endif | |
625 | 545 |
626 #endif /* _PURPLE_CONNECTION_H_ */ | 546 #endif /* _PURPLE_CONNECTION_H_ */ |