annotate libpurple/protocols/bonjour/mdns_avahi.c @ 20543:87ce3da53550

Change mnemonic for Account to avoid conflict with Add. Fixes #3166
author Sean Egan <seanegan@gmail.com>
date Wed, 19 Sep 2007 07:40:17 +0000
parents 44b4e8bd759b
children 5b9da9db7e81
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
1 /*
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
2 * This program is free software; you can redistribute it and/or modify
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
3 * it under the terms of the GNU General Public License as published by
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
4 * the Free Software Foundation; either version 2 of the License, or
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
5 * (at your option) any later version.
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
6 *
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
7 * This program is distributed in the hope that it will be useful,
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
10 * GNU Library General Public License for more details.
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
11 *
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
12 * You should have received a copy of the GNU General Public License
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
13 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19653
diff changeset
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA.
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
15 */
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
16
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
17 #include "internal.h"
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
18
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
19 #include "mdns_interface.h"
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
20 #include "debug.h"
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
21 #include "buddy.h"
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
22 #include "bonjour.h"
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
23
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
24 #include <avahi-client/client.h>
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
25 #include <avahi-client/lookup.h>
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
26 #include <avahi-client/publish.h>
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
27
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
28 #include <avahi-common/address.h>
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
29 #include <avahi-common/malloc.h>
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
30 #include <avahi-common/error.h>
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
31 #include <avahi-common/strlst.h>
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
32
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
33 #include <avahi-glib/glib-malloc.h>
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
34 #include <avahi-glib/glib-watch.h>
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
35
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
36 /* Avahi only defines the types that it actually uses (which at this time doesn't include NULL) */
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
37 #ifndef AVAHI_DNS_TYPE_NULL
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
38 #define AVAHI_DNS_TYPE_NULL 0x0A
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
39 #endif
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
40
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
41 /* data used by avahi bonjour implementation */
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
42 typedef struct _avahi_session_impl_data {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
43 AvahiClient *client;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
44 AvahiGLibPoll *glib_poll;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
45 AvahiServiceBrowser *sb;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
46 AvahiEntryGroup *group;
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
47 AvahiEntryGroup *buddy_icon_group;
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
48 } AvahiSessionImplData;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
49
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
50 typedef struct _avahi_buddy_impl_data {
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
51 AvahiServiceResolver *resolver;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
52 AvahiRecordBrowser *buddy_icon_rec_browser;
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
53 } AvahiBuddyImplData;
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
54
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
55 static void
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
56 _resolver_callback(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiProtocol protocol,
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
57 AvahiResolverEvent event, const char *name, const char *type, const char *domain,
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
58 const char *host_name, const AvahiAddress *a, uint16_t port, AvahiStringList *txt,
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
59 AvahiLookupResultFlags flags, void *userdata) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
60
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
61 PurpleBuddy *pb;
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
62 BonjourBuddy *bb;
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
63 PurpleAccount *account = userdata;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
64 AvahiStringList *l;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
65 size_t size;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
66 char *key, *value;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
67 int ret;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
68
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
69 g_return_if_fail(r != NULL);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
70
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
71 pb = purple_find_buddy(account, name);
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
72 bb = (pb != NULL) ? pb->proto_data : NULL;
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
73
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
74 switch (event) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
75 case AVAHI_RESOLVER_FAILURE:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
76 purple_debug_error("bonjour", "_resolve_callback - Failure: %s\n",
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
77 avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r))));
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
78
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
79 avahi_service_resolver_free(r);
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
80 if (bb != NULL) {
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
81 /* We've already freed the resolver */
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
82 if (r == ((AvahiBuddyImplData *)bb->mdns_impl_data)->resolver)
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
83 ((AvahiBuddyImplData *)bb->mdns_impl_data)->resolver = NULL;
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
84 purple_blist_remove_buddy(pb);
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
85 }
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
86 break;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
87 case AVAHI_RESOLVER_FOUND:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
88 /* create a buddy record */
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
89 if (bb == NULL)
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
90 bb = bonjour_buddy_new(name, account);
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
91
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
92 /* If we're reusing an existing buddy, make sure if it is a different resolver to clean up the old one.
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
93 * I don't think this should ever happen, but I'm afraid we might get events out of sequence. */
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
94 if (((AvahiBuddyImplData *)bb->mdns_impl_data)->resolver != NULL
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
95 && ((AvahiBuddyImplData *)bb->mdns_impl_data)->resolver != r) {
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
96 avahi_service_resolver_free(((AvahiBuddyImplData *)bb->mdns_impl_data)->resolver);
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
97 }
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
98 ((AvahiBuddyImplData *)bb->mdns_impl_data)->resolver = r;
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
99
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
100 g_free(bb->ip);
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
101 /* Get the ip as a string */
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
102 bb->ip = g_malloc(AVAHI_ADDRESS_STR_MAX);
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
103 avahi_address_snprint(bb->ip, AVAHI_ADDRESS_STR_MAX, a);
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
104
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
105 bb->port_p2pj = port;
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
106
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
107 /* Obtain the parameters from the text_record */
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
108 clear_bonjour_buddy_values(bb);
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
109 for(l = txt; l != NULL; l = l->next) {
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
110 if ((ret = avahi_string_list_get_pair(l, &key, &value, &size)) < 0)
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
111 continue;
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
112 set_bonjour_buddy_value(bb, key, value, size);
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
113 /* TODO: Since we're using the glib allocator, I think we
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
114 * can use the values instead of re-copying them */
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
115 avahi_free(key);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
116 avahi_free(value);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
117 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
118
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
119 if (!bonjour_buddy_check(bb)) {
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
120 if (pb != NULL)
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
121 purple_blist_remove_buddy(pb);
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
122 else
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
123 bonjour_buddy_delete(bb);
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
124 } else
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
125 /* Add or update the buddy in our buddy list */
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
126 bonjour_buddy_add_to_purple(bb, pb);
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
127
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
128 break;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
129 default:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
130 purple_debug_info("bonjour", "Unrecognized Service Resolver event: %d.\n", event);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
131 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
132
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
133 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
134
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
135 static void
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
136 _browser_callback(AvahiServiceBrowser *b, AvahiIfIndex interface,
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
137 AvahiProtocol protocol, AvahiBrowserEvent event,
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
138 const char *name, const char *type, const char *domain,
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
139 AvahiLookupResultFlags flags, void *userdata) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
140
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
141 PurpleAccount *account = userdata;
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
142 PurpleBuddy *pb = NULL;
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
143
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
144 switch (event) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
145 case AVAHI_BROWSER_FAILURE:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
146 purple_debug_error("bonjour", "_browser_callback - Failure: %s\n",
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
147 avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b))));
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
148 /* TODO: This is an error that should be handled. */
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
149 break;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
150 case AVAHI_BROWSER_NEW:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
151 /* A new peer has joined the network and uses iChat bonjour */
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
152 purple_debug_info("bonjour", "_browser_callback - new service\n");
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
153 /* Make sure it isn't us */
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
154 if (purple_utf8_strcasecmp(name, account->username) != 0) {
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
155 if (!avahi_service_resolver_new(avahi_service_browser_get_client(b),
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
156 interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC,
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
157 0, _resolver_callback, account)) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
158 purple_debug_warning("bonjour", "_browser_callback -- Error initiating resolver: %s\n",
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
159 avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b))));
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
160 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
161 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
162 break;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
163 case AVAHI_BROWSER_REMOVE:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
164 purple_debug_info("bonjour", "_browser_callback - Remove service\n");
19573
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
165 pb = purple_find_buddy(account, name);
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
166 if (pb != NULL)
affacee881e8 Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18859
diff changeset
167 purple_blist_remove_buddy(pb);
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
168 break;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
169 case AVAHI_BROWSER_ALL_FOR_NOW:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
170 case AVAHI_BROWSER_CACHE_EXHAUSTED:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
171 break;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
172 default:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
173 purple_debug_info("bonjour", "Unrecognized Service browser event: %d.\n", event);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
174 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
175 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
176
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
177 static void
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
178 _buddy_icon_group_cb(AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) {
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
179 BonjourDnsSd *data = userdata;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
180 AvahiSessionImplData *idata = data->mdns_impl_data;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
181
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
182 g_return_if_fail(g == idata->buddy_icon_group || idata->buddy_icon_group == NULL);
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
183
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
184 switch(state) {
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
185 case AVAHI_ENTRY_GROUP_ESTABLISHED:
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
186 purple_debug_info("bonjour", "Successfully registered buddy icon data.\n");
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
187 case AVAHI_ENTRY_GROUP_COLLISION:
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
188 purple_debug_error("bonjour", "Collision registering buddy icon data.\n");
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
189 break;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
190 case AVAHI_ENTRY_GROUP_FAILURE:
19653
941965d6fd88 Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19573
diff changeset
191 purple_debug_error("bonjour", "Error registering buddy icon data: %s.\n",
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
192 avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g))));
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
193 break;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
194 case AVAHI_ENTRY_GROUP_UNCOMMITED:
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
195 case AVAHI_ENTRY_GROUP_REGISTERING:
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
196 break;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
197 }
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
198
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
199 }
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
200
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
201 static void
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
202 _entry_group_cb(AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
203 AvahiSessionImplData *idata = userdata;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
204
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
205 g_return_if_fail(g == idata->group || idata->group == NULL);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
206
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
207 switch(state) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
208 case AVAHI_ENTRY_GROUP_ESTABLISHED:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
209 purple_debug_info("bonjour", "Successfully registered service.\n");
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
210 break;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
211 case AVAHI_ENTRY_GROUP_COLLISION:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
212 purple_debug_error("bonjour", "Collision registering entry group.\n");
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
213 /* TODO: Handle error - this should log out the account. (Possibly with "wants to die")*/
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
214 break;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
215 case AVAHI_ENTRY_GROUP_FAILURE:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
216 purple_debug_error("bonjour", "Error registering entry group: %s\n.",
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
217 avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g))));
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
218 /* TODO: Handle error - this should log out the account.*/
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
219 break;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
220 case AVAHI_ENTRY_GROUP_UNCOMMITED:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
221 case AVAHI_ENTRY_GROUP_REGISTERING:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
222 break;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
223 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
224
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
225 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
226
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
227 static void
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
228 _buddy_icon_record_cb(AvahiRecordBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol,
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
229 AvahiBrowserEvent event, const char *name, uint16_t clazz, uint16_t type,
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
230 const void *rdata, size_t size, AvahiLookupResultFlags flags, void *userdata) {
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
231 BonjourBuddy *buddy = userdata;
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
232 AvahiBuddyImplData *idata = buddy->mdns_impl_data;
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
233
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
234 switch (event) {
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
235 case AVAHI_BROWSER_NEW:
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
236 bonjour_buddy_got_buddy_icon(buddy, rdata, size);
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
237 break;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
238 case AVAHI_BROWSER_REMOVE:
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
239 case AVAHI_BROWSER_CACHE_EXHAUSTED:
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
240 case AVAHI_BROWSER_ALL_FOR_NOW:
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
241 case AVAHI_BROWSER_FAILURE:
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
242 purple_debug_error("bonjour", "Error rerieving buddy icon record: %s\n",
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
243 avahi_strerror(avahi_client_errno(avahi_record_browser_get_client(b))));
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
244 break;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
245 }
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
246
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
247 /* Stop listening */
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
248 avahi_record_browser_free(idata->buddy_icon_rec_browser);
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
249 idata->buddy_icon_rec_browser = NULL;
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
250 }
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
251
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
252 /****************************
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
253 * mdns_interface functions *
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
254 ****************************/
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
255
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
256 gboolean _mdns_init_session(BonjourDnsSd *data) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
257 AvahiSessionImplData *idata = g_new0(AvahiSessionImplData, 1);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
258 const AvahiPoll *poll_api;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
259 int error;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
260
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
261 /* Tell avahi to use g_malloc and g_free */
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
262 avahi_set_allocator (avahi_glib_allocator ());
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
263
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
264 /* This currently depends on the glib mainloop,
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
265 * we should make it use the libpurple abstraction */
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
266
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
267 idata->glib_poll = avahi_glib_poll_new(NULL, G_PRIORITY_DEFAULT);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
268
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
269 poll_api = avahi_glib_poll_get(idata->glib_poll);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
270
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
271 idata->client = avahi_client_new(poll_api, 0, NULL, data, &error);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
272
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
273 if (idata->client == NULL) {
19653
941965d6fd88 Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19573
diff changeset
274 purple_debug_error("bonjour", "Error initializing Avahi: %s\n", avahi_strerror(error));
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
275 avahi_glib_poll_free(idata->glib_poll);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
276 g_free(idata);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
277 return FALSE;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
278 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
279
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
280 data->mdns_impl_data = idata;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
281
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
282 return TRUE;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
283 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
284
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18858
diff changeset
285 gboolean _mdns_publish(BonjourDnsSd *data, PublishType type, GSList *records) {
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
286 int publish_result = 0;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
287 AvahiSessionImplData *idata = data->mdns_impl_data;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
288 AvahiStringList *lst = NULL;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
289
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
290 g_return_val_if_fail(idata != NULL, FALSE);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
291
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
292 if (!idata->group) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
293 idata->group = avahi_entry_group_new(idata->client,
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
294 _entry_group_cb, idata);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
295 if (!idata->group) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
296 purple_debug_error("bonjour",
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
297 "Unable to initialize the data for the mDNS (%s).\n",
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
298 avahi_strerror(avahi_client_errno(idata->client)));
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
299 return FALSE;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
300 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
301 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
302
18859
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18858
diff changeset
303 while (records) {
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18858
diff changeset
304 PurpleKeyValuePair *kvp = records->data;
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18858
diff changeset
305 lst = avahi_string_list_add_pair(lst, kvp->key, kvp->value);
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18858
diff changeset
306 records = records->next;
c1546f6c0432 Yay for code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18858
diff changeset
307 }
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
308
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
309 /* Publish the service */
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
310 switch (type) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
311 case PUBLISH_START:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
312 publish_result = avahi_entry_group_add_service_strlst(
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
313 idata->group, AVAHI_IF_UNSPEC,
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
314 AVAHI_PROTO_UNSPEC, 0,
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
315 purple_account_get_username(data->account),
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
316 ICHAT_SERVICE, NULL, NULL, data->port_p2pj, lst);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
317 break;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
318 case PUBLISH_UPDATE:
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
319 publish_result = avahi_entry_group_update_service_txt_strlst(
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
320 idata->group, AVAHI_IF_UNSPEC,
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
321 AVAHI_PROTO_UNSPEC, 0,
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
322 purple_account_get_username(data->account),
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
323 ICHAT_SERVICE, NULL, lst);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
324 break;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
325 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
326
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
327 /* Free the memory used by temp data */
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
328 avahi_string_list_free(lst);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
329
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
330 if (publish_result < 0) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
331 purple_debug_error("bonjour",
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
332 "Failed to add the " ICHAT_SERVICE " service. Error: %s\n",
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
333 avahi_strerror(publish_result));
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
334 return FALSE;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
335 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
336
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
337 if (type == PUBLISH_START
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
338 && (publish_result = avahi_entry_group_commit(idata->group)) < 0) {
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
339 purple_debug_error("bonjour",
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
340 "Failed to commit " ICHAT_SERVICE " service. Error: %s\n",
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
341 avahi_strerror(publish_result));
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
342 return FALSE;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
343 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
344
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
345 return TRUE;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
346 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
347
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
348 gboolean _mdns_browse(BonjourDnsSd *data) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
349 AvahiSessionImplData *idata = data->mdns_impl_data;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
350
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
351 g_return_val_if_fail(idata != NULL, FALSE);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
352
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
353 idata->sb = avahi_service_browser_new(idata->client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, ICHAT_SERVICE, NULL, 0, _browser_callback, data->account);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
354 if (!idata->sb) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
355
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
356 purple_debug_error("bonjour",
19653
941965d6fd88 Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19573
diff changeset
357 "Unable to initialize service browser. Error: %s.\n",
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
358 avahi_strerror(avahi_client_errno(idata->client)));
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
359 return FALSE;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
360 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
361
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
362 return TRUE;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
363 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
364
18845
09f52521ff5b Fix bonjour buddy icons to work with iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18843
diff changeset
365 gboolean _mdns_set_buddy_icon_data(BonjourDnsSd *data, gconstpointer avatar_data, gsize avatar_len) {
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
366 AvahiSessionImplData *idata = data->mdns_impl_data;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
367
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
368 if (idata == NULL || idata->client == NULL)
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
369 return FALSE;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
370
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
371 if (avatar_data != NULL) {
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
372 gboolean new_group = FALSE;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
373 gchar *svc_name;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
374 int ret;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
375 AvahiPublishFlags flags = 0;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
376
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
377 if (idata->buddy_icon_group == NULL) {
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
378 purple_debug_info("bonjour", "Setting new buddy icon.\n");
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
379 new_group = TRUE;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
380
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
381 idata->buddy_icon_group = avahi_entry_group_new(idata->client,
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
382 _buddy_icon_group_cb, data);
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
383 } else {
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
384 purple_debug_info("bonjour", "Updating existing buddy icon.\n");
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
385 flags |= AVAHI_PUBLISH_UPDATE;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
386 }
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
387
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
388 if (idata->buddy_icon_group == NULL) {
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
389 purple_debug_error("bonjour",
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
390 "Unable to initialize the buddy icon group (%s).\n",
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
391 avahi_strerror(avahi_client_errno(idata->client)));
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
392 return FALSE;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
393 }
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
394
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
395 svc_name = g_strdup_printf("%s." ICHAT_SERVICE "local",
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
396 purple_account_get_username(data->account));
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
397
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
398 ret = avahi_entry_group_add_record(idata->buddy_icon_group, AVAHI_IF_UNSPEC,
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
399 AVAHI_PROTO_UNSPEC, flags, svc_name,
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
400 AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_NULL, 120, avatar_data, avatar_len);
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
401
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
402 g_free(svc_name);
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
403
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
404 if (ret < 0) {
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
405 purple_debug_error("bonjour",
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
406 "Failed to register buddy icon. Error: %s\n", avahi_strerror(ret));
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
407 if (new_group) {
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
408 avahi_entry_group_free(idata->buddy_icon_group);
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
409 idata->buddy_icon_group = NULL;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
410 }
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
411 return FALSE;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
412 }
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
413
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
414 if (new_group && (ret = avahi_entry_group_commit(idata->buddy_icon_group)) < 0) {
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
415 purple_debug_error("bonjour",
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
416 "Failed to commit buddy icon group. Error: %s\n", avahi_strerror(ret));
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
417 if (new_group) {
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
418 avahi_entry_group_free(idata->buddy_icon_group);
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
419 idata->buddy_icon_group = NULL;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
420 }
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
421 return FALSE;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
422 }
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
423 } else if (idata->buddy_icon_group != NULL) {
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
424 purple_debug_info("bonjour", "Removing existing buddy icon.\n");
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
425 avahi_entry_group_free(idata->buddy_icon_group);
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
426 idata->buddy_icon_group = NULL;
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
427 }
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
428
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
429 return TRUE;
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
430 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
431
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
432 void _mdns_stop(BonjourDnsSd *data) {
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
433 AvahiSessionImplData *idata = data->mdns_impl_data;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
434
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
435 if (idata == NULL || idata->client == NULL)
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
436 return;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
437
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
438 if (idata->sb != NULL)
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
439 avahi_service_browser_free(idata->sb);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
440
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
441 avahi_client_free(idata->client);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
442 avahi_glib_poll_free(idata->glib_poll);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
443
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
444 g_free(idata);
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
445
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
446 data->mdns_impl_data = NULL;
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
447 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
448
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
449 void _mdns_init_buddy(BonjourBuddy *buddy) {
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
450 buddy->mdns_impl_data = g_new0(AvahiBuddyImplData, 1);
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
451 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
452
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
453 void _mdns_delete_buddy(BonjourBuddy *buddy) {
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
454 AvahiBuddyImplData *idata = buddy->mdns_impl_data;
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
455
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
456 g_return_if_fail(idata != NULL);
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
457
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
458 if (idata->buddy_icon_rec_browser != NULL)
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
459 avahi_record_browser_free(idata->buddy_icon_rec_browser);
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
460
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
461 if (idata->resolver != NULL)
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
462 avahi_service_resolver_free(idata->resolver);
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
463
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
464 g_free(idata);
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
465
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
466 buddy->mdns_impl_data = NULL;
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
467 }
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
468
18849
1787e601aafc _mdns_retrieve_retrieve_buddy_icon() - what kind of crack am I on anyway?
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18848
diff changeset
469 void _mdns_retrieve_buddy_icon(BonjourBuddy* buddy) {
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
470 PurpleConnection *conn = purple_account_get_connection(buddy->account);
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
471 BonjourData *bd = conn->proto_data;
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
472 AvahiSessionImplData *session_idata = bd->dns_sd_data->mdns_impl_data;
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
473 AvahiBuddyImplData *idata = buddy->mdns_impl_data;
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
474 gchar *name;
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
475
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
476 g_return_if_fail(idata != NULL);
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
477
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
478 if (idata->buddy_icon_rec_browser != NULL)
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
479 avahi_record_browser_free(idata->buddy_icon_rec_browser);
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
480
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
481 purple_debug_info("bonjour", "Retrieving buddy icon for '%s'.\n", buddy->name);
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
482
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
483 name = g_strdup_printf("%s." ICHAT_SERVICE "local", buddy->name);
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
484 idata->buddy_icon_rec_browser = avahi_record_browser_new(session_idata->client, AVAHI_IF_UNSPEC,
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
485 AVAHI_PROTO_UNSPEC, name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_NULL, 0,
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
486 _buddy_icon_record_cb, buddy);
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
487 g_free(name);
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
488
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
489 if (!idata->buddy_icon_rec_browser) {
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
490 purple_debug_error("bonjour",
19653
941965d6fd88 Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19573
diff changeset
491 "Unable to initialize buddy icon record browser. Error: %s.\n",
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
492 avahi_strerror(avahi_client_errno(session_idata->client)));
18850
2283d5bfc24b Implement setting buddy icons for avahi implementation. Fix receiving status changes and some other fixes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18849
diff changeset
493 }
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
494
18805
1244b5f43661 Here is a native avahi implementation of the bonjour prpl that I whipped up. Someone more autofoo savvy will probably want to review what I've done to that stuff. Fixes #326.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
495 }
18830
2ae9b483c4db Avahi bonjour implementation of receiving buddy icons.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18805
diff changeset
496