# HG changeset patch # User Mark Doliner # Date 1076619516 0 # Node ID e7524f4b4ed263b063fb776613dbf9c22466db2f # Parent 91c6629b1ee81187c7c6cf4565901620d9a1e2eb [gaim-migrate @ 8969] Change some listening stuff. Also, the autorecon thing, the signals should get removed when the hash table is destroyed, so that check should not be necessary. If the function really is getting called then I guess this should be re-added or something... committer: Tailor Script diff -r 91c6629b1ee8 -r e7524f4b4ed2 plugins/autorecon.c --- a/plugins/autorecon.c Thu Feb 12 19:55:05 2004 +0000 +++ b/plugins/autorecon.c Thu Feb 12 20:58:36 2004 +0000 @@ -18,8 +18,6 @@ static GHashTable *hash = NULL; static gboolean do_signon(gpointer data) { - g_return_val_if_fail(hash != NULL, FALSE); - GaimAccount *account = data; GaimAutoRecon *info; diff -r 91c6629b1ee8 -r e7524f4b4ed2 src/network.c --- a/src/network.c Thu Feb 12 19:55:05 2004 +0000 +++ b/src/network.c Thu Feb 12 20:58:36 2004 +0000 @@ -189,7 +189,12 @@ return listenfd; } -int gaim_network_listen(short start, short end) +int gaim_network_listen(short port) +{ + return gaim_network_do_listen(port); +} + +int gaim_network_listen_range(short start, short end) { int ret = -1; diff -r 91c6629b1ee8 -r e7524f4b4ed2 src/network.h --- a/src/network.h Thu Feb 12 19:55:05 2004 +0000 +++ b/src/network.h Thu Feb 12 20:58:36 2004 +0000 @@ -88,7 +88,9 @@ const char *gaim_network_get_ip_for_account(const GaimAccount *account, int fd); /** - * Opens a listening port. + * Attempts to open a listening port ONLY on the specified port number. + * Can be used if MUST be listening on a certain port. You probably + * want to use gaim_network_listen_range() instead of this. * * This opens a listening port. The caller will want to set up a watcher * of type GAIM_INPUT_READ on the returned fd. It will probably call @@ -96,15 +98,35 @@ * the listening socket, and add a new watcher on the new socket accept * returned. * - * @param start The port number to bind to, or 0 to let the core decide. - * By default, the core will let the kernel pick one at random, - * but users are allowed to specify a range. - * @param end The highest possible port in the range of ports to listen on, - * or 0 to let the core decide. - * @return The file descriptor of the listening socket, or -1 if + * @param port The port number to bind to. + * + * @return The file descriptor of the listening socket, or -1 if * no socket could be established. */ -int gaim_network_listen(short start, short end); +int gaim_network_listen(short port); + +/** + * Opens a listening port selected from a range of ports. + * + * This opens a listening port. The caller will want to set up a watcher + * of type GAIM_INPUT_READ on the returned fd. It will probably call + * accept in the callback, and then possibly remove the watcher and close + * the listening socket, and add a new watcher on the new socket accept + * returned. + * + * @note This function always lets the core override its args with the + * value of the user preferences. + * + * @param start The port number to bind to, or 0 to let the core decide. + * By default, the core will let the kernel pick one at random. + * Users are allowed to override this arg in prefs. + * @param end The highest possible port in the range of ports to listen on, + * or 0 to let the core decide Users are allowed to override this + * arg in prefs. + * @return The file descriptor of the listening socket, or -1 if + * no socket could be established. + */ +int gaim_network_listen_range(short start, short end); /** * Gets a port number from a file descriptor. diff -r 91c6629b1ee8 -r e7524f4b4ed2 src/protocols/oscar/oscar.c --- a/src/protocols/oscar/oscar.c Thu Feb 12 19:55:05 2004 +0000 +++ b/src/protocols/oscar/oscar.c Thu Feb 12 20:58:36 2004 +0000 @@ -871,7 +871,7 @@ oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); /* Create a listening socket and an associated libfaim conn */ - if ((listenfd = gaim_network_listen(5190, 5199)) < 0) + if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) return; xfer->local_port = gaim_network_get_port_from_fd(listenfd); oft_info->port = xfer->local_port; @@ -6149,7 +6149,7 @@ dim->gc = gc; g_snprintf(dim->name, sizeof dim->name, "%s", data->who); - listenfd = gaim_network_listen(5190, 5199); + listenfd = gaim_network_listen_range(5190, 5199); dim->conn = aim_odc_initiate(od->sess, data->who, listenfd, gaim_network_get_port_from_fd(listenfd)); if (dim->conn != NULL) { od->direct_ims = g_slist_append(od->direct_ims, dim);