comparison libpurple/protocols/myspace/myspace.c @ 16727:cd4a6bd9f69e

Use g_return_if_fail() instead of g_assert(), as to not crash the whole program.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Thu, 10 May 2007 04:05:49 +0000
parents fc80e7b2540d
children 8f6dcd5e9298
comparison
equal deleted inserted replaced
16726:fc80e7b2540d 16727:cd4a6bd9f69e
903 903
904 g_return_if_fail(MSIM_SESSION_VALID(session)); 904 g_return_if_fail(MSIM_SESSION_VALID(session));
905 g_return_if_fail(userinfo != NULL); 905 g_return_if_fail(userinfo != NULL);
906 906
907 body = msim_parse_body(g_hash_table_lookup(userinfo, "body")); 907 body = msim_parse_body(g_hash_table_lookup(userinfo, "body"));
908 g_assert(body); 908 g_return_if_fail(body != NULL);
909 909
910 userid = g_hash_table_lookup(body, "UserID"); 910 userid = g_hash_table_lookup(body, "UserID");
911 911
912 s = (send_im_cb_struct*)data; 912 s = (send_im_cb_struct*)data;
913 msim_send_im_by_userid(session, userid, s->message, s->flags); 913 msim_send_im_by_userid(session, userid, s->message, s->flags);
933 933
934 g_return_if_fail(MSIM_SESSION_VALID(session)); 934 g_return_if_fail(MSIM_SESSION_VALID(session));
935 g_return_if_fail(userinfo != NULL); 935 g_return_if_fail(userinfo != NULL);
936 936
937 body = msim_parse_body(g_hash_table_lookup(userinfo, "body")); 937 body = msim_parse_body(g_hash_table_lookup(userinfo, "body"));
938 g_assert(body != NULL); 938 g_return_if_fail(body != NULL);
939 939
940 username = g_hash_table_lookup(body, "UserName"); 940 username = g_hash_table_lookup(body, "UserName");
941 941
942 msg = (gchar*)data; 942 msg = (gchar*)data;
943 serv_got_im(session->gc, username, msg, PURPLE_MESSAGE_RECV, time(NULL)); 943 serv_got_im(session->gc, username, msg, PURPLE_MESSAGE_RECV, time(NULL));
1196 g_return_if_fail(userinfo != NULL); 1196 g_return_if_fail(userinfo != NULL);
1197 1197
1198 status_str = (gchar*)data; 1198 status_str = (gchar*)data;
1199 1199
1200 body = msim_parse_body(g_hash_table_lookup(userinfo, "body")); 1200 body = msim_parse_body(g_hash_table_lookup(userinfo, "body"));
1201 g_assert(body); 1201 g_return_if_fail(body != NULL);
1202 1202
1203 username = g_hash_table_lookup(body, "UserName"); 1203 username = g_hash_table_lookup(body, "UserName");
1204 /* Note: DisplayName doesn't seem to be resolvable. It could be displayed on 1204 /* Note: DisplayName doesn't seem to be resolvable. It could be displayed on
1205 * the buddy list, if the UserID was stored along with it. */ 1205 * the buddy list, if the UserID was stored along with it. */
1206 1206
1324 gc = (PurpleConnection*)(gc_uncasted); 1324 gc = (PurpleConnection*)(gc_uncasted);
1325 account = purple_connection_get_account(gc); 1325 account = purple_connection_get_account(gc);
1326 session = gc->proto_data; 1326 session = gc->proto_data;
1327 1327
1328 g_return_if_fail(MSIM_SESSION_VALID(session)); 1328 g_return_if_fail(MSIM_SESSION_VALID(session));
1329 1329 g_return_if_fail(cond == PURPLE_INPUT_READ);
1330 g_assert(cond == PURPLE_INPUT_READ);
1331 1330
1332 /* Only can handle so much data at once... 1331 /* Only can handle so much data at once...
1333 * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE. 1332 * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE.
1334 * Should be large enough to hold the largest protocol message. 1333 * Should be large enough to hold the largest protocol message.
1335 */ 1334 */
1627 /** 1626 /**
1628 * Obtain the status text for a buddy. 1627 * Obtain the status text for a buddy.
1629 * 1628 *
1630 * @param buddy The buddy to obtain status text for. 1629 * @param buddy The buddy to obtain status text for.
1631 * 1630 *
1632 * @return Status text. 1631 * @return Status text, or NULL if error.
1633 * 1632 *
1634 * Currently returns the display name.
1635 */ 1633 */
1636 static char *msim_status_text(PurpleBuddy *buddy) 1634 static char *msim_status_text(PurpleBuddy *buddy)
1637 { 1635 {
1638 MsimSession *session; 1636 MsimSession *session;
1639 GHashTable *userinfo; 1637 GHashTable *userinfo;
1640 gchar *display_name; 1638 gchar *display_name;
1641 1639
1642 g_return_val_if_fail(buddy != NULL, NULL); 1640 g_return_val_if_fail(buddy != NULL, NULL);
1643 1641
1644 session = (MsimSession*)buddy->account->gc->proto_data; 1642 session = (MsimSession*)buddy->account->gc->proto_data;
1645 g_assert(MSIM_SESSION_VALID(session)); 1643 g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL);
1646 g_assert(session->user_lookup_cache != NULL); 1644 g_return_val_if_fail(session->user_lookup_cache != NULL, NULL);
1647 1645
1648 userinfo = g_hash_table_lookup(session->user_lookup_cache, buddy->name); 1646 userinfo = g_hash_table_lookup(session->user_lookup_cache, buddy->name);
1649 if (!userinfo) 1647 if (!userinfo)
1650 { 1648 {
1651 return g_strdup(""); 1649 return g_strdup("");
1652 } 1650 }
1653 1651
1654 display_name = g_hash_table_lookup(userinfo, "DisplayName"); 1652 display_name = g_hash_table_lookup(userinfo, "DisplayName");
1655 g_assert(display_name != NULL); 1653 g_return_val_if_fail(display_name != NULL, NULL);
1656 1654
1657 return g_strdup(display_name); 1655 return g_strdup(display_name);
1658 } 1656 }
1659 1657
1660 /** 1658 /**
1675 MsimSession *session; 1673 MsimSession *session;
1676 GHashTable *userinfo; 1674 GHashTable *userinfo;
1677 1675
1678 session = (MsimSession*)buddy->account->gc->proto_data; 1676 session = (MsimSession*)buddy->account->gc->proto_data;
1679 1677
1680 g_assert(MSIM_SESSION_VALID(session)); 1678 g_return_if_fail(MSIM_SESSION_VALID(session));
1681 g_assert(session->user_lookup_cache); 1679 g_return_if_fail(session->user_lookup_cache);
1682 1680
1683 userinfo = g_hash_table_lookup(session->user_lookup_cache, buddy->name); 1681 userinfo = g_hash_table_lookup(session->user_lookup_cache, buddy->name);
1684 1682
1685 g_assert(userinfo != NULL); 1683 g_return_if_fail(userinfo != NULL);
1686 1684
1687 // TODO: if (full), do something different 1685 // TODO: if (full), do something different
1688 purple_notify_user_info_add_pair(user_info, "User ID", g_hash_table_lookup(userinfo, "UserID")); 1686 purple_notify_user_info_add_pair(user_info, "User ID", g_hash_table_lookup(userinfo, "UserID"));
1689 purple_notify_user_info_add_pair(user_info, "Display Name", g_hash_table_lookup(userinfo, "DisplayName")); 1687 purple_notify_user_info_add_pair(user_info, "Display Name", g_hash_table_lookup(userinfo, "DisplayName"));
1690 purple_notify_user_info_add_pair(user_info, "User Name", g_hash_table_lookup(userinfo, "UserName")); 1688 purple_notify_user_info_add_pair(user_info, "User Name", g_hash_table_lookup(userinfo, "UserName"));