comparison libpurple/protocols/myspace/myspace.c @ 17669:d727fda5a8e1

Change around msim_uid2username_from_blist() to try to get it to work (based on finch/gnthistory.c's looping over the buddy list), but leave it commented out because it still causes the crash in msim_parse().
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Tue, 26 Jun 2007 05:33:00 +0000
parents a014bcce5a5d
children 7e4e3f6582d2
comparison
equal deleted inserted replaced
17668:a014bcce5a5d 17669:d727fda5a8e1
1248 /* TODO: Free copy cloned from msim_preprocess_incoming(). */ 1248 /* TODO: Free copy cloned from msim_preprocess_incoming(). */
1249 //XXX msim_msg_free(msg); 1249 //XXX msim_msg_free(msg);
1250 g_hash_table_destroy(body); 1250 g_hash_table_destroy(body);
1251 } 1251 }
1252 1252
1253 #ifdef _MSIM_UID2USERNAME_WORKS 1253 #if 0
1254 /* Lookup a username by userid, from buddy list. 1254 /* Lookup a username by userid, from buddy list.
1255 * 1255 *
1256 * @param wanted_uid 1256 * @param wanted_uid
1257 * 1257 *
1258 * @return Username of wanted_uid, if on blist, or NULL. Static string. 1258 * @return Username of wanted_uid, if on blist, or NULL. Static string.
1260 * XXX WARNING: UNKNOWN MEMORY CORRUPTION HERE! 1260 * XXX WARNING: UNKNOWN MEMORY CORRUPTION HERE!
1261 */ 1261 */
1262 static const gchar * 1262 static const gchar *
1263 msim_uid2username_from_blist(MsimSession *session, guint wanted_uid) 1263 msim_uid2username_from_blist(MsimSession *session, guint wanted_uid)
1264 { 1264 {
1265 GSList *buddies, *buddies_head; 1265 GSList *buddies, *cur;
1266 1266
1267 for (buddies = buddies_head = purple_find_buddies(session->account, NULL); 1267 buddies = purple_find_buddies(session->account, NULL);
1268 buddies; 1268
1269 buddies = g_slist_next(buddies)) 1269 if (!buddies)
1270 {
1271 purple_debug_info("msim", "msim_uid2username_from_blist: no buddies?");
1272 return NULL;
1273 }
1274
1275 for (cur = buddies; cur != NULL; cur = g_slist_next(cur))
1270 { 1276 {
1271 PurpleBuddy *buddy; 1277 PurpleBuddy *buddy;
1278 //PurpleBlistNode *node;
1272 guint uid; 1279 guint uid;
1273 gchar *name; 1280 const gchar *name;
1274 1281
1275 buddy = buddies->data; 1282
1283 /* See finch/gnthistory.c */
1284 buddy = cur->data;
1285 //node = cur->data;
1276 1286
1277 uid = purple_blist_node_get_int(&buddy->node, "UserID"); 1287 uid = purple_blist_node_get_int(&buddy->node, "UserID");
1288 //uid = purple_blist_node_get_int(node, "UserID");
1278 1289
1279 /* name = buddy->name; */ /* crash */ 1290 /* name = buddy->name; */ /* crash */
1280 /* name = PURPLE_BLIST_NODE_NAME(&buddy->node); */ /* crash */ 1291 /* name = PURPLE_BLIST_NODE_NAME(&buddy->node); */ /* crash */
1281 1292
1282 /* XXX Is this right? Memory corruption here somehow. Happens only 1293 /* XXX Is this right? Memory corruption here somehow. Happens only
1283 * when return one of these values. */ 1294 * when return one of these values. */
1284 name = purple_buddy_get_name(buddy); /* crash */ 1295 name = purple_buddy_get_name(buddy); /* crash */
1296 //name = purple_buddy_get_name((PurpleBuddy *)node); /* crash */
1285 /* return name; */ /* crash (with above) */ 1297 /* return name; */ /* crash (with above) */
1286 1298
1287 /* name = NULL; */ /* no crash */ 1299 /* name = NULL; */ /* no crash */
1288 /* return NULL; */ /* no crash (with anything) */ 1300 /* return NULL; */ /* no crash (with anything) */
1289 1301
1321 source=<value optimized out>, cond=<value optimized out>) at myspace.c:1478 1333 source=<value optimized out>, cond=<value optimized out>) at myspace.c:1478
1322 1334
1323 1335
1324 Why is it crashing in msim_parse()'s g_strdup()? 1336 Why is it crashing in msim_parse()'s g_strdup()?
1325 */ 1337 */
1326
1327
1328 purple_debug_info("msim", "msim_uid2username_from_blist: %s's uid=%d (want %d)\n", 1338 purple_debug_info("msim", "msim_uid2username_from_blist: %s's uid=%d (want %d)\n",
1329 name, uid, wanted_uid); 1339 name, uid, wanted_uid);
1330 1340
1331 if (uid == wanted_uid) 1341 if (uid == wanted_uid)
1332 { 1342 {
1333 g_slist_free(buddies_head); 1343 gchar *ret;
1334 1344
1335 return name; 1345 ret = g_strdup(name);
1346
1347 g_slist_free(buddies);
1348
1349 return ret;
1336 } 1350 }
1337 } 1351 }
1338 1352
1339 g_slist_free(buddies_head); 1353 g_slist_free(buddies);
1340 return NULL; 1354 return NULL;
1341 } 1355 }
1342
1343 #endif 1356 #endif
1344 1357
1345 /** Preprocess incoming messages, resolving as needed, calling msim_process() when ready to process. 1358 /** Preprocess incoming messages, resolving as needed, calling msim_process() when ready to process.
1346 * 1359 *
1347 * @param session 1360 * @param session
1358 /* 'f' = userid message is from, in buddy messages */ 1371 /* 'f' = userid message is from, in buddy messages */
1359 uid = msim_msg_get_integer(msg, "f"); 1372 uid = msim_msg_get_integer(msg, "f");
1360 1373
1361 /* TODO: Make caching work. Currently it is commented out because 1374 /* TODO: Make caching work. Currently it is commented out because
1362 * it crashes for unknown reasons, memory realloc error. */ 1375 * it crashes for unknown reasons, memory realloc error. */
1363 //#define _MSIM_UID2USERNAME_WORKS 1376 #if 0
1364 #ifdef _MSIM_UID2USERNAME_WORKS
1365 username = msim_uid2username_from_blist(session, uid); 1377 username = msim_uid2username_from_blist(session, uid);
1366 #else 1378 #else
1367 username = NULL; 1379 username = NULL;
1368 #endif 1380 #endif
1369 1381
1370 if (username) 1382 if (username)
1371 { 1383 {
1372 /* Know username already, use it. */ 1384 /* Know username already, use it. */