libpurple/protocols/bonjour/bonjour.c

Wed, 03 Oct 2007 00:47:25 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Wed, 03 Oct 2007 00:47:25 +0000
changeset 20837
c038b7fffbdc
parent 19859
71d37b57eff2
child 20221
28e31ee832cd
child 20853
2637f895b850
permissions
-rw-r--r--

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.

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;
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
106 purple_connection_error(gc,
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 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
124 purple_connection_error(gc, _("Unable to listen for incoming IM connections\n"));
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
125 return;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
126 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
127
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
128 /* Connect to the mDNS daemon looking for buddies in the LAN */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
129 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
130 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
131 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
132 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
133 /* 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
134 bd->dns_sd_data->vc = g_strdup("!");
11834
9c0104f0b8c3 [gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents: 11829
diff changeset
135
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
136 status = purple_account_get_active_status(account);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
137 presence = purple_account_get_presence(account);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
138 if (purple_presence_is_available(presence))
11834
9c0104f0b8c3 [gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents: 11829
diff changeset
139 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
140 else if (purple_presence_is_idle(presence))
11834
9c0104f0b8c3 [gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents: 11829
diff changeset
141 bd->dns_sd_data->status = g_strdup("away");
9c0104f0b8c3 [gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents: 11829
diff changeset
142 else
9c0104f0b8c3 [gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents: 11829
diff changeset
143 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
144 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
145
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
146 bd->dns_sd_data->account = account;
11927
f9ede13499d0 [gaim-migrate @ 14218]
Mark Doliner <markdoliner@pidgin.im>
parents: 11841
diff changeset
147 if (!bonjour_dns_sd_start(bd->dns_sd_data))
f9ede13499d0 [gaim-migrate @ 14218]
Mark Doliner <markdoliner@pidgin.im>
parents: 11841
diff changeset
148 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
149 purple_connection_error(gc, _("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
150 return;
f9ede13499d0 [gaim-migrate @ 14218]
Mark Doliner <markdoliner@pidgin.im>
parents: 11841
diff changeset
151 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
152
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
153 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
154
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
155 /* Create a group for bonjour buddies */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
156 bonjour_group = purple_group_new(BONJOUR_GROUP_NAME);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
157 purple_blist_add_group(bonjour_group, NULL);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
158
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
159 /* 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
160 purple_connection_set_state(gc, PURPLE_CONNECTED);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
161 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
162
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12339
diff changeset
163 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
164 bonjour_close(PurpleConnection *connection)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
165 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
166 PurpleGroup *bonjour_group;
17632
b27a15168d33 Improve Bonjour error handling when there are errors "connecting".
Daniel Atallah <datallah@pidgin.im>
parents: 17608
diff changeset
167 BonjourData *bd = connection->proto_data;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
168
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
169 /* 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
170 if (bd != NULL && bd->dns_sd_data != NULL)
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
171 {
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
172 bonjour_dns_sd_stop(bd->dns_sd_data);
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
173 bonjour_dns_sd_free(bd->dns_sd_data);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
174 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
175
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
176 if (bd != NULL && bd->jabber_data != NULL)
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
177 {
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
178 /* Stop waiting for conversations */
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
179 bonjour_jabber_stop(bd->jabber_data);
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
180 g_free(bd->jabber_data);
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
181 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
182
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
183 /* Remove all the bonjour buddies */
11691
d46ace30ec7e [gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents: 11539
diff changeset
184 bonjour_removeallfromlocal(connection);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
185
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
186 /* Delete the bonjour group */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
187 bonjour_group = purple_find_group(BONJOUR_GROUP_NAME);
13063
0dcbcfe1c9d7 [gaim-migrate @ 15425]
David Schmitt
parents: 13061
diff changeset
188 if (bonjour_group != NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
189 purple_blist_remove_group(bonjour_group);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
190
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
191 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
192
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12339
diff changeset
193 static const char *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
194 bonjour_list_icon(PurpleAccount *account, PurpleBuddy *buddy)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
195 {
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
196 return BONJOUR_ICON_NAME;
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
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12339
diff changeset
199 static int
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
200 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
201 {
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
202 if(!to || !msg)
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
203 return 0;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
204
11693
1a42a66ca0f8 [gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents: 11691
diff changeset
205 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
206 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
207
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12339
diff changeset
208 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
209 bonjour_set_status(PurpleAccount *account, PurpleStatus *status)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
210 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
211 PurpleConnection *gc;
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
212 BonjourData *bd;
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
213 gboolean disconnected;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
214 PurpleStatusType *type;
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
215 int primitive;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
216 PurplePresence *presence;
11841
85773b4974fe [gaim-migrate @ 14132]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11839
diff changeset
217 const char *message, *bonjour_status;
13061
ab3ef8e402e4 [gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents: 12970
diff changeset
218 gchar *stripped;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
219
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
220 gc = purple_account_get_connection(account);
11839
bb7002373bb6 [gaim-migrate @ 14130]
Mark Doliner <markdoliner@pidgin.im>
parents: 11837
diff changeset
221 bd = gc->proto_data;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
222 disconnected = purple_account_is_disconnected(account);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
223 type = purple_status_get_type(status);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
224 primitive = purple_status_type_get_primitive(type);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
225 presence = purple_account_get_presence(account);
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
226
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
227 message = purple_status_get_attr_string(status, "message");
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
228 if (message == NULL)
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
229 message = "";
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
230 stripped = purple_markup_strip_html(message);
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
231
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
232 /*
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
233 * The three possible status for Bonjour are
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
234 * -available ("avail")
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
235 * -idle ("away")
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
236 * -away ("dnd")
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
237 * Each of them can have an optional message.
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
238 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
239 if (purple_presence_is_available(presence))
11841
85773b4974fe [gaim-migrate @ 14132]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11839
diff changeset
240 bonjour_status = "avail";
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
241 else if (purple_presence_is_idle(presence))
11841
85773b4974fe [gaim-migrate @ 14132]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11839
diff changeset
242 bonjour_status = "away";
11835
da95d476b481 [gaim-migrate @ 14126]
Mark Doliner <markdoliner@pidgin.im>
parents: 11834
diff changeset
243 else
11841
85773b4974fe [gaim-migrate @ 14132]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11839
diff changeset
244 bonjour_status = "dnd";
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
245
13061
ab3ef8e402e4 [gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents: 12970
diff changeset
246 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
247 g_free(stripped);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
248 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
249
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
250 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
251 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
252 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
253 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
254 }
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 }
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
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
257 static GList *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
258 bonjour_status_types(PurpleAccount *account)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
259 {
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
260 GList *status_types = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
261 PurpleStatusType *type;
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
262
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
263 g_return_val_if_fail(account != NULL, NULL);
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
264
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
265 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
266 BONJOUR_STATUS_ID_AVAILABLE,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12489
diff changeset
267 NULL, TRUE, TRUE, FALSE,
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
268 "message", _("Message"),
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
269 purple_value_new(PURPLE_TYPE_STRING), NULL);
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
270 status_types = g_list_append(status_types, type);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
271
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
272 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY,
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
273 BONJOUR_STATUS_ID_AWAY,
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12489
diff changeset
274 NULL, TRUE, TRUE, FALSE,
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
275 "message", _("Message"),
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
276 purple_value_new(PURPLE_TYPE_STRING), NULL);
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
277 status_types = g_list_append(status_types, type);
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
278
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
279 type = purple_status_type_new_full(PURPLE_STATUS_OFFLINE,
12658
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12650
diff changeset
280 BONJOUR_STATUS_ID_OFFLINE,
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12650
diff changeset
281 NULL, TRUE, TRUE, FALSE);
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12650
diff changeset
282 status_types = g_list_append(status_types, type);
4aa7a873628d [gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents: 12650
diff changeset
283
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
284 return status_types;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
285 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
286
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
287 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
288 bonjour_convo_closed(PurpleConnection *connection, const char *who)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
289 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
290 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
291 BonjourBuddy *bb;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
292
11966
ad12fc2943ca [gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents: 11927
diff changeset
293 if (buddy == NULL)
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12489
diff changeset
294 {
11966
ad12fc2943ca [gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents: 11927
diff changeset
295 /*
ad12fc2943ca [gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents: 11927
diff changeset
296 * 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
297 * exist, so we won't have any data about them.
ad12fc2943ca [gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents: 11927
diff changeset
298 */
ad12fc2943ca [gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents: 11927
diff changeset
299 return;
12595
8108c22aa723 [gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents: 12489
diff changeset
300 }
11966
ad12fc2943ca [gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents: 11927
diff changeset
301
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
302 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
303 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
304 bb->conversation = NULL;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
305 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
306
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
307 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
308 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
309 {
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 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
311 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
312 }
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
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
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11519
diff changeset
315 static char *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
316 bonjour_status_text(PurpleBuddy *buddy)
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
317 {
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
318 const PurplePresence *presence;
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
319 const PurpleStatus *status;
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
320 const char *message;
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
321 gchar *ret = NULL;
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
322
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
323 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
324 status = purple_presence_get_active_status(presence);
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
325
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
326 message = purple_status_get_attr_string(status, "message");
12339
9333237efc4f [gaim-migrate @ 14643]
Mark Doliner <markdoliner@pidgin.im>
parents: 12216
diff changeset
327
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
328 if (message != NULL) {
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
329 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
330 purple_util_chrreplace(ret, '\n', ' ');
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
331 }
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
332
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
333 return ret;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
334 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
335
12970
c2f3b4dcf711 [gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents: 12943
diff changeset
336 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
337 bonjour_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
338 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
339 PurplePresence *presence;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
340 PurpleStatus *status;
19219
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
341 BonjourBuddy *bb = buddy->proto_data;
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
342 const char *status_description;
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
343 const char *message;
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
344
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
345 presence = purple_buddy_get_presence(buddy);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
346 status = purple_presence_get_active_status(presence);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
347 message = purple_status_get_attr_string(status, "message");
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
348
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
349 if (purple_presence_is_available(presence))
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
350 status_description = purple_status_get_name(status);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
351 else if (purple_presence_is_idle(presence))
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
352 status_description = _("Idle");
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
353 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
354 status_description = purple_status_get_name(status);
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
355
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
356 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
357 if (message != NULL)
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, _("Message"), message);
19219
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
359
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
360 /* 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
361 if (bb->nick != NULL) {
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
362 if (bb->first != NULL)
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
363 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
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, _("Last name"), bb->last);
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
366 }
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
367
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
368 if (bb->email != NULL)
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
369 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
370
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
371 if (bb->AIM != NULL)
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
372 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
373
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
374 if (bb->jid!= NULL)
e1ef7cdd283a Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents: 19218
diff changeset
375 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
376 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
377
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
378 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
379 plugin_unload(PurplePlugin *plugin)
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
380 {
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
381 /* 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
382
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
383 g_free(default_firstname);
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
384 g_free(default_lastname);
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
385 g_free(default_hostname);
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
386
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
387 return TRUE;
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
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
390 static PurplePlugin *my_protocol = NULL;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
391
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
392 static PurplePluginProtocolInfo prpl_info =
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
393 {
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
394 OPT_PROTO_NO_PASSWORD,
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
395 NULL, /* user_splits */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
396 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
397 {"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
398 bonjour_list_icon, /* list_icon */
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
399 NULL, /* list_emblem */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
400 bonjour_status_text, /* status_text */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
401 bonjour_tooltip_text, /* tooltip_text */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
402 bonjour_status_types, /* status_types */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
403 NULL, /* blist_node_menu */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
404 NULL, /* chat_info */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
405 NULL, /* chat_info_defaults */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
406 bonjour_login, /* login */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
407 bonjour_close, /* close */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
408 bonjour_send_im, /* send_im */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
409 NULL, /* set_info */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
410 NULL, /* send_typing */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
411 NULL, /* get_info */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
412 bonjour_set_status, /* set_status */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
413 NULL, /* set_idle */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
414 NULL, /* change_passwd */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
415 NULL, /* add_buddy */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
416 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
417 bonjour_remove_buddy, /* remove_buddy */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
418 NULL, /* remove_buddies */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
419 NULL, /* add_permit */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
420 NULL, /* add_deny */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
421 NULL, /* rem_permit */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
422 NULL, /* rem_deny */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
423 NULL, /* set_permit_deny */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
424 NULL, /* join_chat */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
425 NULL, /* reject_chat */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
426 NULL, /* get_chat_name */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
427 NULL, /* chat_invite */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
428 NULL, /* chat_leave */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
429 NULL, /* chat_whisper */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
430 NULL, /* chat_send */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
431 NULL, /* keepalive */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
432 NULL, /* register_user */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
433 NULL, /* get_cb_info */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
434 NULL, /* get_cb_away */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
435 NULL, /* alias_buddy */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
436 NULL, /* group_buddy */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
437 NULL, /* rename_group */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
438 NULL, /* buddy_free */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
439 bonjour_convo_closed, /* convo_closed */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
440 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
441 bonjour_set_buddy_icon, /* set_buddy_icon */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
442 NULL, /* remove_group */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
443 NULL, /* get_cb_real_name */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
444 NULL, /* set_chat_topic */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
445 NULL, /* find_blist_chat */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
446 NULL, /* roomlist_get_list */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
447 NULL, /* roomlist_cancel */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
448 NULL, /* roomlist_expand_category */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
449 NULL, /* can_receive_file */
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 12003
diff changeset
450 NULL, /* send_file */
12607
4622f0adedf4 [gaim-migrate @ 14943]
Mark Doliner <markdoliner@pidgin.im>
parents: 12595
diff changeset
451 NULL, /* new_xfer */
12650
ca70a14f4994 [gaim-migrate @ 14988]
Mark Doliner <markdoliner@pidgin.im>
parents: 12607
diff changeset
452 NULL, /* offline_message */
12607
4622f0adedf4 [gaim-migrate @ 14943]
Mark Doliner <markdoliner@pidgin.im>
parents: 12595
diff changeset
453 NULL, /* whiteboard_prpl_ops */
15217
53af6e98dfff [gaim-migrate @ 17941]
Mark Doliner <markdoliner@pidgin.im>
parents: 14604
diff changeset
454 NULL, /* send_raw */
53af6e98dfff [gaim-migrate @ 17941]
Mark Doliner <markdoliner@pidgin.im>
parents: 14604
diff changeset
455 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
456
c9301dd6aa1f Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents: 15996
diff changeset
457 /* 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
458 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
459 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
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
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
462 };
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
463
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
464 static PurplePluginInfo info =
11477
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 PURPLE_PLUGIN_MAGIC,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
467 PURPLE_MAJOR_VERSION,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
468 PURPLE_MINOR_VERSION,
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
469 PURPLE_PLUGIN_PROTOCOL, /**< type */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
470 NULL, /**< ui_requirement */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
471 0, /**< flags */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
472 NULL, /**< dependencies */
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
473 PURPLE_PRIORITY_DEFAULT, /**< priority */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
474
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
475 "prpl-bonjour", /**< id */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
476 "Bonjour", /**< name */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
477 VERSION, /**< version */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
478 /** summary */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
479 N_("Bonjour Protocol Plugin"),
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
480 /** description */
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 NULL, /**< author */
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
483 PURPLE_WEBSITE, /**< homepage */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
484
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
485 NULL, /**< load */
19218
cb1f18ee620b Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
486 plugin_unload, /**< unload */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
487 NULL, /**< destroy */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
488
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
489 NULL, /**< ui_info */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
490 &prpl_info, /**< extra_info */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
491 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
492 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
493
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 /* 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
495 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
496 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
497 NULL,
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
498 NULL
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
499 };
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
500
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
501 #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
502 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
503 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
504 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
505 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
506 PurpleAccountOption *option;
13192
77a782e38011 [gaim-migrate @ 15554]
Mark Doliner <markdoliner@pidgin.im>
parents: 13076
diff changeset
507
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
508 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
509 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
510 return FALSE;
13076
84dfc467ddbd [gaim-migrate @ 15437]
Mark Doliner <markdoliner@pidgin.im>
parents: 13063
diff changeset
511 }
84dfc467ddbd [gaim-migrate @ 15437]
Mark Doliner <markdoliner@pidgin.im>
parents: 13063
diff changeset
512
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
513 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
514 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
515
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 /* 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
517 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
518 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
519 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
520 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
521 } 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
522 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
523 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
524 }
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 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
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
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 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
529 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
530 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
531 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
532 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
533 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
534 }
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
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 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
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
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 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
540 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
541 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
542 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
543
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
544 GetUserNameW((LPWSTR) &username, &dwLenUsername);
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
545
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
546 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
547 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
548 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
549
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 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
551
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
552 /* 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
553
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
554 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
555 && 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
556 && *(((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
557 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
558 ((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
559 -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
560 }
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 /* 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
562 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
563 /* 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
564
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
565 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
566 info = NULL;
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
567
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
568 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
569 && 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
570 && *(((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
571 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
572 ((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
573 -1, NULL, NULL, NULL);
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
574 }
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
575 }
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
576
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
577 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
578 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
579
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
580 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
581 fullname = g_utf16_to_utf8(username, -1, NULL, NULL, NULL);
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
582 }
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
583
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
584 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
585
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 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
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 #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
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 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
591 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
592 {
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 #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
594 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
595 #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
596 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
597 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
598 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
599
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 #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
601 /* 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
602 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
603 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
604 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
605 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
606 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
607 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
608 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
609 #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
610 /* 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
611 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
612 #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
613
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 /* 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
615 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
616 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
617 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
618 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
619 }
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
620
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
621 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
622 fullname = _("Purple Person");
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
623
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
624 /* Split the real name into a first and last name */
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
625 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
626 if (splitpoint != NULL) {
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
627 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
628 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
629
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 /* 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
631 * 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
632 */
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 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
634 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
635 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
636 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
637 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
638 } else {
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
639 default_firstname = g_strdup(fullname);
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
640 default_lastname = g_strdup("");
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
641 }
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
642
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
643 g_free(conv);
12003
6f6cbf74cb27 [gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents: 11984
diff changeset
644
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
645 /* Try to figure out a good host name to use */
13972
50b7226d8519 [gaim-migrate @ 16408]
Mark Doliner <markdoliner@pidgin.im>
parents: 13971
diff changeset
646 /* TODO: Avoid 'localhost,' if possible */
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
647 if (gethostname(hostname, 255) != 0) {
15996
ac5515cbcf4a Minor cleanup
Mark Doliner <markdoliner@pidgin.im>
parents: 15983
diff changeset
648 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
649 strerror(errno));
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
650 strcpy(hostname, "localhost");
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
651 }
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
652 default_hostname = g_strdup(hostname);
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
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
655 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
656 init_plugin(PurplePlugin *plugin)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
657 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
658 PurpleAccountUserSplit *split;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
659 PurpleAccountOption *option;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
660
11984
0ac04d1651b6 [gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents: 11966
diff changeset
661 initialize_default_account_values();
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
662
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
663 /* Creating the user splits */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
664 split = purple_account_user_split_new(_("Hostname"), default_hostname, '@');
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
665 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
666
11829
8d89f3c00831 [gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents: 11718
diff changeset
667 /* Creating the options for the protocol */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
668 option = purple_account_option_string_new(_("First name"), "first", default_firstname);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
669 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
670
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
671 option = purple_account_option_string_new(_("Last name"), "last", default_lastname);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
672 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
673
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
674 option = purple_account_option_string_new(_("E-mail"), "email", "");
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
675 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
676
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
677 option = purple_account_option_string_new(_("AIM Account"), "AIM", "");
13968
45f6a17eca9b [gaim-migrate @ 16400]
Jonty Wareing
parents: 13546
diff changeset
678 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
45f6a17eca9b [gaim-migrate @ 16400]
Jonty Wareing
parents: 13546
diff changeset
679
16961
b6955f946f8f s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents: 16823
diff changeset
680 option = purple_account_option_string_new(_("XMPP Account"), "jid", "");
13968
45f6a17eca9b [gaim-migrate @ 16400]
Jonty Wareing
parents: 13546
diff changeset
681 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
45f6a17eca9b [gaim-migrate @ 16400]
Jonty Wareing
parents: 13546
diff changeset
682
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
683 my_protocol = plugin;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
684 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
685
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15872
diff changeset
686 PURPLE_INIT_PLUGIN(bonjour, init_plugin, info);

mercurial