Exemplo n.º 1
0
void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
	debugLogA("CVkProto::OnReceiveMyInfo %d", reply->resultCode);
	if (reply->resultCode != 200) {
		ConnectionFailed(LOGINERR_WRONGPASSWORD);
		return;
	}

	JSONROOT pRoot;
	JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot);
	if (pResponse == NULL)
		return;

	for (size_t i = 0; i < json_size(pResponse); i++) {
		JSONNODE *it = json_at(pResponse, i);
		LPCSTR id = json_name(it);
		if (!_stricmp(id, "user_id")) {
			m_myUserId = json_as_int(it);
			setDword("ID", m_myUserId);
		}
	}

	OnLoggedIn();
	RetrieveUserInfo(m_myUserId);
	RetrieveFriends();
	RetrieveUnreadMessages();
	RetrievePollingInfo();
}
Exemplo n.º 2
0
void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
	debugLogA("CVkProto::OnReceiveMyInfo %d", reply->resultCode);
	if (reply->resultCode != 200) {
		ConnectionFailed(LOGINERR_WRONGPASSWORD);
		return;
	}

	JSONNode jnRoot;
	const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot);
	if (!jnResponse)
		return;
	
	const JSONNode &jnUser = *(jnResponse.begin());


	m_myUserId = jnUser["id"].as_int();
	setDword("ID", m_myUserId);
		
	OnLoggedIn();
	RetrieveUserInfo(m_myUserId);
	RetrieveUnreadMessages();
	RetrieveFriends();
	RetrievePollingInfo();
}
Exemplo n.º 3
0
void LoginDialog::OnLoginPageFinished() {
    QNetworkReply *reply = qobject_cast<QNetworkReply *>(QObject::sender());
    if (reply->error()) {
        DisplayError("Network error: " + reply->errorString() + "\nTry using another login method.");
        return;
    }

    QByteArray bytes = reply->readAll();
    std::string page(bytes.constData(), bytes.size());
    std::string hash = Util::GetCsrfToken(page, "hash");
    if (hash.empty()) {
        DisplayError("Failed to log in (can't extract form hash from page)");
        return;
    }

    QUrlQuery query;
    query.addQueryItem("login_email", EncodeSpecialCharacters(ui->emailLineEdit->text()));
    query.addQueryItem("login_password", EncodeSpecialCharacters(ui->passwordLineEdit->text()));
    query.addQueryItem("hash", QString(hash.c_str()));
    query.addQueryItem("login", "Login");
    query.addQueryItem("remember_me", "1");

    QUrl url(POE_LOGIN_URL);
    QByteArray data(query.query().toUtf8());
    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    QNetworkReply *logged_in = login_manager_->post(request, data);
    connect(logged_in, SIGNAL(finished()), this, SLOT(OnLoggedIn()));
}
Exemplo n.º 4
0
void LoginDialog::LoginWithCookie(const QString &cookie) {
    QNetworkCookie poeCookie(POE_COOKIE_NAME, cookie.toUtf8());
    poeCookie.setPath("/");
    poeCookie.setDomain(".pathofexile.com");

    login_manager_->cookieJar()->insertCookie(poeCookie);

    QNetworkReply *login_page = login_manager_->get(QNetworkRequest(QUrl(POE_LOGIN_URL)));
    connect(login_page, SIGNAL(finished()), this, SLOT(OnLoggedIn()));
}
Exemplo n.º 5
0
void LoginDialog::OnLoginPageFinished() {
    QNetworkReply *reply = qobject_cast<QNetworkReply *>(QObject::sender());
    if (reply->error()) {
        DisplayError("Network error: " + reply->errorString());
        return;
    }
    switch (ui->loginTabs->currentIndex()) {
        case LOGIN_PASSWORD: {
            QByteArray bytes = reply->readAll();
            std::string page(bytes.constData(), bytes.size());
            std::string hash = Util::GetCsrfToken(page, "hash");
            if (hash.empty()) {
                DisplayError("Failed to log in (can't extract form hash from page)");
                return;
            }

            QUrlQuery query;
            query.addQueryItem("login_email", EncodeSpecialCharacters(ui->emailLineEdit->text()));
            query.addQueryItem("login_password", EncodeSpecialCharacters(ui->passwordLineEdit->text()));
            query.addQueryItem("hash", QString(hash.c_str()));
            query.addQueryItem("login", "Login");

            QUrl url(POE_LOGIN_URL);
            QByteArray data(query.query().toUtf8());
            QNetworkRequest request(url);
            request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
            QNetworkReply *logged_in = login_manager_->post(request, data);
            connect(logged_in, SIGNAL(finished()), this, SLOT(OnLoggedIn()));
            break;
        }
        case LOGIN_STEAM: {
            if (!steam_login_dialog_)
                InitSteamDialog();
            steam_login_dialog_->show();
            steam_login_dialog_->Init();
            break;
        }
        case LOGIN_SESSIONID: {
            LoginWithCookie(ui->sessionIDLineEdit->text());
            break;
        }
    }
}