Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static inline void
- oim_send_request (PnNode *conn,
- OimRequest *oim_request)
- {
- gchar *body;
- gchar *header;
- gsize body_len;
- pn_log ("begin");
- body = g_strdup_printf ("<?xml version=\"1.0\" encoding=\"utf-8\"?>",
- "<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/\">",
- "<soap:Header>",
- "<From memberName=\"%s\" friendlyName=\"%s%s%s\" xml:lang=\"nl-nl\" proxy=\"MSNMSGR\" xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\" msnpVer=\"MSNP13\" buildVer=\"8.0.0328\"/>",
- "<To memberName=\"%s\" xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\"/>",
- "<Ticket passport=\"%s\" appid=\"%s\" lockkey=\"%s\" xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\"/>",
- "<Sequence xmlns=\"http://schemas.xmlsoap.org/ws/2003/03/rm\">",
- "<Identifier xmlns=\"http://schemas.xmlsoap.org/ws/2002/07/utility\">http://messenger.msn.com</Identifier>",
- "<MessageNumber>%i</MessageNumber>",
- "</Sequence>",
- "</soap:Header>",
- "<soap:Body>",
- "<MessageType xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\">%s</MessageType>",
- "<Content xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\">MIME-Version: 1.0",
- "Content-Type: text/plain; charset=UTF-8",
- "Content-Transfer-Encoding: base64",
- "X-OIM-Message-Type: OfflineMessage",
- "X-OIM-Run-Id: %s",
- "X-OIM-Sequence-Num: %i",
- "\r\n",
- "%s",
- "</Content>",
- "</soap:Body>",
- "</soap:Envelope>",
- memberName,
- "=?utf-8?B?", pecan_base64_encode (friendly_name), "?=",
- memberName,
- passport,
- appid,
- lockkey, /** @todo session->lockkey ? */
- MessageNumber = X-OIM-Sequence-Num, /** @todo ++contact->sent_oims ? */
- "text",
- X-OIM-Run-Id,
- MessageNumber = X-OIM-Sequence-Num, /** @todo ++contact->sent_oims ? */
- purple_base64_encode (str));
- body_len = strlen (body);
- header = g_strdup_printf ("POST /OimWS/oim.asmx HTTP/1.1\r\n"
- "Accept: */*\r\n"
- "SOAPAction: \"http://messenger.msn.com/ws/2004/09/oim/Store\"\r\n"
- "Content-Type: text/xml; charset=utf-8\r\n"
- "Content-Length: %" G_GSIZE_FORMAT "\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"
- /* "Cookie: MSPAuth=%s\r\n" */
- "\r\n%s",
- body_len,
- "ows.messenger.msn.com",
- /* session->passport_info.mspauth, */
- body);
- g_free (body);
- pn_debug ("header=[%s]", header);
- /* pn_debug ("body=[%s]", body); */
- {
- gsize len;
- pn_node_write (conn, header, strlen (header), &len, NULL);
- pn_debug ("write_len=%d", len);
- }
- g_free (header);
- pn_log ("end");
- }
- static void
- read_cb (PnNode *conn,
- gpointer data)
- {
- OimRequest *oim_request;
- GIOStatus status = G_IO_STATUS_NORMAL;
- gchar *str = NULL;
- oim_request = data;
- gsize terminator_pos;
- status = pn_parser_read_line (oim_request->parser, &str, NULL, &terminator_pos, NULL);
- if (status == G_IO_STATUS_AGAIN)
- return;
- if (status != G_IO_STATUS_NORMAL)
- goto leave;
- if (str)
- {
- if (strcmp (str, "HTTP/1.1 200 OK") == 0)
- goto leave; /** is this correct? */
- g_free (str);
- }
- while (oim_request->parser_state < 1)
- {
- gsize terminator_pos;
- status = pn_parser_read_line (oim_request->parser, &str, NULL, &terminator_pos, NULL);
- if (status == G_IO_STATUS_AGAIN)
- return;
- if (status != G_IO_STATUS_NORMAL)
- goto leave;
- if (str)
- {
- str[terminator_pos] = '\0';
- /* now comes the content */
- if (str[0] == '\0')
- oim_request->parser_state++;
- g_free (str);
- }
- }
- while (oim_request->parser_state == 1)
- {
- gsize terminator_pos;
- status = pn_parser_read_line (oim_request->parser, &str, NULL, &terminator_pos, NULL);
- if (status == G_IO_STATUS_AGAIN)
- return;
- if (status != G_IO_STATUS_NORMAL)
- goto leave;
- if (str)
- {
- str[terminator_pos] = '\0';
- if (strncmp (str, "<LockKeyChallenge xmlns=\"http://messenger.msn.com/ws/2004/09/oim/\">", 67) == 0)
- {
- /** @todo: save the lockkey in session->lockkey */
- /** @todo: resend the message */
- goto leave; /** is this correct? */
- }
- /* now comes the content */
- if (str[0] == '\0')
- oim_request->parser_state++;
- g_free (str);
- }
- }
- leave:
- pn_node_close (conn);
- next_request (oim_request->oim_session);
- }
Advertisement
Add Comment
Please, Sign In to add comment