1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Frameworks/libpurple.framework/Versions/0.6.2/Headers/servconn.h Fri Aug 21 13:25:11 2009 -0700
1.3 @@ -0,0 +1,192 @@
1.4 +/**
1.5 + * @file servconn.h Server connection functions
1.6 + *
1.7 + * purple
1.8 + *
1.9 + * Purple is the legal property of its developers, whose names are too numerous
1.10 + * to list here. Please refer to the COPYRIGHT file distributed with this
1.11 + * source distribution.
1.12 + *
1.13 + * This program is free software; you can redistribute it and/or modify
1.14 + * it under the terms of the GNU General Public License as published by
1.15 + * the Free Software Foundation; either version 2 of the License, or
1.16 + * (at your option) any later version.
1.17 + *
1.18 + * This program is distributed in the hope that it will be useful,
1.19 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.20 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.21 + * GNU General Public License for more details.
1.22 + *
1.23 + * You should have received a copy of the GNU General Public License
1.24 + * along with this program; if not, write to the Free Software
1.25 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
1.26 + */
1.27 +#ifndef _MSN_SERVCONN_H_
1.28 +#define _MSN_SERVCONN_H_
1.29 +
1.30 +typedef struct _MsnServConn MsnServConn;
1.31 +
1.32 +#include "session.h"
1.33 +#include "cmdproc.h"
1.34 +
1.35 +#include "proxy.h"
1.36 +#include "httpconn.h"
1.37 +
1.38 +/**
1.39 + * Connection error types.
1.40 + */
1.41 +typedef enum
1.42 +{
1.43 + MSN_SERVCONN_ERROR_NONE,
1.44 + MSN_SERVCONN_ERROR_CONNECT,
1.45 + MSN_SERVCONN_ERROR_WRITE,
1.46 + MSN_SERVCONN_ERROR_READ
1.47 +
1.48 +} MsnServConnError;
1.49 +
1.50 +/**
1.51 + * Connection types.
1.52 + */
1.53 +typedef enum
1.54 +{
1.55 + MSN_SERVCONN_NS,
1.56 + MSN_SERVCONN_SB
1.57 +
1.58 +} MsnServConnType;
1.59 +
1.60 +/**
1.61 + * A Connection.
1.62 + */
1.63 +struct _MsnServConn
1.64 +{
1.65 + MsnServConnType type; /**< The type of this connection. */
1.66 + MsnSession *session; /**< The MSN session of this connection. */
1.67 + MsnCmdProc *cmdproc; /**< The command processor of this connection. */
1.68 +
1.69 + PurpleProxyConnectData *connect_data;
1.70 +
1.71 + gboolean connected; /**< A flag that states if it's connected. */
1.72 + gboolean processing; /**< A flag that states if something is working
1.73 + with this connection. */
1.74 + gboolean wasted; /**< A flag that states if it should be destroyed. */
1.75 +
1.76 + char *host; /**< The host this connection is connected or should be
1.77 + connected to. */
1.78 + int num; /**< A number id of this connection. */
1.79 +
1.80 + MsnHttpConn *httpconn; /**< The HTTP connection this connection should use. */
1.81 +
1.82 + int fd; /**< The connection's file descriptor. */
1.83 + int inpa; /**< The connection's input handler. */
1.84 +
1.85 + char *rx_buf; /**< The receive buffer. */
1.86 + int rx_len; /**< The receive buffer lenght. */
1.87 +
1.88 + size_t payload_len; /**< The length of the payload.
1.89 + It's only set when we've received a command that
1.90 + has a payload. */
1.91 +
1.92 + PurpleCircBuffer *tx_buf;
1.93 + guint tx_handler;
1.94 + guint timeout_sec;
1.95 + guint timeout_handle;
1.96 +
1.97 + void (*connect_cb)(MsnServConn *); /**< The callback to call when connecting. */
1.98 + void (*disconnect_cb)(MsnServConn *); /**< The callback to call when disconnecting. */
1.99 + void (*destroy_cb)(MsnServConn *); /**< The callback to call when destroying. */
1.100 +};
1.101 +
1.102 +/**
1.103 + * Creates a new connection object.
1.104 + *
1.105 + * @param session The session.
1.106 + * @param type The type of the connection.
1.107 + */
1.108 +MsnServConn *msn_servconn_new(MsnSession *session, MsnServConnType type);
1.109 +
1.110 +/**
1.111 + * Destroys a connection object.
1.112 + *
1.113 + * @param servconn The connection.
1.114 + */
1.115 +void msn_servconn_destroy(MsnServConn *servconn);
1.116 +
1.117 +/**
1.118 + * Connects to a host.
1.119 + *
1.120 + * @param servconn The connection.
1.121 + * @param host The host.
1.122 + * @param port The port.
1.123 + * @param force Force this servconn to connect to a new server.
1.124 + */
1.125 +gboolean msn_servconn_connect(MsnServConn *servconn, const char *host, int port,
1.126 + gboolean force);
1.127 +
1.128 +/**
1.129 + * Disconnects.
1.130 + *
1.131 + * @param servconn The connection.
1.132 + */
1.133 +void msn_servconn_disconnect(MsnServConn *servconn);
1.134 +
1.135 +/**
1.136 + * Sets the connect callback.
1.137 + *
1.138 + * @param servconn The servconn.
1.139 + * @param connect_cb The connect callback.
1.140 + */
1.141 +void msn_servconn_set_connect_cb(MsnServConn *servconn,
1.142 + void (*connect_cb)(MsnServConn *));
1.143 +/**
1.144 + * Sets the disconnect callback.
1.145 + *
1.146 + * @param servconn The servconn.
1.147 + * @param disconnect_cb The disconnect callback.
1.148 + */
1.149 +void msn_servconn_set_disconnect_cb(MsnServConn *servconn,
1.150 + void (*disconnect_cb)(MsnServConn *));
1.151 +/**
1.152 + * Sets the destroy callback.
1.153 + *
1.154 + * @param servconn The servconn that's being destroyed.
1.155 + * @param destroy_cb The destroy callback.
1.156 + */
1.157 +void msn_servconn_set_destroy_cb(MsnServConn *servconn,
1.158 + void (*destroy_cb)(MsnServConn *));
1.159 +
1.160 +/**
1.161 + * Writes a chunck of data to the servconn.
1.162 + *
1.163 + * @param servconn The servconn.
1.164 + * @param buf The data to write.
1.165 + * @param size The size of the data.
1.166 + */
1.167 +gssize msn_servconn_write(MsnServConn *servconn, const char *buf,
1.168 + size_t size);
1.169 +
1.170 +/**
1.171 + * Function to call whenever an error related to a switchboard occurs.
1.172 + *
1.173 + * @param servconn The servconn.
1.174 + * @param error The error that happened.
1.175 + */
1.176 +void msn_servconn_got_error(MsnServConn *servconn, MsnServConnError error,
1.177 + const char *reason);
1.178 +
1.179 +/**
1.180 + * Process the data in servconn->rx_buf. This is called after reading
1.181 + * data from the socket.
1.182 + *
1.183 + * @param servconn The servconn.
1.184 + */
1.185 +void msn_servconn_process_data(MsnServConn *servconn);
1.186 +
1.187 +/**
1.188 + * Set a idle timeout fot this servconn
1.189 + *
1.190 + * @param servconn The servconn
1.191 + * @param seconds The idle timeout in seconds
1.192 + */
1.193 +void msn_servconn_set_idle_timeout(MsnServConn *servconn, guint seconds);
1.194 +
1.195 +#endif /* _MSN_SERVCONN_H_ */