| 265 data->mdns_impl_data = idata; |
265 data->mdns_impl_data = idata; |
| 266 |
266 |
| 267 return TRUE; |
267 return TRUE; |
| 268 } |
268 } |
| 269 |
269 |
| 270 gboolean _mdns_publish(BonjourDnsSd *data, PublishType type) { |
270 gboolean _mdns_publish(BonjourDnsSd *data, PublishType type, GSList *records) { |
| 271 int publish_result = 0; |
271 int publish_result = 0; |
| 272 char portstring[6]; |
|
| 273 const char *jid, *aim, *email; |
|
| 274 AvahiSessionImplData *idata = data->mdns_impl_data; |
272 AvahiSessionImplData *idata = data->mdns_impl_data; |
| 275 AvahiStringList *lst = NULL; |
273 AvahiStringList *lst = NULL; |
| 276 |
274 |
| 277 g_return_val_if_fail(idata != NULL, FALSE); |
275 g_return_val_if_fail(idata != NULL, FALSE); |
| 278 |
276 |
| 285 avahi_strerror(avahi_client_errno(idata->client))); |
283 avahi_strerror(avahi_client_errno(idata->client))); |
| 286 return FALSE; |
284 return FALSE; |
| 287 } |
285 } |
| 288 } |
286 } |
| 289 |
287 |
| 290 /* Convert the port to a string */ |
288 while (records) { |
| 291 snprintf(portstring, sizeof(portstring), "%d", data->port_p2pj); |
289 PurpleKeyValuePair *kvp = records->data; |
| 292 |
290 lst = avahi_string_list_add_pair(lst, kvp->key, kvp->value); |
| 293 jid = purple_account_get_string(data->account, "jid", NULL); |
291 records = records->next; |
| 294 aim = purple_account_get_string(data->account, "AIM", NULL); |
292 } |
| 295 email = purple_account_get_string(data->account, "email", NULL); |
|
| 296 |
|
| 297 /* We should try to follow XEP-0174, but some clients have "issues", so we humor them. |
|
| 298 * See http://telepathy.freedesktop.org/wiki/SalutInteroperability |
|
| 299 */ |
|
| 300 |
|
| 301 /* Needed by iChat */ |
|
| 302 lst = avahi_string_list_add_pair(lst,"txtvers", "1"); |
|
| 303 /* Needed by Gaim/Pidgin <= 2.0.1 (remove at some point) */ |
|
| 304 lst = avahi_string_list_add_pair(lst, "1st", data->first); |
|
| 305 /* Needed by Gaim/Pidgin <= 2.0.1 (remove at some point) */ |
|
| 306 lst = avahi_string_list_add_pair(lst, "last", data->last); |
|
| 307 /* Needed by Adium */ |
|
| 308 lst = avahi_string_list_add_pair(lst, "port.p2pj", portstring); |
|
| 309 /* Needed by iChat, Gaim/Pidgin <= 2.0.1 */ |
|
| 310 lst = avahi_string_list_add_pair(lst, "status", data->status); |
|
| 311 /* Currently always set to "!" since we don't support AV and wont ever be in a conference */ |
|
| 312 lst = avahi_string_list_add_pair(lst, "vc", data->vc); |
|
| 313 lst = avahi_string_list_add_pair(lst, "ver", VERSION); |
|
| 314 if (email != NULL && *email != '\0') |
|
| 315 lst = avahi_string_list_add_pair(lst, "email", email); |
|
| 316 if (jid != NULL && *jid != '\0') |
|
| 317 lst = avahi_string_list_add_pair(lst, "jid", jid); |
|
| 318 /* Nonstandard, but used by iChat */ |
|
| 319 if (aim != NULL && *aim != '\0') |
|
| 320 lst = avahi_string_list_add_pair(lst, "AIM", aim); |
|
| 321 if (data->msg != NULL && *data->msg != '\0') |
|
| 322 lst = avahi_string_list_add_pair(lst, "msg", data->msg); |
|
| 323 if (data->phsh != NULL && *data->phsh != '\0') |
|
| 324 lst = avahi_string_list_add_pair(lst, "phsh", data->phsh); |
|
| 325 |
|
| 326 /* TODO: ext, nick, node */ |
|
| 327 |
|
| 328 |
293 |
| 329 /* Publish the service */ |
294 /* Publish the service */ |
| 330 switch (type) { |
295 switch (type) { |
| 331 case PUBLISH_START: |
296 case PUBLISH_START: |
| 332 publish_result = avahi_entry_group_add_service_strlst( |
297 publish_result = avahi_entry_group_add_service_strlst( |