Mercurial > pidgin
comparison src/ft.c @ 6263:3565ee7a5dd3
[gaim-migrate @ 6760]
Renamed gaim_xfer_init() to gaim_xfers_init(), and added a function for
returning the system's local IP address.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Tue, 22 Jul 2003 03:26:33 +0000 |
| parents | f0b0c5bca588 |
| children | 084e1f6610a8 |
comparison
equal
deleted
inserted
replaced
| 6262:4fcfe659568a | 6263:3565ee7a5dd3 |
|---|---|
| 49 if ((ip = gaim_account_get_public_ip(account)) != NULL) | 49 if ((ip = gaim_account_get_public_ip(account)) != NULL) |
| 50 ip = gaim_prefs_get_string("/core/ft/public_ip"); | 50 ip = gaim_prefs_get_string("/core/ft/public_ip"); |
| 51 | 51 |
| 52 if (ip != NULL && *ip != '\0') | 52 if (ip != NULL && *ip != '\0') |
| 53 xfer->local_ip = g_strdup(ip); | 53 xfer->local_ip = g_strdup(ip); |
| 54 else | |
| 55 xfer->local_ip = gaim_xfers_get_local_ip(); | |
| 54 | 56 |
| 55 ui_ops = gaim_xfer_get_ui_ops(xfer); | 57 ui_ops = gaim_xfer_get_ui_ops(xfer); |
| 56 | 58 |
| 57 if (ui_ops != NULL && ui_ops->new_xfer != NULL) | 59 if (ui_ops != NULL && ui_ops->new_xfer != NULL) |
| 58 ui_ops->new_xfer(xfer); | 60 ui_ops->new_xfer(xfer); |
| 702 gaim_notify_error(NULL, NULL, title, msg); | 704 gaim_notify_error(NULL, NULL, title, msg); |
| 703 | 705 |
| 704 g_free(title); | 706 g_free(title); |
| 705 } | 707 } |
| 706 | 708 |
| 707 void | 709 /************************************************************************** |
| 708 gaim_xfer_init(void) | 710 * File Transfer Subsystem API |
| 711 **************************************************************************/ | |
| 712 char * | |
| 713 gaim_xfers_get_local_ip(void) | |
| 714 { | |
| 715 struct hostent *host; | |
| 716 char localhost[129]; | |
| 717 long unsigned add; | |
| 718 char ip[46]; | |
| 719 | |
| 720 if (gethostname(localhost, 128) < 0) | |
| 721 return NULL; | |
| 722 | |
| 723 if ((host = gethostbyname(localhost)) == NULL) | |
| 724 return NULL; | |
| 725 | |
| 726 memcpy(&add, host->h_addr_list[0], 4); | |
| 727 add = htonl(add); | |
| 728 | |
| 729 g_snprintf(ip, 11, "%lu", add); | |
| 730 | |
| 731 return g_strdup(ip); | |
| 732 } | |
| 733 | |
| 734 void | |
| 735 gaim_xfers_init(void) | |
| 709 { | 736 { |
| 710 gaim_prefs_add_none("/core/ft"); | 737 gaim_prefs_add_none("/core/ft"); |
| 711 gaim_prefs_add_string("/core/ft/public_ip", ""); | 738 gaim_prefs_add_string("/core/ft/public_ip", ""); |
| 712 } | 739 } |
| 713 | 740 |
