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