Mercurial > pidgin.yaz
comparison libpurple/protocols/bonjour/bonjour.c @ 31018:9c8b28dc6656
The hostname used for a bonjour account should always be the current machine
name. This fixes our behavior so the previous statement is always the case.
Unfortunately, this means that if the hostname was previously not the current
machine name, the bonjour jid ends up looking like "username\40otherhost@hostname".
Fixes #12674
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 04 Oct 2010 00:48:25 +0000 |
parents | 351d07aefb09 |
children | 7a4f51a1e156 |
comparison
equal
deleted
inserted
replaced
31017:014a58e994da | 31018:9c8b28dc6656 |
---|---|
44 #include "buddy.h" | 44 #include "buddy.h" |
45 #include "bonjour_ft.h" | 45 #include "bonjour_ft.h" |
46 | 46 |
47 static char *default_firstname; | 47 static char *default_firstname; |
48 static char *default_lastname; | 48 static char *default_lastname; |
49 static char *default_hostname; | 49 |
50 const char * | |
51 bonjour_get_jid(PurpleAccount *account) | |
52 { | |
53 PurpleConnection *conn = purple_account_get_connection(account); | |
54 BonjourData *bd = conn->proto_data; | |
55 return bd->jid; | |
56 } | |
50 | 57 |
51 static void | 58 static void |
52 bonjour_removeallfromlocal(PurpleConnection *conn, PurpleGroup *bonjour_group) | 59 bonjour_removeallfromlocal(PurpleConnection *conn, PurpleGroup *bonjour_group) |
53 { | 60 { |
54 PurpleAccount *account = purple_connection_get_account(conn); | 61 PurpleAccount *account = purple_connection_get_account(conn); |
180 /* Cancel any file transfers */ | 187 /* Cancel any file transfers */ |
181 while (bd != NULL && bd->xfer_lists) { | 188 while (bd != NULL && bd->xfer_lists) { |
182 purple_xfer_cancel_local(bd->xfer_lists->data); | 189 purple_xfer_cancel_local(bd->xfer_lists->data); |
183 } | 190 } |
184 | 191 |
192 g_free(bd->jid); | |
185 g_free(bd); | 193 g_free(bd); |
186 connection->proto_data = NULL; | 194 connection->proto_data = NULL; |
187 } | 195 } |
188 | 196 |
189 static const char * | 197 static const char * |
387 | 395 |
388 if (bb->jid != NULL && *bb->jid != '\0') | 396 if (bb->jid != NULL && *bb->jid != '\0') |
389 purple_notify_user_info_add_pair(user_info, _("XMPP Account"), bb->jid); | 397 purple_notify_user_info_add_pair(user_info, _("XMPP Account"), bb->jid); |
390 } | 398 } |
391 | 399 |
392 static void bonjour_do_group_change(PurpleBuddy *buddy, const char *new_group) { | 400 static void |
401 bonjour_do_group_change(PurpleBuddy *buddy, const char *new_group) { | |
393 PurpleBlistNodeFlags oldflags; | 402 PurpleBlistNodeFlags oldflags; |
394 | 403 |
395 if (buddy == NULL) | 404 if (buddy == NULL) |
396 return; | 405 return; |
397 | 406 |
443 { | 452 { |
444 /* These shouldn't happen here because they are allocated in _init() */ | 453 /* These shouldn't happen here because they are allocated in _init() */ |
445 | 454 |
446 g_free(default_firstname); | 455 g_free(default_firstname); |
447 g_free(default_lastname); | 456 g_free(default_lastname); |
448 g_free(default_hostname); | |
449 | 457 |
450 return TRUE; | 458 return TRUE; |
451 } | 459 } |
452 | 460 |
453 static PurplePlugin *my_protocol = NULL; | 461 static PurplePlugin *my_protocol = NULL; |
564 NULL, | 572 NULL, |
565 NULL | 573 NULL |
566 }; | 574 }; |
567 | 575 |
568 #ifdef WIN32 | 576 #ifdef WIN32 |
569 static gboolean _set_default_name_cb(gpointer data) { | 577 static gboolean |
578 _set_default_name_cb(gpointer data) { | |
570 gchar *fullname = data; | 579 gchar *fullname = data; |
571 const char *splitpoint; | 580 const char *splitpoint; |
572 GList *tmp = prpl_info.protocol_options; | 581 GList *tmp = prpl_info.protocol_options; |
573 PurpleAccountOption *option; | 582 PurpleAccountOption *option; |
574 | 583 |
601 } | 610 } |
602 | 611 |
603 return FALSE; | 612 return FALSE; |
604 } | 613 } |
605 | 614 |
606 static gpointer _win32_name_lookup_thread(gpointer data) { | 615 static gpointer |
616 _win32_name_lookup_thread(gpointer data) { | |
607 gchar *fullname = NULL; | 617 gchar *fullname = NULL; |
608 wchar_t username[UNLEN + 1]; | 618 wchar_t username[UNLEN + 1]; |
609 DWORD dwLenUsername = UNLEN + 1; | 619 DWORD dwLenUsername = UNLEN + 1; |
610 | 620 |
611 GetUserNameW((LPWSTR) &username, &dwLenUsername); | 621 GetUserNameW((LPWSTR) &username, &dwLenUsername); |
705 default_firstname = g_strdup(fullname); | 715 default_firstname = g_strdup(fullname); |
706 default_lastname = g_strdup(""); | 716 default_lastname = g_strdup(""); |
707 } | 717 } |
708 | 718 |
709 g_free(conv); | 719 g_free(conv); |
710 | |
711 /* Try to figure out a good host name to use */ | |
712 /* TODO: Avoid 'localhost,' if possible */ | |
713 default_hostname = g_strdup(purple_get_host_name()); | |
714 } | 720 } |
715 | 721 |
716 static void | 722 static void |
717 init_plugin(PurplePlugin *plugin) | 723 init_plugin(PurplePlugin *plugin) |
718 { | 724 { |
719 PurpleAccountUserSplit *split; | |
720 PurpleAccountOption *option; | 725 PurpleAccountOption *option; |
721 | 726 |
722 initialize_default_account_values(); | 727 initialize_default_account_values(); |
723 | |
724 /* Creating the user splits */ | |
725 split = purple_account_user_split_new(_("Hostname"), default_hostname, '@'); | |
726 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); | |
727 | 728 |
728 /* Creating the options for the protocol */ | 729 /* Creating the options for the protocol */ |
729 option = purple_account_option_int_new(_("Local Port"), "port", BONJOUR_DEFAULT_PORT); | 730 option = purple_account_option_int_new(_("Local Port"), "port", BONJOUR_DEFAULT_PORT); |
730 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 731 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
731 | 732 |