Mercurial > pidgin
comparison libgaim/protocols/simple/simple.c @ 14308:9ad313800b19
[gaim-migrate @ 16998]
Make gaim_srv_resolve cancelable. Please test and let me know of any
problems. I was unable to test the WIN32 method for this, since it
actually uses Windows stuff.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 23 Aug 2006 08:02:05 +0000 |
parents | 645598a4ec04 |
children | 8ed6ef220b2d |
comparison
equal
deleted
inserted
replaced
14307:7c91ba42b9ba | 14308:9ad313800b19 |
---|---|
1582 gaim_connection_error(sip->gc, _("Couldn't create socket")); | 1582 gaim_connection_error(sip->gc, _("Couldn't create socket")); |
1583 } | 1583 } |
1584 } | 1584 } |
1585 | 1585 |
1586 static void srvresolved(GaimSrvResponse *resp, int results, gpointer data) { | 1586 static void srvresolved(GaimSrvResponse *resp, int results, gpointer data) { |
1587 GaimConnection *gc; | |
1588 struct simple_account_data *sip; | 1587 struct simple_account_data *sip; |
1589 gchar *hostname; | 1588 gchar *hostname; |
1590 int port; | 1589 int port; |
1591 | 1590 |
1592 gc = data; | 1591 sip = data; |
1593 if (!GAIM_CONNECTION_IS_VALID(gc)) | 1592 sip->srv_query_data = NULL; |
1594 { | 1593 |
1595 /* This connection has been closed */ | |
1596 g_free(resp); | |
1597 return; | |
1598 } | |
1599 | |
1600 sip = gc->proto_data; | |
1601 port = gaim_account_get_int(sip->account, "port", 0); | 1594 port = gaim_account_get_int(sip->account, "port", 0); |
1602 | 1595 |
1603 /* find the host to connect to */ | 1596 /* find the host to connect to */ |
1604 if(results) { | 1597 if(results) { |
1605 hostname = g_strdup(resp->hostname); | 1598 hostname = g_strdup(resp->hostname); |
1680 hosttoconnect = g_strdup(sip->servername); | 1673 hosttoconnect = g_strdup(sip->servername); |
1681 } else { | 1674 } else { |
1682 hosttoconnect = g_strdup(gaim_account_get_string(account, "proxy", sip->servername)); | 1675 hosttoconnect = g_strdup(gaim_account_get_string(account, "proxy", sip->servername)); |
1683 } | 1676 } |
1684 | 1677 |
1685 /* TCP case */ | 1678 sip->srv_query_data = gaim_srv_resolve("sip", |
1686 if(!sip->udp) { | 1679 sip->udp ? "udp" : "tcp", hosttoconnect, srvresolved, sip); |
1687 gaim_srv_resolve("sip", "tcp", hosttoconnect, srvresolved, gc); | |
1688 } else { /* UDP */ | |
1689 gaim_srv_resolve("sip", "udp", hosttoconnect, srvresolved, gc); | |
1690 } | |
1691 g_free(hosttoconnect); | 1680 g_free(hosttoconnect); |
1692 } | 1681 } |
1693 | 1682 |
1694 static void simple_close(GaimConnection *gc) | 1683 static void simple_close(GaimConnection *gc) |
1695 { | 1684 { |
1700 do_register_exp(sip, 0); | 1689 do_register_exp(sip, 0); |
1701 connection_free_all(sip); | 1690 connection_free_all(sip); |
1702 | 1691 |
1703 if (sip->query_data != NULL) | 1692 if (sip->query_data != NULL) |
1704 gaim_dnsquery_destroy(sip->query_data); | 1693 gaim_dnsquery_destroy(sip->query_data); |
1694 | |
1695 if (sip->srv_query_data != NULL) | |
1696 gaim_srv_cancel(sip->srv_query_data); | |
1705 | 1697 |
1706 if (sip->listen_data != NULL) | 1698 if (sip->listen_data != NULL) |
1707 gaim_network_listen_cancel(sip->listen_data); | 1699 gaim_network_listen_cancel(sip->listen_data); |
1708 | 1700 |
1709 g_free(sip->servername); | 1701 g_free(sip->servername); |