Exemplo n.º 1
0
void GagBookManager::login(const QString &username, const QString &password)
{
    Q_ASSERT(m_netManager);

    if (m_loginReply != 0) {
        m_loginReply->disconnect();
        m_loginReply->deleteLater();
        m_loginReply = 0;
    }

    if (m_isBusy != true) {
        m_isBusy = true;
        emit busyChanged();
    }

    QByteArray postData;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    QUrlQuery postDataQuery;
    postDataQuery.addQueryItem("username", username);
    postDataQuery.addQueryItem("password", password);
    postData = postDataQuery.toString(QUrl::FullyEncoded).toUtf8();
#else
    QUrl postDataQuery;
    postDataQuery.addQueryItem("username", username);
    postDataQuery.addQueryItem("password", password);
    postData = postDataQuery.encodedQuery();
#endif

    m_loginReply = m_netManager->createPostRequest(QUrl("https://9gag.com/login"), postData);
    connect(m_loginReply, SIGNAL(finished()), SLOT(onLoginFinished()));
}
Exemplo n.º 2
0
GameState::GameState(
    const QString            & host,
    quint16                    port,
    const QString            & userName,
    NetworkClient::TcpClient & tcpClient) :

    NetworkClient::BaseGameState(nullptr),
    m_host(host),
    m_port(port),
    m_userName(userName)
{
    nc::LoginHandler * loginHandler = new nc::LoginHandler;
    // Special signals are connected manually for now.
    connect(loginHandler, SIGNAL(compressionThresholdChanged(int)), &tcpClient, SLOT(setCompressionThreshold(int)));
    connect(loginHandler, SIGNAL(loginFinished()), this, SLOT(onLoginFinished()));
    addMessageHandler(loginHandler);

    addMessageHandler(new nc::KeepAliveHandler);

    ChatHandler * chatHandler = new ChatHandler;
    connect(chatHandler, SIGNAL(chatMessageReceived(QString)), this, SIGNAL(chatMessageReceived(QString)));
    addMessageHandler(chatHandler);

    DisconnectHandler * disconnectHandler = new DisconnectHandler;
    connect(disconnectHandler, SIGNAL(disconnectedFromServer(QString)), this, SIGNAL(disconnectedFromServer(QString)));
    addMessageHandler(disconnectHandler);
}
Exemplo n.º 3
0
void Pastebin::login(const QString& username, const QString& password) {
    QNetworkRequest request(buildUrl("http://pastebin.com/api/api_login.php"));
    request.setHeader(QNetworkRequest::ContentTypeHeader, URLENCODED_CONTENT_TYPE);

    QUrl params;
    params.addQueryItem("api_dev_key", PASTEBIN_DEV_KEY);
    params.addQueryItem("api_user_name", username.toUtf8());
    params.addQueryItem("api_user_password", password.toUtf8());

    QNetworkReply *reply = accessManager_.post(request, params.encodedQuery());
    connect(reply, SIGNAL(finished()), this, SLOT(onLoginFinished()));
}