Mercurial > pidgin
comparison src/protocols/irc/irc.c @ 6270:1bf6fd117797
[gaim-migrate @ 6767]
IRC should now use the new IP code. Or it'll break horribly and nobody's
DCC sends will work. One of those.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 22 Jul 2003 08:23:51 +0000 |
parents | ac191233b816 |
children | 3613007cbb6e |
comparison
equal
deleted
inserted
replaced
6269:0a902bd3e170 | 6270:1bf6fd117797 |
---|---|
2564 { | 2564 { |
2565 if (b->present == GAIM_BUDDY_OFFLINE) | 2565 if (b->present == GAIM_BUDDY_OFFLINE) |
2566 *se = "offline"; | 2566 *se = "offline"; |
2567 } | 2567 } |
2568 | 2568 |
2569 static int | |
2570 getlocalip(char *ip) /* Thanks, libfaim */ | |
2571 { | |
2572 struct hostent *hptr; | |
2573 char localhost[129]; | |
2574 long unsigned add; | |
2575 | |
2576 /* XXX if available, use getaddrinfo() */ | |
2577 /* XXX allow client to specify which IP to use for multihomed boxes */ | |
2578 | |
2579 if (gethostname(localhost, 128) < 0) | |
2580 return -1; | |
2581 | |
2582 if (!(hptr = gethostbyname(localhost))) | |
2583 return -1; | |
2584 | |
2585 memcpy(&add, hptr->h_addr_list[0], 4); | |
2586 add = htonl(add); | |
2587 g_snprintf(ip, 11, "%lu", add); | |
2588 | |
2589 return 0; | |
2590 } | |
2591 | |
2592 static void | 2569 static void |
2593 dcc_chat_connected(gpointer data, gint source, GdkInputCondition condition) | 2570 dcc_chat_connected(gpointer data, gint source, GdkInputCondition condition) |
2594 { | 2571 { |
2595 struct dcc_chat *chat = data; | 2572 struct dcc_chat *chat = data; |
2596 GaimConversation *convo; | 2573 GaimConversation *convo; |
2849 irc_start_chat(GaimConnection *gc, const char *who) { | 2826 irc_start_chat(GaimConnection *gc, const char *who) { |
2850 struct dcc_chat *chat; | 2827 struct dcc_chat *chat; |
2851 int len; | 2828 int len; |
2852 struct sockaddr_in addr; | 2829 struct sockaddr_in addr; |
2853 char buf[IRC_BUF_LEN]; | 2830 char buf[IRC_BUF_LEN]; |
2831 const char *ip; | |
2854 | 2832 |
2855 /* Create a socket */ | 2833 /* Create a socket */ |
2856 chat = g_new0 (struct dcc_chat, 1); | 2834 chat = g_new0 (struct dcc_chat, 1); |
2857 chat->fd = socket (AF_INET, SOCK_STREAM, 0); | 2835 chat->fd = socket (AF_INET, SOCK_STREAM, 0); |
2858 chat->gc = gc; | 2836 chat->gc = gc; |
2867 bind (chat->fd, (struct sockaddr *) &addr, sizeof (addr)); | 2845 bind (chat->fd, (struct sockaddr *) &addr, sizeof (addr)); |
2868 listen (chat->fd, 1); | 2846 listen (chat->fd, 1); |
2869 len = sizeof (addr); | 2847 len = sizeof (addr); |
2870 getsockname (chat->fd, (struct sockaddr *) &addr, &len); | 2848 getsockname (chat->fd, (struct sockaddr *) &addr, &len); |
2871 chat->port = ntohs (addr.sin_port); | 2849 chat->port = ntohs (addr.sin_port); |
2872 getlocalip(chat->ip_address); | 2850 |
2851 ip = gaim_xfers_get_ip_for_account(gaim_connection_get_account(gc)); | |
2852 strncpy(chat->ip_address, ip, INET6_ADDRSTRLEN); | |
2853 | |
2873 chat->inpa = | 2854 chat->inpa = |
2874 gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_connected, | 2855 gaim_input_add (chat->fd, GAIM_INPUT_READ, dcc_chat_connected, |
2875 chat); | 2856 chat); |
2876 g_snprintf (buf, sizeof buf, "\001DCC CHAT chat %s %d\001\n", | 2857 g_snprintf (buf, sizeof buf, "\001DCC CHAT chat %s %d\001\n", |
2877 chat->ip_address, chat->port); | 2858 chat->ip_address, chat->port); |