Mon, 18 Jun 2007 01:48:35 +0000
explicit merge of '87854ccfae544467c988edbac854c1ae2018eed4'
and '4fe92c2fa5afd77565c3b27aba6c2b9674a88322'
| 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 | ||
|
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
|
17 | #include "mdns_howl.h" |
| 11477 | 18 | |
|
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
|
19 | #include "debug.h" |
| 11477 | 20 | #include "buddy.h" |
| 21 | ||
|
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
|
22 | sw_result HOWL_API |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
23 | _publish_reply(sw_discovery discovery, sw_discovery_oid oid, |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
24 | sw_discovery_publish_status status, sw_opaque extra) |
| 11477 | 25 | { |
| 15884 | 26 | purple_debug_warning("bonjour", "_publish_reply --> Start\n"); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
27 | |
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11773
diff
changeset
|
28 | /* Check the answer from the mDNS daemon */ |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
29 | switch (status) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
30 | { |
| 11477 | 31 | case SW_DISCOVERY_PUBLISH_STARTED : |
| 15884 | 32 | purple_debug_info("bonjour", "_publish_reply --> Service started\n"); |
| 11477 | 33 | break; |
| 34 | case SW_DISCOVERY_PUBLISH_STOPPED : | |
| 15884 | 35 | purple_debug_info("bonjour", "_publish_reply --> Service stopped\n"); |
| 11477 | 36 | break; |
| 37 | case SW_DISCOVERY_PUBLISH_NAME_COLLISION : | |
| 15884 | 38 | purple_debug_info("bonjour", "_publish_reply --> Name collision\n"); |
| 11477 | 39 | break; |
| 40 | case SW_DISCOVERY_PUBLISH_INVALID : | |
| 15884 | 41 | purple_debug_info("bonjour", "_publish_reply --> Service invalid\n"); |
| 11477 | 42 | break; |
| 43 | } | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
44 | |
| 11477 | 45 | return SW_OKAY; |
| 46 | } | |
| 47 | ||
|
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
|
48 | sw_result HOWL_API |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
49 | _resolve_reply(sw_discovery discovery, sw_discovery_oid oid, |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
50 | sw_uint32 interface_index, sw_const_string name, |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
51 | sw_const_string type, sw_const_string domain, |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
52 | sw_ipv4_address address, sw_port port, |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
53 | sw_octets text_record, sw_ulong text_record_len, |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
54 | sw_opaque extra) |
| 11477 | 55 | { |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
56 | BonjourBuddy *buddy; |
| 15884 | 57 | PurpleAccount *account = (PurpleAccount*)extra; |
| 11477 | 58 | gint address_length = 16; |
| 59 | sw_text_record_iterator iterator; | |
|
11498
e48f1ed75fd7
[gaim-migrate @ 13743]
Mark Doliner <markdoliner@pidgin.im>
parents:
11496
diff
changeset
|
60 | char key[SW_TEXT_RECORD_MAX_LEN]; |
|
e48f1ed75fd7
[gaim-migrate @ 13743]
Mark Doliner <markdoliner@pidgin.im>
parents:
11496
diff
changeset
|
61 | char value[SW_TEXT_RECORD_MAX_LEN]; |
| 11477 | 62 | sw_uint32 value_length; |
| 63 | ||
| 64 | sw_discovery_cancel(discovery, oid); | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
65 | |
|
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
|
66 | /* create a buddy record */ |
|
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
|
67 | buddy = bonjour_buddy_new(name, account); |
|
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
|
68 | |
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11773
diff
changeset
|
69 | /* Get the ip as a string */ |
|
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
|
70 | buddy->ip = g_malloc(address_length); |
|
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
|
71 | sw_ipv4_address_name(address, buddy->ip, address_length); |
|
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
|
72 | |
|
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
|
73 | buddy->port_p2pj = port; |
| 11477 | 74 | |
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11773
diff
changeset
|
75 | /* Obtain the parameters from the text_record */ |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
76 | if ((text_record_len > 0) && (text_record) && (*text_record != '\0')) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
77 | { |
| 11477 | 78 | sw_text_record_iterator_init(&iterator, text_record, text_record_len); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
79 | while (sw_text_record_iterator_next(iterator, key, (sw_octet *)value, &value_length) == SW_OKAY) |
|
17611
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17610
diff
changeset
|
80 | set_bonjour_buddy_value(buddy, key, value, value_length); |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17610
diff
changeset
|
81 | |
|
1f221c4f82d6
Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents:
17610
diff
changeset
|
82 | sw_text_record_iterator_fina(iterator); |
| 11477 | 83 | } |
| 84 | ||
|
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
|
85 | if (!bonjour_buddy_check(buddy)) |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
86 | { |
|
13650
8c1043337393
[gaim-migrate @ 16050]
Mark Doliner <markdoliner@pidgin.im>
parents:
13063
diff
changeset
|
87 | bonjour_buddy_delete(buddy); |
| 11477 | 88 | return SW_DISCOVERY_E_UNKNOWN; |
| 89 | } | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
90 | |
|
11496
0f61069a4a3f
[gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents:
11477
diff
changeset
|
91 | /* Add or update the buddy in our buddy list */ |
|
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
|
92 | bonjour_buddy_add_to_purple(buddy); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
93 | |
| 11477 | 94 | return SW_OKAY; |
| 95 | } | |
| 96 | ||
|
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
|
97 | sw_result HOWL_API |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
98 | _browser_reply(sw_discovery discovery, sw_discovery_oid oid, |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
99 | sw_discovery_browse_status status, |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
100 | sw_uint32 interface_index, sw_const_string name, |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
101 | sw_const_string type, sw_const_string domain, |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
102 | sw_opaque_t extra) |
| 11477 | 103 | { |
| 104 | sw_discovery_resolve_id rid; | |
| 15884 | 105 | PurpleAccount *account = (PurpleAccount*)extra; |
| 106 | PurpleBuddy *gb = NULL; | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
107 | |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
108 | switch (status) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
109 | { |
| 11477 | 110 | case SW_DISCOVERY_BROWSE_INVALID: |
| 15884 | 111 | purple_debug_warning("bonjour", "_browser_reply --> Invalid\n"); |
| 11477 | 112 | break; |
| 113 | case SW_DISCOVERY_BROWSE_RELEASE: | |
| 15884 | 114 | purple_debug_warning("bonjour", "_browser_reply --> Release\n"); |
| 11477 | 115 | break; |
| 116 | case SW_DISCOVERY_BROWSE_ADD_DOMAIN: | |
| 15884 | 117 | purple_debug_warning("bonjour", "_browser_reply --> Add domain\n"); |
| 11477 | 118 | break; |
| 119 | case SW_DISCOVERY_BROWSE_ADD_DEFAULT_DOMAIN: | |
| 15884 | 120 | purple_debug_warning("bonjour", "_browser_reply --> Add default domain\n"); |
| 11477 | 121 | break; |
| 122 | case SW_DISCOVERY_BROWSE_REMOVE_DOMAIN: | |
| 15884 | 123 | purple_debug_warning("bonjour", "_browser_reply --> Remove domain\n"); |
| 11477 | 124 | break; |
| 125 | case SW_DISCOVERY_BROWSE_ADD_SERVICE: | |
| 13971 | 126 | /* A new peer has joined the network and uses iChat bonjour */ |
| 15884 | 127 | purple_debug_info("bonjour", "_browser_reply --> Add service\n"); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
128 | if (g_ascii_strcasecmp(name, account->username) != 0) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
129 | { |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
130 | if (sw_discovery_resolve(discovery, interface_index, name, type, |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
131 | domain, _resolve_reply, extra, &rid) != SW_OKAY) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
132 | { |
| 15884 | 133 | purple_debug_warning("bonjour", "_browser_reply --> Cannot send resolve\n"); |
| 11477 | 134 | } |
| 135 | } | |
| 136 | break; | |
| 137 | case SW_DISCOVERY_BROWSE_REMOVE_SERVICE: | |
| 15884 | 138 | purple_debug_info("bonjour", "_browser_reply --> Remove service\n"); |
| 139 | gb = purple_find_buddy((PurpleAccount*)extra, name); | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
140 | if (gb != NULL) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
141 | { |
| 11477 | 142 | bonjour_buddy_delete(gb->proto_data); |
| 15884 | 143 | purple_blist_remove_buddy(gb); |
| 11477 | 144 | } |
| 145 | break; | |
| 146 | case SW_DISCOVERY_BROWSE_RESOLVED: | |
| 15884 | 147 | purple_debug_info("bonjour", "_browse_reply --> Resolved\n"); |
| 11477 | 148 | break; |
| 149 | default: | |
| 150 | break; | |
| 151 | } | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
152 | |
| 11477 | 153 | return SW_OKAY; |
| 154 | } | |
| 155 | ||
|
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
|
156 | int |
|
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 | _mdns_publish(BonjourDnsSd *data, PublishType type) |
| 11477 | 158 | { |
| 159 | sw_text_record dns_data; | |
|
11773
009a22a5ce53
[gaim-migrate @ 14064]
Gary Kramlich <grim@reaperworld.com>
parents:
11678
diff
changeset
|
160 | sw_result publish_result = SW_OKAY; |
| 13971 | 161 | char portstring[6]; |
|
17608
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
162 | const char *jid, *aim, *email; |
| 11477 | 163 | |
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11773
diff
changeset
|
164 | /* Fill the data for the service */ |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
165 | if (sw_text_record_init(&dns_data) != SW_OKAY) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
166 | { |
| 15884 | 167 | purple_debug_error("bonjour", "Unable to initialize the data for the mDNS.\n"); |
| 11477 | 168 | return -1; |
| 169 | } | |
| 170 | ||
| 13971 | 171 | /* Convert the port to a string */ |
| 172 | snprintf(portstring, sizeof(portstring), "%d", data->port_p2pj); | |
| 173 | ||
|
17608
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
174 | jid = purple_account_get_string(data->account, "jid", NULL); |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
175 | aim = purple_account_get_string(data->account, "AIM", NULL); |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
176 | email = purple_account_get_string(data->account, "email", NULL); |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
177 | |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
178 | /* We should try to follow XEP-0174, but some clients have "issues", so we humor them. |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
179 | * See http://telepathy.freedesktop.org/wiki/SalutInteroperability |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
180 | */ |
| 13968 | 181 | |
|
17608
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
182 | /* Needed by iChat */ |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
183 | sw_text_record_add_key_and_string_value(dns_data, "txtvers", "1"); |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
184 | /* Needed by Gaim/Pidgin <= 2.0.1 (remove at some point) */ |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
185 | sw_text_record_add_key_and_string_value(dns_data, "1st", data->first); |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
186 | /* Needed by Gaim/Pidgin <= 2.0.1 (remove at some point) */ |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
187 | sw_text_record_add_key_and_string_value(dns_data, "last", data->last); |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
188 | /* Needed by Adium */ |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
189 | sw_text_record_add_key_and_string_value(dns_data, "port.p2pj", portstring); |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
190 | /* Needed by iChat, Gaim/Pidgin <= 2.0.1 */ |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
191 | sw_text_record_add_key_and_string_value(dns_data, "status", data->status); |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
192 | /* Currently always set to "!" since we don't support AV and wont ever be in a conference */ |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
193 | sw_text_record_add_key_and_string_value(dns_data, "vc", data->vc); |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
194 | sw_text_record_add_key_and_string_value(dns_data, "ver", VERSION); |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
195 | if (email != NULL && *email != '\0') |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
196 | sw_text_record_add_key_and_string_value(dns_data, "email", email); |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
197 | if (jid != NULL && *jid != '\0') |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
198 | sw_text_record_add_key_and_string_value(dns_data, "jid", jid); |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
199 | /* Nonstandard, but used by iChat */ |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
200 | if (aim != NULL && *aim != '\0') |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
201 | sw_text_record_add_key_and_string_value(dns_data, "AIM", aim); |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
202 | if (data->msg != NULL && *data->msg != '\0') |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
203 | sw_text_record_add_key_and_string_value(dns_data, "msg", data->msg); |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
204 | if (data->phsh != NULL && *data->phsh != '\0') |
|
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
205 | sw_text_record_add_key_and_string_value(dns_data, "phsh", data->phsh); |
| 13968 | 206 | |
|
17608
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
207 | /* TODO: ext, nick, node */ |
| 11477 | 208 | |
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11773
diff
changeset
|
209 | /* Publish the service */ |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
210 | switch (type) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
211 | { |
| 11477 | 212 | case PUBLISH_START: |
|
17608
795ce8e3d44e
Clean up Bonjour service publishing and improve XEP-0174 compliance.
Daniel Atallah <datallah@pidgin.im>
parents:
17606
diff
changeset
|
213 | publish_result = sw_discovery_publish(data->session, 0, purple_account_get_username(data->account), ICHAT_SERVICE, NULL, |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
214 | NULL, data->port_p2pj, sw_text_record_bytes(dns_data), sw_text_record_len(dns_data), |
|
12104
c9f345830d7b
[gaim-migrate @ 14401]
Mark Doliner <markdoliner@pidgin.im>
parents:
12094
diff
changeset
|
215 | _publish_reply, NULL, &data->session_id); |
| 11477 | 216 | break; |
| 217 | case PUBLISH_UPDATE: | |
|
12104
c9f345830d7b
[gaim-migrate @ 14401]
Mark Doliner <markdoliner@pidgin.im>
parents:
12094
diff
changeset
|
218 | publish_result = sw_discovery_publish_update(data->session, data->session_id, |
| 11477 | 219 | sw_text_record_bytes(dns_data), sw_text_record_len(dns_data)); |
| 220 | break; | |
| 221 | } | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
222 | if (publish_result != SW_OKAY) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
223 | { |
| 15884 | 224 | purple_debug_error("bonjour", "Unable to publish or change the status of the _presence._tcp service.\n"); |
| 11477 | 225 | return -1; |
| 226 | } | |
| 227 | ||
|
11829
8d89f3c00831
[gaim-migrate @ 14120]
Richard Laager <rlaager@pidgin.im>
parents:
11773
diff
changeset
|
228 | /* Free the memory used by temp data */ |
| 11477 | 229 | sw_text_record_fina(dns_data); |
| 230 | ||
| 231 | return 0; | |
| 232 | } | |
| 233 | ||
|
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
|
234 | void |
|
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
|
235 | _mdns_handle_event(gpointer data, gint source, PurpleInputCondition condition) |
| 11477 | 236 | { |
|
12104
c9f345830d7b
[gaim-migrate @ 14401]
Mark Doliner <markdoliner@pidgin.im>
parents:
12094
diff
changeset
|
237 | sw_discovery_read_socket((sw_discovery)data); |
| 11477 | 238 | } |