comparison libpurple/protocols/bonjour/buddy.c @ 24286:fe7504f465a2

More Bonjour struct hiding fixes.
author Richard Laager <rlaager@wiktel.com>
date Thu, 30 Oct 2008 20:02:30 +0000
parents ef0bcbe33689
children 5ace6c024230 efe41c4e0df0 ac967ea95b05
comparison
equal deleted inserted replaced
24285:716048e4fbbd 24286:fe7504f465a2
125 void 125 void
126 bonjour_buddy_add_to_purple(BonjourBuddy *bonjour_buddy, PurpleBuddy *buddy) 126 bonjour_buddy_add_to_purple(BonjourBuddy *bonjour_buddy, PurpleBuddy *buddy)
127 { 127 {
128 PurpleGroup *group; 128 PurpleGroup *group;
129 PurpleAccount *account = bonjour_buddy->account; 129 PurpleAccount *account = bonjour_buddy->account;
130 const char *status_id, *old_hash, *new_hash; 130 const char *status_id, *old_hash, *new_hash, *name;
131 131
132 /* Translate between the Bonjour status and the Purple status */ 132 /* Translate between the Bonjour status and the Purple status */
133 if (bonjour_buddy->status != NULL && g_ascii_strcasecmp("dnd", bonjour_buddy->status) == 0) 133 if (bonjour_buddy->status != NULL && g_ascii_strcasecmp("dnd", bonjour_buddy->status) == 0)
134 status_id = BONJOUR_STATUS_ID_AWAY; 134 status_id = BONJOUR_STATUS_ID_AWAY;
135 else 135 else
156 purple_blist_node_set_flags((PurpleBlistNode *)buddy, PURPLE_BLIST_NODE_FLAG_NO_SAVE); 156 purple_blist_node_set_flags((PurpleBlistNode *)buddy, PURPLE_BLIST_NODE_FLAG_NO_SAVE);
157 purple_blist_add_buddy(buddy, NULL, group, NULL); 157 purple_blist_add_buddy(buddy, NULL, group, NULL);
158 } 158 }
159 159
160 buddy->proto_data = bonjour_buddy; 160 buddy->proto_data = bonjour_buddy;
161 name = purple_buddy_get_name(buddy);
161 162
162 /* Create the alias for the buddy using the first and the last name */ 163 /* Create the alias for the buddy using the first and the last name */
163 if (bonjour_buddy->nick) 164 if (bonjour_buddy->nick)
164 serv_got_alias(purple_account_get_connection(account), buddy->name, bonjour_buddy->nick); 165 serv_got_alias(purple_account_get_connection(account), name, bonjour_buddy->nick);
165 else { 166 else {
166 gchar *alias = NULL; 167 gchar *alias = NULL;
167 const char *first, *last; 168 const char *first, *last;
168 first = bonjour_buddy->first; 169 first = bonjour_buddy->first;
169 last = bonjour_buddy->last; 170 last = bonjour_buddy->last;
170 if ((first && *first) || (last && *last)) 171 if ((first && *first) || (last && *last))
171 alias = g_strdup_printf("%s%s%s", 172 alias = g_strdup_printf("%s%s%s",
172 (first && *first ? first : ""), 173 (first && *first ? first : ""),
173 (first && *first && last && *last ? " " : ""), 174 (first && *first && last && *last ? " " : ""),
174 (last && *last ? last : "")); 175 (last && *last ? last : ""));
175 serv_got_alias(purple_account_get_connection(account), buddy->name, alias); 176 serv_got_alias(purple_account_get_connection(account), name, alias);
176 g_free(alias); 177 g_free(alias);
177 } 178 }
178 179
179 /* Set the user's status */ 180 /* Set the user's status */
180 if (bonjour_buddy->msg != NULL) 181 if (bonjour_buddy->msg != NULL)
181 purple_prpl_got_user_status(account, buddy->name, status_id, 182 purple_prpl_got_user_status(account, name, status_id,
182 "message", bonjour_buddy->msg, NULL); 183 "message", bonjour_buddy->msg, NULL);
183 else 184 else
184 purple_prpl_got_user_status(account, buddy->name, status_id, NULL); 185 purple_prpl_got_user_status(account, name, status_id, NULL);
185 186
186 purple_prpl_got_user_idle(account, buddy->name, FALSE, 0); 187 purple_prpl_got_user_idle(account, name, FALSE, 0);
187 188
188 /* TODO: Because we don't save Bonjour buddies in blist.xml, 189 /* TODO: Because we don't save Bonjour buddies in blist.xml,
189 * we will always have to look up the buddy icon at login time. 190 * we will always have to look up the buddy icon at login time.
190 * I think we should figure out a way to do something about this. */ 191 * I think we should figure out a way to do something about this. */
191 192
196 /* Look up the new icon data */ 197 /* Look up the new icon data */
197 /* TODO: Make sure the hash assigned to the retrieved buddy icon is the same 198 /* TODO: Make sure the hash assigned to the retrieved buddy icon is the same
198 * as what we looked up. */ 199 * as what we looked up. */
199 bonjour_dns_sd_retrieve_buddy_icon(bonjour_buddy); 200 bonjour_dns_sd_retrieve_buddy_icon(bonjour_buddy);
200 } else if (!new_hash) 201 } else if (!new_hash)
201 purple_buddy_icons_set_for_user(account, buddy->name, NULL, 0, NULL); 202 purple_buddy_icons_set_for_user(account, name, NULL, 0, NULL);
202 } 203 }
203 204
204 /** 205 /**
205 * The buddy has signed off Bonjour. 206 * The buddy has signed off Bonjour.
206 * If the buddy is being saved, mark as offline, otherwise delete 207 * If the buddy is being saved, mark as offline, otherwise delete