Mercurial > pidgin.yaz
diff src/protocols/simple/simple.c @ 12730:d5b8f4dc1622
[gaim-migrate @ 15074]
Update gaim_network_listen*() to have the socket type specified. This allows us to use the same functionality to listen on UDP sockets too. There are probably a couple things that should be updated to use this. I also updated SIMPLE to allow the connect port to be specified in the account options.
committer: Tailor Script <tailor@pidgin.im>
| author | Daniel Atallah <daniel.atallah@gmail.com> |
|---|---|
| date | Thu, 05 Jan 2006 05:04:07 +0000 |
| parents | e893563d965d |
| children | 2b61e6ed85c3 |
line wrap: on
line diff
--- a/src/protocols/simple/simple.c Thu Jan 05 04:32:25 2006 +0000 +++ b/src/protocols/simple/simple.c Thu Jan 05 05:04:07 2006 +0000 @@ -1198,15 +1198,16 @@ struct simple_account_data *sip = (struct simple_account_data*) data; gchar *hostname; - int port = 5060; + int port = gaim_account_get_int(sip->account, "port", 0); int error = 0; - struct sockaddr_in addr; struct hostent *h; /* find the host to connect to */ if(results) { hostname = g_strdup(resp->hostname); + /* TODO: Should this work more like Jabber where the SRV value will be ignored + * if there is one manually specified? */ port = resp->port; g_free(resp); } else { @@ -1222,7 +1223,7 @@ /* TCP case */ if(! sip->udp) { /* create socket for incoming connections */ - sip->listenfd = gaim_network_listen_range(5060, 5160); + sip->listenfd = gaim_network_listen_range(5060, 5160, SOCK_STREAM); if(sip->listenfd == -1) { gaim_connection_error(sip->gc, _("Could not create listen socket")); return; @@ -1246,15 +1247,14 @@ return; } - sip->fd = socket(AF_INET, SOCK_DGRAM, 0); + /* create socket for incoming connections */ + sip->fd = gaim_network_listen_range(5060, 5160, SOCK_DGRAM); - addr.sin_family = AF_INET; - addr.sin_port = htons(5060); - addr.sin_addr.s_addr = INADDR_ANY; - while((bind(sip->fd, (struct sockaddr*)&addr, sizeof(struct sockaddr_in)) <0) && ntohs(addr.sin_port)<5160) { - addr.sin_port = htons(ntohs(addr.sin_port)+1); + if(sip->fd == -1) { + gaim_connection_error(sip->gc, _("Could not create listen socket")); + return; } - sip->listenport = ntohs(addr.sin_port); + sip->listenfd = sip->fd; sip->listenpa = gaim_input_add(sip->fd, GAIM_INPUT_READ, simple_udp_process, sip->gc); @@ -1461,6 +1461,10 @@ option = gaim_account_option_bool_new(_("Publish status (note: everyone may watch you)"), "dopublish", TRUE); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); + option = gaim_account_option_int_new(_("Connect port"), "port", 5060); + prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); + + option = gaim_account_option_bool_new(_("Use UDP"), "udp", FALSE); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); option = gaim_account_option_bool_new(_("Use proxy"), "useproxy", FALSE);
