comparison libpurple/protocols/myspace/myspace.c @ 16734:3f53f8f502b2

Replacement magic numbers by symbolic constants. Add MSIM_AUTH_ALGORITHM. Use MSIM_BM_INSTANT.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Sun, 20 May 2007 20:56:04 +0000
parents a8e8482a2dc6
children 52357f6392a4
comparison
equal deleted inserted replaced
16733:a8e8482a2dc6 16734:3f53f8f502b2
647 - message order? should login2 come first? 647 - message order? should login2 come first?
648 - something else? 648 - something else?
649 */ 649 */
650 #if 0 650 #if 0
651 msim_send(session, 651 msim_send(session,
652 "login2", g_strdup_printf("%d", 196610), 652 "login2", g_strdup_printf("%d", MSIM_AUTH_ALGORITHM),
653 "username", g_strdup(account->username), 653 "username", g_strdup(account->username),
654 "response", g_strdup(response_str), 654 "response", g_strdup(response_str),
655 "clientver", g_strdup_printf("%d", MSIM_CLIENT_VERSION), 655 "clientver", g_strdup_printf("%d", MSIM_CLIENT_VERSION),
656 "reconn", g_strdup_printf("%d", 0), 656 "reconn", g_strdup_printf("%d", 0),
657 "status", g_strdup_printf("%d", 100), 657 "status", g_strdup_printf("%d", 100),
660 #else 660 #else
661 661
662 /* TODO: use msim_send. But, response_str must NOT be escaped. */ 662 /* TODO: use msim_send. But, response_str must NOT be escaped. */
663 /* \login2\196610\username\msimprpl@xyzzy.cjb.net\response\nseVXvvrwgQsv7FUAbHJLMP8YPEGKHftwN+Z0zCjmxOTOc0/nVPQWZ5Znv5i6kh26XfZlqNzvoPqaXNbXL6TsSZpU/guAAg0o6XBA1e/Sw==\clientver\673\reconn\0\status\100\id\1\final\ - works*/ 663 /* \login2\196610\username\msimprpl@xyzzy.cjb.net\response\nseVXvvrwgQsv7FUAbHJLMP8YPEGKHftwN+Z0zCjmxOTOc0/nVPQWZ5Znv5i6kh26XfZlqNzvoPqaXNbXL6TsSZpU/guAAg0o6XBA1e/Sw==\clientver\673\reconn\0\status\100\id\1\final\ - works*/
664 buf = g_strdup_printf("\\login2\\%d\\username\\%s\\response\\%s\\clientver\\%d\\reconn\\%d\\status\\%d\\id\\1\\final\\", 664 buf = g_strdup_printf("\\login2\\%d\\username\\%s\\response\\%s\\clientver\\%d\\reconn\\%d\\status\\%d\\id\\1\\final\\",
665 196610, account->username, response_str, MSIM_CLIENT_VERSION, 0, 100); 665 MSIM_AUTH_ALGORITHM, account->username, response_str, MSIM_CLIENT_VERSION, 0, 100);
666 666
667 667
668 purple_debug_info("msim", "response=<%s>\n", buf); 668 purple_debug_info("msim", "response=<%s>\n", buf);
669 669
670 msim_send_raw(session, buf); 670 msim_send_raw(session, buf);
880 * anyways except make note of that fact. Probably important for any 880 * anyways except make note of that fact. Probably important for any
881 * kind of direct connection, or file transfer functionality. 881 * kind of direct connection, or file transfer functionality.
882 */ 882 */
883 /* rc4 encrypt: 883 /* rc4 encrypt:
884 * nonce1+email+IP list */ 884 * nonce1+email+IP list */
885 data_len = NONCE_SIZE + strlen(email) + 25; 885 data_len = NONCE_SIZE + strlen(email)
886 /* TODO: change to length of IP list */
887 + 25;
886 data = g_new0(guchar, data_len); 888 data = g_new0(guchar, data_len);
887 memcpy(data, nonce, NONCE_SIZE); 889 memcpy(data, nonce, NONCE_SIZE);
888 memcpy(data + NONCE_SIZE, email, strlen(email)); 890 memcpy(data + NONCE_SIZE, email, strlen(email));
889 memcpy(data + NONCE_SIZE + strlen(email), 891 memcpy(data + NONCE_SIZE + strlen(email),
890 /* TODO: IP addresses of network interfaces */ 892 /* TODO: IP addresses of network interfaces */
1008 * 1010 *
1009 */ 1011 */
1010 static int msim_send_im_by_userid(MsimSession *session, const gchar *userid, const gchar *message, PurpleMessageFlags flags) 1012 static int msim_send_im_by_userid(MsimSession *session, const gchar *userid, const gchar *message, PurpleMessageFlags flags)
1011 { 1013 {
1012 gchar *msg_string; 1014 gchar *msg_string;
1015 gchar *escaped_message;
1013 1016
1014 g_return_val_if_fail(MSIM_SESSION_VALID(session), 0); 1017 g_return_val_if_fail(MSIM_SESSION_VALID(session), 0);
1015 g_return_val_if_fail(userid != NULL, 0); 1018 g_return_val_if_fail(userid != NULL, 0);
1016 g_return_val_if_fail(msim_is_userid(userid) == TRUE, 0); 1019 g_return_val_if_fail(msim_is_userid(userid) == TRUE, 0);
1017 g_return_val_if_fail(message != NULL, 0); 1020 g_return_val_if_fail(message != NULL, 0);
1018 1021
1019 /* XXX: delete after escape each value */ 1022 /* TODO: Remove this code and use MsimMessage after it is implemented and escapes strings. */
1020 message = msim_escape(message); 1023 escaped_message = msim_escape(message);
1021 1024
1022 /* TODO: constants for bm types */
1023 /* TODO: escape values */ 1025 /* TODO: escape values */
1024 msg_string = g_strdup_printf("\\bm\\121\\sesskey\\%s\\t\\%s\\cv\\%d\\msg\\%s\\final\\", 1026 msg_string = g_strdup_printf("\\bm\\%d\\sesskey\\%s\\t\\%s\\cv\\%d\\msg\\%s\\final\\",
1025 session->sesskey, userid, MSIM_CLIENT_VERSION, message); 1027 MSIM_BM_INSTANT, session->sesskey, userid, MSIM_CLIENT_VERSION, message);
1026 1028
1027 /* XXX: delete after escape each value */ 1029 /* TODO: Remove this code and use MsimMessage after it is implemented and escapes strings. */
1028 g_free((char*)message); 1030 g_free(escaped_message);
1029 1031
1030 purple_debug_info("msim", "going to write: %s\n", msg_string); 1032 purple_debug_info("msim", "going to write: %s\n", msg_string);
1031 1033
1032 msim_send_raw(session, msg_string); 1034 msim_send_raw(session, msg_string);
1033 1035
1431 g_return_val_if_fail(table != NULL, 0); 1433 g_return_val_if_fail(table != NULL, 0);
1432 1434
1433 status_str = g_hash_table_lookup(table, "msg"); 1435 status_str = g_hash_table_lookup(table, "msg");
1434 if (!status_str) 1436 if (!status_str)
1435 { 1437 {
1436 purple_debug_info("msim", "msim_status: bm=100 but no status msg\n"); 1438 purple_debug_info("msim", "msim_status: bm is status but no status msg\n");
1437 return 0; 1439 return 0;
1438 } 1440 }
1439 1441
1440 userid = g_hash_table_lookup(table, "f"); 1442 userid = g_hash_table_lookup(table, "f");
1441 if (!userid) 1443 if (!userid)
1442 { 1444 {
1443 purple_debug_info("msim", "msim_status: bm=100 but no f field\n"); 1445 purple_debug_info("msim", "msim_status: bm is status but no f field\n");
1444 return 0; 1446 return 0;
1445 } 1447 }
1446 1448
1447 /* TODO: if buddies were identified on buddy list by uid, wouldn't have to lookup 1449 /* TODO: if buddies were identified on buddy list by uid, wouldn't have to lookup
1448 * before updating the status! Much more efficient. */ 1450 * before updating the status! Much more efficient. */