static void login_open_cb(PnNode *conn, gpointer data) { MsnNexus *nexus = data; MsnSession *session; const char *username, *password; char *req, *head, *tail; guint32 ctint; GIOStatus status = G_IO_STATUS_NORMAL; g_return_if_fail(conn); g_signal_handler_disconnect(conn, nexus->open_handler); nexus->open_handler = 0; session = nexus->session; username = msn_session_get_username(session); password = msn_session_get_password(session); ctint = strtoul((char *) g_hash_table_lookup(nexus->challenge_data, "ct"), NULL, 10) + 200; head = g_strdup_printf("GET %s HTTP/1.1\r\n" "Authorization: Passport1.4 OrgVerb=GET,OrgURL=%s,sign-in=%s", nexus->login_path, (char *) g_hash_table_lookup(nexus->challenge_data, "ru"), purple_url_encode(username)); tail = g_strdup_printf("lc=%s,id=%s,tw=%s,fs=%s,ru=%s,ct=%" G_GUINT32_FORMAT ",kpp=%s,kv=%s,ver=%s,tpf=%s\r\n" "User-Agent: MSMSGS\r\n" "Host: %s\r\n" "Connection: Keep-Alive\r\n" "Cache-Control: no-cache\r\n", get_key(nexus->challenge_data, "lc"), get_key(nexus->challenge_data, "id"), get_key(nexus->challenge_data, "tw"), get_key(nexus->challenge_data, "fs"), get_key(nexus->challenge_data, "ru"), ctint, get_key(nexus->challenge_data, "kpp"), get_key(nexus->challenge_data, "kv"), get_key(nexus->challenge_data, "ver"), get_key(nexus->challenge_data, "tpf"), nexus->login_host); req = g_strdup_printf("%s,pwd=%s,%s\r\n", head, purple_url_encode(password), tail); g_free(head); g_free(tail); status = pn_node_write(conn, req, strlen(req), NULL, NULL); if (status != G_IO_STATUS_NORMAL) { msn_session_set_error(nexus->session, MSN_ERROR_AUTH, _("nexus stream error")); } g_free(req); }
static void nexus_open_cb(PnNode *conn, gpointer data) { MsnNexus *nexus = data; const gchar *req = "GET /rdr/pprdr.asp\r\n\r\n"; GIOStatus status = G_IO_STATUS_NORMAL; g_return_if_fail(conn); g_signal_handler_disconnect(conn, nexus->open_handler); nexus->open_handler = 0; g_signal_handler_disconnect(conn, nexus->error_handler); nexus->error_handler = 0; pn_node_write(conn, req, strlen(req), NULL, NULL); if (status != G_IO_STATUS_NORMAL) { msn_session_set_error(nexus->session, MSN_ERROR_AUTH, _("nexus stream error")); } }
static GIOStatus write_impl (PnNode *conn, const gchar *buf, gsize count, gsize *ret_bytes_written, GError **error) { GIOStatus status = G_IO_STATUS_NORMAL; pn_debug ("name=%s", conn->name); if (conn->next) { PnNode *next; next = conn->next; /* conn->next has already a ref from conn, but let's just be sure and * ref anyway */ g_object_ref (next); next->prev = conn; status = pn_node_write (next, buf, count, ret_bytes_written, error); next->prev = NULL; g_object_unref (next); } else { GError *tmp_error = NULL; gsize bytes_written = 0; pn_debug ("stream=%p", conn->stream); status = pn_stream_write_full (conn->stream, buf, count, &bytes_written, &tmp_error); pn_log ("bytes_written=%zu", bytes_written); if (status == G_IO_STATUS_NORMAL) { if (bytes_written < count) { /* This shouldn't happen, right? */ /* It doesn't seem to happen, but keep checking for now. */ pn_error ("write check: %zu < %zu", bytes_written, count); } } else { pn_warning ("not normal: status=%d (%s)", status, status_to_str (status)); } if (ret_bytes_written) *ret_bytes_written = bytes_written; if (tmp_error) { conn->error = g_error_copy (tmp_error); g_propagate_error (error, tmp_error); } } return status; }
static inline void send_update_profile_request (PnNode *conn, RoamingRequest *roaming_request) { gchar *body; gchar *header; gsize body_len; PnAuth *auth = roaming_request->roaming_session->session->auth; gchar *friendly = roaming_request->value; gchar *psm = roaming_request->extra_value; pn_log ("begin"); body = g_strdup_printf ("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n" "<soap:Header>\r\n" "<AffinityCacheHeader xmlns=\"http://www.msn.com/webservices/storage/w10\">\r\n" "<CacheKey>%s</CacheKey>\r\n" "</AffinityCacheHeader>\r\n" "<StorageApplicationHeader xmlns=\"http://www.msn.com/webservices/storage/w10\">\r\n" "<ApplicationID>Messenger Client 8.5</ApplicationID>\r\n" "<Scenario>RoamingIdentityChanged</Scenario>\r\n" "</StorageApplicationHeader>\r\n" "<StorageUserHeader xmlns=\"http://www.msn.com/webservices/storage/w10\">\r\n" "<Puid>0</Puid>\r\n" "<TicketToken>%s</TicketToken>\r\n" "</StorageUserHeader>\r\n" "</soap:Header>\r\n" "<soap:Body>\r\n" "<UpdateProfile xmlns=\"http://www.msn.com/webservices/storage/w10\">\r\n" "<profile>\r\n" "<ResourceID>%s</ResourceID>\r\n" "<ExpressionProfile>\r\n" "<FreeText>Update</FreeText>\r\n" "%s%s%s\r\n" "%s%s%s" "<Flags>0</Flags>\r\n" "</ExpressionProfile>\r\n" "</profile>\r\n" "</UpdateProfile>\r\n" "</soap:Body>\r\n" "</soap:Envelope>", roaming_request->roaming_session->cachekey, auth->security_token.storage_msn_com, roaming_request->roaming_session->resource_id, friendly ? "<DisplayName>" : "", friendly ? friendly : "", friendly ? "</DisplayName>\r\n" : "", psm ? "<PersonalStatus>" : "", psm ? psm : "", psm ? "</PersonalStatus>\r\n" : ""); body_len = strlen (body); header = g_strdup_printf ("POST /storageservice/SchematizedStore.asmx HTTP/1.1\r\n" "Accept: */*\r\n" "SOAPAction: \"http://www.msn.com/webservices/storage/w10/UpdateProfile\"\r\n" "Content-Type: text/xml; charset=utf-8\r\n" "Content-Length: %zu\r\n" "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n" "Host: %s\r\n" "Connection: Keep-Alive\r\n" "Cache-Control: no-cache\r\n" "\r\n%s", body_len, roaming_request->roaming_session->hostname ? roaming_request->roaming_session->hostname : "storage.msn.com", body); g_free (body); pn_debug ("header=[%s]", header); { gsize len; pn_node_write (conn, header, strlen (header), &len, NULL); pn_debug ("write_len=%zu", len); } g_free (header); pn_log ("end"); }
static inline void send_get_profile_request (PnNode *conn, RoamingRequest *roaming_request) { gchar *body; gchar *header; gsize body_len; PnAuth *auth = roaming_request->roaming_session->session->auth; pn_log ("begin"); body = g_strdup_printf ("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n" "<soap:Header>\r\n" "<StorageApplicationHeader xmlns=\"http://www.msn.com/webservices/storage/w10\">\r\n" "<ApplicationID>Messenger Client 8.5</ApplicationID>\r\n" "<Scenario>RoamingSeed</Scenario>\r\n" "</StorageApplicationHeader>\r\n" "<StorageUserHeader xmlns=\"http://www.msn.com/webservices/storage/w10\"><Puid>0</Puid>\r\n" "<TicketToken>%s</TicketToken>\r\n" "</StorageUserHeader>\r\n" "</soap:Header>\r\n" "<soap:Body>\r\n" "<GetProfile xmlns=\"http://www.msn.com/webservices/storage/w10\">\r\n" "<profileHandle>\r\n" "<Alias>\r\n" "<Name>%s</Name>\r\n" "<NameSpace>MyCidStuff</NameSpace>\r\n" "</Alias>\r\n" "<RelationshipName>MyProfile</RelationshipName>\r\n" "</profileHandle>\r\n" "<profileAttributes>\r\n" "<ResourceID>true</ResourceID>\r\n" "<DateModified>true</DateModified>\r\n" "<ExpressionProfileAttributes>\r\n" "<ResourceID>true</ResourceID>\r\n" "<DateModified>true</DateModified>\r\n" "<DisplayName>true</DisplayName>\r\n" "<DisplayNameLastModified>true</DisplayNameLastModified>\r\n" "<PersonalStatus>true</PersonalStatus>\r\n" "<PersonalStatusLastModified>true</PersonalStatusLastModified>\r\n" "<StaticUserTilePublicURL>true</StaticUserTilePublicURL>\r\n" "<Photo>true</Photo>\r\n" "<Flags>true</Flags>\r\n" "</ExpressionProfileAttributes>\r\n" "</profileAttributes>\r\n" "</GetProfile>\r\n" "</soap:Body>\r\n" "</soap:Envelope>", auth->security_token.storage_msn_com, roaming_request->roaming_session->session->cid); body_len = strlen (body); header = g_strdup_printf ("POST /storageservice/SchematizedStore.asmx HTTP/1.1\r\n" "Accept: */*\r\n" "SOAPAction: \"http://www.msn.com/webservices/storage/w10/GetProfile\"\r\n" "Content-Type: text/xml; charset=utf-8\r\n" "Content-Length: %zu\r\n" "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n" "Host: %s\r\n" "Connection: Keep-Alive\r\n" "Cache-Control: no-cache\r\n" "\r\n%s", body_len, roaming_request->roaming_session->hostname ? roaming_request->roaming_session->hostname : "storage.msn.com", body); g_free (body); pn_debug ("header=[%s]", header); { gsize len; pn_node_write (conn, header, strlen (header), &len, NULL); pn_debug ("write_len=%zu", len); } g_free (header); pn_log ("end"); }