libpurple/protocols/bonjour/bonjour.c

Fri, 05 Oct 2007 16:50:54 +0000

author
Will Thompson <resiak@pidgin.im>
date
Fri, 05 Oct 2007 16:50:54 +0000
branch
cpw.resiak.disconnectreason
changeset 20854
c844b5545119
parent 20853
2637f895b850
child 21152
2357a7a795eb
permissions
-rw-r--r--

Add reasons to a couple of new errors (and to a commented-out one, for
completeness).

11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
2 * purple - Bonjour Protocol Plugin
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
3 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
6 * source distribution.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
7 *
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
12 *
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
17 *
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19842
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
21 */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
22 #include <glib.h>
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
23 #ifndef _WIN32
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
24 #include <pwd.h>
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
25 #else
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
26 #define UNICODE
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
27 #include <windows.h>
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
28 #include <lm.h>
20837
c038b7fffbdc Don't link the bonjour prpl on win32 directly to the Apple Bonjour library, instead do everything indirectly and display an error message at login time indicating that Bonjour isn't installed. This should make the prpl more discoverable.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
29 #include "dns_sd_proxy.h"
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
30 #endif
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
31
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
32 #include "internal.h"
13061
ab3ef8e402e4 [gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents: 12970
diff changeset
33
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
34 #include "account.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
35 #include "accountopt.h"
13061
ab3ef8e402e4 [gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents: 12970
diff changeset
36 #include "debug.h"
ab3ef8e402e4 [gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents: 12970
diff changeset
37 #include "util.h"
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
38 #include "version.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
39
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
40 #include "bonjour.h"
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 16961
diff changeset
41 #include "mdns_common.h"
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
42 #include "jabber.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
43 #include "buddy.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
44
12339
9333237efc4f [gaim-migrate @ 14643]
Mark Doliner <markdoliner@pidgin.im>
parents: 12216
diff changeset
45 /*
9333237efc4f [gaim-migrate @ 14643]
Mark Doliner <markdoliner@pidgin.im>
parents: 12216
diff changeset
46 * TODO: Should implement an add_buddy callback that removes the buddy
9333237efc4f [gaim-migrate @ 14643]
Mark Doliner <markdoliner@pidgin.im>
parents: 12216
diff changeset
47 * from the local list. Bonjour manages buddies for you, and
13061
ab3ef8e402e4 [gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents: 12970
diff changeset
48 * adding someone locally by hand is stupid. Or, maybe even better,
ab3ef8e402e4 [gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents: 12970
diff changeset
49 * if a PRPL does not have an add_buddy callback then do not allow
ab3ef8e402e4 [gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents: 12970
diff changeset
50 * users to add buddies.
12339
9333237efc4f [gaim-migrate @ 14643]
Mark Doliner <markdoliner@pidgin.im>
parents: 12216
diff changeset
51 */
9333237efc4f [gaim-migrate @ 14643]
Mark Doliner <markdoliner@pidgin.im>
parents: 12216
diff changeset
52
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
53 static char *default_firstname;
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
54 static char *default_lastname;
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
55 static char *default_hostname;
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
56
11691
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
57 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
58 bonjour_removeallfromlocal(PurpleConnection *gc)
11691
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
59 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
60 PurpleAccount *account = purple_connection_get_account(gc);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
61 PurpleBuddyList *blist;
15983
31740b53ecd3 Fix some reads of invalid memory when shutting down bonjour when there
Mark Doliner <markdoliner@pidgin.im>
parents: 15884
diff changeset
62 PurpleBlistNode *gnode, *cnode, *cnodenext, *bnode, *bnodenext;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
63 PurpleBuddy *buddy;
11691
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
64
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
65 blist = purple_get_blist();
11691
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
66 if (blist == NULL)
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
67 return;
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
68
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
69 /* Go through and remove all buddies that belong to this account */
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
70 for (gnode = blist->root; gnode; gnode = gnode->next)
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
71 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
72 if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
11691
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
73 continue;
15983
31740b53ecd3 Fix some reads of invalid memory when shutting down bonjour when there
Mark Doliner <markdoliner@pidgin.im>
parents: 15884
diff changeset
74 for (cnode = gnode->child; cnode; cnode = cnodenext)
11691
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
75 {
15983
31740b53ecd3 Fix some reads of invalid memory when shutting down bonjour when there
Mark Doliner <markdoliner@pidgin.im>
parents: 15884
diff changeset
76 cnodenext = cnode->next;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
77 if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
11691
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
78 continue;
15983
31740b53ecd3 Fix some reads of invalid memory when shutting down bonjour when there
Mark Doliner <markdoliner@pidgin.im>
parents: 15884
diff changeset
79 for (bnode = cnode->child; bnode; bnode = bnodenext)
11691
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
80 {
15983
31740b53ecd3 Fix some reads of invalid memory when shutting down bonjour when there
Mark Doliner <markdoliner@pidgin.im>
parents: 15884
diff changeset
81 bnodenext = bnode->next;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
82 if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
11691
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
83 continue;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
84 buddy = (PurpleBuddy *)bnode;
11691
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
85 if (buddy->account != account)
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
86 continue;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
87 purple_prpl_got_user_status(account, buddy->name, "offline", NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
88 purple_blist_remove_buddy(buddy);
11691
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
89 }
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
90 }
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
91 }
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
92 }
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
93
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12339
diff changeset
94 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
95 bonjour_login(PurpleAccount *account)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
96 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
97 PurpleConnection *gc = purple_account_get_connection(account);
17632
b27a15168d33 Improve Bonjour error handling when there are errors "connecting".
Daniel Atallah <datallah@pidgin.im>
parents: 17608
diff changeset
98 PurpleGroup *bonjour_group;
b27a15168d33 Improve Bonjour error handling when there are errors "connecting".
Daniel Atallah <datallah@pidgin.im>
parents: 17608
diff changeset
99 BonjourData *bd;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
100 PurpleStatus *status;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
101 PurplePresence *presence;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
102
20837
c038b7fffbdc Don't link the bonjour prpl on win32 directly to the Apple Bonjour library, instead do everything indirectly and display an error message at login time indicating that Bonjour isn't installed. This should make the prpl more discoverable.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
103 #ifdef _WIN32
c038b7fffbdc Don't link the bonjour prpl on win32 directly to the Apple Bonjour library, instead do everything indirectly and display an error message at login time indicating that Bonjour isn't installed. This should make the prpl more discoverable.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
104 if (!dns_sd_available()) {
c038b7fffbdc Don't link the bonjour prpl on win32 directly to the Apple Bonjour library, instead do everything indirectly and display an error message at login time indicating that Bonjour isn't installed. This should make the prpl more discoverable.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
105 gc->wants_to_die = TRUE;
20854
c844b5545119 Add reasons to a couple of new errors (and to a commented-out one, for
Will Thompson <resiak@pidgin.im>
parents: 20853
diff changeset
106 purple_connection_error_reason(gc, PURPLE_REASON_OTHER_ERROR,
20837
c038b7fffbdc Don't link the bonjour prpl on win32 directly to the Apple Bonjour library, instead do everything indirectly and display an error message at login time indicating that Bonjour isn't installed. This should make the prpl more discoverable.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
107 _("The Apple Bonjour For Windows toolkit wasn't found, see the FAQ at: "
c038b7fffbdc Don't link the bonjour prpl on win32 directly to the Apple Bonjour library, instead do everything indirectly and display an error message at login time indicating that Bonjour isn't installed. This should make the prpl more discoverable.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
108 "http://developer.pidgin.im/wiki/Using%20Pidgin#CanIusePidginforBonjourLink-LocalMessaging"
c038b7fffbdc Don't link the bonjour prpl on win32 directly to the Apple Bonjour library, instead do everything indirectly and display an error message at login time indicating that Bonjour isn't installed. This should make the prpl more discoverable.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
109 " for more information."));
c038b7fffbdc Don't link the bonjour prpl on win32 directly to the Apple Bonjour library, instead do everything indirectly and display an error message at login time indicating that Bonjour isn't installed. This should make the prpl more discoverable.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
110 return;
c038b7fffbdc Don't link the bonjour prpl on win32 directly to the Apple Bonjour library, instead do everything indirectly and display an error message at login time indicating that Bonjour isn't installed. This should make the prpl more discoverable.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
111 }
c038b7fffbdc Don't link the bonjour prpl on win32 directly to the Apple Bonjour library, instead do everything indirectly and display an error message at login time indicating that Bonjour isn't installed. This should make the prpl more discoverable.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
112 #endif
c038b7fffbdc Don't link the bonjour prpl on win32 directly to the Apple Bonjour library, instead do everything indirectly and display an error message at login time indicating that Bonjour isn't installed. This should make the prpl more discoverable.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
113
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
114 gc->flags |= PURPLE_CONNECTION_HTML;
17632
b27a15168d33 Improve Bonjour error handling when there are errors "connecting".
Daniel Atallah <datallah@pidgin.im>
parents: 17608
diff changeset
115 gc->proto_data = bd = g_new0(BonjourData, 1);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
116
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
117 /* Start waiting for jabber connections (iChat style) */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
118 bd->jabber_data = g_new(BonjourJabber, 1);
13971
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13968
diff changeset
119 bd->jabber_data->port = BONJOUR_DEFAULT_PORT_INT;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
120 bd->jabber_data->account = account;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
121
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
122 if (bonjour_jabber_start(bd->jabber_data) == -1) {
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
123 /* Send a message about the connection error */
20435
bc4b48f6fbaa Fix up Bonjour to use purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents: 19859
diff changeset
124 purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR,
bc4b48f6fbaa Fix up Bonjour to use purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents: 19859
diff changeset
125 _("Unable to listen for incoming IM connections\n"));
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
126 return;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
127 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
128
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
129 /* Connect to the mDNS daemon looking for buddies in the LAN */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
130 bd->dns_sd_data = bonjour_dns_sd_new();
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
131 bd->dns_sd_data->first = g_strdup(purple_account_get_string(account, "first", default_firstname));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
132 bd->dns_sd_data->last = g_strdup(purple_account_get_string(account, "last", default_lastname));
13971
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13968
diff changeset
133 bd->dns_sd_data->port_p2pj = bd->jabber_data->port;
17608
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
134 /* Not engaged in AV conference */
795ce8e3d44e Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
135 bd->dns_sd_data->vc = g_strdup("!");
11834
9c0104f0b8c3 [gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents: 11829
diff changeset
136
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
137 status = purple_account_get_active_status(account);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
138 presence = purple_account_get_presence(account);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
139 if (purple_presence_is_available(presence))
11834
9c0104f0b8c3 [gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents: 11829
diff changeset
140 bd->dns_sd_data->status = g_strdup("avail");
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
141 else if (purple_presence_is_idle(presence))
11834
9c0104f0b8c3 [gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents: 11829
diff changeset
142 bd->dns_sd_data->status = g_strdup("away");
9c0104f0b8c3 [gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents: 11829
diff changeset
143 else
9c0104f0b8c3 [gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents: 11829
diff changeset
144 bd->dns_sd_data->status = g_strdup("dnd");
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
145 bd->dns_sd_data->msg = g_strdup(purple_status_get_attr_string(status, "message"));
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
146
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
147 bd->dns_sd_data->account = account;
11927
f9ede13499d0 [gaim-migrate @ 14218]
Mark Doliner <markdoliner@pidgin.im>
parents: 11841
diff changeset
148 if (!bonjour_dns_sd_start(bd->dns_sd_data))
f9ede13499d0 [gaim-migrate @ 14218]
Mark Doliner <markdoliner@pidgin.im>
parents: 11841
diff changeset
149 {
20435
bc4b48f6fbaa Fix up Bonjour to use purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents: 19859
diff changeset
150 purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR,
bc4b48f6fbaa Fix up Bonjour to use purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents: 19859
diff changeset
151 _("Unable to establish connection with the local mDNS server. Is it running?"));
11927
f9ede13499d0 [gaim-migrate @ 14218]
Mark Doliner <markdoliner@pidgin.im>
parents: 11841
diff changeset
152 return;
f9ede13499d0 [gaim-migrate @ 14218]
Mark Doliner <markdoliner@pidgin.im>
parents: 11841
diff changeset
153 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
154
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 18844
diff changeset
155 bonjour_dns_sd_update_buddy_icon(bd->dns_sd_data);
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 18844
diff changeset
156
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
157 /* Create a group for bonjour buddies */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
158 bonjour_group = purple_group_new(BONJOUR_GROUP_NAME);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
159 purple_blist_add_group(bonjour_group, NULL);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
160
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
161 /* Show the buddy list by telling Purple we have already connected */
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
162 purple_connection_set_state(gc, PURPLE_CONNECTED);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
163 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
164
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12339
diff changeset
165 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
166 bonjour_close(PurpleConnection *connection)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
167 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
168 PurpleGroup *bonjour_group;
17632
b27a15168d33 Improve Bonjour error handling when there are errors "connecting".
Daniel Atallah <datallah@pidgin.im>
parents: 17608
diff changeset
169 BonjourData *bd = connection->proto_data;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
170
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
171 /* Stop looking for buddies in the LAN */
20837
c038b7fffbdc Don't link the bonjour prpl on win32 directly to the Apple Bonjour library, instead do everything indirectly and display an error message at login time indicating that Bonjour isn't installed. This should make the prpl more discoverable.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
172 if (bd != NULL && bd->dns_sd_data != NULL)
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
173 {
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
174 bonjour_dns_sd_stop(bd->dns_sd_data);
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
175 bonjour_dns_sd_free(bd->dns_sd_data);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
176 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
177
20837
c038b7fffbdc Don't link the bonjour prpl on win32 directly to the Apple Bonjour library, instead do everything indirectly and display an error message at login time indicating that Bonjour isn't installed. This should make the prpl more discoverable.
Daniel Atallah <datallah@pidgin.im>
parents: 19859
diff changeset
178 if (bd != NULL && bd->jabber_data != NULL)
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
179 {
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
180 /* Stop waiting for conversations */
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
181 bonjour_jabber_stop(bd->jabber_data);
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
182 g_free(bd->jabber_data);
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
183 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
184
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
185 /* Remove all the bonjour buddies */
11691
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
186 bonjour_removeallfromlocal(connection);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
187
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
188 /* Delete the bonjour group */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
189 bonjour_group = purple_find_group(BONJOUR_GROUP_NAME);
13063
0dcbcfe1c9d7 [gaim-migrate @ 15425]
David Schmitt
parents: 13061
diff changeset
190 if (bonjour_group != NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
191 purple_blist_remove_group(bonjour_group);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
192
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
193 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
194
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12339
diff changeset
195 static const char *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
196 bonjour_list_icon(PurpleAccount *account, PurpleBuddy *buddy)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
197 {
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
198 return BONJOUR_ICON_NAME;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
199 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
200
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12339
diff changeset
201 static int
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
202 bonjour_send_im(PurpleConnection *connection, const char *to, const char *msg, PurpleMessageFlags flags)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
203 {
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
204 if(!to || !msg)
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
205 return 0;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
206
11693
1a42a66ca0f8 [gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents: 11691
diff changeset
207 return bonjour_jabber_send_message(((BonjourData*)(connection->proto_data))->jabber_data, to, msg);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
208 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
209
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12339
diff changeset
210 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
211 bonjour_set_status(PurpleAccount *account, PurpleStatus *status)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
212 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
213 PurpleConnection *gc;
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
214 BonjourData *bd;
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
215 gboolean disconnected;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
216 PurpleStatusType *type;
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
217 int primitive;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
218 PurplePresence *presence;
11841
85773b4974fe [gaim-migrate @ 14132]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11839
diff changeset
219 const char *message, *bonjour_status;
13061
ab3ef8e402e4 [gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents: 12970
diff changeset
220 gchar *stripped;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
221
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
222 gc = purple_account_get_connection(account);
11839
bb7002373bb6 [gaim-migrate @ 14130]
Mark Doliner <markdoliner@pidgin.im>
parents: 11837
diff changeset
223 bd = gc->proto_data;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
224 disconnected = purple_account_is_disconnected(account);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
225 type = purple_status_get_type(status);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
226 primitive = purple_status_type_get_primitive(type);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
227 presence = purple_account_get_presence(account);
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
228
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
229 message = purple_status_get_attr_string(status, "message");
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
230 if (message == NULL)
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
231 message = "";
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
232 stripped = purple_markup_strip_html(message);
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
233
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
234 /*
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
235 * The three possible status for Bonjour are
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
236 * -available ("avail")
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
237 * -idle ("away")
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
238 * -away ("dnd")
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
239 * Each of them can have an optional message.
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
240 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
241 if (purple_presence_is_available(presence))
11841
85773b4974fe [gaim-migrate @ 14132]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11839
diff changeset
242 bonjour_status = "avail";
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
243 else if (purple_presence_is_idle(presence))
11841
85773b4974fe [gaim-migrate @ 14132]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11839
diff changeset
244 bonjour_status = "away";
11835
da95d476b481 [gaim-migrate @ 14126]
Mark Doliner <markdoliner@pidgin.im>
parents: 11834
diff changeset
245 else
11841
85773b4974fe [gaim-migrate @ 14132]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11839
diff changeset
246 bonjour_status = "dnd";
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
247
13061
ab3ef8e402e4 [gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents: 12970
diff changeset
248 bonjour_dns_sd_send_status(bd->dns_sd_data, bonjour_status, stripped);
ab3ef8e402e4 [gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents: 12970
diff changeset
249 g_free(stripped);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
250 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
251
19748
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19219
diff changeset
252 static void bonjour_remove_buddy(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group) {
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19219
diff changeset
253 if (buddy->proto_data) {
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19219
diff changeset
254 bonjour_buddy_delete(buddy->proto_data);
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19219
diff changeset
255 buddy->proto_data = NULL;
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19219
diff changeset
256 }
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19219
diff changeset
257 }
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19219
diff changeset
258
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
259 static GList *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
260 bonjour_status_types(PurpleAccount *account)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
261 {
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
262 GList *status_types = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
263 PurpleStatusType *type;
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
264
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
265 g_return_val_if_fail(account != NULL, NULL);
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
266
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
267 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
268 BONJOUR_STATUS_ID_AVAILABLE,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12489
diff changeset
269 NULL, TRUE, TRUE, FALSE,
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
270 "message", _("Message"),
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
271 purple_value_new(PURPLE_TYPE_STRING), NULL);
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
272 status_types = g_list_append(status_types, type);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
273
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
274 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY,
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
275 BONJOUR_STATUS_ID_AWAY,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12489
diff changeset
276 NULL, TRUE, TRUE, FALSE,
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
277 "message", _("Message"),
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
278 purple_value_new(PURPLE_TYPE_STRING), NULL);
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
279 status_types = g_list_append(status_types, type);
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
280
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
281 type = purple_status_type_new_full(PURPLE_STATUS_OFFLINE,
12658
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12650
diff changeset
282 BONJOUR_STATUS_ID_OFFLINE,
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12650
diff changeset
283 NULL, TRUE, TRUE, FALSE);
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12650
diff changeset
284 status_types = g_list_append(status_types, type);
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12650
diff changeset
285
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
286 return status_types;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
287 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
288
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
289 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
290 bonjour_convo_closed(PurpleConnection *connection, const char *who)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
291 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
292 PurpleBuddy *buddy = purple_find_buddy(connection->account, who);
17663
fd736a4d91a9 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17660
diff changeset
293 BonjourBuddy *bb;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
294
11966
ad12fc2943ca [gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents: 11927
diff changeset
295 if (buddy == NULL)
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12489
diff changeset
296 {
11966
ad12fc2943ca [gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents: 11927
diff changeset
297 /*
ad12fc2943ca [gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents: 11927
diff changeset
298 * This buddy is not in our buddy list, and therefore does not really
ad12fc2943ca [gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents: 11927
diff changeset
299 * exist, so we won't have any data about them.
ad12fc2943ca [gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents: 11927
diff changeset
300 */
ad12fc2943ca [gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents: 11927
diff changeset
301 return;
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12489
diff changeset
302 }
11966
ad12fc2943ca [gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents: 11927
diff changeset
303
17663
fd736a4d91a9 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17660
diff changeset
304 bb = buddy->proto_data;
fd736a4d91a9 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17660
diff changeset
305 bonjour_jabber_close_conversation(bb->conversation);
fd736a4d91a9 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17660
diff changeset
306 bb->conversation = NULL;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
307 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
308
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 18844
diff changeset
309 static
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 18844
diff changeset
310 void bonjour_set_buddy_icon(PurpleConnection *conn, PurpleStoredImage *img)
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 18844
diff changeset
311 {
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 18844
diff changeset
312 BonjourData *bd = conn->proto_data;
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 18844
diff changeset
313 bonjour_dns_sd_update_buddy_icon(bd->dns_sd_data);
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 18844
diff changeset
314 }
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 18844
diff changeset
315
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 18844
diff changeset
316
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
317 static char *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
318 bonjour_status_text(PurpleBuddy *buddy)
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
319 {
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
320 const PurplePresence *presence;
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
321 const PurpleStatus *status;
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
322 const char *message;
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
323 gchar *ret = NULL;
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
324
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
325 presence = purple_buddy_get_presence(buddy);
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
326 status = purple_presence_get_active_status(presence);
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
327
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
328 message = purple_status_get_attr_string(status, "message");
12339
9333237efc4f [gaim-migrate @ 14643]
Mark Doliner <markdoliner@pidgin.im>
parents: 12216
diff changeset
329
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
330 if (message != NULL) {
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
331 ret = g_markup_escape_text(message, -1);
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
332 purple_util_chrreplace(ret, '\n', ' ');
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
333 }
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
334
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
335 return ret;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
336 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
337
12970
c2f3b4dcf711 [gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents: 12943
diff changeset
338 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
339 bonjour_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
340 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
341 PurplePresence *presence;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
342 PurpleStatus *status;
19219
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
343 BonjourBuddy *bb = buddy->proto_data;
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
344 const char *status_description;
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
345 const char *message;
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
346
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
347 presence = purple_buddy_get_presence(buddy);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
348 status = purple_presence_get_active_status(presence);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
349 message = purple_status_get_attr_string(status, "message");
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
350
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
351 if (purple_presence_is_available(presence))
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
352 status_description = purple_status_get_name(status);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
353 else if (purple_presence_is_idle(presence))
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
354 status_description = _("Idle");
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
355 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
356 status_description = purple_status_get_name(status);
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
357
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
358 purple_notify_user_info_add_pair(user_info, _("Status"), status_description);
11519
abb61e69b1cf [gaim-migrate @ 13764]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
359 if (message != NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
360 purple_notify_user_info_add_pair(user_info, _("Message"), message);
19219
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
361
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
362 /* Only show first/last name if there is a nickname set (to avoid duplication) */
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
363 if (bb->nick != NULL) {
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
364 if (bb->first != NULL)
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
365 purple_notify_user_info_add_pair(user_info, _("First name"), bb->first);
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
366 if (bb->first != NULL)
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
367 purple_notify_user_info_add_pair(user_info, _("Last name"), bb->last);
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
368 }
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
369
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
370 if (bb->email != NULL)
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
371 purple_notify_user_info_add_pair(user_info, _("E-Mail"), bb->email);
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
372
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
373 if (bb->AIM != NULL)
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
374 purple_notify_user_info_add_pair(user_info, _("AIM Account"), bb->AIM);
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
375
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
376 if (bb->jid!= NULL)
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
377 purple_notify_user_info_add_pair(user_info, _("XMPP Account"), bb->jid);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
378 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
379
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
380 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
381 plugin_unload(PurplePlugin *plugin)
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
382 {
17660
23c712d0a795 Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
383 /* These shouldn't happen here because they are allocated in _init() */
23c712d0a795 Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
384
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
385 g_free(default_firstname);
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
386 g_free(default_lastname);
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
387 g_free(default_hostname);
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
388
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
389 return TRUE;
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
390 }
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
391
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
392 static PurplePlugin *my_protocol = NULL;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
393
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
394 static PurplePluginProtocolInfo prpl_info =
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
395 {
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
396 OPT_PROTO_NO_PASSWORD,
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
397 NULL, /* user_splits */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
398 NULL, /* protocol_options */
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 18844
diff changeset
399 {"png,gif,jpeg", 0, 0, 96, 96, 65535, PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
400 bonjour_list_icon, /* list_icon */
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
401 NULL, /* list_emblem */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
402 bonjour_status_text, /* status_text */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
403 bonjour_tooltip_text, /* tooltip_text */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
404 bonjour_status_types, /* status_types */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
405 NULL, /* blist_node_menu */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
406 NULL, /* chat_info */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
407 NULL, /* chat_info_defaults */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
408 bonjour_login, /* login */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
409 bonjour_close, /* close */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
410 bonjour_send_im, /* send_im */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
411 NULL, /* set_info */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
412 NULL, /* send_typing */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
413 NULL, /* get_info */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
414 bonjour_set_status, /* set_status */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
415 NULL, /* set_idle */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
416 NULL, /* change_passwd */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
417 NULL, /* add_buddy */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
418 NULL, /* add_buddies */
19748
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19219
diff changeset
419 bonjour_remove_buddy, /* remove_buddy */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
420 NULL, /* remove_buddies */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
421 NULL, /* add_permit */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
422 NULL, /* add_deny */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
423 NULL, /* rem_permit */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
424 NULL, /* rem_deny */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
425 NULL, /* set_permit_deny */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
426 NULL, /* join_chat */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
427 NULL, /* reject_chat */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
428 NULL, /* get_chat_name */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
429 NULL, /* chat_invite */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
430 NULL, /* chat_leave */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
431 NULL, /* chat_whisper */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
432 NULL, /* chat_send */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
433 NULL, /* keepalive */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
434 NULL, /* register_user */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
435 NULL, /* get_cb_info */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
436 NULL, /* get_cb_away */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
437 NULL, /* alias_buddy */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
438 NULL, /* group_buddy */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
439 NULL, /* rename_group */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
440 NULL, /* buddy_free */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
441 bonjour_convo_closed, /* convo_closed */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
442 NULL, /* normalize */
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 18844
diff changeset
443 bonjour_set_buddy_icon, /* set_buddy_icon */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
444 NULL, /* remove_group */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
445 NULL, /* get_cb_real_name */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
446 NULL, /* set_chat_topic */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
447 NULL, /* find_blist_chat */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
448 NULL, /* roomlist_get_list */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
449 NULL, /* roomlist_cancel */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
450 NULL, /* roomlist_expand_category */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
451 NULL, /* can_receive_file */
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 12003
diff changeset
452 NULL, /* send_file */
12607
4622f0adedf4 [gaim-migrate @ 14943]
Mark Doliner <markdoliner@pidgin.im>
parents: 12595
diff changeset
453 NULL, /* new_xfer */
12650
ca70a14f4994 [gaim-migrate @ 14988]
Mark Doliner <markdoliner@pidgin.im>
parents: 12607
diff changeset
454 NULL, /* offline_message */
12607
4622f0adedf4 [gaim-migrate @ 14943]
Mark Doliner <markdoliner@pidgin.im>
parents: 12595
diff changeset
455 NULL, /* whiteboard_prpl_ops */
15217
53af6e98dfff [gaim-migrate @ 17941]
Mark Doliner <markdoliner@pidgin.im>
parents: 14604
diff changeset
456 NULL, /* send_raw */
53af6e98dfff [gaim-migrate @ 17941]
Mark Doliner <markdoliner@pidgin.im>
parents: 14604
diff changeset
457 NULL, /* roomlist_room_serialize */
16776
c9301dd6aa1f Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents: 15996
diff changeset
458
c9301dd6aa1f Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents: 15996
diff changeset
459 /* padding */
c9301dd6aa1f Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents: 15996
diff changeset
460 NULL,
c9301dd6aa1f Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents: 15996
diff changeset
461 NULL,
c9301dd6aa1f Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents: 15996
diff changeset
462 NULL,
c9301dd6aa1f Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents: 15996
diff changeset
463 NULL
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
464 };
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
465
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
466 static PurplePluginInfo info =
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
467 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
468 PURPLE_PLUGIN_MAGIC,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
469 PURPLE_MAJOR_VERSION,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
470 PURPLE_MINOR_VERSION,
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
471 PURPLE_PLUGIN_PROTOCOL, /**< type */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
472 NULL, /**< ui_requirement */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
473 0, /**< flags */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
474 NULL, /**< dependencies */
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
475 PURPLE_PRIORITY_DEFAULT, /**< priority */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
476
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
477 "prpl-bonjour", /**< id */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
478 "Bonjour", /**< name */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
479 VERSION, /**< version */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
480 /** summary */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
481 N_("Bonjour Protocol Plugin"),
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
482 /** description */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
483 N_("Bonjour Protocol Plugin"),
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
484 NULL, /**< author */
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
485 PURPLE_WEBSITE, /**< homepage */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
486
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
487 NULL, /**< load */
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
488 plugin_unload, /**< unload */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
489 NULL, /**< destroy */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
490
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
491 NULL, /**< ui_info */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
492 &prpl_info, /**< extra_info */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
493 NULL, /**< prefs_info */
16776
c9301dd6aa1f Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents: 15996
diff changeset
494 NULL,
c9301dd6aa1f Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents: 15996
diff changeset
495
c9301dd6aa1f Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents: 15996
diff changeset
496 /* padding */
c9301dd6aa1f Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents: 15996
diff changeset
497 NULL,
c9301dd6aa1f Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents: 15996
diff changeset
498 NULL,
c9301dd6aa1f Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents: 15996
diff changeset
499 NULL,
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
500 NULL
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
501 };
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
502
19824
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
503 #ifdef WIN32
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
504 static gboolean _set_default_name_cb(gpointer data) {
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
505 gchar *fullname = data;
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
506 const char *splitpoint;
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
507 GList *tmp = prpl_info.protocol_options;
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
508 PurpleAccountOption *option;
13192
77a782e38011 [gaim-migrate @ 15554]
Mark Doliner <markdoliner@pidgin.im>
parents: 13076
diff changeset
509
19824
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
510 if (!fullname) {
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
511 purple_debug_info("bonjour", "Unable to look up First and Last name or Username from system; using defaults.\n");
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
512 return FALSE;
13076
84dfc467ddbd [gaim-migrate @ 15437]
Mark Doliner <markdoliner@pidgin.im>
parents: 13063
diff changeset
513 }
84dfc467ddbd [gaim-migrate @ 15437]
Mark Doliner <markdoliner@pidgin.im>
parents: 13063
diff changeset
514
19824
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
515 g_free(default_firstname);
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
516 g_free(default_lastname);
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
517
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
518 /* Split the real name into a first and last name */
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
519 splitpoint = strchr(fullname, ' ');
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
520 if (splitpoint != NULL) {
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
521 default_firstname = g_strndup(fullname, splitpoint - fullname);
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
522 default_lastname = g_strdup(&splitpoint[1]);
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
523 } else {
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
524 default_firstname = g_strdup(fullname);
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
525 default_lastname = g_strdup("");
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
526 }
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
527 g_free(fullname);
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
528
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
529
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
530 for(; tmp != NULL; tmp = tmp->next) {
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
531 option = tmp->data;
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
532 if (strcmp("first", purple_account_option_get_setting(option)) == 0)
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
533 purple_account_option_set_default_string(option, default_firstname);
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
534 else if (strcmp("last", purple_account_option_get_setting(option)) == 0)
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
535 purple_account_option_set_default_string(option, default_lastname);
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
536 }
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
537
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
538 return FALSE;
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
539 }
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
540
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
541 static gpointer _win32_name_lookup_thread(gpointer data) {
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
542 gchar *fullname = NULL;
18844
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
543 wchar_t username[UNLEN + 1];
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
544 DWORD dwLenUsername = UNLEN + 1;
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
545
19824
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
546 GetUserNameW((LPWSTR) &username, &dwLenUsername);
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
547
18844
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
548 if (username != NULL && *username != '\0') {
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
549 LPBYTE servername = NULL;
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
550 LPBYTE info = NULL;
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
551
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
552 NetGetDCName(NULL, NULL, &servername);
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
553
19824
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
554 /* purple_debug_info("bonjour", "Looking up the full name from the %s.\n", (servername ? "domain controller" : "local machine")); */
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
555
18844
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
556 if (NetUserGetInfo((LPCWSTR) servername, username, 10, &info) == NERR_Success
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
557 && info != NULL && ((LPUSER_INFO_10) info)->usri10_full_name != NULL
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
558 && *(((LPUSER_INFO_10) info)->usri10_full_name) != '\0') {
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
559 fullname = g_utf16_to_utf8(
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
560 ((LPUSER_INFO_10) info)->usri10_full_name,
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
561 -1, NULL, NULL, NULL);
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
562 }
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
563 /* Fall back to the local machine if we didn't get the full name from the domain controller */
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
564 else if (servername != NULL) {
19824
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
565 /* purple_debug_info("bonjour", "Looking up the full name from the local machine"); */
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
566
18844
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
567 if (info != NULL) NetApiBufferFree(info);
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
568 info = NULL;
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
569
18844
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
570 if (NetUserGetInfo(NULL, username, 10, &info) == NERR_Success
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
571 && info != NULL && ((LPUSER_INFO_10) info)->usri10_full_name != NULL
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
572 && *(((LPUSER_INFO_10) info)->usri10_full_name) != '\0') {
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
573 fullname = g_utf16_to_utf8(
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
574 ((LPUSER_INFO_10) info)->usri10_full_name,
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
575 -1, NULL, NULL, NULL);
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
576 }
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
577 }
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
578
18844
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
579 if (info != NULL) NetApiBufferFree(info);
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
580 if (servername != NULL) NetApiBufferFree(servername);
19824
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
581
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
582 if (!fullname)
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
583 fullname = g_utf16_to_utf8(username, -1, NULL, NULL, NULL);
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
584 }
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
585
19824
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
586 g_idle_add(_set_default_name_cb, fullname);
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
587
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
588 return NULL;
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
589 }
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
590 #endif
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
591
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
592 static void
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
593 initialize_default_account_values()
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
594 {
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
595 #ifndef _WIN32
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
596 struct passwd *info;
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
597 #endif
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
598 const char *fullname = NULL, *splitpoint, *tmp;
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
599 char hostname[255];
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
600 gchar *conv = NULL;
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
601
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
602 #ifndef _WIN32
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
603 /* Try to figure out the user's real name */
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
604 info = getpwuid(getuid());
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
605 if ((info != NULL) && (info->pw_gecos != NULL) && (info->pw_gecos[0] != '\0'))
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
606 fullname = info->pw_gecos;
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
607 else if ((info != NULL) && (info->pw_name != NULL) && (info->pw_name[0] != '\0'))
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
608 fullname = info->pw_name;
19842
4630c7f60cb9 We have got an empty fullname, set it to NULL so that we fall back to
Mark Doliner <markdoliner@pidgin.im>
parents: 19824
diff changeset
609 else if (((fullname = getlogin()) != NULL) && (fullname[0] == '\0'))
4630c7f60cb9 We have got an empty fullname, set it to NULL so that we fall back to
Mark Doliner <markdoliner@pidgin.im>
parents: 19824
diff changeset
610 fullname = NULL;
19824
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
611 #else
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
612 /* The Win32 username lookup functions are synchronous so we do it in a thread */
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
613 g_thread_create(_win32_name_lookup_thread, NULL, FALSE, NULL);
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
614 #endif
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
615
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
616 /* Make sure fullname is valid UTF-8. If not, try to convert it. */
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
617 if (fullname != NULL && !g_utf8_validate(fullname, -1, NULL)) {
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
618 fullname = conv = g_locale_to_utf8(fullname, -1, NULL, NULL, NULL);
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
619 if (conv == NULL || *conv == '\0')
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
620 fullname = NULL;
18844
257e1878df25 Bonjour only works on Windows2000 or newer, so we don't need to indirectly access the Net* functions. Avoid doing an unnecessary domain query to find the Domain Controller (which was causing a several second delay at startup). Also, try harder to avoid empty default names and falling back to "Purple Person".
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
621 }
19824
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
622
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
623 if (fullname == NULL)
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
624 fullname = _("Purple Person");
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
625
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
626 /* Split the real name into a first and last name */
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
627 splitpoint = strchr(fullname, ' ');
19824
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
628 if (splitpoint != NULL) {
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
629 default_firstname = g_strndup(fullname, splitpoint - fullname);
16823
c505ca263924 The last name from /etc/passwd may have additional comma-delimited data which we should ignore when determining the default Bonjour name. Fixes #477
Evan Schoenberg <evands@pidgin.im>
parents: 16799
diff changeset
630 tmp = &splitpoint[1];
19204
ccc7ec4ea4dc Some more minor mdns implementation abstraction tweaks and implementation of setting buddy icons for the win32 bonjour implementation.
Daniel Atallah <datallah@pidgin.im>
parents: 18844
diff changeset
631
16823
c505ca263924 The last name from /etc/passwd may have additional comma-delimited data which we should ignore when determining the default Bonjour name. Fixes #477
Evan Schoenberg <evands@pidgin.im>
parents: 16799
diff changeset
632 /* The last name may be followed by a comma and additional data.
c505ca263924 The last name from /etc/passwd may have additional comma-delimited data which we should ignore when determining the default Bonjour name. Fixes #477
Evan Schoenberg <evands@pidgin.im>
parents: 16799
diff changeset
633 * Only use the last name itself.
c505ca263924 The last name from /etc/passwd may have additional comma-delimited data which we should ignore when determining the default Bonjour name. Fixes #477
Evan Schoenberg <evands@pidgin.im>
parents: 16799
diff changeset
634 */
c505ca263924 The last name from /etc/passwd may have additional comma-delimited data which we should ignore when determining the default Bonjour name. Fixes #477
Evan Schoenberg <evands@pidgin.im>
parents: 16799
diff changeset
635 splitpoint = strchr(tmp, ',');
c505ca263924 The last name from /etc/passwd may have additional comma-delimited data which we should ignore when determining the default Bonjour name. Fixes #477
Evan Schoenberg <evands@pidgin.im>
parents: 16799
diff changeset
636 if (splitpoint != NULL)
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 16961
diff changeset
637 default_lastname = g_strndup(tmp, splitpoint - tmp);
16823
c505ca263924 The last name from /etc/passwd may have additional comma-delimited data which we should ignore when determining the default Bonjour name. Fixes #477
Evan Schoenberg <evands@pidgin.im>
parents: 16799
diff changeset
638 else
c505ca263924 The last name from /etc/passwd may have additional comma-delimited data which we should ignore when determining the default Bonjour name. Fixes #477
Evan Schoenberg <evands@pidgin.im>
parents: 16799
diff changeset
639 default_lastname = g_strdup(tmp);
19824
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
640 } else {
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
641 default_firstname = g_strdup(fullname);
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
642 default_lastname = g_strdup("");
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
643 }
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
644
19824
f99f468cda22 Lookup the default First and Last name values for bonjour on win32 in a thread to avoid delays when the plugin is being loaded. Apparently for some people the delay is quite significant when they're part of a domain, but the domain server isn't accessible.
Daniel Atallah <datallah@pidgin.im>
parents: 19748
diff changeset
645 g_free(conv);
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
646
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
647 /* Try to figure out a good host name to use */
13972
50b7226d8519 [gaim-migrate @ 16408]
Mark Doliner <markdoliner@pidgin.im>
parents: 13971
diff changeset
648 /* TODO: Avoid 'localhost,' if possible */
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
649 if (gethostname(hostname, 255) != 0) {
15996
ac5515cbcf4a Minor cleanup
Mark Doliner <markdoliner@pidgin.im>
parents: 15983
diff changeset
650 purple_debug_warning("bonjour", "Error when getting host name: %s. Using \"localhost.\"\n",
ac5515cbcf4a Minor cleanup
Mark Doliner <markdoliner@pidgin.im>
parents: 15983
diff changeset
651 strerror(errno));
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
652 strcpy(hostname, "localhost");
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
653 }
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
654 default_hostname = g_strdup(hostname);
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
655 }
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
656
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
657 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
658 init_plugin(PurplePlugin *plugin)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
659 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
660 PurpleAccountUserSplit *split;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
661 PurpleAccountOption *option;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
662
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
663 initialize_default_account_values();
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
664
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
665 /* Creating the user splits */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
666 split = purple_account_user_split_new(_("Hostname"), default_hostname, '@');
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
667 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
668
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
669 /* Creating the options for the protocol */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
670 option = purple_account_option_string_new(_("First name"), "first", default_firstname);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
671 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
672
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
673 option = purple_account_option_string_new(_("Last name"), "last", default_lastname);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
674 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
675
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
676 option = purple_account_option_string_new(_("E-mail"), "email", "");
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
677 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
678
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
679 option = purple_account_option_string_new(_("AIM Account"), "AIM", "");
13968
45f6a17eca9b [gaim-migrate @ 16400]
Jonty Wareing
parents: 13546
diff changeset
680 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
45f6a17eca9b [gaim-migrate @ 16400]
Jonty Wareing
parents: 13546
diff changeset
681
16961
b6955f946f8f s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents: 16823
diff changeset
682 option = purple_account_option_string_new(_("XMPP Account"), "jid", "");
13968
45f6a17eca9b [gaim-migrate @ 16400]
Jonty Wareing
parents: 13546
diff changeset
683 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
45f6a17eca9b [gaim-migrate @ 16400]
Jonty Wareing
parents: 13546
diff changeset
684
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
685 my_protocol = plugin;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
686 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
687
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
688 PURPLE_INIT_PLUGIN(bonjour, init_plugin, info);

mercurial