Tue, 03 Jun 2003 19:55:47 +0000
[gaim-migrate @ 6138]
this almost kinda sorta works. It's the wonderful connecting dialog
that shows you how far along you are in connecting. This also gets rid of
the ever-present signon dialog.
Oh, and I ended up digging through header hell and changing a lot. Hopefully
I didn't break anything too badly.
| 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> | |
| 27 | ||
| 28 | typedef struct _GaimConnection GaimConnection; | |
| 29 | ||
| 30 | #include "account.h" | |
| 31 | #include "plugin.h" | |
| 32 | ||
| 33 | typedef enum | |
| 34 | { | |
| 35 | GAIM_DISCONNECTED = 0, /**< Disconnected. */ | |
| 36 | GAIM_CONNECTED, /**< Connected. */ | |
| 37 | GAIM_CONNECTING /**< Connecting. */ | |
| 38 | ||
| 39 | } GaimConnectionState; | |
| 40 | ||
| 41 | typedef struct | |
| 42 | { | |
| 43 | void (*connect_progress)(GaimConnection *gc, const char *text, | |
| 44 | size_t step, size_t step_count); | |
| 45 | void (*connected)(GaimConnection *gc); | |
| 46 | void (*request_pass)(GaimConnection *gc); | |
| 47 | void (*disconnected)(GaimConnection *gc, const char *reason); | |
|
5571
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
48 | void (*notice)(GaimConnection *gc, const char *text); |
| 5563 | 49 | |
| 50 | } GaimConnectionUiOps; | |
| 51 | ||
| 52 | struct _GaimConnection | |
| 53 | { | |
| 54 | GaimPlugin *prpl; /**< The protocol plugin. */ | |
| 55 | guint32 flags; /**< Connection flags. */ | |
| 56 | ||
| 57 | GaimConnectionState state; /**< The connection state. */ | |
| 58 | ||
| 59 | GaimAccount *account; /**< The account being connected to. */ | |
| 60 | int inpa; /**< The input watcher. */ | |
| 61 | ||
| 62 | GSList *buddy_chats; /**< A list of active chats. */ | |
| 63 | void *proto_data; /**< Protocol-specific data. */ | |
| 64 | ||
| 65 | char *display_name; /**< The name displayed. */ | |
| 66 | guint keep_alive; /**< Keep-alive. */ | |
| 67 | ||
| 68 | guint idle_timer; /**< The idle timer. */ | |
| 69 | time_t login_time; /**< Time of login. */ | |
| 70 | time_t login_time_official; /**< Official time of login. */ | |
| 71 | time_t last_sent_time; /**< The time something was last sent. */ | |
| 72 | int is_idle; /**< Idle state of the connection. */ | |
| 73 | ||
| 74 | char *away; /**< The current away message, or NULL */ | |
| 75 | char *away_state; /**< The last away type. */ | |
| 76 | gboolean is_auto_away; /**< Whether or not it's auto-away. */ | |
| 77 | ||
| 78 | int evil; /**< Warning level for AIM (why is | |
| 79 | this here?) */ | |
| 80 | ||
| 81 | gboolean wants_to_die; /**< Wants to Die state. */ | |
| 82 | }; | |
| 83 | ||
| 84 | /** | |
| 85 | * Creates a connection to the specified account. | |
| 86 | * | |
| 87 | * @param account The account the connection should be connecting to. | |
| 88 | * | |
| 89 | * @return The gaim connection. | |
| 90 | */ | |
| 91 | GaimConnection *gaim_connection_new(GaimAccount *account); | |
| 92 | ||
| 93 | /** | |
| 94 | * Destroys and closes a gaim connection. | |
| 95 | * | |
| 96 | * @param gc The gaim connection to destroy. | |
| 97 | */ | |
| 98 | void gaim_connection_destroy(GaimConnection *gc); | |
| 99 | ||
| 100 | /** | |
| 101 | * Signs a connection on. | |
| 102 | * | |
| 103 | * @param gc The connection to sign on. | |
| 104 | * | |
| 105 | * @see gaim_connection_disconnect() | |
| 106 | */ | |
| 107 | void gaim_connection_connect(GaimConnection *gc); | |
| 108 | ||
| 109 | /** | |
| 110 | * Signs a connection off. | |
| 111 | * | |
| 112 | * @param gc The connection to sign off. | |
| 113 | * | |
| 114 | * @see gaim_connection_connect() | |
| 115 | */ | |
| 116 | void gaim_connection_disconnect(GaimConnection *gc); | |
| 117 | ||
| 118 | /** | |
| 119 | * Sets the connection state. | |
| 120 | * | |
| 121 | * @param gc The connection. | |
| 122 | * @param state The connection state. | |
| 123 | */ | |
| 124 | void gaim_connection_set_state(GaimConnection *gc, GaimConnectionState state); | |
| 125 | ||
| 126 | /** | |
| 127 | * Sets the connection's account. | |
| 128 | * | |
| 129 | * @param gc The connection. | |
| 130 | * @param account The account. | |
| 131 | */ | |
| 132 | void gaim_connection_set_account(GaimConnection *gc, GaimAccount *account); | |
| 133 | ||
| 134 | /** | |
| 135 | * Sets the connection's displayed name. | |
| 136 | * | |
| 137 | * @param gc The connection. | |
| 138 | * @param name The displayed name. | |
| 139 | */ | |
| 140 | void gaim_connection_set_display_name(GaimConnection *gc, const char *name); | |
| 141 | ||
| 142 | /** | |
| 143 | * Returns the connection state. | |
| 144 | * | |
| 145 | * @param gc The connection. | |
| 146 | * | |
| 147 | * @return The connection state. | |
| 148 | */ | |
| 149 | GaimConnectionState gaim_connection_get_state(const GaimConnection *gc); | |
| 150 | ||
| 151 | /** | |
| 152 | * Returns the connection's account. | |
| 153 | * | |
| 154 | * @param gc The connection. | |
| 155 | * | |
| 156 | * @return The connection's account. | |
| 157 | */ | |
| 158 | GaimAccount *gaim_connection_get_account(const GaimConnection *gc); | |
| 159 | ||
| 160 | /** | |
| 161 | * Returns the connection's displayed name. | |
| 162 | * | |
| 163 | * @param gc The connection. | |
| 164 | * | |
| 165 | * @return The connection's displayed name. | |
| 166 | */ | |
| 167 | const char *gaim_connection_get_display_name(const GaimConnection *gc); | |
| 168 | ||
| 169 | /** | |
| 170 | * Updates the connection progress. | |
| 171 | * | |
| 172 | * @param gc The connection. | |
| 173 | * @param text Information on the current step. | |
| 174 | * @param step The current step. | |
| 175 | * @param count The total number of steps. | |
| 176 | */ | |
| 177 | void gaim_connection_update_progress(GaimConnection *gc, const char *text, | |
| 178 | size_t step, size_t count); | |
| 179 | ||
| 180 | /** | |
|
5571
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
181 | * Displays a connection-specific notice. |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
182 | * |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
183 | * @param gc The connection. |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
184 | * @param text The notice text. |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
185 | */ |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
186 | void gaim_connection_notice(GaimConnection *gc, const char *text); |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
187 | |
|
b709464f507e
[gaim-migrate @ 5973]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
188 | /** |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
189 | * Closes a connection with an error. |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
190 | * |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
191 | * @param gc The connection. |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
192 | * @param reason The error text. |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
193 | */ |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
194 | void gaim_connection_error(GaimConnection *gc, const char *reason); |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
195 | |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
196 | /** |
| 5563 | 197 | * Disconnects from all connections. |
| 198 | */ | |
| 199 | void gaim_connections_disconnect_all(void); | |
| 200 | ||
| 201 | /** | |
| 202 | * Returns a list of all active connections. | |
| 203 | * | |
| 204 | * @return A list of all active connections. | |
| 205 | */ | |
| 206 | GList *gaim_connections_get_all(void); | |
| 207 | ||
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
208 | /** |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
209 | * Returns a list of all connections in the process of connecting. |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
210 | * |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
211 | * @return A list of connecting connections. |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
212 | */ |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
213 | GList *gaim_connections_get_connecting(void); |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
214 | |
| 5563 | 215 | /**************************************************************************/ |
| 216 | /** @name UI Operations API */ | |
| 217 | /**************************************************************************/ | |
| 218 | /*@{*/ | |
| 219 | ||
| 220 | /** | |
| 221 | * Sets the UI operations structure to be used for connections. | |
| 222 | * | |
| 223 | * @param ops The UI operations structure. | |
| 224 | */ | |
| 225 | void gaim_set_connection_ui_ops(GaimConnectionUiOps *ops); | |
| 226 | ||
| 227 | /** | |
| 228 | * Returns the UI operations structure used for connections. | |
| 229 | * | |
| 230 | * @return The UI operations structure in use. | |
| 231 | */ | |
| 232 | GaimConnectionUiOps *gaim_get_connection_ui_ops(void); | |
| 233 | ||
| 234 | /*@}*/ | |
| 235 | ||
| 236 | #endif /* _GAIM_CONNECTION_H_ */ |