| 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_UNKNOWN /**< An unknown error occurred. */ |
|
| 49 |
|
| 50 } MsnSBErrorType; |
|
| 51 |
|
| 52 /** |
|
| 53 * A switchboard flag. |
|
| 54 */ |
|
| 55 typedef enum |
|
| 56 { |
|
| 57 MSN_SB_FLAG_IM = 0x01, /**< This switchboard is being used for a conversation. */ |
|
| 58 MSN_SB_FLAG_FT = 0x02, /**< This switchboard is being used for file transfer. */ |
|
| 59 |
|
| 60 } MsnSBFlag; |
|
| 61 |
|
| 62 /** |
|
| 63 * A switchboard. |
|
| 64 * |
|
| 65 * A place where a bunch of users send messages to the rest of the users. |
|
| 66 */ |
|
| 67 struct _MsnSwitchBoard |
|
| 68 { |
|
| 69 MsnSession *session; |
|
| 70 MsnServConn *servconn; |
|
| 71 MsnCmdProc *cmdproc; |
|
| 72 char *im_user; |
|
| 73 |
|
| 74 MsnSBFlag flag; |
|
| 75 char *auth_key; |
|
| 76 char *session_id; |
|
| 77 |
|
| 78 GaimConversation *conv; /**< The conversation that displays the |
|
| 79 messages of this switchboard, or @c NULL if |
|
| 80 this is a helper switchboard. */ |
|
| 81 |
|
| 82 gboolean empty; /**< A flag that states if the swithcboard has no |
|
| 83 users in it. */ |
|
| 84 gboolean invited; /**< A flag that states if we were invited to the |
|
| 85 switchboard. */ |
|
| 86 gboolean ready; /**< A flag that states if this switchboard is |
|
| 87 ready to be used. */ |
|
| 88 gboolean closed; /**< A flag that states if the switchboard has |
|
| 89 been closed by the user. */ |
|
| 90 gboolean destroying; /**< A flag that states if the switchboard is |
|
| 91 alredy on the process of destruction. */ |
|
| 92 |
|
| 93 int current_users; |
|
| 94 int total_users; |
|
| 95 GList *users; |
|
| 96 |
|
| 97 int chat_id; |
|
| 98 |
|
| 99 GQueue *msg_queue; /**< Queue of messages to send. */ |
|
| 100 GList *ack_list; /**< List of messages waiting for an ack. */ |
|
| 101 |
|
| 102 MsnSBErrorType error; /**< The error that occurred in this switchboard |
|
| 103 (if applicable). */ |
|
| 104 MsnSlpLink *slplink; /**< The slplink that is using this switchboard. */ |
|
| 105 }; |
|
| 106 |
|
| 107 /** |
|
| 108 * Initialize the variables for switchboard creation. |
|
| 109 */ |
|
| 110 void msn_switchboard_init(void); |
|
| 111 |
|
| 112 /** |
|
| 113 * Destroy the variables for switchboard creation. |
|
| 114 */ |
|
| 115 void msn_switchboard_end(void); |
|
| 116 |
|
| 117 /** |
|
| 118 * Creates a new switchboard. |
|
| 119 * |
|
| 120 * @param session The MSN session. |
|
| 121 * |
|
| 122 * @return The new switchboard. |
|
| 123 */ |
|
| 124 MsnSwitchBoard *msn_switchboard_new(MsnSession *session); |
|
| 125 |
|
| 126 /** |
|
| 127 * Destroys a switchboard. |
|
| 128 * |
|
| 129 * @param swboard The switchboard to destroy. |
|
| 130 */ |
|
| 131 void msn_switchboard_destroy(MsnSwitchBoard *swboard); |
|
| 132 |
|
| 133 /** |
|
| 134 * Sets the auth key the switchboard must use when connecting. |
|
| 135 * |
|
| 136 * @param swboard The switchboard. |
|
| 137 * @param key The auth key. |
|
| 138 */ |
|
| 139 void msn_switchboard_set_auth_key(MsnSwitchBoard *swboard, const char *key); |
|
| 140 |
|
| 141 /** |
|
| 142 * Returns the auth key the switchboard must use when connecting. |
|
| 143 * |
|
| 144 * @param swboard The switchboard. |
|
| 145 * |
|
| 146 * @return The auth key. |
|
| 147 */ |
|
| 148 const char *msn_switchboard_get_auth_key(MsnSwitchBoard *swboard); |
|
| 149 |
|
| 150 /** |
|
| 151 * Sets the session ID the switchboard must use when connecting. |
|
| 152 * |
|
| 153 * @param swboard The switchboard. |
|
| 154 * @param id The session ID. |
|
| 155 */ |
|
| 156 void msn_switchboard_set_session_id(MsnSwitchBoard *swboard, const char *id); |
|
| 157 |
|
| 158 /** |
|
| 159 * Returns the session ID the switchboard must use when connecting. |
|
| 160 * |
|
| 161 * @param swboard The switchboard. |
|
| 162 * |
|
| 163 * @return The session ID. |
|
| 164 */ |
|
| 165 const char *msn_switchboard_get_session_id(MsnSwitchBoard *swboard); |
|
| 166 |
|
| 167 /** |
|
| 168 * Sets whether or not we were invited to this switchboard. |
|
| 169 * |
|
| 170 * @param swboard The switchboard. |
|
| 171 * @param invite @c TRUE if invited, @c FALSE otherwise. |
|
| 172 */ |
|
| 173 void msn_switchboard_set_invited(MsnSwitchBoard *swboard, gboolean invited); |
|
| 174 |
|
| 175 /** |
|
| 176 * Returns whether or not we were invited to this switchboard. |
|
| 177 * |
|
| 178 * @param swboard The switchboard. |
|
| 179 * |
|
| 180 * @return @c TRUE if invited, @c FALSE otherwise. |
|
| 181 */ |
|
| 182 gboolean msn_switchboard_is_invited(MsnSwitchBoard *swboard); |
|
| 183 |
|
| 184 /** |
|
| 185 * Connects to a switchboard. |
|
| 186 * |
|
| 187 * @param swboard The switchboard. |
|
| 188 * @param host The switchboard server host. |
|
| 189 * @param port The switcbharod server port. |
|
| 190 * |
|
| 191 * @return @c TRUE if able to connect, or @c FALSE otherwise. |
|
| 192 */ |
|
| 193 gboolean msn_switchboard_connect(MsnSwitchBoard *swboard, |
|
| 194 const char *host, int port); |
|
| 195 |
|
| 196 /** |
|
| 197 * Disconnects from a switchboard. |
|
| 198 * |
|
| 199 * @param swboard The switchboard to disconnect from. |
|
| 200 */ |
|
| 201 void msn_switchboard_disconnect(MsnSwitchBoard *swboard); |
|
| 202 |
|
| 203 /** |
|
| 204 * Closes the switchboard. |
|
| 205 * |
|
| 206 * Called when a conversation is closed. |
|
| 207 * |
|
| 208 * @param swboard The switchboard to close. |
|
| 209 */ |
|
| 210 void msn_switchboard_close(MsnSwitchBoard *swboard); |
|
| 211 |
|
| 212 /** |
|
| 213 * Release a switchboard from a certain function. |
|
| 214 * |
|
| 215 * @param swboard The switchboard to release. |
|
| 216 * @param flag The flag that states the function. |
|
| 217 * |
|
| 218 * @return @c TRUE if the switchboard was closed, @c FALSE otherwise. |
|
| 219 */ |
|
| 220 gboolean msn_switchboard_release(MsnSwitchBoard *swboard, MsnSBFlag flag); |
|
| 221 |
|
| 222 /** |
|
| 223 * Returns whether or not we currently can send a message through this |
|
| 224 * switchboard. |
|
| 225 * |
|
| 226 * @param swboard The switchboard. |
|
| 227 * |
|
| 228 * @return @c TRUE if a message can be sent, @c FALSE otherwise. |
|
| 229 */ |
|
| 230 gboolean msn_switchboard_can_send(MsnSwitchBoard *swboard); |
|
| 231 |
|
| 232 /** |
|
| 233 * Sends a message through this switchboard. |
|
| 234 * |
|
| 235 * @param swboard The switchboard. |
|
| 236 * @param msg The message. |
|
| 237 * @param queue A flag that states if we want this message to be queued (in |
|
| 238 * the case it cannot currently be sent). |
|
| 239 * |
|
| 240 * @return @c TRUE if a message can be sent, @c FALSE otherwise. |
|
| 241 */ |
|
| 242 void msn_switchboard_send_msg(MsnSwitchBoard *swboard, MsnMessage *msg, |
|
| 243 gboolean queue); |
|
| 244 |
|
| 245 gboolean msn_switchboard_chat_leave(MsnSwitchBoard *swboard); |
|
| 246 gboolean msn_switchboard_chat_invite(MsnSwitchBoard *swboard, const char *who); |
|
| 247 |
|
| 248 void msn_switchboard_request(MsnSwitchBoard *swboard); |
|
| 249 void msn_switchboard_request_add_user(MsnSwitchBoard *swboard, const char *user); |
|
| 250 |
|
| 251 /** |
|
| 252 * Processes peer to peer messages. |
|
| 253 * |
|
| 254 * @param cmdproc The command processor. |
|
| 255 * @param msg The message. |
|
| 256 */ |
|
| 257 void msn_p2p_msg(MsnCmdProc *cmdproc, MsnMessage *msg); |
|
| 258 |
|
| 259 /** |
|
| 260 * Processes emoticon messages. |
|
| 261 * |
|
| 262 * @param cmdproc The command processor. |
|
| 263 * @param msg The message. |
|
| 264 */ |
|
| 265 void msn_emoticon_msg(MsnCmdProc *cmdproc, MsnMessage *msg); |
|
| 266 |
|
| 267 /** |
|
| 268 * Processes INVITE messages. |
|
| 269 * |
|
| 270 * @param cmdproc The command processor. |
|
| 271 * @param msg The message. |
|
| 272 */ |
|
| 273 void msn_invite_msg(MsnCmdProc *cmdproc, MsnMessage *msg); |
|
| 274 |
|
| 275 #endif /* _MSN_SWITCHBOARD_H_ */ |
|