2 * @file switchboard.h MSN switchboard functions
6 * Purple 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
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
24 #ifndef _MSN_SWITCHBOARD_H_
25 #define _MSN_SWITCHBOARD_H_
27 typedef struct _MsnSwitchBoard MsnSwitchBoard;
29 #include "conversation.h"
39 * A switchboard error.
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_AUTHFAILED, /**< Authentication failed joining the switchboard session */
50 MSN_SB_ERROR_UNKNOWN /**< An unknown error occurred. */
59 MSN_SB_FLAG_IM = 0x01, /**< This switchboard is being used for a conversation. */
60 MSN_SB_FLAG_FT = 0x02 /**< This switchboard is being used for file transfer. */
67 * A place where a bunch of users send messages to the rest of the users.
69 struct _MsnSwitchBoard
71 MsnSession *session; /**< Our parent session. */
72 MsnServConn *servconn; /**< The physical connection for this switchboard. */
73 MsnCmdProc *cmdproc; /**< Convenience variable for servconn->cmdproc. */
80 PurpleConversation *conv; /**< The conversation that displays the
81 messages of this switchboard, or @c NULL if
82 this is a helper switchboard. */
84 gboolean empty; /**< A flag that states if the swithcboard has no
86 gboolean invited; /**< A flag that states if we were invited to the
88 gboolean ready; /**< A flag that states if this switchboard is
90 gboolean closed; /**< A flag that states if the switchboard has
91 been closed by the user. */
92 gboolean destroying; /**< A flag that states if the switchboard is
93 alredy on the process of destruction. */
101 GQueue *msg_queue; /**< Queue of messages to send. */
102 GList *ack_list; /**< List of messages waiting for an ack. */
104 MsnSBErrorType error; /**< The error that occurred in this switchboard
106 GList *slplinks; /**< The list of slplinks that are using this switchboard. */
107 guint reconn_timeout_h;
111 * Initialize the variables for switchboard creation.
113 void msn_switchboard_init(void);
116 * Destroy the variables for switchboard creation.
118 void msn_switchboard_end(void);
121 * Creates a new switchboard.
123 * @param session The MSN session.
125 * @return The new switchboard.
127 MsnSwitchBoard *msn_switchboard_new(MsnSession *session);
130 * Destroys a switchboard.
132 * @param swboard The switchboard to destroy.
134 void msn_switchboard_destroy(MsnSwitchBoard *swboard);
137 * Sets the auth key the switchboard must use when connecting.
139 * @param swboard The switchboard.
140 * @param key The auth key.
142 void msn_switchboard_set_auth_key(MsnSwitchBoard *swboard, const char *key);
145 * Returns the auth key the switchboard must use when connecting.
147 * @param swboard The switchboard.
149 * @return The auth key.
151 const char *msn_switchboard_get_auth_key(MsnSwitchBoard *swboard);
154 * Sets the session ID the switchboard must use when connecting.
156 * @param swboard The switchboard.
157 * @param id The session ID.
159 void msn_switchboard_set_session_id(MsnSwitchBoard *swboard, const char *id);
162 * Returns the session ID the switchboard must use when connecting.
164 * @param swboard The switchboard.
166 * @return The session ID.
168 const char *msn_switchboard_get_session_id(MsnSwitchBoard *swboard);
171 * Returns the next chat ID for use by a switchboard.
173 * @return The chat ID.
175 int msn_switchboard_get_chat_id(void);
178 * Sets whether or not we were invited to this switchboard.
180 * @param swboard The switchboard.
181 * @param invite @c TRUE if invited, @c FALSE otherwise.
183 void msn_switchboard_set_invited(MsnSwitchBoard *swboard, gboolean invited);
186 * Returns whether or not we were invited to this switchboard.
188 * @param swboard The switchboard.
190 * @return @c TRUE if invited, @c FALSE otherwise.
192 gboolean msn_switchboard_is_invited(MsnSwitchBoard *swboard);
195 * Connects to a switchboard.
197 * @param swboard The switchboard.
198 * @param host The switchboard server host.
199 * @param port The switcbharod server port.
201 * @return @c TRUE if able to connect, or @c FALSE otherwise.
203 gboolean msn_switchboard_connect(MsnSwitchBoard *swboard,
204 const char *host, int port);
207 * Disconnects from a switchboard.
209 * @param swboard The switchboard to disconnect from.
211 void msn_switchboard_disconnect(MsnSwitchBoard *swboard);
214 * Closes the switchboard.
216 * Called when a conversation is closed.
218 * @param swboard The switchboard to close.
220 void msn_switchboard_close(MsnSwitchBoard *swboard);
223 * Release a switchboard from a certain function.
225 * @param swboard The switchboard to release.
226 * @param flag The flag that states the function.
228 void msn_switchboard_release(MsnSwitchBoard *swboard, MsnSBFlag flag);
231 * Returns whether or not we currently can send a message through this
234 * @param swboard The switchboard.
236 * @return @c TRUE if a message can be sent, @c FALSE otherwise.
238 gboolean msn_switchboard_can_send(MsnSwitchBoard *swboard);
241 * Sends a message through this switchboard.
243 * @param swboard The switchboard.
244 * @param msg The message.
245 * @param queue A flag that states if we want this message to be queued (in
246 * the case it cannot currently be sent).
248 * @return @c TRUE if a message can be sent, @c FALSE otherwise.
250 void msn_switchboard_send_msg(MsnSwitchBoard *swboard, MsnMessage *msg,
253 gboolean msn_switchboard_chat_leave(MsnSwitchBoard *swboard);
254 gboolean msn_switchboard_chat_invite(MsnSwitchBoard *swboard, const char *who);
256 void msn_switchboard_request(MsnSwitchBoard *swboard);
257 void msn_switchboard_request_add_user(MsnSwitchBoard *swboard, const char *user);
260 * Processes peer to peer messages.
262 * @param cmdproc The command processor.
263 * @param msg The message.
265 void msn_p2p_msg(MsnCmdProc *cmdproc, MsnMessage *msg);
268 * Processes emoticon messages.
270 * @param cmdproc The command processor.
271 * @param msg The message.
273 void msn_emoticon_msg(MsnCmdProc *cmdproc, MsnMessage *msg);
276 * Processes INVITE messages.
278 * @param cmdproc The command processor.
279 * @param msg The message.
281 void msn_invite_msg(MsnCmdProc *cmdproc, MsnMessage *msg);
284 * Shows an ink message from this switchboard.
286 * @param swboard The switchboard.
287 * @param passport The user that sent the ink.
288 * @param data The ink data.
290 void msn_switchboard_show_ink(MsnSwitchBoard *swboard, const char *passport,
293 #endif /* _MSN_SWITCHBOARD_H_ */