示例#1
0
void Shop::OnEditPageFinished() {
    QNetworkReply *reply = qobject_cast<QNetworkReply *>(QObject::sender());
    QByteArray bytes = reply->readAll();
    std::string page(bytes.constData(), bytes.size());
    std::string hash = Util::GetCsrfToken(page, "forum_thread");
    if (hash.empty()) {
        QLOG_ERROR() << "Can't update shop -- cannot extract CSRF token from the page. Check if thread ID is valid.";
        submitting_ = false;
        return;
    }

    // now submit our edit

    // holy shit give me some html parser library please
    std::string title = Util::FindTextBetween(page, "<input type=\"text\" name=\"title\" id=\"title\" value=\"", "\" class=\"textInput\">");
    if (title.empty()) {
        QLOG_ERROR() << "Can't update shop -- title is empty. Check if thread ID is valid.";
        submitting_ = false;
        return;
    }

    QUrlQuery query;
    query.addQueryItem("forum_thread", hash.c_str());
    query.addQueryItem("title", title.c_str());
    query.addQueryItem("content", requests_completed_ < shop_data_.size() ? shop_data_[requests_completed_].c_str() : "Empty");
    query.addQueryItem("submit", "Submit");

    QByteArray data(query.query().toUtf8());
    QNetworkRequest request((QUrl(ShopEditUrl(requests_completed_).c_str())));
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    QNetworkReply *submitted = app_.logged_in_nm().post(request, data);
    new QReplyTimeout(submitted, kEditThreadTimeout);
    connect(submitted, SIGNAL(finished()), this, SLOT(OnShopSubmitted()));
}
void ShopSubmitter::SubmitShop(ShopSubmission* submission) {
    QUrlQuery query;
    query.addQueryItem("forum_thread", submission->data.value("forum_thread").toString());
    query.addQueryItem("title", submission->data.value("forum_title").toString());
    query.addQueryItem("content", submission->shopData);
    query.addQueryItem("submit", "Submit");

    submission->timerId = startTimer(GetTimeout());

    QNetworkRequest request(QUrl(ShopEditUrl(submission->threadId)));
    request.setAttribute((QNetworkRequest::Attribute) SHOP_DATA_THREAD, submission->threadId);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    QNetworkReply *submitted = network->post(request, query.query().toUtf8());
    submission->state = SHOP_SUBMISSION_SUBMITTING;
    submission->currentReply = submitted;
    connect(submitted, SIGNAL(finished()), this, SLOT(OnShopSubmitted()));
}
示例#3
0
void Shop::OnEditPageFinished() {
    QNetworkReply *reply = qobject_cast<QNetworkReply *>(QObject::sender());
    QByteArray bytes = reply->readAll();
    std::string page(bytes.constData(), bytes.size());
    std::string hash = Util::GetCsrfToken(page, "forum_thread");
    if (hash.empty()) {
        QLOG_ERROR() << "Can't update shop -- cannot extract CSRF token from the page. Check if thread ID is valid."
            << "If you're using Steam to login make sure you use the same login method (steam or login/password) in Acquisition, Path of Exile website and Path of Exile game client."
            << "For example, if you created a shop thread while using Steam to log into the website and then logged into Acquisition with login/password it will not work."
            << "In this case you should either recreate your shop thread or use a correct login method in Acquisition.";
        submitting_ = false;
        return;
    }

    // now submit our edit

    // holy shit give me some html parser library please
    std::string title = Util::FindTextBetween(page, "<input type=\"text\" name=\"title\" id=\"title\" value=\"", "\" class=\"textInput\">");
    if (title.empty()) {
        QLOG_ERROR() << "Can't update shop -- title is empty. Check if thread ID is valid.";
        submitting_ = false;
        return;
    }

    QUrlQuery query;
    query.addQueryItem("forum_thread", hash.c_str());
    query.addQueryItem("title", Util::Decode(title).c_str());
    query.addQueryItem("content", requests_completed_ < shop_data_.size() ? shop_data_[requests_completed_].c_str() : "Empty");
    query.addQueryItem("submit", "Submit");

    QByteArray data(query.query().toUtf8());
    QNetworkRequest request((QUrl(ShopEditUrl(requests_completed_).c_str())));
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    QNetworkReply *submitted = app_.logged_in_nm().post(request, data);
    new QReplyTimeout(submitted, kEditThreadTimeout);
    connect(submitted, SIGNAL(finished()), this, SLOT(OnShopSubmitted()));
}