comparison libpurple/protocols/myspace/myspace.c @ 19439:0202145e3465

In msimprpl, fix the msim_uri_handler(). The sendIM and addContact commands now work (accepting a contact ID).
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Sun, 26 Aug 2007 18:51:06 +0000
parents a8c9c42c3572
children bbb205c49228
comparison
equal deleted inserted replaced
19438:fdddf11a42f2 19439:0202145e3465
2993 guint uid, cid; 2993 guint uid, cid;
2994 2994
2995 if (g_ascii_strcasecmp(proto, "myim")) 2995 if (g_ascii_strcasecmp(proto, "myim"))
2996 return FALSE; 2996 return FALSE;
2997 2997
2998 uid_str = g_hash_table_lookup(params, "uID"); 2998 /* Parameters are case-insensitive. */
2999 cid_str = g_hash_table_lookup(params, "cID"); 2999 uid_str = g_hash_table_lookup(params, "uid");
3000 cid_str = g_hash_table_lookup(params, "cid");
3000 3001
3001 uid = uid_str ? atol(uid_str) : 0; 3002 uid = uid_str ? atol(uid_str) : 0;
3002 cid = cid_str ? atol(cid_str) : 0; 3003 cid = cid_str ? atol(cid_str) : 0;
3004
3005 /* Need a contact. */
3006 g_return_val_if_fail(cid != 0, FALSE);
3003 3007
3004 /* Find our account with specified user id, or use first connected account if uid=0. */ 3008 /* Find our account with specified user id, or use first connected account if uid=0. */
3005 account = NULL; 3009 account = NULL;
3006 l = purple_accounts_get_all(); 3010 l = purple_accounts_get_all();
3007 while (l) { 3011 while (l) {
3018 _("No suitable MySpaceIM account could be found to open this myim URL."), 3022 _("No suitable MySpaceIM account could be found to open this myim URL."),
3019 _("Enable the proper MySpaceIM account and try again.")); 3023 _("Enable the proper MySpaceIM account and try again."));
3020 return FALSE; 3024 return FALSE;
3021 } 3025 }
3022 3026
3027 /* TODO: msim_lookup_user() on cid, so can add by username? */
3028
3023 /* myim:sendIM?uID=USERID&cID=CONTACTID */ 3029 /* myim:sendIM?uID=USERID&cID=CONTACTID */
3024 if (!g_ascii_strcasecmp(cmd, "sendIM")) { 3030 if (!g_ascii_strcasecmp(cmd, "sendIM")) {
3025 PurpleConversation *conv; 3031 PurpleConversation *conv;
3026 3032
3027 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, cid_str, account); 3033 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, cid_str, account);
3028 if (!conv) 3034 if (!conv) {
3035 purple_debug_info("msim_uri_handler", "creating new conversation for %s\n", cid_str);
3029 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, cid_str); 3036 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, cid_str);
3037 }
3038
3039 /* Just open the window so the user can send an IM. */
3030 purple_conversation_present(conv); 3040 purple_conversation_present(conv);
3031
3032 /* TODO: where to get the message? or is there any? */
3033 purple_conv_send_confirm(conv, "test");
3034 3041
3035 /* myim:addContact?uID=USERID&cID=CONTACTID */ 3042 /* myim:addContact?uID=USERID&cID=CONTACTID */
3036 } else if (!g_ascii_strcasecmp(cmd, "addContact")) { 3043 } else if (!g_ascii_strcasecmp(cmd, "addContact")) {
3037 purple_blist_request_add_buddy(account, cid_str, _("Buddies"), NULL); 3044 purple_blist_request_add_buddy(account, cid_str, _("Buddies"), NULL);
3038 } 3045 }