annotate libpurple/protocols/bonjour/buddy.c @ 17658:4f65f25f9447

Update for (future) 0.8.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Sun, 24 Jun 2007 05:07:43 +0000
parents 612dc5149964
children 1faa319ab4c3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * GNU Library General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * along with this program; if not, write to the Free Software
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 #include <glib.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 #include <stdlib.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 #include "buddy.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 #include "account.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 #include "blist.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "bonjour.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 * Creates a new buddy.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 BonjourBuddy *
17495
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
30 bonjour_buddy_new(const gchar *name, PurpleAccount* account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 {
17498
e165d1ba8844 Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
32 BonjourBuddy *buddy = g_new0(BonjourBuddy, 1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33
17495
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
34 buddy->account = account;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 buddy->name = g_strdup(name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 return buddy;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39
17498
e165d1ba8844 Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
40 void
17504
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
41 set_bonjour_buddy_value(BonjourBuddy* buddy, const char *record_key, const char *value, uint32_t len){
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
42 gchar **fld = NULL;
17498
e165d1ba8844 Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
43
17504
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
44 if (!strcmp(record_key, "1st"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
45 fld = &buddy->first;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
46 else if(!strcmp(record_key, "email"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
47 fld = &buddy->email;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
48 else if(!strcmp(record_key, "ext"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
49 fld = &buddy->ext;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
50 else if(!strcmp(record_key, "jid"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
51 fld = &buddy->jid;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
52 else if(!strcmp(record_key, "last"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
53 fld = &buddy->last;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
54 else if(!strcmp(record_key, "msg"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
55 fld = &buddy->msg;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
56 else if(!strcmp(record_key, "nick"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
57 fld = &buddy->nick;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
58 else if(!strcmp(record_key, "node"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
59 fld = &buddy->node;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
60 else if(!strcmp(record_key, "phsh"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
61 fld = &buddy->phsh;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
62 else if(!strcmp(record_key, "status"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
63 fld = &buddy->status;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
64 else if(!strcmp(record_key, "vc"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
65 fld = &buddy->vc;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
66 else if(!strcmp(record_key, "ver"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
67 fld = &buddy->ver;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
68 else if(!strcmp(record_key, "AIM"))
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
69 fld = &buddy->AIM;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
70
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
71 if(fld == NULL)
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
72 return;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
73
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
74 g_free(*fld);
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
75 *fld = NULL;
c921f901c7ea Improve bonjour buddy TXT record parsing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17498
diff changeset
76 *fld = g_strndup(value, len);
17495
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
77 }
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
78
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 * Check if all the compulsory buddy data is present.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 gboolean
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 bonjour_buddy_check(BonjourBuddy *buddy)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 {
17495
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
85 if (buddy->account == NULL)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87
17498
e165d1ba8844 Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
88 if (buddy->name == NULL)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 * If the buddy does not yet exist, then create it and add it to
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 * our buddy list. In either case we set the correct status for
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 * the buddy.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 void
17495
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
100 bonjour_buddy_add_to_purple(BonjourBuddy *bonjour_buddy)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
102 PurpleBuddy *buddy;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
103 PurpleGroup *group;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 const char *status_id, *first, *last;
17498
e165d1ba8844 Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
105 gchar *alias;
e165d1ba8844 Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
106
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
107 /* Translate between the Bonjour status and the Purple status */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 if (g_ascii_strcasecmp("dnd", bonjour_buddy->status) == 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 status_id = BONJOUR_STATUS_ID_AWAY;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 status_id = BONJOUR_STATUS_ID_AVAILABLE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 * TODO: Figure out the idle time by getting the "away"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 * field from the DNS SD.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 /* Create the alias for the buddy using the first and the last name */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 first = bonjour_buddy->first;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 last = bonjour_buddy->last;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 alias = g_strdup_printf("%s%s%s",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 (first && *first ? first : ""),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 (first && *first && last && *last ? " " : ""),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 (last && *last ? last : ""));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 /* Make sure the Bonjour group exists in our buddy list */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
127 group = purple_find_group(BONJOUR_GROUP_NAME); /* Use the buddy's domain, instead? */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 if (group == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
130 group = purple_group_new(BONJOUR_GROUP_NAME);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
131 purple_blist_add_group(group, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 /* Make sure the buddy exists in our buddy list */
17495
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
135 buddy = purple_find_buddy(bonjour_buddy->account, bonjour_buddy->name);
17498
e165d1ba8844 Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
136
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 if (buddy == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 {
17495
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
139 buddy = purple_buddy_new(bonjour_buddy->account, bonjour_buddy->name, alias);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 buddy->proto_data = bonjour_buddy;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
141 purple_blist_node_set_flags((PurpleBlistNode *)buddy, PURPLE_BLIST_NODE_FLAG_NO_SAVE);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
142 purple_blist_add_buddy(buddy, NULL, group, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 /* Set the user's status */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 if (bonjour_buddy->msg != NULL)
17495
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
147 purple_prpl_got_user_status(bonjour_buddy->account, buddy->name, status_id,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 "message", bonjour_buddy->msg,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 else
17495
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
151 purple_prpl_got_user_status(bonjour_buddy->account, buddy->name, status_id,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 NULL);
17495
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
153 purple_prpl_got_user_idle(bonjour_buddy->account, buddy->name, FALSE, 0);
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
154
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 g_free(alias);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 * Deletes a buddy from memory.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 bonjour_buddy_delete(BonjourBuddy *buddy)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 g_free(buddy->name);
17540
eae7a411e3a1 Fix leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
165 g_free(buddy->ip);
eae7a411e3a1 Fix leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
166
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 g_free(buddy->first);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 g_free(buddy->phsh);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 g_free(buddy->status);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 g_free(buddy->email);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 g_free(buddy->last);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 g_free(buddy->jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 g_free(buddy->AIM);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 g_free(buddy->vc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 g_free(buddy->msg);
17540
eae7a411e3a1 Fix leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
176 g_free(buddy->ext);
eae7a411e3a1 Fix leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
177 g_free(buddy->nick);
eae7a411e3a1 Fix leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
178 g_free(buddy->node);
eae7a411e3a1 Fix leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17504
diff changeset
179 g_free(buddy->ver);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180
17556
612dc5149964 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17540
diff changeset
181 bonjour_jabber_close_conversation(buddy->conversation);
612dc5149964 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17540
diff changeset
182 buddy->conversation = NULL;
17498
e165d1ba8844 Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
183
17495
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
184 #ifdef USE_BONJOUR_APPLE
17498
e165d1ba8844 Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
185 if (buddy->txt_query != NULL)
e165d1ba8844 Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
186 {
17495
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
187 purple_input_remove(buddy->txt_query_fd);
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
188 DNSServiceRefDeallocate(buddy->txt_query);
17498
e165d1ba8844 Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
189 }
17495
d7b50cac1c7a 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 <daniel.atallah@gmail.com>
parents: 15822
diff changeset
190 #endif
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191
17498
e165d1ba8844 Don't force Bonjour buddies to have firstname, lastname and status TXT records - they are optional. Also, minor cleanup and use glib to allocate memory instead of the crt.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
192 g_free(buddy);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 }