libpurple/protocols/bonjour/buddy.h

Wed, 30 Jul 2008 03:58:21 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Wed, 30 Jul 2008 03:58:21 +0000
changeset 23931
8975bb78b51a
parent 23140
0e14208595bc
child 39556
622bf98df0ac
permissions
-rw-r--r--

Cleanup unnecessary casts and etc.

11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1 /*
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
2 * This program is free software; you can redistribute it and/or modify
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
3 * it under the terms of the GNU General Public License as published by
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
4 * the Free Software Foundation; either version 2 of the License, or
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
5 * (at your option) any later version.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
6 *
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
7 * This program is distributed in the hope that it will be useful,
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
10 * GNU Library General Public License for more details.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
11 *
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
12 * You should have received a copy of the GNU General Public License
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
13 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19748
diff changeset
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA.
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
15 */
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
16
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
17 #ifndef _BONJOUR_BUDDY
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
18 #define _BONJOUR_BUDDY
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
19
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
20 #include <glib.h>
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
21
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
22 #include "account.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
23 #include "jabber.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
24
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
25 typedef struct _BonjourBuddy
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
26 {
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
27 PurpleAccount *account;
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
28
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
29 gchar *name;
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 20238
diff changeset
30 GSList *ips;
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
31 gint port_p2pj;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
32
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
33 gchar *first;
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
34 gchar *phsh;
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
35 gchar *status;
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
36 gchar *email;
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
37 gchar *last;
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
38 gchar *jid;
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
39 gchar *AIM;
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
40 gchar *vc;
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
41 gchar *msg;
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
42 gchar *ext;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
43 gchar *nick;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
44 gchar *node;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
45 gchar *ver;
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
46
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
47 BonjourJabberConversation *conversation;
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
48
19093
b2657106df0e Refactor the bonjour mdns implementation abstraction in preparation for the avahi implementation. Also fix alias assignment from the server to populate the server alias instead of the local alias.
Daniel Atallah <datallah@pidgin.im>
parents: 17611
diff changeset
49 gpointer mdns_impl_data;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
50 } BonjourBuddy;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
51
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
52 static const char *const buddy_TXT_records[] = {
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
53 "1st",
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
54 "email",
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
55 "ext",
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
56 "jid",
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
57 "last",
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
58 "msg",
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
59 "nick",
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
60 "node",
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
61 "phsh",
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
62 /* "port.p2pj", Deprecated - MUST ignore */
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
63 "status",
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
64 /* "txtvers", Deprecated - hardcoded to 1 */
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
65 "vc",
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
66 "ver",
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
67 "AIM", /* non standard */
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
68 NULL
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
69 };
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
70
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
71 /**
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
72 * Creates a new buddy.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
73 */
17611
1f221c4f82d6 Improve bonjour buddy TXT record parsing.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
74 BonjourBuddy *bonjour_buddy_new(const gchar *name, PurpleAccount *account);
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
75
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
76 /**
19220
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
77 * Clear any existing values from the buddy.
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
78 * This is called before updating so that we can notice removals
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
79 */
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
80 void clear_bonjour_buddy_values(BonjourBuddy *buddy);
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
81
60d667d6bdc5 Clear bonjour buddy values before resetting them so that we notice value removals.
Daniel Atallah <datallah@pidgin.im>
parents: 19208
diff changeset
82 /**
17596
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
83 * Sets a value in the BonjourBuddy struct, destroying the old value
45f6190fe54a This is a patch from Chris Davies to make Bonjour work on Windows using the Apple Bonjour framework. It turns out that the actual DNS-SD library is (3 clause) BSD licensed, so we can use it.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
84 */
20238
e4abd12fb7ec applied changes from e9e74094baa29c6f5589385507221a2502b817fb
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
85 void set_bonjour_buddy_value(BonjourBuddy *buddy, const char *record_key, const char *value, guint32 len);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
86
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
87 /**
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
88 * Check if all the compulsory buddy data is present.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
89 */
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
90 gboolean bonjour_buddy_check(BonjourBuddy *buddy);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
91
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
92 /**
23140
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
93 * If the buddy doesn't previously exists, it is created. Else, its data is changed (???)
19748
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19220
diff changeset
94 * purple_buddy is optional; it saves an additional lookup if we already have it
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
95 */
19748
ae5eab65f8de Fix a couple potential leaks and prevent the avahi record resolver from being freed multiple times.
Daniel Atallah <datallah@pidgin.im>
parents: 19220
diff changeset
96 void bonjour_buddy_add_to_purple(BonjourBuddy *bonjour_buddy, PurpleBuddy *purple_buddy);
11496
0f61069a4a3f [gaim-migrate @ 13740]
Mark Doliner <markdoliner@pidgin.im>
parents: 11477
diff changeset
97
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
98 /**
23140
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
99 * The buddy has signed off Bonjour.
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
100 * If the buddy is being saved, mark as offline, otherwise delete
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
101 */
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
102 void bonjour_buddy_signed_off(PurpleBuddy *purple_buddy);
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
103
0e14208595bc Bonjour buddies will be saved persistently if they're moved out of the
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
104 /**
19208
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
105 * We got the buddy icon data; deal with it
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
106 */
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
107 void bonjour_buddy_got_buddy_icon(BonjourBuddy *buddy, gconstpointer data, gsize len);
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
108
34419d052ac8 Calculate the icon hash instead of using the current phsh value - iChat seems to update the TXT record before updating the NULL record containing image data, this causes the old image to be retrieved - perhaps we should re-fetch when this happens?
Daniel Atallah <datallah@pidgin.im>
parents: 19204
diff changeset
109 /**
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
110 * Deletes a buddy from memory.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
111 */
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11496
diff changeset
112 void bonjour_buddy_delete(BonjourBuddy *buddy);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
113
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
114 #endif

mercurial