comparison libpurple/protocols/simple/simple.c @ 24120:16734635febf

Start hiding blist.h internals in prpls.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 27 Sep 2008 06:33:42 +0000
parents 7f401e99f9d9
children aa876d48b5b2
comparison
equal deleted inserted replaced
24119:d1cfa8c11902 24120:16734635febf
194 194
195 static void simple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) 195 static void simple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
196 { 196 {
197 struct simple_account_data *sip = (struct simple_account_data *)gc->proto_data; 197 struct simple_account_data *sip = (struct simple_account_data *)gc->proto_data;
198 struct simple_buddy *b; 198 struct simple_buddy *b;
199 if(strncmp("sip:", buddy->name, 4)) { 199 const char *name = purple_buddy_get_name(buddy);
200 gchar *buf = g_strdup_printf("sip:%s", buddy->name); 200 if(strncmp("sip:", name, 4)) {
201 gchar *buf = g_strdup_printf("sip:%s", name);
201 purple_blist_rename_buddy(buddy, buf); 202 purple_blist_rename_buddy(buddy, buf);
202 g_free(buf); 203 g_free(buf);
203 } 204 }
204 if(!g_hash_table_lookup(sip->buddies, buddy->name)) { 205 if(!g_hash_table_lookup(sip->buddies, name)) {
205 b = g_new0(struct simple_buddy, 1); 206 b = g_new0(struct simple_buddy, 1);
206 purple_debug_info("simple", "simple_add_buddy %s\n", buddy->name); 207 purple_debug_info("simple", "simple_add_buddy %s\n", name);
207 b->name = g_strdup(buddy->name); 208 b->name = g_strdup(name);
208 g_hash_table_insert(sip->buddies, b->name, b); 209 g_hash_table_insert(sip->buddies, b->name, b);
209 } else { 210 } else {
210 purple_debug_info("simple", "buddy %s already in internal list\n", buddy->name); 211 purple_debug_info("simple", "buddy %s already in internal list\n", name);
211 } 212 }
212 } 213 }
213 214
214 static void simple_get_buddies(PurpleConnection *gc) { 215 static void simple_get_buddies(PurpleConnection *gc) {
215 PurpleBlistNode *gnode, *cnode, *bnode; 216 PurpleBlistNode *gnode, *cnode, *bnode;
217 PurpleAccount *account;
216 218
217 purple_debug_info("simple", "simple_get_buddies\n"); 219 purple_debug_info("simple", "simple_get_buddies\n");
218 220
219 for(gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { 221 account = purple_connection_get_account(gc);
222 for(gnode = purple_blist_get_root(); gnode; gnode = gnode->next) {
220 if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue; 223 if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue;
221 for(cnode = gnode->child; cnode; cnode = cnode->next) { 224 for(cnode = gnode->child; cnode; cnode = cnode->next) {
222 if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) continue; 225 if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) continue;
223 for(bnode = cnode->child; bnode; bnode = bnode->next) { 226 for(bnode = cnode->child; bnode; bnode = bnode->next) {
224 if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) continue; 227 if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) continue;
225 if(((PurpleBuddy*)bnode)->account == gc->account) 228 if(purple_buddy_get_account((PurpleBuddy*)bnode) == account)
226 simple_add_buddy(gc, (PurpleBuddy*)bnode, (PurpleGroup *)gnode); 229 simple_add_buddy(gc, (PurpleBuddy*)bnode, (PurpleGroup *)gnode);
227 } 230 }
228 } 231 }
229 } 232 }
230 } 233 }
231 234
232 static void simple_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) 235 static void simple_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
233 { 236 {
237 const char *name = purple_buddy_get_name(buddy);
234 struct simple_account_data *sip = (struct simple_account_data *)gc->proto_data; 238 struct simple_account_data *sip = (struct simple_account_data *)gc->proto_data;
235 struct simple_buddy *b = g_hash_table_lookup(sip->buddies, buddy->name); 239 struct simple_buddy *b = g_hash_table_lookup(sip->buddies, name);
236 g_hash_table_remove(sip->buddies, buddy->name); 240 g_hash_table_remove(sip->buddies, name);
237 g_free(b->name); 241 g_free(b->name);
238 g_free(b); 242 g_free(b);
239 } 243 }
240 244
241 static GList *simple_status_types(PurpleAccount *acc) { 245 static GList *simple_status_types(PurpleAccount *acc) {
920 g_free(buddy_name); 924 g_free(buddy_name);
921 925
922 purple_blist_add_buddy(b, NULL, g, NULL); 926 purple_blist_add_buddy(b, NULL, g, NULL);
923 purple_blist_alias_buddy(b, uri); 927 purple_blist_alias_buddy(b, uri);
924 bs = g_new0(struct simple_buddy, 1); 928 bs = g_new0(struct simple_buddy, 1);
925 bs->name = g_strdup(b->name); 929 bs->name = g_strdup(purple_buddy_get_name(b));
926 g_hash_table_insert(sip->buddies, bs->name, bs); 930 g_hash_table_insert(sip->buddies, bs->name, bs);
927 } 931 }
928 xmlnode_free(isc); 932 xmlnode_free(isc);
929 } 933 }
930 return 0; 934 return 0;