Sun, 05 Aug 2007 02:50:48 +0000
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
| 11477 | 1 | /* |
| 2 | * This program is free software; you can redistribute it and/or modify | |
| 3 | * it under the terms of the GNU General Public License as published by | |
| 4 | * the Free Software Foundation; either version 2 of the License, or | |
| 5 | * (at your option) any later version. | |
| 6 | * | |
| 7 | * This program is distributed in the hope that it will be useful, | |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 10 | * GNU Library General Public License for more details. | |
| 11 | * | |
| 12 | * You should have received a copy of the GNU General Public License | |
| 13 | * along with this program; if not, write to the Free Software | |
| 14 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 15 | */ | |
| 16 | ||
| 17 | #include <glib.h> | |
| 18 | #include <stdlib.h> | |
| 19 | ||
|
18338
d3cb08f27e04
More compile fixes from rekkanoryo for G_GNUC_NULL_TERMINATED issues
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17663
diff
changeset
|
20 | #include "internal.h" |
| 11477 | 21 | #include "buddy.h" |
| 22 | #include "account.h" | |
| 23 | #include "blist.h" | |
| 24 | #include "bonjour.h" | |
|
19093
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
25 | #include "mdns_interface.h" |
| 11477 | 26 | #include "debug.h" |
| 27 | ||
| 28 | /** | |
| 29 | * Creates a new buddy. | |
| 30 | */ | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
31 | BonjourBuddy * |
|
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:
15884
diff
changeset
|
32 | bonjour_buddy_new(const gchar *name, PurpleAccount* account) |
| 11477 | 33 | { |
|
17599
8b0aa6917c6d
Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
34 | BonjourBuddy *buddy = g_new0(BonjourBuddy, 1); |
| 11477 | 35 | |
|
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:
15884
diff
changeset
|
36 | buddy->account = account; |
| 11477 | 37 | buddy->name = g_strdup(name); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
38 | |
|
19093
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
39 | _mdns_init_buddy(buddy); |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
40 | |
| 11477 | 41 | return buddy; |
| 42 | } | |
| 43 | ||
|
17599
8b0aa6917c6d
Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
44 | void |
|
17611
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
45 | set_bonjour_buddy_value(BonjourBuddy* buddy, const char *record_key, const char *value, uint32_t len){ |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
46 | gchar **fld = NULL; |
|
17599
8b0aa6917c6d
Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
47 | |
|
17611
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
48 | if (!strcmp(record_key, "1st")) |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
49 | fld = &buddy->first; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
50 | else if(!strcmp(record_key, "email")) |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
51 | fld = &buddy->email; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
52 | else if(!strcmp(record_key, "ext")) |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
53 | fld = &buddy->ext; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
54 | else if(!strcmp(record_key, "jid")) |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
55 | fld = &buddy->jid; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
56 | else if(!strcmp(record_key, "last")) |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
57 | fld = &buddy->last; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
58 | else if(!strcmp(record_key, "msg")) |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
59 | fld = &buddy->msg; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
60 | else if(!strcmp(record_key, "nick")) |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
61 | fld = &buddy->nick; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
62 | else if(!strcmp(record_key, "node")) |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
63 | fld = &buddy->node; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
64 | else if(!strcmp(record_key, "phsh")) |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
65 | fld = &buddy->phsh; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
66 | else if(!strcmp(record_key, "status")) |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
67 | fld = &buddy->status; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
68 | else if(!strcmp(record_key, "vc")) |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
69 | fld = &buddy->vc; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
70 | else if(!strcmp(record_key, "ver")) |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
71 | fld = &buddy->ver; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
72 | else if(!strcmp(record_key, "AIM")) |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
73 | fld = &buddy->AIM; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
74 | |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
75 | if(fld == NULL) |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
76 | return; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
77 | |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
78 | g_free(*fld); |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
79 | *fld = NULL; |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17599
diff
changeset
|
80 | *fld = g_strndup(value, len); |
|
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:
15884
diff
changeset
|
81 | } |
|
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:
15884
diff
changeset
|
82 | |
| 11477 | 83 | /** |
| 84 | * Check if all the compulsory buddy data is present. | |
| 85 | */ | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
86 | gboolean |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
87 | bonjour_buddy_check(BonjourBuddy *buddy) |
| 11477 | 88 | { |
|
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:
15884
diff
changeset
|
89 | if (buddy->account == NULL) |
| 11477 | 90 | return FALSE; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
91 | |
|
17599
8b0aa6917c6d
Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
92 | if (buddy->name == NULL) |
| 11477 | 93 | return FALSE; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
94 | |
| 11477 | 95 | return TRUE; |
| 96 | } | |
| 97 | ||
| 98 | /** | |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
99 | * If the buddy does not yet exist, then create it and add it to |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
100 | * our buddy list. In either case we set the correct status for |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
101 | * the buddy. |
| 11477 | 102 | */ |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
103 | void |
|
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:
15884
diff
changeset
|
104 | bonjour_buddy_add_to_purple(BonjourBuddy *bonjour_buddy) |
| 11477 | 105 | { |
| 15884 | 106 | PurpleBuddy *buddy; |
| 107 | PurpleGroup *group; | |
|
19093
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
108 | PurpleAccount *account = bonjour_buddy->account; |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
109 | const char *status_id, *first, *last, *old_hash, *new_hash; |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
110 | gchar *alias = NULL; |
|
17599
8b0aa6917c6d
Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
111 | |
| 15884 | 112 | /* Translate between the Bonjour status and the Purple status */ |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
113 | if (g_ascii_strcasecmp("dnd", bonjour_buddy->status) == 0) |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
114 | status_id = BONJOUR_STATUS_ID_AWAY; |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
115 | else |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
116 | status_id = BONJOUR_STATUS_ID_AVAILABLE; |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
117 | |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
118 | /* |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
119 | * TODO: Figure out the idle time by getting the "away" |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
120 | * field from the DNS SD. |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
121 | */ |
| 11477 | 122 | |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
123 | /* Make sure the Bonjour group exists in our buddy list */ |
| 15884 | 124 | group = purple_find_group(BONJOUR_GROUP_NAME); /* Use the buddy's domain, instead? */ |
|
19093
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
125 | if (group == NULL) { |
| 15884 | 126 | group = purple_group_new(BONJOUR_GROUP_NAME); |
| 127 | purple_blist_add_group(group, NULL); | |
| 11477 | 128 | } |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
129 | |
|
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
130 | /* Make sure the buddy exists in our buddy list */ |
|
19093
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
131 | buddy = purple_find_buddy(account, bonjour_buddy->name); |
|
17599
8b0aa6917c6d
Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
132 | |
|
19093
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
133 | if (buddy == NULL) { |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
134 | buddy = purple_buddy_new(account, bonjour_buddy->name, NULL); |
|
11519
abb61e69b1cf
[gaim-migrate @ 13764]
Mark Doliner <markdoliner@pidgin.im>
parents:
11496
diff
changeset
|
135 | buddy->proto_data = bonjour_buddy; |
| 15884 | 136 | purple_blist_node_set_flags((PurpleBlistNode *)buddy, PURPLE_BLIST_NODE_FLAG_NO_SAVE); |
| 137 | purple_blist_add_buddy(buddy, NULL, group, NULL); | |
| 11477 | 138 | } |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
139 | |
|
19093
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
140 | /* Create the alias for the buddy using the first and the last name */ |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
141 | first = bonjour_buddy->first; |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
142 | last = bonjour_buddy->last; |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
143 | if ((first && *first) || (last && *last)) |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
144 | alias = g_strdup_printf("%s%s%s", |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
145 | (first && *first ? first : ""), |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
146 | (first && *first && last && *last ? " " : ""), |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
147 | (last && *last ? last : "")); |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
148 | serv_got_alias(purple_account_get_connection(account), buddy->name, alias); |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
149 | g_free(alias); |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
150 | |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
151 | /* Set the user's status */ |
|
11519
abb61e69b1cf
[gaim-migrate @ 13764]
Mark Doliner <markdoliner@pidgin.im>
parents:
11496
diff
changeset
|
152 | if (bonjour_buddy->msg != NULL) |
|
19093
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
153 | purple_prpl_got_user_status(account, buddy->name, status_id, |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
154 | "message", bonjour_buddy->msg, NULL); |
|
11519
abb61e69b1cf
[gaim-migrate @ 13764]
Mark Doliner <markdoliner@pidgin.im>
parents:
11496
diff
changeset
|
155 | else |
|
19093
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
156 | purple_prpl_got_user_status(account, buddy->name, status_id, 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:
15884
diff
changeset
|
157 | |
|
19093
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
158 | purple_prpl_got_user_idle(account, buddy->name, FALSE, 0); |
|
19094
b4d0fe1a515a
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents:
19093
diff
changeset
|
159 | |
|
b4d0fe1a515a
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents:
19093
diff
changeset
|
160 | /* TODO: Because we don't save Bonjour buddies in blist.xml, |
|
b4d0fe1a515a
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents:
19093
diff
changeset
|
161 | * we will always have to look up the buddy icon at login time. |
|
b4d0fe1a515a
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents:
19093
diff
changeset
|
162 | * I think we should figure out a way to do something about this. */ |
|
b4d0fe1a515a
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents:
19093
diff
changeset
|
163 | |
|
b4d0fe1a515a
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents:
19093
diff
changeset
|
164 | /* Deal with the buddy icon */ |
|
b4d0fe1a515a
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents:
19093
diff
changeset
|
165 | old_hash = purple_buddy_icons_get_checksum_for_user(buddy); |
|
b4d0fe1a515a
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents:
19093
diff
changeset
|
166 | new_hash = (bonjour_buddy->phsh && *(bonjour_buddy->phsh)) ? bonjour_buddy->phsh : NULL; |
|
b4d0fe1a515a
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents:
19093
diff
changeset
|
167 | if (new_hash && (!old_hash || strcmp(old_hash, new_hash) != 0)) { |
|
b4d0fe1a515a
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents:
19093
diff
changeset
|
168 | /* Look up the new icon data */ |
|
b4d0fe1a515a
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents:
19093
diff
changeset
|
169 | bonjour_dns_sd_retrieve_buddy_icon(bonjour_buddy); |
|
b4d0fe1a515a
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents:
19093
diff
changeset
|
170 | } else |
|
b4d0fe1a515a
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents:
19093
diff
changeset
|
171 | purple_buddy_icons_set_for_user(account, buddy->name, NULL, 0, NULL); |
| 11477 | 172 | } |
| 173 | ||
| 174 | /** | |
| 175 | * Deletes a buddy from memory. | |
| 176 | */ | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
177 | void |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
178 | bonjour_buddy_delete(BonjourBuddy *buddy) |
| 11477 | 179 | { |
| 180 | g_free(buddy->name); | |
| 17631 | 181 | g_free(buddy->ip); |
|
19094
b4d0fe1a515a
Implement bonjour buddy icons in the win32 implementation. Avahi's howl wrapper doesn't implement sw_discovery_query_record(), so we can't do it elsewhere yet.
Daniel Atallah <datallah@pidgin.im>
parents:
19093
diff
changeset
|
182 | g_free(buddy->full_service_name); |
| 17631 | 183 | |
| 11477 | 184 | g_free(buddy->first); |
| 185 | g_free(buddy->phsh); | |
| 186 | g_free(buddy->status); | |
| 187 | g_free(buddy->email); | |
| 188 | g_free(buddy->last); | |
| 189 | g_free(buddy->jid); | |
| 190 | g_free(buddy->AIM); | |
| 191 | g_free(buddy->vc); | |
| 192 | g_free(buddy->msg); | |
| 17631 | 193 | g_free(buddy->ext); |
| 194 | g_free(buddy->nick); | |
| 195 | g_free(buddy->node); | |
| 196 | g_free(buddy->ver); | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
197 | |
|
17663
fd736a4d91a9
Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <datallah@pidgin.im>
parents:
17631
diff
changeset
|
198 | bonjour_jabber_close_conversation(buddy->conversation); |
|
fd736a4d91a9
Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <datallah@pidgin.im>
parents:
17631
diff
changeset
|
199 | buddy->conversation = NULL; |
|
17599
8b0aa6917c6d
Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
200 | |
|
19093
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
201 | /* Clean up any mdns implementation data */ |
|
b2657106df0e
Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents:
18338
diff
changeset
|
202 | _mdns_delete_buddy(buddy); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11519
diff
changeset
|
203 | |
|
17599
8b0aa6917c6d
Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
204 | g_free(buddy); |
| 11477 | 205 | } |