Mercurial > pidgin
annotate src/connection.h @ 5872:059d95c67cda
[gaim-migrate @ 6304]
The legendary Header File Cleanup! Files now only include what they need.
This should reduce the number of files that must recompile when a header
file changes. It's a lot nicer. Trust me on it. I also added a couple new
header files. I hope I didn't break TOO much!
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Sat, 14 Jun 2003 23:21:02 +0000 |
| parents | 4350b62bac45 |
| children | 158196b2db19 |
| 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> | |
| 8 * | |
| 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 | |
| 31 #include "account.h" | |
| 32 #include "plugin.h" | |
| 33 | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5733
diff
changeset
|
34 #define OPT_CONN_HTML 0x00000001 |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5733
diff
changeset
|
35 /* 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
|
36 #define OPT_CONN_AUTO_RESP 0x00000002 |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5733
diff
changeset
|
37 |
| 5563 | 38 typedef enum |
| 39 { | |
| 40 GAIM_DISCONNECTED = 0, /**< Disconnected. */ | |
| 41 GAIM_CONNECTED, /**< Connected. */ | |
| 42 GAIM_CONNECTING /**< Connecting. */ | |
| 43 | |
| 44 } GaimConnectionState; | |
| 45 | |
| 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); | |
| 51 void (*request_pass)(GaimConnection *gc); | |
| 52 void (*disconnected)(GaimConnection *gc, const char *reason); | |
|
5571
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
53 void (*notice)(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. */ | |
| 87 }; | |
| 88 | |
| 89 /** | |
| 90 * Creates a connection to the specified account. | |
| 91 * | |
| 92 * @param account The account the connection should be connecting to. | |
| 93 * | |
| 94 * @return The gaim connection. | |
| 95 */ | |
| 96 GaimConnection *gaim_connection_new(GaimAccount *account); | |
| 97 | |
| 98 /** | |
| 99 * Destroys and closes a gaim connection. | |
| 100 * | |
| 101 * @param gc The gaim connection to destroy. | |
| 102 */ | |
| 103 void gaim_connection_destroy(GaimConnection *gc); | |
| 104 | |
| 105 /** | |
| 106 * Signs a connection on. | |
| 107 * | |
| 108 * @param gc The connection to sign on. | |
| 109 * | |
| 110 * @see gaim_connection_disconnect() | |
| 111 */ | |
| 112 void gaim_connection_connect(GaimConnection *gc); | |
| 113 | |
| 114 /** | |
| 115 * Signs a connection off. | |
| 116 * | |
| 117 * @param gc The connection to sign off. | |
| 118 * | |
| 119 * @see gaim_connection_connect() | |
| 120 */ | |
| 121 void gaim_connection_disconnect(GaimConnection *gc); | |
| 122 | |
| 123 /** | |
| 124 * Sets the connection state. | |
| 125 * | |
| 126 * @param gc The connection. | |
| 127 * @param state The connection state. | |
| 128 */ | |
| 129 void gaim_connection_set_state(GaimConnection *gc, GaimConnectionState state); | |
| 130 | |
| 131 /** | |
| 132 * Sets the connection's account. | |
| 133 * | |
| 134 * @param gc The connection. | |
| 135 * @param account The account. | |
| 136 */ | |
| 137 void gaim_connection_set_account(GaimConnection *gc, GaimAccount *account); | |
| 138 | |
| 139 /** | |
| 140 * Sets the connection's displayed name. | |
| 141 * | |
| 142 * @param gc The connection. | |
| 143 * @param name The displayed name. | |
| 144 */ | |
| 145 void gaim_connection_set_display_name(GaimConnection *gc, const char *name); | |
| 146 | |
| 147 /** | |
| 148 * Returns the connection state. | |
| 149 * | |
| 150 * @param gc The connection. | |
| 151 * | |
| 152 * @return The connection state. | |
| 153 */ | |
| 154 GaimConnectionState gaim_connection_get_state(const GaimConnection *gc); | |
| 155 | |
| 156 /** | |
| 157 * Returns the connection's account. | |
| 158 * | |
| 159 * @param gc The connection. | |
| 160 * | |
| 161 * @return The connection's account. | |
| 162 */ | |
| 163 GaimAccount *gaim_connection_get_account(const GaimConnection *gc); | |
| 164 | |
| 165 /** | |
| 166 * Returns the connection's displayed name. | |
| 167 * | |
| 168 * @param gc The connection. | |
| 169 * | |
| 170 * @return The connection's displayed name. | |
| 171 */ | |
| 172 const char *gaim_connection_get_display_name(const GaimConnection *gc); | |
| 173 | |
| 174 /** | |
| 175 * Updates the connection progress. | |
| 176 * | |
| 177 * @param gc The connection. | |
| 178 * @param text Information on the current step. | |
| 179 * @param step The current step. | |
| 180 * @param count The total number of steps. | |
| 181 */ | |
| 182 void gaim_connection_update_progress(GaimConnection *gc, const char *text, | |
| 183 size_t step, size_t count); | |
| 184 | |
| 185 /** | |
|
5571
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
186 * Displays a connection-specific notice. |
|
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
187 * |
|
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
188 * @param gc The connection. |
|
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
189 * @param text The notice text. |
|
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
190 */ |
|
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
191 void gaim_connection_notice(GaimConnection *gc, const char *text); |
|
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
192 |
|
113090160626
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
193 /** |
|
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
194 * Closes a connection with an error. |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
195 * |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
196 * @param gc The connection. |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
197 * @param reason The error text. |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
198 */ |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
199 void gaim_connection_error(GaimConnection *gc, const char *reason); |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
200 |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
201 /** |
| 5563 | 202 * Disconnects from all connections. |
| 203 */ | |
| 204 void gaim_connections_disconnect_all(void); | |
| 205 | |
| 206 /** | |
| 207 * Returns a list of all active connections. | |
| 208 * | |
| 209 * @return A list of all active connections. | |
| 210 */ | |
| 211 GList *gaim_connections_get_all(void); | |
| 212 | |
|
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
213 /** |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
214 * Returns a list of all connections in the process of connecting. |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
215 * |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
216 * @return A list of connecting connections. |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
217 */ |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
218 GList *gaim_connections_get_connecting(void); |
|
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
219 |
| 5563 | 220 /**************************************************************************/ |
| 221 /** @name UI Operations API */ | |
| 222 /**************************************************************************/ | |
| 223 /*@{*/ | |
| 224 | |
| 225 /** | |
| 226 * Sets the UI operations structure to be used for connections. | |
| 227 * | |
| 228 * @param ops The UI operations structure. | |
| 229 */ | |
| 230 void gaim_set_connection_ui_ops(GaimConnectionUiOps *ops); | |
| 231 | |
| 232 /** | |
| 233 * Returns the UI operations structure used for connections. | |
| 234 * | |
| 235 * @return The UI operations structure in use. | |
| 236 */ | |
| 237 GaimConnectionUiOps *gaim_get_connection_ui_ops(void); | |
| 238 | |
| 239 /*@}*/ | |
| 240 | |
| 241 #endif /* _GAIM_CONNECTION_H_ */ |
