summaryrefslogtreecommitdiff
path: root/libpurple/connection.h
blob: 28b535bced66b2549329b91f0ef9e0f01d38dc32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
/* purple
 *
 * Purple is the legal property of its developers, whose names are too numerous
 * to list here.  Please refer to the COPYRIGHT file distributed with this
 * source distribution.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 */
/**
 * SECTION:connection
 * @section_id: libpurple-connection
 * @short_description: <filename>connection.h</filename>
 * @title: Connection API
 * @see_also: <link linkend="chapter-signals-connection">Connection signals</link>
 */

#ifndef _PURPLE_CONNECTION_H_
#define _PURPLE_CONNECTION_H_

#define PURPLE_TYPE_CONNECTION             (purple_connection_get_type())
#define PURPLE_CONNECTION(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_CONNECTION, PurpleConnection))
#define PURPLE_CONNECTION_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_CONNECTION, PurpleConnectionClass))
#define PURPLE_IS_CONNECTION(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_CONNECTION))
#define PURPLE_IS_CONNECTION_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_CONNECTION))
#define PURPLE_CONNECTION_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_CONNECTION, PurpleConnectionClass))

#define PURPLE_TYPE_CONNECTION_ERROR_INFO  (purple_connection_error_info_get_type())

typedef struct _PurpleConnection PurpleConnection;
typedef struct _PurpleConnectionClass PurpleConnectionClass;

typedef struct _PurpleConnectionUiOps PurpleConnectionUiOps;

typedef struct _PurpleConnectionErrorInfo PurpleConnectionErrorInfo;

/**
 * PurpleConnectionFlags:
 * @PURPLE_CONNECTION_FLAG_HTML: Connection sends/receives in 'HTML'
 * @PURPLE_CONNECTION_FLAG_NO_BGCOLOR: Connection does not send/receive
 *                                     background colors
 * @PURPLE_CONNECTION_FLAG_AUTO_RESP: Send auto responses when away
 * @PURPLE_CONNECTION_FLAG_FORMATTING_WBFO: The text buffer must be formatted
 *                                          as a whole
 * @PURPLE_CONNECTION_FLAG_NO_NEWLINES: No new lines are allowed in outgoing
 *                                      messages
 * @PURPLE_CONNECTION_FLAG_NO_FONTSIZE: Connection does not send/receive font
 *                                      sizes
 * @PURPLE_CONNECTION_FLAG_NO_URLDESC: Connection does not support descriptions
 *                                     with links
 * @PURPLE_CONNECTION_FLAG_NO_IMAGES: Connection does not support sending of
 *                                    images
 * @PURPLE_CONNECTION_FLAG_ALLOW_CUSTOM_SMILEY: Connection supports sending
 *                                              and receiving custom smileys
 * @PURPLE_CONNECTION_FLAG_SUPPORT_MOODS: Connection supports setting moods
 * @PURPLE_CONNECTION_FLAG_SUPPORT_MOOD_MESSAGES: Connection supports setting
 *                                                a message on moods
 *
 * Flags to change behavior of the client for a given connection.
 */
typedef enum /*< flags >*/
{
	PURPLE_CONNECTION_FLAG_HTML       = 0x0001,
	PURPLE_CONNECTION_FLAG_NO_BGCOLOR = 0x0002,
	PURPLE_CONNECTION_FLAG_AUTO_RESP  = 0x0004,
	PURPLE_CONNECTION_FLAG_FORMATTING_WBFO = 0x0008,
	PURPLE_CONNECTION_FLAG_NO_NEWLINES = 0x0010,
	PURPLE_CONNECTION_FLAG_NO_FONTSIZE = 0x0020,
	PURPLE_CONNECTION_FLAG_NO_URLDESC = 0x0040,
	PURPLE_CONNECTION_FLAG_NO_IMAGES = 0x0080,
	PURPLE_CONNECTION_FLAG_ALLOW_CUSTOM_SMILEY = 0x0100,
	PURPLE_CONNECTION_FLAG_SUPPORT_MOODS = 0x0200,
	PURPLE_CONNECTION_FLAG_SUPPORT_MOOD_MESSAGES = 0x0400
} PurpleConnectionFlags;

/**
 * PurpleConnectionState:
 * @PURPLE_CONNECTION_DISCONNECTED: Disconnected.
 * @PURPLE_CONNECTION_CONNECTED:    Connected.
 * @PURPLE_CONNECTION_CONNECTING:   Connecting.
 */
typedef enum
{
	PURPLE_CONNECTION_DISCONNECTED = 0,
	PURPLE_CONNECTION_CONNECTED,
	PURPLE_CONNECTION_CONNECTING
} PurpleConnectionState;

/**
 * PurpleConnectionError:
 * @PURPLE_CONNECTION_ERROR_NETWORK_ERROR: There was an error sending or
 *         receiving on the network socket, or there was some protocol error
 *         (such as the server sending malformed data).
 * @PURPLE_CONNECTION_ERROR_INVALID_USERNAME: The username supplied was not
 *         valid.
 * @PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED: The username, password or
 *         some other credential was incorrect.  Use
 *         #PURPLE_CONNECTION_ERROR_INVALID_USERNAME instead if the username
 *         is known to be invalid.
 * @PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE: libpurple doesn't speak
 *         any of the authentication methods the server offered.
 * @PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT: libpurple was built without SSL
 *         support, and the connection needs SSL.
 * @PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR: There was an error negotiating
 *         SSL on this connection, or the server does not support encryption
 *         but an account option was set to require it.
 * @PURPLE_CONNECTION_ERROR_NAME_IN_USE: Someone is already connected to the
 *         server using the name you are trying to connect with.
 * @PURPLE_CONNECTION_ERROR_INVALID_SETTINGS: The username/server/other
 *         preference for the account isn't valid.  For instance, on IRC the
 *         username cannot contain white space.  This reason should not be used
 *         for incorrect passwords etc: use
 *         #PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED for that.
 *         @todo This reason really shouldn't be necessary.  Usernames and
 *               other account preferences should be validated when the
 *               account is created.
 * @PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED: The server did not provide a
 *         SSL certificate.
 * @PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED: The server's SSL certificate could
 *         not be trusted.
 * @PURPLE_CONNECTION_ERROR_CERT_EXPIRED: The server's SSL certificate has
 *         expired.
 * @PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED: The server's SSL certificate is
 *         not yet valid.
 * @PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH: The server's SSL
 *         certificate did not match its hostname.
 * @PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH: The server's SSL
 *         certificate does not have the expected fingerprint.
 * @PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED: The server's SSL certificate is
 *         self-signed.
 * @PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR: There was some other error
 *         validating the server's SSL certificate.
 * @PURPLE_CONNECTION_ERROR_OTHER_ERROR: Some other error occurred which fits
 *         into none of the other categories.
 *
 * Possible errors that can cause a connection to be closed.
 */
typedef enum
{
	PURPLE_CONNECTION_ERROR_NETWORK_ERROR = 0,
	PURPLE_CONNECTION_ERROR_INVALID_USERNAME = 1,
	PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED = 2,
	PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE = 3,
	PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT = 4,
	PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR = 5,
	PURPLE_CONNECTION_ERROR_NAME_IN_USE = 6,
	PURPLE_CONNECTION_ERROR_INVALID_SETTINGS = 7,
	PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED = 8,
	PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED = 9,
	PURPLE_CONNECTION_ERROR_CERT_EXPIRED = 10,
	PURPLE_CONNECTION_ERROR_CERT_NOT_ACTIVATED = 11,
	PURPLE_CONNECTION_ERROR_CERT_HOSTNAME_MISMATCH = 12,
	PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH = 13,
	PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED = 14,
	PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR = 15,

	/* purple_connection_error() in connection.c uses the fact that
	 * this is the last member of the enum when sanity-checking; if other
	 * reasons are added after it, the check must be updated.
	 */
	PURPLE_CONNECTION_ERROR_OTHER_ERROR = 16
} PurpleConnectionError;

/**
 * PurpleConnectionErrorInfo:
 * @type: The type of error.
 * @description: A localised, human-readable description of the error.
 *
 * Holds the type of an error along with its description.
 */
struct _PurpleConnectionErrorInfo
{
	PurpleConnectionError type;
	char *description;
};

#include <time.h>

#include "account.h"
#include "plugin.h"
#include "status.h"
#include "sslconn.h"

/**
 * PurpleConnectionUiOps:
 * @connect_progress: When an account is connecting, this operation is called to
 *                    notify the UI of what is happening, as well as which @step
 *                    out of @step_count has been reached (which might be
 *                    displayed as a progress bar).
 *                    <sbr/>See purple_connection_update_progress().
 * @connected: Called when a connection is established (just before the
 *   <link linkend="connections-signed-on"><literal>"signed-on"</literal></link>
 *             signal).
 * @disconnected: Called when a connection is ended (between the
 *   <link linkend="connections-signing-off"><literal>"signing-off"</literal></link>
 *   and <link linkend="connections-signed-off"><literal>"signed-off"</literal></link>
 *                signals).
 * @notice: Used to display connection-specific notices. (Pidgin's Gtk user
 *          interface implements this as a no-op; purple_connection_notice(),
 *          which uses this operation, is not used by any of the protocols
 *          shipped with libpurple.)
 * @network_connected: Called when libpurple discovers that the computer's
 *                     network connection is active.  On Linux, this uses
 *                     Network Manager if available; on Windows, it uses
 *                     Win32's network change notification infrastructure.
 * @network_disconnected: Called when libpurple discovers that the computer's
 *                        network connection has gone away.
 * @report_disconnect: Called when an error causes a connection to be
 *                     disconnected. Called before @disconnected.
 *                     <sbr/>See purple_connection_error().
 *                     <sbr/>@reason: why the connection ended, if known, or
 *                                 #PURPLE_CONNECTION_ERROR_OTHER_ERROR, if not.
 *                     <sbr/>@text:   a localized message describing the
 *                                 disconnection in more detail to the user.
 *
 * Connection UI operations.  Used to notify the user of changes to
 * connections, such as being disconnected, and to respond to the
 * underlying network connection appearing and disappearing.  UIs should
 * call #purple_connections_set_ui_ops() with an instance of this struct.
 *
 * See <link linkend="chapter-ui-ops">List of <literal>UiOps</literal> Structures</link>
 */
struct _PurpleConnectionUiOps
{
	void (*connect_progress)(PurpleConnection *gc,
	                         const char *text,
	                         size_t step,
	                         size_t step_count);

	void (*connected)(PurpleConnection *gc);
	void (*disconnected)(PurpleConnection *gc);

	void (*notice)(PurpleConnection *gc, const char *text);

	void (*network_connected)(void);
	void (*network_disconnected)(void);

	void (*report_disconnect)(PurpleConnection *gc,
	                          PurpleConnectionError reason,
	                          const char *text);

	/*< private >*/
	void (*_purple_reserved1)(void);
	void (*_purple_reserved2)(void);
	void (*_purple_reserved3)(void);
	void (*_purple_reserved4)(void);
};

/**
 * PurpleConnection:
 *
 * Represents an active connection on an account.
 */
struct _PurpleConnection
{
	GObject gparent;
};

/**
 * PurpleConnectionClass:
 *
 * Base class for all #PurpleConnection's
 */
struct _PurpleConnectionClass {
	GObjectClass parent_class;

	/*< private >*/
	void (*_purple_reserved1)(void);
	void (*_purple_reserved2)(void);
	void (*_purple_reserved3)(void);
	void (*_purple_reserved4)(void);
};

G_BEGIN_DECLS

/**************************************************************************/
/* Connection API                                                         */
/**************************************************************************/
/*@{*/

/**
 * purple_connection_get_type:
 *
 * Returns: The #GType for the Connection object.
 */
GType purple_connection_get_type(void);

/**
 * purple_connection_error_info_get_type:
 *
 * Returns: The #GType for the #PurpleConnectionErrorInfo boxed structure.
 */
GType purple_connection_error_info_get_type(void);

/**
 * purple_connection_set_state:
 * @gc:    The connection.
 * @state: The connection state.
 *
 * Sets the connection state.  Protocols should call this and pass in
 * the state #PURPLE_CONNECTION_CONNECTED when the account is completely
 * signed on.  What does it mean to be completely signed on?  If
 * the core can call protocol's set_status, and it successfully changes
 * your status, then the account is online.
 */
void purple_connection_set_state(PurpleConnection *gc, PurpleConnectionState state);

/**
 * purple_connection_set_flags:
 * @gc:    The connection.
 * @flags: The flags.
 *
 * Sets the connection flags.
 */
void purple_connection_set_flags(PurpleConnection *gc, PurpleConnectionFlags flags);

/**
 * purple_connection_set_display_name:
 * @gc:   The connection.
 * @name: The displayed name.
 *
 * Sets the connection's displayed name.
 */
void purple_connection_set_display_name(PurpleConnection *gc, const char *name);

/**
 * purple_connection_set_protocol_data:
 * @connection: The PurpleConnection.
 * @proto_data: The protocol data to set for the connection.
 *
 * Sets the protocol data for a connection.
 */
void purple_connection_set_protocol_data(PurpleConnection *connection, void *proto_data);

/**
 * purple_connection_get_state:
 * @gc: The connection.
 *
 * Returns the connection state.
 *
 * Returns: The connection state.
 */
PurpleConnectionState purple_connection_get_state(const PurpleConnection *gc);

/**
 * purple_connection_get_flags:
 * @gc: The connection.
 *
 * Returns the connection flags.
 *
 * Returns: The connection flags.
 */
PurpleConnectionFlags purple_connection_get_flags(const PurpleConnection *gc);

/**
 * PURPLE_CONNECTION_IS_CONNECTED:
 *
 * Returns TRUE if the account is connected, otherwise returns FALSE.
 *
 * Returns: TRUE if the account is connected, otherwise returns FALSE.
 */
#define PURPLE_CONNECTION_IS_CONNECTED(gc) \
	(purple_connection_get_state(gc) == PURPLE_CONNECTION_CONNECTED)

/**
 * purple_connection_get_account:
 * @gc: The connection.
 *
 * Returns the connection's account.
 *
 * Returns: The connection's account.
 */
PurpleAccount *purple_connection_get_account(const PurpleConnection *gc);

/**
 * purple_connection_get_prpl:
 * @gc: The connection.
 *
 * Returns the protocol plugin managing a connection.
 *
 * Returns: The protocol plugin.
 */
PurplePlugin *purple_connection_get_prpl(const PurpleConnection *gc);

/**
 * purple_connection_get_password:
 * @gc: The connection.
 *
 * Returns the connection's password.
 *
 * Returns: The connection's password.
 */
const char *purple_connection_get_password(const PurpleConnection *gc);

/**
 * purple_connection_get_active_chats:
 * @gc: The connection.
 *
 * Returns a list of active chat conversations on a connection.
 *
 * Returns: The active chats on the connection.
 */
GSList *purple_connection_get_active_chats(const PurpleConnection *gc);

/**
 * purple_connection_get_display_name:
 * @gc: The connection.
 *
 * Returns the connection's displayed name.
 *
 * Returns: The connection's displayed name.
 */
const char *purple_connection_get_display_name(const PurpleConnection *gc);

/**
 * purple_connection_get_protocol_data:
 * @gc: The PurpleConnection.
 *
 * Gets the protocol data from a connection.
 *
 * Returns: The protocol data for the connection.
 */
void *purple_connection_get_protocol_data(const PurpleConnection *gc);

/**
 * purple_connection_update_progress:
 * @gc:    The connection.
 * @text:  Information on the current step.
 * @step:  The current step.
 * @count: The total number of steps.
 *
 * Updates the connection progress.
 */
void purple_connection_update_progress(PurpleConnection *gc, const char *text,
									 size_t step, size_t count);

/**
 * purple_connection_notice:
 * @gc:   The connection.
 * @text: The notice text.
 *
 * Displays a connection-specific notice.
 */
void purple_connection_notice(PurpleConnection *gc, const char *text);

/**
 * purple_connection_error:
 * @gc:          the connection which is closing.
 * @reason:      why the connection is closing.
 * @description: a localized description of the error (not %NULL ).
 *
 * Closes a connection with an error and a human-readable description of the
 * error.
 */
void
purple_connection_error(PurpleConnection *gc,
                        PurpleConnectionError reason,
                        const char *description);

/**
 * purple_connection_get_error_info:
 * @gc: The connection.
 *
 * Returns the #PurpleConnectionErrorInfo instance of a connection if an
 * error exists.
 *
 * Returns: The #PurpleConnectionErrorInfo instance of the connection if an
 *         error exists, %NULL otherwise.
 */
PurpleConnectionErrorInfo *
purple_connection_get_error_info(const PurpleConnection *gc);

/**
 * purple_connection_ssl_error:
 *
 * Closes a connection due to an SSL error; this is basically a shortcut to
 * turning the #PurpleSslErrorType into a #PurpleConnectionError and a
 * human-readable string and then calling purple_connection_error().
 */
void
purple_connection_ssl_error (PurpleConnection *gc,
                             PurpleSslErrorType ssl_error);

/**
 * purple_connection_error_is_fatal:
 *
 * Reports whether a disconnection reason is fatal (in which case the account
 * should probably not be automatically reconnected) or transient (so
 * auto-reconnection is a good idea).
 * For instance, #PURPLE_CONNECTION_ERROR_NETWORK_ERROR is a temporary error,
 * which might be caused by losing the network connection, so <literal>
 * purple_connection_error_is_fatal (PURPLE_CONNECTION_ERROR_NETWORK_ERROR)</literal>
 * is %FALSE.  On the other hand,
 * #PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED probably indicates a
 * misconfiguration of the account which needs the user to go fix it up, so
 * <literal> purple_connection_error_is_fatal
 * (PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED)</literal> is %TRUE.
 *
 * Returns: %TRUE if the account should not be automatically reconnected, and
 *         %FALSE otherwise.
 */
gboolean
purple_connection_error_is_fatal (PurpleConnectionError reason);

/**
 * purple_connection_update_last_received:
 * @gc:   The connection.
 *
 * Indicate that a packet was received on the connection.
 * Set by the protocol to avoid sending unneeded keepalives.
 */
void purple_connection_update_last_received(PurpleConnection *gc);

/*@}*/

/**************************************************************************/
/* Connections API                                                        */
/**************************************************************************/
/*@{*/

/**
 * purple_connections_disconnect_all:
 *
 * Disconnects from all connections.
 */
void purple_connections_disconnect_all(void);

/**
 * purple_connections_get_all:
 *
 * Returns a list of all active connections.  This does not
 * include connections that are in the process of connecting.
 *
 * Returns: (transfer none): A list of all active connections.
 */
GList *purple_connections_get_all(void);

/**
 * purple_connections_get_connecting:
 *
 * Returns a list of all connections in the process of connecting.
 *
 * Returns: (transfer none): A list of connecting connections.
 */
GList *purple_connections_get_connecting(void);

/**
 * PURPLE_CONNECTION_IS_VALID:
 * @gc: The connection to check
 *
 * Checks if @gc is still a valid pointer to a connection.
 *
 * This is deprecated -- do not use this. Instead, cancel your asynchronous
 * request when the #PurpleConnection is destroyed.
 *
 * Returns: %TRUE if @gc is valid.
 */
/*
 * TODO: Eventually this bad boy will be removed, because it is
 *       a gross fix for a crashy problem.
 */
#define PURPLE_CONNECTION_IS_VALID(gc) \
	(g_list_find(purple_connections_get_all(), (gc)) != NULL)

/*@}*/

/**************************************************************************/
/* UI Registration Functions                                              */
/**************************************************************************/
/*@{*/

/**
 * purple_connections_set_ui_ops:
 * @ops: The UI operations structure.
 *
 * Sets the UI operations structure to be used for connections.
 */
void purple_connections_set_ui_ops(PurpleConnectionUiOps *ops);

/**
 * purple_connections_get_ui_ops:
 *
 * Returns the UI operations structure used for connections.
 *
 * Returns: The UI operations structure in use.
 */
PurpleConnectionUiOps *purple_connections_get_ui_ops(void);

/*@}*/

/**************************************************************************/
/* Connections Subsystem                                                  */
/**************************************************************************/
/*@{*/

/**
 * purple_connections_init:
 *
 * Initializes the connections subsystem.
 */
void purple_connections_init(void);

/**
 * purple_connections_uninit:
 *
 * Uninitializes the connections subsystem.
 */
void purple_connections_uninit(void);

/**
 * purple_connections_get_handle:
 *
 * Returns the handle to the connections subsystem.
 *
 * Returns: The connections subsystem handle.
 */
void *purple_connections_get_handle(void);

/*@}*/


G_END_DECLS

#endif /* _PURPLE_CONNECTION_H_ */