| 1 /** |
|
| 2 * @file switchboard.h MSN switchboard functions |
|
| 3 * |
|
| 4 * gaim |
|
| 5 * |
|
| 6 * Gaim is the legal property of its developers, whose names are too numerous |
|
| 7 * to list here. Please refer to the COPYRIGHT file distributed with this |
|
| 8 * source distribution. |
|
| 9 * |
|
| 10 * This program is free software; you can redistribute it and/or modify |
|
| 11 * it under the terms of the GNU General Public License as published by |
|
| 12 * the Free Software Foundation; either version 2 of the License, or |
|
| 13 * (at your option) any later version. |
|
| 14 * |
|
| 15 * This program is distributed in the hope that it will be useful, |
|
| 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 18 * GNU General Public License for more details. |
|
| 19 * |
|
| 20 * You should have received a copy of the GNU General Public License |
|
| 21 * along with this program; if not, write to the Free Software |
|
| 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 23 */ |
|
| 24 #ifndef _MSN_SWITCHBOARD_H_ |
|
| 25 #define _MSN_SWITCHBOARD_H_ |
|
| 26 |
|
| 27 typedef struct _MsnSwitchBoard MsnSwitchBoard; |
|
| 28 |
|
| 29 #include "conversation.h" |
|
| 30 |
|
| 31 #include "msg.h" |
|
| 32 #include "user.h" |
|
| 33 |
|
| 34 #include "servconn.h" |
|
| 35 |
|
| 36 #include "slplink.h" |
|
| 37 |
|
| 38 /** |
|
| 39 * A switchboard error. |
|
| 40 */ |
|
| 41 typedef enum |
|
| 42 { |
|
| 43 MSN_SB_ERROR_NONE, /**< No error. */ |
|
| 44 MSN_SB_ERROR_CAL, /**< The user could not join (answer the call). */ |
|
| 45 MSN_SB_ERROR_OFFLINE, /**< The account is offline. */ |
|
| 46 MSN_SB_ERROR_USER_OFFLINE, /**< The user to call is offline. */ |
|
| 47 MSN_SB_ERROR_CONNECTION, /**< There was a connection error. */ |
|
| 48 MSN_SB_ERROR_TOO_FAST, /**< We are sending too fast */ |
|
| 49 MSN_SB_ERROR_UNKNOWN /**< An unknown error occurred. */ |
|
| 50 |
|
| 51 } MsnSBErrorType; |
|
| 52 |
|
| 53 /** |
|
| 54 * A switchboard flag. |
|
| 55 */ |
|
| 56 typedef enum |
|
| 57 { |
|
| 58 MSN_SB_FLAG_IM = 0x01, /**< This switchboard is being used for a conversation. */ |
|
| 59 MSN_SB_FLAG_FT = 0x02, /**< This switchboard is being used for file transfer. */ |
|
| 60 |
|
| 61 } MsnSBFlag; |
|
| 62 |
|
| 63 /** |
|
| 64 * A switchboard. |
|
| 65 * |
|
| 66 * A place where a bunch of users send messages to the rest of the users. |
|
| 67 */ |
|
| 68 struct _MsnSwitchBoard |
|
| 69 { |
|
| 70 MsnSession *session; |
|
| 71 MsnServConn *servconn; |
|
| 72 MsnCmdProc *cmdproc; |
|
| 73 char *im_user; |
|
| 74 |
|
| 75 MsnSBFlag flag; |
|
| 76 char *auth_key; |
|
| 77 char *session_id; |
|
| 78 |
|
| 79 GaimConversation *conv; /**< The conversation that displays the |
|
| 80 messages of this switchboard, or @c NULL if |
|
| 81 this is a helper switchboard. */ |
|
| 82 |
|
| 83 gboolean empty; /**< A flag that states if the swithcboard has no |
|
| 84 users in it. */ |
|
| 85 gboolean invited; /**< A flag that states if we were invited to the |
|
| 86 switchboard. */ |
|
| 87 gboolean ready; /**< A flag that states if this switchboard is |
|
| 88 ready to be used. */ |
|
| 89 gboolean closed; /**< A flag that states if the switchboard has |
|
| 90 been closed by the user. */ |
|
| 91 gboolean destroying; /**< A flag that states if the switchboard is |
|
| 92 alredy on the process of destruction. */ |
|
| 93 |
|
| 94 int current_users; |
|
| 95 int total_users; |
|
| 96 GList *users; |
|
| 97 |
|
| 98 int chat_id; |
|
| 99 |
|
| 100 GQueue *msg_queue; /**< Queue of messages to send. */ |
|
| 101 GList *ack_list; /**< List of messages waiting for an ack. */ |
|
| 102 |
|
| 103 MsnSBErrorType error; /**< The error that occurred in this switchboard |
|
| 104 (if applicable). */ |
|
| 105 GList *slplinks; /**< The list of slplinks that are using this switchboard. */ |
|
| 106 }; |
|
| 107 |
|
| 108 /** |
|
| 109 * Initialize the variables for switchboard creation. |
|
| 110 */ |
|
| 111 void msn_switchboard_init(void); |
|
| 112 |
|
| 113 /** |
|
| 114 * Destroy the variables for switchboard creation. |
|
| 115 */ |
|
| 116 void msn_switchboard_end(void); |
|
| 117 |
|
| 118 /** |
|
| 119 * Creates a new switchboard. |
|
| 120 * |
|
| 121 * @param session The MSN session. |
|
| 122 * |
|
| 123 * @return The new switchboard. |
|
| 124 */ |
|
| 125 MsnSwitchBoard *msn_switchboard_new(MsnSession *session); |
|
| 126 |
|
| 127 /** |
|
| 128 * Destroys a switchboard. |
|
| 129 * |
|
| 130 * @param swboard The switchboard to destroy. |
|
| 131 */ |
|
| 132 void msn_switchboard_destroy(MsnSwitchBoard *swboard); |
|
| 133 |
|
| 134 /** |
|
| 135 * Sets the auth key the switchboard must use when connecting. |
|
| 136 * |
|
| 137 * @param swboard The switchboard. |
|
| 138 * @param key The auth key. |
|
| 139 */ |
|
| 140 void msn_switchboard_set_auth_key(MsnSwitchBoard *swboard, const char *key); |
|
| 141 |
|
| 142 /** |
|
| 143 * Returns the auth key the switchboard must use when connecting. |
|
| 144 * |
|
| 145 * @param swboard The switchboard. |
|
| 146 * |
|
| 147 * @return The auth key. |
|
| 148 */ |
|
| 149 const char *msn_switchboard_get_auth_key(MsnSwitchBoard *swboard); |
|
| 150 |
|
| 151 /** |
|
| 152 * Sets the session ID the switchboard must use when connecting. |
|
| 153 * |
|
| 154 * @param swboard The switchboard. |
|
| 155 * @param id The session ID. |
|
| 156 */ |
|
| 157 void msn_switchboard_set_session_id(MsnSwitchBoard *swboard, const char *id); |
|
| 158 |
|
| 159 /** |
|
| 160 * Returns the session ID the switchboard must use when connecting. |
|
| 161 * |
|
| 162 * @param swboard The switchboard. |
|
| 163 * |
|
| 164 * @return The session ID. |
|
| 165 */ |
|
| 166 const char *msn_switchboard_get_session_id(MsnSwitchBoard *swboard); |
|
| 167 |
|
| 168 /** |
|
| 169 * Sets whether or not we were invited to this switchboard. |
|
| 170 * |
|
| 171 * @param swboard The switchboard. |
|
| 172 * @param invite @c TRUE if invited, @c FALSE otherwise. |
|
| 173 */ |
|
| 174 void msn_switchboard_set_invited(MsnSwitchBoard *swboard, gboolean invited); |
|
| 175 |
|
| 176 /** |
|
| 177 * Returns whether or not we were invited to this switchboard. |
|
| 178 * |
|
| 179 * @param swboard The switchboard. |
|
| 180 * |
|
| 181 * @return @c TRUE if invited, @c FALSE otherwise. |
|
| 182 */ |
|
| 183 gboolean msn_switchboard_is_invited(MsnSwitchBoard *swboard); |
|
| 184 |
|
| 185 /** |
|
| 186 * Connects to a switchboard. |
|
| 187 * |
|
| 188 * @param swboard The switchboard. |
|
| 189 * @param host The switchboard server host. |
|
| 190 * @param port The switcbharod server port. |
|
| 191 * |
|
| 192 * @return @c TRUE if able to connect, or @c FALSE otherwise. |
|
| 193 */ |
|
| 194 gboolean msn_switchboard_connect(MsnSwitchBoard *swboard, |
|
| 195 const char *host, int port); |
|
| 196 |
|
| 197 /** |
|
| 198 * Disconnects from a switchboard. |
|
| 199 * |
|
| 200 * @param swboard The switchboard to disconnect from. |
|
| 201 */ |
|
| 202 void msn_switchboard_disconnect(MsnSwitchBoard *swboard); |
|
| 203 |
|
| 204 /** |
|
| 205 * Closes the switchboard. |
|
| 206 * |
|
| 207 * Called when a conversation is closed. |
|
| 208 * |
|
| 209 * @param swboard The switchboard to close. |
|
| 210 */ |
|
| 211 void msn_switchboard_close(MsnSwitchBoard *swboard); |
|
| 212 |
|
| 213 /** |
|
| 214 * Release a switchboard from a certain function. |
|
| 215 * |
|
| 216 * @param swboard The switchboard to release. |
|
| 217 * @param flag The flag that states the function. |
|
| 218 * |
|
| 219 * @return @c TRUE if the switchboard was closed, @c FALSE otherwise. |
|
| 220 */ |
|
| 221 gboolean msn_switchboard_release(MsnSwitchBoard *swboard, MsnSBFlag flag); |
|
| 222 |
|
| 223 /** |
|
| 224 * Returns whether or not we currently can send a message through this |
|
| 225 * switchboard. |
|
| 226 * |
|
| 227 * @param swboard The switchboard. |
|
| 228 * |
|
| 229 * @return @c TRUE if a message can be sent, @c FALSE otherwise. |
|
| 230 */ |
|
| 231 gboolean msn_switchboard_can_send(MsnSwitchBoard *swboard); |
|
| 232 |
|
| 233 /** |
|
| 234 * Sends a message through this switchboard. |
|
| 235 * |
|
| 236 * @param swboard The switchboard. |
|
| 237 * @param msg The message. |
|
| 238 * @param queue A flag that states if we want this message to be queued (in |
|
| 239 * the case it cannot currently be sent). |
|
| 240 * |
|
| 241 * @return @c TRUE if a message can be sent, @c FALSE otherwise. |
|
| 242 */ |
|
| 243 void msn_switchboard_send_msg(MsnSwitchBoard *swboard, MsnMessage *msg, |
|
| 244 gboolean queue); |
|
| 245 |
|
| 246 gboolean msn_switchboard_chat_leave(MsnSwitchBoard *swboard); |
|
| 247 gboolean msn_switchboard_chat_invite(MsnSwitchBoard *swboard, const char *who); |
|
| 248 |
|
| 249 void msn_switchboard_request(MsnSwitchBoard *swboard); |
|
| 250 void msn_switchboard_request_add_user(MsnSwitchBoard *swboard, const char *user); |
|
| 251 |
|
| 252 /** |
|
| 253 * Processes peer to peer messages. |
|
| 254 * |
|
| 255 * @param cmdproc The command processor. |
|
| 256 * @param msg The message. |
|
| 257 */ |
|
| 258 void msn_p2p_msg(MsnCmdProc *cmdproc, MsnMessage *msg); |
|
| 259 |
|
| 260 /** |
|
| 261 * Processes emoticon messages. |
|
| 262 * |
|
| 263 * @param cmdproc The command processor. |
|
| 264 * @param msg The message. |
|
| 265 */ |
|
| 266 void msn_emoticon_msg(MsnCmdProc *cmdproc, MsnMessage *msg); |
|
| 267 |
|
| 268 /** |
|
| 269 * Processes INVITE messages. |
|
| 270 * |
|
| 271 * @param cmdproc The command processor. |
|
| 272 * @param msg The message. |
|
| 273 */ |
|
| 274 void msn_invite_msg(MsnCmdProc *cmdproc, MsnMessage *msg); |
|
| 275 |
|
| 276 #endif /* _MSN_SWITCHBOARD_H_ */ |
|