Thu, 09 Aug 2007 22:37:06 +0000
Add data to the bonjour tooltip.
| 11477 | 1 | /* |
| 15884 | 2 | * purple - Bonjour Protocol Plugin |
| 11477 | 3 | * |
| 15884 | 4 | * Purple is the legal property of its developers, whose names are too numerous |
| 11477 | 5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 | * source distribution. | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 | */ | |
| 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> |
|
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
29 | #endif |
| 11477 | 30 | |
| 31 | #include "internal.h" | |
|
13061
ab3ef8e402e4
[gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents:
12970
diff
changeset
|
32 | |
| 11477 | 33 | #include "account.h" |
| 34 | #include "accountopt.h" | |
|
13061
ab3ef8e402e4
[gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents:
12970
diff
changeset
|
35 | #include "debug.h" |
|
ab3ef8e402e4
[gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents:
12970
diff
changeset
|
36 | #include "util.h" |
| 11477 | 37 | #include "version.h" |
| 38 | ||
| 39 | #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
|
40 | #include "mdns_common.h" |
| 11477 | 41 | #include "jabber.h" |
| 42 | #include "buddy.h" | |
| 43 | ||
|
12339
9333237efc4f
[gaim-migrate @ 14643]
Mark Doliner <markdoliner@pidgin.im>
parents:
12216
diff
changeset
|
44 | /* |
|
9333237efc4f
[gaim-migrate @ 14643]
Mark Doliner <markdoliner@pidgin.im>
parents:
12216
diff
changeset
|
45 | * TODO: Should implement an add_buddy callback that removes the buddy |
|
9333237efc4f
[gaim-migrate @ 14643]
Mark Doliner <markdoliner@pidgin.im>
parents:
12216
diff
changeset
|
46 | * from the local list. Bonjour manages buddies for you, and |
|
13061
ab3ef8e402e4
[gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents:
12970
diff
changeset
|
47 | * adding someone locally by hand is stupid. Or, maybe even better, |
|
ab3ef8e402e4
[gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents:
12970
diff
changeset
|
48 | * 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
|
49 | * users to add buddies. |
|
12339
9333237efc4f
[gaim-migrate @ 14643]
Mark Doliner <markdoliner@pidgin.im>
parents:
12216
diff
changeset
|
50 | */ |
|
9333237efc4f
[gaim-migrate @ 14643]
Mark Doliner <markdoliner@pidgin.im>
parents:
12216
diff
changeset
|
51 | |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
52 | static char *default_firstname; |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
53 | static char *default_lastname; |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
54 | static char *default_hostname; |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
55 | |
|
11691
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
56 | static void |
| 15884 | 57 | bonjour_removeallfromlocal(PurpleConnection *gc) |
|
11691
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
58 | { |
| 15884 | 59 | PurpleAccount *account = purple_connection_get_account(gc); |
| 60 | 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
|
61 | PurpleBlistNode *gnode, *cnode, *cnodenext, *bnode, *bnodenext; |
| 15884 | 62 | PurpleBuddy *buddy; |
|
11691
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
63 | |
| 15884 | 64 | blist = purple_get_blist(); |
|
11691
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
65 | if (blist == NULL) |
|
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
66 | return; |
|
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
67 | |
|
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
68 | /* Go through and remove all buddies that belong to this account */ |
|
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
69 | for (gnode = blist->root; gnode; gnode = gnode->next) |
|
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
70 | { |
| 15884 | 71 | if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
|
11691
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
72 | continue; |
|
15983
31740b53ecd3
Fix some reads of invalid memory when shutting down bonjour when there
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
73 | for (cnode = gnode->child; cnode; cnode = cnodenext) |
|
11691
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
74 | { |
|
15983
31740b53ecd3
Fix some reads of invalid memory when shutting down bonjour when there
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
75 | cnodenext = cnode->next; |
| 15884 | 76 | if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
|
11691
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
77 | continue; |
|
15983
31740b53ecd3
Fix some reads of invalid memory when shutting down bonjour when there
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
78 | for (bnode = cnode->child; bnode; bnode = bnodenext) |
|
11691
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
79 | { |
|
15983
31740b53ecd3
Fix some reads of invalid memory when shutting down bonjour when there
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
80 | bnodenext = bnode->next; |
| 15884 | 81 | if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
|
11691
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
82 | continue; |
| 15884 | 83 | buddy = (PurpleBuddy *)bnode; |
|
11691
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
84 | if (buddy->account != account) |
|
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
85 | continue; |
| 15884 | 86 | purple_prpl_got_user_status(account, buddy->name, "offline", NULL); |
| 87 | purple_blist_remove_buddy(buddy); | |
|
11691
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
88 | } |
|
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 | |
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12339
diff
changeset
|
93 | static void |
| 15884 | 94 | bonjour_login(PurpleAccount *account) |
| 11477 | 95 | { |
| 15884 | 96 | 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
|
97 | PurpleGroup *bonjour_group; |
|
b27a15168d33
Improve Bonjour error handling when there are errors "connecting".
Daniel Atallah <datallah@pidgin.im>
parents:
17608
diff
changeset
|
98 | BonjourData *bd; |
| 15884 | 99 | PurpleStatus *status; |
| 100 | PurplePresence *presence; | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
101 | |
| 15884 | 102 | 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
|
103 | gc->proto_data = bd = g_new0(BonjourData, 1); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
104 | |
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11718
diff
changeset
|
105 | /* Start waiting for jabber connections (iChat style) */ |
| 11477 | 106 | bd->jabber_data = g_new(BonjourJabber, 1); |
| 13971 | 107 | bd->jabber_data->port = BONJOUR_DEFAULT_PORT_INT; |
| 11477 | 108 | bd->jabber_data->account = account; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
109 | |
| 11477 | 110 | if (bonjour_jabber_start(bd->jabber_data) == -1) { |
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11718
diff
changeset
|
111 | /* Send a message about the connection error */ |
| 15884 | 112 | purple_connection_error(gc, _("Unable to listen for incoming IM connections\n")); |
| 11477 | 113 | return; |
| 114 | } | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
115 | |
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11718
diff
changeset
|
116 | /* Connect to the mDNS daemon looking for buddies in the LAN */ |
| 11477 | 117 | bd->dns_sd_data = bonjour_dns_sd_new(); |
| 15884 | 118 | bd->dns_sd_data->first = g_strdup(purple_account_get_string(account, "first", default_firstname)); |
| 119 | bd->dns_sd_data->last = g_strdup(purple_account_get_string(account, "last", default_lastname)); | |
| 13971 | 120 | 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
|
121 | /* 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
|
122 | bd->dns_sd_data->vc = g_strdup("!"); |
|
11834
9c0104f0b8c3
[gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents:
11829
diff
changeset
|
123 | |
| 15884 | 124 | status = purple_account_get_active_status(account); |
| 125 | presence = purple_account_get_presence(account); | |
| 126 | if (purple_presence_is_available(presence)) | |
|
11834
9c0104f0b8c3
[gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents:
11829
diff
changeset
|
127 | bd->dns_sd_data->status = g_strdup("avail"); |
| 15884 | 128 | else if (purple_presence_is_idle(presence)) |
|
11834
9c0104f0b8c3
[gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents:
11829
diff
changeset
|
129 | bd->dns_sd_data->status = g_strdup("away"); |
|
9c0104f0b8c3
[gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents:
11829
diff
changeset
|
130 | else |
|
9c0104f0b8c3
[gaim-migrate @ 14125]
Mark Doliner <markdoliner@pidgin.im>
parents:
11829
diff
changeset
|
131 | bd->dns_sd_data->status = g_strdup("dnd"); |
| 15884 | 132 | 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
|
133 | |
| 11477 | 134 | bd->dns_sd_data->account = account; |
|
11927
f9ede13499d0
[gaim-migrate @ 14218]
Mark Doliner <markdoliner@pidgin.im>
parents:
11841
diff
changeset
|
135 | if (!bonjour_dns_sd_start(bd->dns_sd_data)) |
|
f9ede13499d0
[gaim-migrate @ 14218]
Mark Doliner <markdoliner@pidgin.im>
parents:
11841
diff
changeset
|
136 | { |
| 15884 | 137 | 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
|
138 | return; |
|
f9ede13499d0
[gaim-migrate @ 14218]
Mark Doliner <markdoliner@pidgin.im>
parents:
11841
diff
changeset
|
139 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
140 | |
|
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
|
141 | 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
|
142 | |
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11718
diff
changeset
|
143 | /* Create a group for bonjour buddies */ |
| 15884 | 144 | bonjour_group = purple_group_new(BONJOUR_GROUP_NAME); |
| 145 | purple_blist_add_group(bonjour_group, NULL); | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
146 | |
| 15884 | 147 | /* Show the buddy list by telling Purple we have already connected */ |
| 148 | purple_connection_set_state(gc, PURPLE_CONNECTED); | |
| 11477 | 149 | } |
| 150 | ||
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12339
diff
changeset
|
151 | static void |
| 15884 | 152 | bonjour_close(PurpleConnection *connection) |
| 11477 | 153 | { |
| 15884 | 154 | PurpleGroup *bonjour_group; |
|
17632
b27a15168d33
Improve Bonjour error handling when there are errors "connecting".
Daniel Atallah <datallah@pidgin.im>
parents:
17608
diff
changeset
|
155 | BonjourData *bd = connection->proto_data; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
156 | |
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11718
diff
changeset
|
157 | /* Stop looking for buddies in the LAN */ |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
158 | if (bd->dns_sd_data != NULL) |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
159 | { |
| 11477 | 160 | bonjour_dns_sd_stop(bd->dns_sd_data); |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
161 | bonjour_dns_sd_free(bd->dns_sd_data); |
| 11477 | 162 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
163 | |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
164 | if (bd->jabber_data != NULL) |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
165 | { |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
166 | /* Stop waiting for conversations */ |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
167 | bonjour_jabber_stop(bd->jabber_data); |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
168 | g_free(bd->jabber_data); |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
169 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
170 | |
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11718
diff
changeset
|
171 | /* Remove all the bonjour buddies */ |
|
11691
d46ace30ec7e
[gaim-migrate @ 13977]
Mark Doliner <markdoliner@pidgin.im>
parents:
11539
diff
changeset
|
172 | bonjour_removeallfromlocal(connection); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
173 | |
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11718
diff
changeset
|
174 | /* Delete the bonjour group */ |
| 15884 | 175 | bonjour_group = purple_find_group(BONJOUR_GROUP_NAME); |
| 13063 | 176 | if (bonjour_group != NULL) |
| 15884 | 177 | purple_blist_remove_group(bonjour_group); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
178 | |
| 11477 | 179 | } |
| 180 | ||
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12339
diff
changeset
|
181 | static const char * |
| 15884 | 182 | bonjour_list_icon(PurpleAccount *account, PurpleBuddy *buddy) |
| 11477 | 183 | { |
| 184 | return BONJOUR_ICON_NAME; | |
| 185 | } | |
| 186 | ||
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12339
diff
changeset
|
187 | static int |
| 15884 | 188 | bonjour_send_im(PurpleConnection *connection, const char *to, const char *msg, PurpleMessageFlags flags) |
| 11477 | 189 | { |
| 190 | if(!to || !msg) | |
| 191 | return 0; | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
192 | |
|
11693
1a42a66ca0f8
[gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents:
11691
diff
changeset
|
193 | return bonjour_jabber_send_message(((BonjourData*)(connection->proto_data))->jabber_data, to, msg); |
| 11477 | 194 | } |
| 195 | ||
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12339
diff
changeset
|
196 | static void |
| 15884 | 197 | bonjour_set_status(PurpleAccount *account, PurpleStatus *status) |
| 11477 | 198 | { |
| 15884 | 199 | PurpleConnection *gc; |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
200 | BonjourData *bd; |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
201 | gboolean disconnected; |
| 15884 | 202 | PurpleStatusType *type; |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
203 | int primitive; |
| 15884 | 204 | PurplePresence *presence; |
|
11841
85773b4974fe
[gaim-migrate @ 14132]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11839
diff
changeset
|
205 | const char *message, *bonjour_status; |
|
13061
ab3ef8e402e4
[gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents:
12970
diff
changeset
|
206 | gchar *stripped; |
| 11477 | 207 | |
| 15884 | 208 | gc = purple_account_get_connection(account); |
|
11839
bb7002373bb6
[gaim-migrate @ 14130]
Mark Doliner <markdoliner@pidgin.im>
parents:
11837
diff
changeset
|
209 | bd = gc->proto_data; |
| 15884 | 210 | disconnected = purple_account_is_disconnected(account); |
| 211 | type = purple_status_get_type(status); | |
| 212 | primitive = purple_status_type_get_primitive(type); | |
| 213 | presence = purple_account_get_presence(account); | |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
214 | |
| 15884 | 215 | message = purple_status_get_attr_string(status, "message"); |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
216 | if (message == NULL) |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
217 | message = ""; |
| 15884 | 218 | stripped = purple_markup_strip_html(message); |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
219 | |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
220 | /* |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
221 | * The three possible status for Bonjour are |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
222 | * -available ("avail") |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
223 | * -idle ("away") |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
224 | * -away ("dnd") |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
225 | * Each of them can have an optional message. |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
226 | */ |
| 15884 | 227 | if (purple_presence_is_available(presence)) |
|
11841
85773b4974fe
[gaim-migrate @ 14132]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11839
diff
changeset
|
228 | bonjour_status = "avail"; |
| 15884 | 229 | else if (purple_presence_is_idle(presence)) |
|
11841
85773b4974fe
[gaim-migrate @ 14132]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11839
diff
changeset
|
230 | bonjour_status = "away"; |
|
11835
da95d476b481
[gaim-migrate @ 14126]
Mark Doliner <markdoliner@pidgin.im>
parents:
11834
diff
changeset
|
231 | else |
|
11841
85773b4974fe
[gaim-migrate @ 14132]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11839
diff
changeset
|
232 | bonjour_status = "dnd"; |
| 11477 | 233 | |
|
13061
ab3ef8e402e4
[gaim-migrate @ 15423]
Mark Doliner <markdoliner@pidgin.im>
parents:
12970
diff
changeset
|
234 | 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
|
235 | g_free(stripped); |
| 11477 | 236 | } |
| 237 | ||
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
238 | static GList * |
| 15884 | 239 | bonjour_status_types(PurpleAccount *account) |
| 11477 | 240 | { |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
241 | GList *status_types = NULL; |
| 15884 | 242 | PurpleStatusType *type; |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
243 | |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
244 | g_return_val_if_fail(account != NULL, NULL); |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
245 | |
| 15884 | 246 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE, |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
247 | BONJOUR_STATUS_ID_AVAILABLE, |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
248 | NULL, TRUE, TRUE, FALSE, |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
249 | "message", _("Message"), |
| 15884 | 250 | purple_value_new(PURPLE_TYPE_STRING), NULL); |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
251 | status_types = g_list_append(status_types, type); |
| 11477 | 252 | |
| 15884 | 253 | type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY, |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
254 | BONJOUR_STATUS_ID_AWAY, |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
255 | NULL, TRUE, TRUE, FALSE, |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
256 | "message", _("Message"), |
| 15884 | 257 | purple_value_new(PURPLE_TYPE_STRING), NULL); |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
258 | status_types = g_list_append(status_types, type); |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
259 | |
| 15884 | 260 | type = purple_status_type_new_full(PURPLE_STATUS_OFFLINE, |
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12650
diff
changeset
|
261 | BONJOUR_STATUS_ID_OFFLINE, |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12650
diff
changeset
|
262 | NULL, TRUE, TRUE, FALSE); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12650
diff
changeset
|
263 | status_types = g_list_append(status_types, type); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12650
diff
changeset
|
264 | |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
265 | return status_types; |
| 11477 | 266 | } |
| 267 | ||
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
268 | static void |
| 15884 | 269 | bonjour_convo_closed(PurpleConnection *connection, const char *who) |
| 11477 | 270 | { |
| 15884 | 271 | 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
|
272 | BonjourBuddy *bb; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
273 | |
|
11966
ad12fc2943ca
[gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents:
11927
diff
changeset
|
274 | if (buddy == NULL) |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
275 | { |
|
11966
ad12fc2943ca
[gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents:
11927
diff
changeset
|
276 | /* |
|
ad12fc2943ca
[gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents:
11927
diff
changeset
|
277 | * 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
|
278 | * exist, so we won't have any data about them. |
|
ad12fc2943ca
[gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents:
11927
diff
changeset
|
279 | */ |
|
ad12fc2943ca
[gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents:
11927
diff
changeset
|
280 | return; |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12489
diff
changeset
|
281 | } |
|
11966
ad12fc2943ca
[gaim-migrate @ 14258]
Mark Doliner <markdoliner@pidgin.im>
parents:
11927
diff
changeset
|
282 | |
|
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
|
283 | 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
|
284 | 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
|
285 | bb->conversation = NULL; |
| 11477 | 286 | } |
| 287 | ||
|
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
|
288 | 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
|
289 | 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
|
290 | { |
|
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
|
291 | 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
|
292 | 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
|
293 | } |
|
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
|
294 | |
|
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
|
295 | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
296 | static char * |
| 15884 | 297 | bonjour_status_text(PurpleBuddy *buddy) |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
298 | { |
|
19218
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
299 | const PurplePresence *presence; |
|
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
300 | const PurpleStatus *status; |
|
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
301 | const char *message; |
|
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
302 | gchar *ret = NULL; |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
303 | |
| 15884 | 304 | 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
|
305 | status = purple_presence_get_active_status(presence); |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
306 | |
|
19218
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
307 | message = purple_status_get_attr_string(status, "message"); |
|
12339
9333237efc4f
[gaim-migrate @ 14643]
Mark Doliner <markdoliner@pidgin.im>
parents:
12216
diff
changeset
|
308 | |
|
19218
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
309 | if (message != NULL) { |
|
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
310 | 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
|
311 | purple_util_chrreplace(ret, '\n', ' '); |
|
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
312 | } |
|
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
313 | |
|
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
314 | return ret; |
| 11477 | 315 | } |
| 316 | ||
|
12970
c2f3b4dcf711
[gaim-migrate @ 15323]
Richard Laager <rlaager@pidgin.im>
parents:
12943
diff
changeset
|
317 | static void |
| 15884 | 318 | bonjour_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full) |
| 11477 | 319 | { |
| 15884 | 320 | PurplePresence *presence; |
| 321 | PurpleStatus *status; | |
|
19219
e1ef7cdd283a
Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents:
19218
diff
changeset
|
322 | BonjourBuddy *bb = buddy->proto_data; |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
323 | const char *status_description; |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
324 | const char *message; |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
325 | |
| 15884 | 326 | presence = purple_buddy_get_presence(buddy); |
| 327 | status = purple_presence_get_active_status(presence); | |
| 328 | message = purple_status_get_attr_string(status, "message"); | |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
329 | |
| 15884 | 330 | if (purple_presence_is_available(presence)) |
| 331 | status_description = purple_status_get_name(status); | |
| 332 | else if (purple_presence_is_idle(presence)) | |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
333 | status_description = _("Idle"); |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
334 | else |
| 15884 | 335 | status_description = purple_status_get_name(status); |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
336 | |
| 15884 | 337 | 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
|
338 | if (message != NULL) |
| 15884 | 339 | 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
|
340 | |
|
e1ef7cdd283a
Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents:
19218
diff
changeset
|
341 | /* 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
|
342 | if (bb->nick != NULL) { |
|
e1ef7cdd283a
Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents:
19218
diff
changeset
|
343 | if (bb->first != NULL) |
|
e1ef7cdd283a
Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents:
19218
diff
changeset
|
344 | 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
|
345 | if (bb->first != NULL) |
|
e1ef7cdd283a
Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents:
19218
diff
changeset
|
346 | 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
|
347 | } |
|
e1ef7cdd283a
Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents:
19218
diff
changeset
|
348 | |
|
e1ef7cdd283a
Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents:
19218
diff
changeset
|
349 | if (bb->email != NULL) |
|
e1ef7cdd283a
Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents:
19218
diff
changeset
|
350 | 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
|
351 | |
|
e1ef7cdd283a
Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents:
19218
diff
changeset
|
352 | if (bb->AIM != NULL) |
|
e1ef7cdd283a
Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents:
19218
diff
changeset
|
353 | 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
|
354 | |
|
e1ef7cdd283a
Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents:
19218
diff
changeset
|
355 | if (bb->jid!= NULL) |
|
e1ef7cdd283a
Add data to the bonjour tooltip.
Daniel Atallah <datallah@pidgin.im>
parents:
19218
diff
changeset
|
356 | purple_notify_user_info_add_pair(user_info, _("XMPP Account"), bb->jid); |
| 11477 | 357 | } |
| 358 | ||
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
359 | static gboolean |
| 15884 | 360 | plugin_unload(PurplePlugin *plugin) |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
361 | { |
|
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
|
362 | /* 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
|
363 | |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
364 | g_free(default_firstname); |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
365 | g_free(default_lastname); |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
366 | g_free(default_hostname); |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
367 | |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
368 | return TRUE; |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
369 | } |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
370 | |
| 15884 | 371 | static PurplePlugin *my_protocol = NULL; |
| 11477 | 372 | |
| 15884 | 373 | static PurplePluginProtocolInfo prpl_info = |
| 11477 | 374 | { |
| 375 | OPT_PROTO_NO_PASSWORD, | |
| 376 | NULL, /* user_splits */ | |
| 377 | 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
|
378 | {"png,gif,jpeg", 0, 0, 96, 96, 65535, PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */ |
| 11477 | 379 | bonjour_list_icon, /* list_icon */ |
|
19218
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
380 | NULL, /* list_emblem */ |
| 11477 | 381 | bonjour_status_text, /* status_text */ |
| 382 | bonjour_tooltip_text, /* tooltip_text */ | |
| 383 | bonjour_status_types, /* status_types */ | |
| 384 | NULL, /* blist_node_menu */ | |
| 385 | NULL, /* chat_info */ | |
| 386 | NULL, /* chat_info_defaults */ | |
| 387 | bonjour_login, /* login */ | |
| 388 | bonjour_close, /* close */ | |
| 389 | bonjour_send_im, /* send_im */ | |
| 390 | NULL, /* set_info */ | |
| 391 | NULL, /* send_typing */ | |
| 392 | NULL, /* get_info */ | |
| 393 | bonjour_set_status, /* set_status */ | |
| 394 | NULL, /* set_idle */ | |
| 395 | NULL, /* change_passwd */ | |
| 396 | NULL, /* add_buddy */ | |
| 397 | NULL, /* add_buddies */ | |
| 398 | NULL, /* remove_buddy */ | |
| 399 | NULL, /* remove_buddies */ | |
| 400 | NULL, /* add_permit */ | |
| 401 | NULL, /* add_deny */ | |
| 402 | NULL, /* rem_permit */ | |
| 403 | NULL, /* rem_deny */ | |
| 404 | NULL, /* set_permit_deny */ | |
| 405 | NULL, /* join_chat */ | |
| 406 | NULL, /* reject_chat */ | |
| 407 | NULL, /* get_chat_name */ | |
| 408 | NULL, /* chat_invite */ | |
| 409 | NULL, /* chat_leave */ | |
| 410 | NULL, /* chat_whisper */ | |
| 411 | NULL, /* chat_send */ | |
| 412 | NULL, /* keepalive */ | |
| 413 | NULL, /* register_user */ | |
| 414 | NULL, /* get_cb_info */ | |
| 415 | NULL, /* get_cb_away */ | |
| 416 | NULL, /* alias_buddy */ | |
| 417 | NULL, /* group_buddy */ | |
| 418 | NULL, /* rename_group */ | |
| 419 | NULL, /* buddy_free */ | |
| 420 | bonjour_convo_closed, /* convo_closed */ | |
| 421 | 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
|
422 | bonjour_set_buddy_icon, /* set_buddy_icon */ |
| 11477 | 423 | NULL, /* remove_group */ |
| 424 | NULL, /* get_cb_real_name */ | |
| 425 | NULL, /* set_chat_topic */ | |
| 426 | NULL, /* find_blist_chat */ | |
| 427 | NULL, /* roomlist_get_list */ | |
| 428 | NULL, /* roomlist_cancel */ | |
| 429 | NULL, /* roomlist_expand_category */ | |
| 430 | NULL, /* can_receive_file */ | |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12003
diff
changeset
|
431 | NULL, /* send_file */ |
|
12607
4622f0adedf4
[gaim-migrate @ 14943]
Mark Doliner <markdoliner@pidgin.im>
parents:
12595
diff
changeset
|
432 | NULL, /* new_xfer */ |
|
12650
ca70a14f4994
[gaim-migrate @ 14988]
Mark Doliner <markdoliner@pidgin.im>
parents:
12607
diff
changeset
|
433 | NULL, /* offline_message */ |
|
12607
4622f0adedf4
[gaim-migrate @ 14943]
Mark Doliner <markdoliner@pidgin.im>
parents:
12595
diff
changeset
|
434 | NULL, /* whiteboard_prpl_ops */ |
|
15217
53af6e98dfff
[gaim-migrate @ 17941]
Mark Doliner <markdoliner@pidgin.im>
parents:
14604
diff
changeset
|
435 | NULL, /* send_raw */ |
|
53af6e98dfff
[gaim-migrate @ 17941]
Mark Doliner <markdoliner@pidgin.im>
parents:
14604
diff
changeset
|
436 | 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
|
437 | |
|
c9301dd6aa1f
Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents:
15996
diff
changeset
|
438 | /* 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
|
439 | 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
|
440 | 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
|
441 | 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
|
442 | NULL |
| 11477 | 443 | }; |
| 444 | ||
| 15884 | 445 | static PurplePluginInfo info = |
| 11477 | 446 | { |
| 15884 | 447 | PURPLE_PLUGIN_MAGIC, |
| 448 | PURPLE_MAJOR_VERSION, | |
| 449 | PURPLE_MINOR_VERSION, | |
|
19218
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
450 | PURPLE_PLUGIN_PROTOCOL, /**< type */ |
| 11477 | 451 | NULL, /**< ui_requirement */ |
| 452 | 0, /**< flags */ | |
| 453 | NULL, /**< dependencies */ | |
|
19218
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
454 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 11477 | 455 | |
| 456 | "prpl-bonjour", /**< id */ | |
| 457 | "Bonjour", /**< name */ | |
| 458 | VERSION, /**< version */ | |
| 459 | /** summary */ | |
| 460 | N_("Bonjour Protocol Plugin"), | |
| 461 | /** description */ | |
| 462 | N_("Bonjour Protocol Plugin"), | |
| 463 | NULL, /**< author */ | |
|
19218
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
464 | PURPLE_WEBSITE, /**< homepage */ |
| 11477 | 465 | |
| 466 | NULL, /**< load */ | |
|
19218
cb1f18ee620b
Show bonjour status messages in the buddy list.
Daniel Atallah <datallah@pidgin.im>
parents:
19204
diff
changeset
|
467 | plugin_unload, /**< unload */ |
| 11477 | 468 | NULL, /**< destroy */ |
| 469 | ||
| 470 | NULL, /**< ui_info */ | |
| 471 | &prpl_info, /**< extra_info */ | |
| 472 | 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
|
473 | 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
|
474 | |
|
c9301dd6aa1f
Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents:
15996
diff
changeset
|
475 | /* 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
|
476 | 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
|
477 | 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
|
478 | NULL, |
| 11477 | 479 | NULL |
| 480 | }; | |
| 481 | ||
| 482 | static void | |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
483 | initialize_default_account_values() |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
484 | { |
|
13192
77a782e38011
[gaim-migrate @ 15554]
Mark Doliner <markdoliner@pidgin.im>
parents:
13076
diff
changeset
|
485 | #ifdef _WIN32 |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
486 | char *fullname = NULL; |
|
13192
77a782e38011
[gaim-migrate @ 15554]
Mark Doliner <markdoliner@pidgin.im>
parents:
13076
diff
changeset
|
487 | #else |
|
77a782e38011
[gaim-migrate @ 15554]
Mark Doliner <markdoliner@pidgin.im>
parents:
13076
diff
changeset
|
488 | struct passwd *info; |
|
77a782e38011
[gaim-migrate @ 15554]
Mark Doliner <markdoliner@pidgin.im>
parents:
13076
diff
changeset
|
489 | const char *fullname = NULL; |
|
77a782e38011
[gaim-migrate @ 15554]
Mark Doliner <markdoliner@pidgin.im>
parents:
13076
diff
changeset
|
490 | #endif |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
491 | char *splitpoint = NULL; |
|
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
|
492 | char *tmp; |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
493 | char hostname[255]; |
|
13192
77a782e38011
[gaim-migrate @ 15554]
Mark Doliner <markdoliner@pidgin.im>
parents:
13076
diff
changeset
|
494 | |
|
12003
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
495 | #ifndef _WIN32 |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
496 | /* Try to figure out the user's real name */ |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
497 | info = getpwuid(getuid()); |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
498 | if ((info != NULL) && (info->pw_gecos != NULL) && (info->pw_gecos[0] != '\0')) |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
499 | fullname = info->pw_gecos; |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
500 | else if ((info != NULL) && (info->pw_name != NULL) && (info->pw_name[0] != '\0')) |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
501 | fullname = info->pw_name; |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
502 | else if (((fullname = getlogin()) != NULL) && (fullname[0] != '\0')) |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
503 | ; |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
504 | else |
| 15996 | 505 | fullname = _("Purple Person"); |
|
13076
84dfc467ddbd
[gaim-migrate @ 15437]
Mark Doliner <markdoliner@pidgin.im>
parents:
13063
diff
changeset
|
506 | /* Make sure fullname is valid UTF-8. If not, try to convert it. */ |
|
84dfc467ddbd
[gaim-migrate @ 15437]
Mark Doliner <markdoliner@pidgin.im>
parents:
13063
diff
changeset
|
507 | if (!g_utf8_validate(fullname, -1, NULL)) |
|
84dfc467ddbd
[gaim-migrate @ 15437]
Mark Doliner <markdoliner@pidgin.im>
parents:
13063
diff
changeset
|
508 | { |
|
84dfc467ddbd
[gaim-migrate @ 15437]
Mark Doliner <markdoliner@pidgin.im>
parents:
13063
diff
changeset
|
509 | gchar *tmp; |
|
84dfc467ddbd
[gaim-migrate @ 15437]
Mark Doliner <markdoliner@pidgin.im>
parents:
13063
diff
changeset
|
510 | tmp = g_locale_to_utf8(fullname, -1, NULL, NULL, NULL); |
|
84dfc467ddbd
[gaim-migrate @ 15437]
Mark Doliner <markdoliner@pidgin.im>
parents:
13063
diff
changeset
|
511 | if ((tmp == NULL) || (*tmp == '\0')) |
|
15498
2ee3112b6f24
This should be the last of the string changes
Sean Egan <seanegan@pidgin.im>
parents:
15444
diff
changeset
|
512 | fullname = _("Purple Person"); |
|
13076
84dfc467ddbd
[gaim-migrate @ 15437]
Mark Doliner <markdoliner@pidgin.im>
parents:
13063
diff
changeset
|
513 | } |
|
84dfc467ddbd
[gaim-migrate @ 15437]
Mark Doliner <markdoliner@pidgin.im>
parents:
13063
diff
changeset
|
514 | |
|
12003
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
515 | #else |
|
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
|
516 | 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
|
517 | 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
|
518 | |
|
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
|
519 | if (!GetUserNameW((LPWSTR) &username, &dwLenUsername)) |
|
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
|
520 | purple_debug_warning("bonjour", "Unable to look up username\n"); |
|
12003
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
521 | |
|
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
|
522 | 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
|
523 | 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
|
524 | 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
|
525 | |
|
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
|
526 | 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
|
527 | |
|
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
|
528 | 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
|
529 | |
|
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
|
530 | 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
|
531 | && 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
|
532 | && *(((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
|
533 | 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
|
534 | ((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
|
535 | -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
|
536 | } |
|
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
|
537 | /* 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
|
538 | else if (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
|
539 | 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
|
540 | |
|
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 | 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
|
542 | info = NULL; |
|
12003
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
543 | |
|
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
|
544 | 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
|
545 | && 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
|
546 | && *(((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
|
547 | 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
|
548 | ((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
|
549 | -1, NULL, NULL, NULL); |
|
12003
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
550 | } |
|
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
551 | } |
|
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
552 | |
|
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
|
553 | 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
|
554 | if (servername != NULL) NetApiBufferFree(servername); |
|
12003
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
555 | } |
|
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
556 | |
|
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
|
557 | if (!fullname) { |
|
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 | 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
|
559 | fullname = g_utf16_to_utf8(username, -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 | else |
|
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 | fullname = g_strdup(_("Purple Person")); |
|
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 | } |
|
12003
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
563 | #endif |
|
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
564 | |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
565 | /* Split the real name into a first and last name */ |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
566 | splitpoint = strchr(fullname, ' '); |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
567 | if (splitpoint != NULL) |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
568 | { |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
569 | 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
|
570 | 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
|
571 | |
|
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
|
572 | /* 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
|
573 | * 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
|
574 | */ |
|
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
|
575 | 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
|
576 | 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
|
577 | 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
|
578 | 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
|
579 | default_lastname = g_strdup(tmp); |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
580 | } |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
581 | else |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
582 | { |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
583 | default_firstname = g_strdup(fullname); |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
584 | default_lastname = g_strdup(""); |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
585 | } |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
586 | |
|
12003
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
587 | #ifdef _WIN32 |
|
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
588 | g_free(fullname); |
|
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
589 | #endif |
|
6f6cbf74cb27
[gaim-migrate @ 14296]
Daniel Atallah <datallah@pidgin.im>
parents:
11984
diff
changeset
|
590 | |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
591 | /* Try to figure out a good host name to use */ |
|
13972
50b7226d8519
[gaim-migrate @ 16408]
Mark Doliner <markdoliner@pidgin.im>
parents:
13971
diff
changeset
|
592 | /* TODO: Avoid 'localhost,' if possible */ |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
593 | if (gethostname(hostname, 255) != 0) { |
| 15996 | 594 | purple_debug_warning("bonjour", "Error when getting host name: %s. Using \"localhost.\"\n", |
| 595 | strerror(errno)); | |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
596 | strcpy(hostname, "localhost"); |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
597 | } |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
598 | default_hostname = g_strdup(hostname); |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
599 | } |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
600 | |
|
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
601 | static void |
| 15884 | 602 | init_plugin(PurplePlugin *plugin) |
| 11477 | 603 | { |
| 15884 | 604 | PurpleAccountUserSplit *split; |
| 605 | PurpleAccountOption *option; | |
| 11477 | 606 | |
|
11984
0ac04d1651b6
[gaim-migrate @ 14277]
Mark Doliner <markdoliner@pidgin.im>
parents:
11966
diff
changeset
|
607 | initialize_default_account_values(); |
| 11477 | 608 | |
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11718
diff
changeset
|
609 | /* Creating the user splits */ |
| 15884 | 610 | split = purple_account_user_split_new(_("Hostname"), default_hostname, '@'); |
| 11477 | 611 | 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
|
612 | |
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11718
diff
changeset
|
613 | /* Creating the options for the protocol */ |
| 15884 | 614 | option = purple_account_option_string_new(_("First name"), "first", default_firstname); |
| 11477 | 615 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 616 | ||
| 15884 | 617 | option = purple_account_option_string_new(_("Last name"), "last", default_lastname); |
| 11477 | 618 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 619 | ||
| 15884 | 620 | option = purple_account_option_string_new(_("E-mail"), "email", ""); |
| 11477 | 621 | 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
|
622 | |
| 15884 | 623 | option = purple_account_option_string_new(_("AIM Account"), "AIM", ""); |
| 13968 | 624 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 625 | ||
|
16961
b6955f946f8f
s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents:
16823
diff
changeset
|
626 | option = purple_account_option_string_new(_("XMPP Account"), "jid", ""); |
| 13968 | 627 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 628 | ||
| 11477 | 629 | my_protocol = plugin; |
| 630 | } | |
| 631 | ||
| 15884 | 632 | PURPLE_INIT_PLUGIN(bonjour, init_plugin, info); |