1.1 --- a/Frameworks/libpurple.framework/Versions/0.5.6/Headers/network.h Sun Jun 21 22:04:11 2009 -0400
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,233 +0,0 @@
1.4 -/**
1.5 - * @file network.h Network API
1.6 - * @ingroup core
1.7 - */
1.8 -
1.9 -/* purple
1.10 - *
1.11 - * Purple is the legal property of its developers, whose names are too numerous
1.12 - * to list here. Please refer to the COPYRIGHT file distributed with this
1.13 - * source distribution.
1.14 - *
1.15 - * This program is free software; you can redistribute it and/or modify
1.16 - * it under the terms of the GNU General Public License as published by
1.17 - * the Free Software Foundation; either version 2 of the License, or
1.18 - * (at your option) any later version.
1.19 - *
1.20 - * This program is distributed in the hope that it will be useful,
1.21 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.22 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.23 - * GNU General Public License for more details.
1.24 - *
1.25 - * You should have received a copy of the GNU General Public License
1.26 - * along with this program; if not, write to the Free Software
1.27 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
1.28 - */
1.29 -#ifndef _PURPLE_NETWORK_H_
1.30 -#define _PURPLE_NETWORK_H_
1.31 -
1.32 -#ifdef __cplusplus
1.33 -extern "C" {
1.34 -#endif
1.35 -
1.36 -/**************************************************************************/
1.37 -/** @name Network API */
1.38 -/**************************************************************************/
1.39 -/*@{*/
1.40 -
1.41 -typedef struct _PurpleNetworkListenData PurpleNetworkListenData;
1.42 -
1.43 -typedef void (*PurpleNetworkListenCallback) (int listenfd, gpointer data);
1.44 -
1.45 -/**
1.46 - * Converts a dot-decimal IP address to an array of unsigned
1.47 - * chars. For example, converts 192.168.0.1 to a 4 byte
1.48 - * array containing 192, 168, 0 and 1.
1.49 - *
1.50 - * @param ip An IP address in dot-decimal notiation.
1.51 - * @return An array of 4 bytes containing an IP addresses
1.52 - * equivalent to the given parameter, or NULL if
1.53 - * the given IP address is invalid. This value
1.54 - * is statically allocated and should not be
1.55 - * freed.
1.56 - */
1.57 -const unsigned char *purple_network_ip_atoi(const char *ip);
1.58 -
1.59 -/**
1.60 - * Sets the IP address of the local system in preferences. This
1.61 - * is the IP address that should be used for incoming connections
1.62 - * (file transfer, direct IM, etc.) and should therefore be
1.63 - * publicly accessible.
1.64 - *
1.65 - * @param ip The local IP address.
1.66 - */
1.67 -void purple_network_set_public_ip(const char *ip);
1.68 -
1.69 -/**
1.70 - * Returns the IP address of the local system set in preferences.
1.71 - *
1.72 - * This returns the value set via purple_network_set_public_ip().
1.73 - * You probably want to use purple_network_get_my_ip() instead.
1.74 - *
1.75 - * @return The local IP address set in preferences.
1.76 - */
1.77 -const char *purple_network_get_public_ip(void);
1.78 -
1.79 -/**
1.80 - * Returns the IP address of the local system.
1.81 - *
1.82 - * You probably want to use purple_network_get_my_ip() instead.
1.83 - *
1.84 - * @note The returned string is a pointer to a static buffer. If this
1.85 - * function is called twice, it may be important to make a copy
1.86 - * of the returned string.
1.87 - *
1.88 - * @param fd The fd to use to help figure out the IP, or else -1.
1.89 - * @return The local IP address.
1.90 - */
1.91 -const char *purple_network_get_local_system_ip(int fd);
1.92 -
1.93 -/**
1.94 - * Returns the IP address that should be used anywhere a
1.95 - * public IP addresses is needed (listening for an incoming
1.96 - * file transfer, etc).
1.97 - *
1.98 - * If the user has manually specified an IP address via
1.99 - * preferences, then this IP is returned. Otherwise the
1.100 - * IP address returned by purple_network_get_local_system_ip()
1.101 - * is returned.
1.102 - *
1.103 - * @note The returned string is a pointer to a static buffer. If this
1.104 - * function is called twice, it may be important to make a copy
1.105 - * of the returned string.
1.106 - *
1.107 - * @param fd The fd to use to help figure out the IP, or -1.
1.108 - * @return The local IP address to be used.
1.109 - */
1.110 -const char *purple_network_get_my_ip(int fd);
1.111 -
1.112 -/**
1.113 - * Should calls to purple_network_listen() and purple_network_listen_range()
1.114 - * map the port externally using NAT-PMP or UPnP?
1.115 - * The default value is TRUE
1.116 - *
1.117 - * @param map_external Should the open port be mapped externally?
1.118 - * @deprecated In 3.0.0 a boolean will be added to the above functions to
1.119 - * perform the same function.
1.120 - * @since 2.3.0
1.121 - */
1.122 -void purple_network_listen_map_external(gboolean map_external);
1.123 -
1.124 -/**
1.125 - * Attempts to open a listening port ONLY on the specified port number.
1.126 - * You probably want to use purple_network_listen_range() instead of this.
1.127 - * This function is useful, for example, if you wanted to write a telnet
1.128 - * server as a Purple plugin, and you HAD to listen on port 23. Why anyone
1.129 - * would want to do that is beyond me.
1.130 - *
1.131 - * This opens a listening port. The caller will want to set up a watcher
1.132 - * of type PURPLE_INPUT_READ on the fd returned in cb. It will probably call
1.133 - * accept in the watcher callback, and then possibly remove the watcher and close
1.134 - * the listening socket, and add a new watcher on the new socket accept
1.135 - * returned.
1.136 - *
1.137 - * @param port The port number to bind to. Must be greater than 0.
1.138 - * @param socket_type The type of socket to open for listening.
1.139 - * This will be either SOCK_STREAM for TCP or SOCK_DGRAM for UDP.
1.140 - * @param cb The callback to be invoked when the port to listen on is available.
1.141 - * The file descriptor of the listening socket will be specified in
1.142 - * this callback, or -1 if no socket could be established.
1.143 - * @param cb_data extra data to be returned when cb is called
1.144 - *
1.145 - * @return A pointer to a data structure that can be used to cancel
1.146 - * the pending listener, or NULL if unable to obtain a local
1.147 - * socket to listen on.
1.148 - */
1.149 -PurpleNetworkListenData *purple_network_listen(unsigned short port,
1.150 - int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data);
1.151 -
1.152 -/**
1.153 - * Opens a listening port selected from a range of ports. The range of
1.154 - * ports used is chosen in the following manner:
1.155 - * If a range is specified in preferences, these values are used.
1.156 - * If a non-0 values are passed to the function as parameters, these
1.157 - * values are used.
1.158 - * Otherwise a port is chosen at random by the operating system.
1.159 - *
1.160 - * This opens a listening port. The caller will want to set up a watcher
1.161 - * of type PURPLE_INPUT_READ on the fd returned in cb. It will probably call
1.162 - * accept in the watcher callback, and then possibly remove the watcher and close
1.163 - * the listening socket, and add a new watcher on the new socket accept
1.164 - * returned.
1.165 - *
1.166 - * @param start The port number to bind to, or 0 to pick a random port.
1.167 - * Users are allowed to override this arg in prefs.
1.168 - * @param end The highest possible port in the range of ports to listen on,
1.169 - * or 0 to pick a random port. Users are allowed to override this
1.170 - * arg in prefs.
1.171 - * @param socket_type The type of socket to open for listening.
1.172 - * This will be either SOCK_STREAM for TCP or SOCK_DGRAM for UDP.
1.173 - * @param cb The callback to be invoked when the port to listen on is available.
1.174 - * The file descriptor of the listening socket will be specified in
1.175 - * this callback, or -1 if no socket could be established.
1.176 - * @param cb_data extra data to be returned when cb is called
1.177 - *
1.178 - * @return A pointer to a data structure that can be used to cancel
1.179 - * the pending listener, or NULL if unable to obtain a local
1.180 - * socket to listen on.
1.181 - */
1.182 -PurpleNetworkListenData *purple_network_listen_range(unsigned short start,
1.183 - unsigned short end, int socket_type,
1.184 - PurpleNetworkListenCallback cb, gpointer cb_data);
1.185 -
1.186 -/**
1.187 - * This can be used to cancel any in-progress listener connection
1.188 - * by passing in the return value from either purple_network_listen()
1.189 - * or purple_network_listen_range().
1.190 - *
1.191 - * @param listen_data This listener attempt will be canceled and
1.192 - * the struct will be freed.
1.193 - */
1.194 -void purple_network_listen_cancel(PurpleNetworkListenData *listen_data);
1.195 -
1.196 -/**
1.197 - * Gets a port number from a file descriptor.
1.198 - *
1.199 - * @param fd The file descriptor. This should be a tcp socket. The current
1.200 - * implementation probably dies on anything but IPv4. Perhaps this
1.201 - * possible bug will inspire new and valuable contributors to Purple.
1.202 - * @return The port number, in host byte order.
1.203 - */
1.204 -unsigned short purple_network_get_port_from_fd(int fd);
1.205 -
1.206 -/**
1.207 - * Detects if there is an available network connection.
1.208 - *
1.209 - * @return TRUE if the network is available
1.210 - */
1.211 -gboolean purple_network_is_available(void);
1.212 -
1.213 -/**
1.214 - * Get the handle for the network system
1.215 - *
1.216 - * @return the handle to the network system
1.217 - */
1.218 -void *purple_network_get_handle(void);
1.219 -
1.220 -/**
1.221 - * Initializes the network subsystem.
1.222 - */
1.223 -void purple_network_init(void);
1.224 -
1.225 -/**
1.226 - * Shuts down the network subsystem.
1.227 - */
1.228 -void purple_network_uninit(void);
1.229 -
1.230 -/*@}*/
1.231 -
1.232 -#ifdef __cplusplus
1.233 -}
1.234 -#endif
1.235 -
1.236 -#endif /* _PURPLE_NETWORK_H_ */