static void pn_send_login_uux (MsnSession *session) { MsnCmdProc *cmdproc; gchar *payload; const gchar *state_text; cmdproc = session->notification->cmdproc; payload = g_strdup_printf ("<EndpointData><Capabilities>%ld:0</Capabilities></EndpointData>", session->client_id); { MsnTransaction *trans; trans = msn_transaction_new (cmdproc, "UUX", "%d", strlen (payload)); msn_transaction_set_payload (trans, payload, strlen (payload)); msn_cmdproc_send_trans (cmdproc, trans); } g_free (payload); state_text = util_type_to_str (util_status_from_session (session)); payload = g_strdup_printf ("<PrivateEndpointData><EpName>msn-pecan</EpName><Idle>%s</Idle><ClientType>1</ClientType><State>%s</State></PrivateEndpointData>", strcmp (state_text, "ILN") == 0 ? "true" : "false", state_text); { MsnTransaction *trans; trans = msn_transaction_new (cmdproc, "UUX", "%d", strlen (payload)); msn_transaction_set_payload (trans, payload, strlen (payload)); msn_cmdproc_send_trans (cmdproc, trans); } g_free (payload); }
static void connect_cb(MsnServConn *servconn) { MsnSwitchBoard *swboard; MsnTransaction *trans; MsnCmdProc *cmdproc; PurpleAccount *account; cmdproc = servconn->cmdproc; g_return_if_fail(cmdproc != NULL); account = cmdproc->session->account; swboard = cmdproc->data; g_return_if_fail(swboard != NULL); if (msn_switchboard_is_invited(swboard)) { swboard->empty = FALSE; trans = msn_transaction_new(cmdproc, "ANS", "%s %s %s", purple_account_get_username(account), swboard->auth_key, swboard->session_id); } else { trans = msn_transaction_new(cmdproc, "USR", "%s %s", purple_account_get_username(account), swboard->auth_key); } msn_transaction_set_error_cb(trans, ans_usr_error); msn_transaction_set_data(trans, swboard); msn_cmdproc_send_trans(cmdproc, trans); }
static void chl_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { MsnTransaction *trans; char buf[33]; const char *challenge_resp; GaimCipher *cipher; GaimCipherContext *context; guchar digest[16]; int i; cipher = gaim_ciphers_find_cipher("md5"); context = gaim_cipher_context_new(cipher, NULL); gaim_cipher_context_append(context, (const guchar *)cmd->params[1], strlen(cmd->params[1])); challenge_resp = "VT6PX?UQTM4WM%YR"; gaim_cipher_context_append(context, (const guchar *)challenge_resp, strlen(challenge_resp)); gaim_cipher_context_digest(context, sizeof(digest), digest, NULL); gaim_cipher_context_destroy(context); for (i = 0; i < 16; i++) g_snprintf(buf + (i*2), 3, "%02x", digest[i]); trans = msn_transaction_new(cmdproc, "QRY", "%s 32", "PROD0038W!61ZTF9"); msn_transaction_set_payload(trans, buf, 32); msn_cmdproc_send_trans(cmdproc, trans); }
void msn_switchboard_close(MsnSwitchBoard *swboard) { g_return_if_fail(swboard != NULL); if (swboard->error != MSN_SB_ERROR_NONE) { msn_switchboard_destroy(swboard); } else if (g_queue_is_empty(swboard->msg_queue) || !swboard->session->connected) { MsnCmdProc *cmdproc; MsnTransaction *trans; cmdproc = swboard->cmdproc; trans = msn_transaction_new(cmdproc, "OUT", NULL); msn_transaction_set_saveable(trans, FALSE); msn_cmdproc_send_trans(cmdproc, trans); msn_switchboard_destroy(swboard); } else { swboard->closed = TRUE; } }
void msn_cmdproc_send(MsnCmdProc *cmdproc, const char *command, const char *format, ...) { MsnTransaction *trans; va_list arg; g_return_if_fail(cmdproc != NULL); g_return_if_fail(command != NULL); if (!cmdproc->servconn->connected) return; trans = g_new0(MsnTransaction, 1); trans->cmdproc = cmdproc; trans->command = g_strdup(command); if (format != NULL) { va_start(arg, format); trans->params = g_strdup_vprintf(format, arg); va_end(arg); } msn_cmdproc_send_trans(cmdproc, trans); }
static void release_msg(MsnSwitchBoard *swboard, MsnMessage *msg) { MsnCmdProc *cmdproc; MsnTransaction *trans; char *payload; gsize payload_len; char flag; g_return_if_fail(swboard != NULL); g_return_if_fail(msg != NULL); cmdproc = swboard->cmdproc; payload = msn_message_gen_payload(msg, &payload_len); if (purple_debug_is_verbose()) { purple_debug_info("msn", "SB length:{%" G_GSIZE_FORMAT "}\n", payload_len); msn_message_show_readable(msg, "SB SEND", FALSE); } flag = msn_message_get_flag(msg); trans = msn_transaction_new(cmdproc, "MSG", "%c %" G_GSIZE_FORMAT, flag, payload_len); /* Data for callbacks */ msn_transaction_set_data(trans, msg); if (flag != 'U') { if (msg->type == MSN_MSG_TEXT) { msg->ack_ref = TRUE; msn_message_ref(msg); swboard->ack_list = g_list_append(swboard->ack_list, msg); msn_transaction_set_timeout_cb(trans, msg_timeout); } else if (msg->type == MSN_MSG_SLP) { msg->ack_ref = TRUE; msn_message_ref(msg); swboard->ack_list = g_list_append(swboard->ack_list, msg); msn_transaction_set_timeout_cb(trans, msg_timeout); #if 0 if (msg->ack_cb != NULL) { msn_transaction_add_cb(trans, "ACK", msg_ack); msn_transaction_add_cb(trans, "NAK", msg_nak); } #endif } } trans->payload = payload; trans->payload_len = payload_len; msg->trans = trans; msn_cmdproc_send_trans(cmdproc, trans); }
void msn_cmdproc_process_queue(MsnCmdProc *cmdproc) { MsnTransaction *trans; while ((trans = g_queue_pop_head(cmdproc->txqueue)) != NULL) msn_cmdproc_send_trans(cmdproc, trans); }
void msn_transaction_unqueue(MsnTransaction *trans, MsnCmdProc *cmdproc) { MsnTransaction *elem; while ((elem = g_queue_pop_head(trans->queue)) != NULL) msn_cmdproc_send_trans(cmdproc, elem); }
static void email_msg(MsnCmdProc *cmdproc, MsnMessage *msg) { MsnSession *session; GaimConnection *gc; GHashTable *table; char *from, *subject, *tmp; session = cmdproc->session; gc = session->account->gc; if (strcmp(msg->remote_user, "Hotmail")) /* This isn't an official message. */ return; if (session->passport_info.file == NULL) { MsnTransaction *trans; trans = msn_transaction_new(cmdproc, "URL", "%s", "INBOX"); msn_transaction_queue_cmd(trans, msg->cmd); msn_cmdproc_send_trans(cmdproc, trans); return; } if (!gaim_account_get_check_mail(session->account)) return; table = msn_message_get_hashtable_from_body(msg); from = subject = NULL; tmp = g_hash_table_lookup(table, "From"); if (tmp != NULL) from = gaim_mime_decode_field(tmp); tmp = g_hash_table_lookup(table, "Subject"); if (tmp != NULL) subject = gaim_mime_decode_field(tmp); gaim_notify_email(gc, (subject != NULL ? subject : ""), (from != NULL ? from : ""), msn_user_get_passport(session->user), session->passport_info.file, NULL, NULL); if (from != NULL) g_free(from); if (subject != NULL) g_free(subject); g_hash_table_destroy(table); }
static void release_msg(MsnSwitchBoard *swboard, MsnMessage *msg) { MsnCmdProc *cmdproc; MsnTransaction *trans; char *payload; gsize payload_len; g_return_if_fail(swboard != NULL); g_return_if_fail(msg != NULL); cmdproc = swboard->cmdproc; payload = msn_message_gen_payload(msg, &payload_len); #ifdef MSN_DEBUG_SB msn_message_show_readable(msg, "SB SEND", FALSE); #endif trans = msn_transaction_new(cmdproc, "MSG", "%c %d", msn_message_get_flag(msg), payload_len); /* Data for callbacks */ msn_transaction_set_data(trans, msg); if (msg->type == MSN_MSG_TEXT) { msg->ack_ref = TRUE; msn_message_ref(msg); swboard->ack_list = g_list_append(swboard->ack_list, msg); msn_transaction_set_timeout_cb(trans, msg_timeout); } else if (msg->type == MSN_MSG_SLP) { msg->ack_ref = TRUE; msn_message_ref(msg); swboard->ack_list = g_list_append(swboard->ack_list, msg); msn_transaction_set_timeout_cb(trans, msg_timeout); #if 0 if (msg->ack_cb != NULL) { msn_transaction_add_cb(trans, "ACK", msg_ack); msn_transaction_add_cb(trans, "NAK", msg_nak); } #endif } trans->payload = payload; trans->payload_len = payload_len; msg->trans = trans; msn_cmdproc_send_trans(cmdproc, trans); }
static void initial_email_msg(MsnCmdProc *cmdproc, MsnMessage *msg) { MsnSession *session; GaimConnection *gc; GHashTable *table; const char *unread; session = cmdproc->session; gc = session->account->gc; if (strcmp(msg->remote_user, "Hotmail")) /* This isn't an official message. */ return; if (session->passport_info.file == NULL) { MsnTransaction *trans; trans = msn_transaction_new(cmdproc, "URL", "%s", "INBOX"); msn_transaction_queue_cmd(trans, msg->cmd); msn_cmdproc_send_trans(cmdproc, trans); return; } if (!gaim_account_get_check_mail(session->account)) return; table = msn_message_get_hashtable_from_body(msg); unread = g_hash_table_lookup(table, "Inbox-Unread"); if (unread != NULL) { int count = atoi(unread); if (count > 0) { const char *passport; const char *url; passport = msn_user_get_passport(session->user); url = session->passport_info.file; gaim_notify_emails(gc, atoi(unread), FALSE, NULL, NULL, &passport, &url, NULL, NULL); } } g_hash_table_destroy(table); }
void msn_switchboard_request(MsnSwitchBoard *swboard) { MsnCmdProc *cmdproc; MsnTransaction *trans; g_return_if_fail(swboard != NULL); cmdproc = swboard->session->notification->cmdproc; trans = msn_transaction_new(cmdproc, "XFR", "%s", "SB"); msn_transaction_add_cb(trans, "XFR", got_swboard); msn_transaction_set_data(trans, swboard); msn_transaction_set_error_cb(trans, xfr_error); msn_cmdproc_send_trans(cmdproc, trans); }
void msn_notification_add_buddy(MsnNotification *notification, const char *list, const char *who, const gchar *user_guid, const char *store_name, const gchar *group_guid) { MsnCmdProc *cmdproc; cmdproc = notification->cmdproc; /* moogman: * If old_group_name == NULL, then ADC cmd is different. * If a new buddy (as opposed to a buddy move), ADC cmd is different. * If !Fl, then do same as "new". */ if (user_guid && group_guid) { /* Buddy already in FL. Add it to group_guid. */ msn_cmdproc_send (cmdproc, "ADC", "%s C=%s %s", list, user_guid, group_guid); } else if (strcmp(list, "FL") == 0) { /* Add buddy to our FL. */ /* FunkTastic Foo! */ MsnTransaction *trans; MsnAddBuddy *data; data = g_new0 (MsnAddBuddy, 1); data->who = g_strdup (who); data->group_guid = g_strdup (group_guid); trans = msn_transaction_new (cmdproc, "ADC", "%s N=%s F=%s", list, who, purple_url_encode (store_name)); msn_transaction_set_data (trans, data); msn_cmdproc_send_trans (cmdproc, trans); } else { /* Add buddy to another list (BL, AL). */ msn_cmdproc_send (cmdproc, "ADC", "%s N=%s", list, who); } }
static inline void pn_set_personal_message (MsnSession *session, gchar *value, gchar *current_media) { MsnCmdProc *cmdproc; gchar *payload; cmdproc = session->notification->cmdproc; payload = g_strdup_printf ("<Data><PSM>%s</PSM><CurrentMedia>%s</CurrentMedia></Data>", value ? value : "", current_media ? current_media : ""); { MsnTransaction *trans; trans = msn_transaction_new (cmdproc, "UUX", "%d", strlen (payload)); msn_transaction_set_payload (trans, payload, strlen (payload)); msn_cmdproc_send_trans (cmdproc, trans); } g_free (payload); }
static void chl_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { MsnTransaction *trans; gchar buf[32]; #if 0 PurpleCipher *cipher; PurpleCipherContext *context; guchar digest[16]; const char *challenge_resp; int i; cipher = purple_ciphers_find_cipher("md5"); context = purple_cipher_context_new(cipher, NULL); purple_cipher_context_append(context, (const guchar *)cmd->params[1], strlen(cmd->params[1])); challenge_resp = "VT6PX?UQTM4WM%YR"; purple_cipher_context_append(context, (const guchar *)challenge_resp, strlen(challenge_resp)); purple_cipher_context_digest(context, sizeof(digest), digest, NULL); purple_cipher_context_destroy(context); for (i = 0; i < 16; i++) g_snprintf(buf + (i*2), 3, "%02x", digest[i]); #else pecan_handle_challenge (cmd->params[1], "PROD0101{0RM?UBW", buf); #endif /* trans = msn_transaction_new(cmdproc, "QRY", "%s 32", "PROD0038W!61ZTF9"); */ trans = msn_transaction_new (cmdproc, "QRY", "%s 32", "PROD0101{0RM?UBW"); msn_transaction_set_payload (trans, buf, 32); msn_cmdproc_send_trans (cmdproc, trans); }
void msn_switchboard_request_add_user(MsnSwitchBoard *swboard, const char *user) { MsnTransaction *trans; MsnCmdProc *cmdproc; g_return_if_fail(swboard != NULL); cmdproc = swboard->cmdproc; trans = msn_transaction_new(cmdproc, "CAL", "%s", user); /* this doesn't do anything, but users seem to think that * 'Unhandled command' is some kind of error, so we don't report it */ msn_transaction_add_cb(trans, "CAL", got_cal); msn_transaction_set_data(trans, swboard); msn_transaction_set_timeout_cb(trans, cal_timeout); if (swboard->ready) msn_cmdproc_send_trans(cmdproc, trans); else msn_cmdproc_queue_trans(cmdproc, trans); }
static void msn_request_add_group(MsnUserList *userlist, const char *who, const char *old_group_name, const char *new_group_name) { MsnCmdProc *cmdproc; MsnTransaction *trans; MsnMoveBuddy *data; cmdproc = userlist->session->notification->cmdproc; data = g_new0(MsnMoveBuddy, 1); data->who = g_strdup(who); if (old_group_name) data->old_group_name = g_strdup(old_group_name); trans = msn_transaction_new(cmdproc, "ADG", "%s %d", purple_url_encode(new_group_name), 0); msn_transaction_set_data(trans, data); msn_cmdproc_send_trans(cmdproc, trans); }
void msn_change_status(MsnSession *session) { PurpleAccount *account; MsnCmdProc *cmdproc; MsnTransaction *trans; MsnUser *user; MsnObject *msnobj; const char *state_text; GHashTable *ui_info = purple_core_get_ui_info(); MsnClientCaps caps = MSN_CLIENT_ID; g_return_if_fail(session != NULL); g_return_if_fail(session->notification != NULL); /* set client caps based on what the UI tells us it is... */ if (ui_info) { const gchar *client_type = g_hash_table_lookup(ui_info, "client_type"); if (client_type) { if (strcmp(client_type, "phone") == 0 || strcmp(client_type, "handheld") == 0) { caps |= MSN_CAP_VIA_MOBILE; } else if (strcmp(client_type, "web") == 0) { caps |= MSN_CAP_VIA_WEBIM; } else if (strcmp(client_type, "bot") == 0) { caps |= MSN_CAP_BOT; } /* MSN doesn't a "console" type... What, they have no ncurses UI? :-) */ } } account = session->account; cmdproc = session->notification->cmdproc; user = session->user; state_text = msn_state_get_text(msn_state_from_account(account)); /* If we're not logged in yet, don't send the status to the server, * it will be sent when login completes */ if (!session->logged_in) return; msn_set_psm(session); msnobj = msn_user_get_object(user); if (msnobj == NULL) { trans = msn_transaction_new(cmdproc, "CHG", "%s %u:%02u 0", state_text, caps, MSN_CLIENT_ID_EXT_CAPS); } else { char *msnobj_str; msnobj_str = msn_object_to_string(msnobj); trans = msn_transaction_new(cmdproc, "CHG", "%s %u:%02u %s", state_text, caps, MSN_CLIENT_ID_EXT_CAPS, purple_url_encode(msnobj_str)); g_free(msnobj_str); } msn_cmdproc_send_trans(cmdproc, trans); }