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