static void login_read_cb(PnNode *conn, gpointer data) { MsnNexus *nexus = data; GIOStatus status = G_IO_STATUS_NORMAL; gchar *str = NULL; if (!nexus->header) nexus->header = g_string_new(NULL); g_object_ref (conn); while (nexus->parser_state == 0) { gsize terminator_pos; status = pn_parser_read_line(nexus->parser, &str, NULL, &terminator_pos, NULL); if (status == G_IO_STATUS_AGAIN) goto leave; if (status != G_IO_STATUS_NORMAL) { msn_session_set_error(nexus->session, MSN_ERROR_AUTH, _("nexus stream error")); goto leave; } if (str) { str[terminator_pos] = '\0'; nexus->header = g_string_append(nexus->header, str); if (str[0] == '\0') { gchar *tmp; nexus->parser_state++; tmp = g_string_free(nexus->header, FALSE); nexus->header = NULL; got_header(nexus, tmp); g_free(tmp); g_free(str); break; } g_free(str); } } leave: g_object_unref(conn); }
static void nexus_read_cb(PnNode *conn, gpointer data) { MsnNexus *nexus = data; GIOStatus status = G_IO_STATUS_NORMAL; gchar *str = NULL; while (nexus->parser_state == 0) { gsize terminator_pos; status = pn_parser_read_line(nexus->parser, &str, NULL, &terminator_pos, NULL); if (status == G_IO_STATUS_AGAIN) return; if (status != G_IO_STATUS_NORMAL) { msn_session_set_error(nexus->session, MSN_ERROR_AUTH, _("nexus stream error")); return; } if (str) { char *field; str[terminator_pos] = '\0'; if ((field = get_field(str, "PassportURLs: "))) { char *da_login; da_login = strstr(field, "DALogin="******"DALogin="******"msnia.login.live.com"); #endif } } g_free(str); if (nexus->login_host) { PnSslConn *ssl_conn; PnNode *conn; ssl_conn = pn_ssl_conn_new("login", PN_NODE_NULL); conn = PN_NODE(ssl_conn); conn->session = nexus->session; if (nexus->error_handler) g_signal_handler_disconnect(nexus->conn, nexus->error_handler); if (nexus->open_handler) g_signal_handler_disconnect(nexus->conn, nexus->open_handler); g_object_unref(nexus->conn); pn_parser_free(nexus->parser); nexus->parser_state = 0; nexus->parser = pn_parser_new(conn); pn_ssl_conn_set_read_cb(ssl_conn, login_read_cb, nexus); nexus->conn = conn; nexus->open_handler = g_signal_connect(conn, "open", G_CALLBACK(login_open_cb), nexus); nexus->error_handler = g_signal_connect(conn, "error", G_CALLBACK(close_cb), nexus); pn_node_connect(conn, nexus->login_host, 443); return; } } } }
static void read_cb (PnNode *conn, gpointer data) { RoamingRequest *roaming_request; GIOStatus status = G_IO_STATUS_NORMAL; gchar *str = NULL; gboolean got_hostname = FALSE; roaming_request = data; while (roaming_request->parser_state == 0) { gsize terminator_pos; status = pn_parser_read_line (roaming_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, "Content-Length: ", 16) == 0) roaming_request->content_size = atoi(str + 16); if (strncmp (str, "Location: ", 10) == 0) roaming_request->location = g_strdup (str + 10); /* now comes the content */ if (str[0] == '\0') { roaming_request->parser_state++; break; } g_free (str); } } if (roaming_request->parser_state == 1) { gchar *body; status = pn_parser_read (roaming_request->parser, &body, roaming_request->content_size, NULL); if (status == G_IO_STATUS_AGAIN) return; if (status != G_IO_STATUS_NORMAL) goto leave; if (roaming_request->location != NULL) { gchar *cur; cur = strstr (roaming_request->location, "://") + 3; if (cur) { gchar *end = strchr (cur, '/'); g_free (roaming_request->roaming_session->hostname); roaming_request->roaming_session->hostname = g_strndup (cur, end - cur); got_hostname = TRUE; goto leave; } } pn_debug ("%s", body); if (roaming_request->type == PN_GET_PROFILE) { char *cachekey; pn_parse_xml_tag (body, "CacheKey", &cachekey); if (cachekey) { g_free (roaming_request->roaming_session->cachekey); roaming_request->roaming_session->cachekey = cachekey; } } if (roaming_request->type == PN_GET_PROFILE) process_get_profile (roaming_request, body); /* else if (roaming_request->type == PN_UPDATE_PROFILE) */ g_free(body); } leave: pn_node_close (conn); next_request (roaming_request->roaming_session, got_hostname); }