Esempio n. 1
0
void JSKitXMLHttpRequest::handleReplyFinished()
{
    if (!_reply) {
        qCDebug(l) << "reply finished too late";
        return;
    }

    _response = _reply->readAll();
    qCDebug(l) << "reply finished, reply text:" << QString::fromUtf8(_response);

    emit readyStateChanged();
    emit statusChanged();
    emit statusTextChanged();
    emit responseChanged();
    emit responseTextChanged();

    if (_onload.isCallable()) {
        qCDebug(l) << "going to call onload handler:" << _onload.toString();
        QJSValue result = _onload.callWithInstance(_mgr->engine()->newQObject(this));
        if (result.isError()) {
            qCWarning(l) << "JS error on onload handler:" << JSKitManager::describeError(result);
        }
    } else {
        qCDebug(l) << "No onload set";
    }
}
Esempio n. 2
0
void WebRequester::setResponse(Response *response)
{
    if (d->response != response)
    {
        d->response = response;
        emit responseChanged(response);
    }
}
bool ContactRequestClient::handleResponse()
{
    uchar response;
    if (socket->read(reinterpret_cast<char*>(&response), 1) < 1)
        return true;

    /* TODO much more state handling and cleanup */

    switch (response)
    {
    case 0x00: /* Acknowledge */
        qDebug() << "Contact request for" << user->uniqueID << "acknowledged; waiting for response";
        state = WaitResponse;
        m_response = Acknowledged;
        emit acknowledged();
        break;

    case 0x01: /* Accept */
        qDebug() << "Contact request for" << user->uniqueID << "accepted! Converting connection to primary";

        m_response = Accepted;
        emit accepted();

        socket->disconnect(this);
        user->incomingProtocolSocket(socket);
        Q_ASSERT(socket->parent() != this);
        socket = 0;

        break;

    case 0x40:
        qDebug() << "Contact request for" << user->uniqueID << "rejected by user";
        m_response = Rejected;
        break;

    default: /* Error */
        qDebug() << "Contact request for" << user->uniqueID << "rejected with code" << hex << (int)response;
        m_response = Error;
        break;
    }

    emit responseChanged();

    if (m_response >= Rejected)
    {
        emit rejected(response);
        return false;
    }

    return true;
}
void OutgoingContactRequest::startConnection()
{
    if (m_client)
        return;

    qDebug() << "Starting outgoing contact request for" << user->uniqueID;

    m_client = new ContactRequestClient(user);

    connect(m_client, SIGNAL(accepted()), SLOT(accept()));
    connect(m_client, SIGNAL(rejected(int)), SLOT(requestRejected(int)));
    connect(m_client, SIGNAL(acknowledged()), SLOT(requestAcknowledged()));
    connect(m_client, SIGNAL(responseChanged()), SIGNAL(connectedChanged()));

    m_client->setMyNickname(myNickname());
    m_client->setMessage(message());
    m_client->sendRequest();
}
Esempio n. 5
0
void TriCasterDevice::sendNotification()
{
    switch (this->command)
    {
        case NTFCDevice::CONNECTIONSTATE:
        {
            emit connectionStateChanged(*this);

            break;
        }
        default:
        {
            emit responseChanged(NTFCDevice::response.at(0), *this);

            break;
        }
    }

    resetDevice();
}
//! [3]
void SslClient::socketEncrypted()
{
    if (!m_socket)
        return; // Might have disconnected already

    // We started a new connection, so clear the response from previous connections
    m_response.clear();
    emit responseChanged();

    // Retrieve the information about the used cipher and update the property
    const QSslCipher cipher = m_socket->sessionCipher();
    m_cipher = QString("%1, %2 (%3/%4)").arg(cipher.authenticationMethod())
            .arg(cipher.name())
            .arg(cipher.usedBits())
            .arg(cipher.supportedBits());

    emit cipherChanged();

    // Tell the CertificateInfoControl about the certificate chain of this connection
    emit certificateChainChanged(m_socket->peerCertificateChain());
}
void JSKitXMLHttpRequest::handleReplyFinished()
{
    if (!m_reply) {
        qCDebug(l) << "reply finished too late";
        return;
    }

    m_response = m_reply->readAll();
    qCDebug(l) << "reply finished, reply text:" << QString::fromUtf8(m_response) << "status:" << status();

    emit readyStateChanged();
    emit statusChanged();
    emit statusTextChanged();
    emit responseChanged();
    emit responseTextChanged();

    if (m_onload.isCallable()) {
        qCDebug(l) << "going to call onload handler:" << m_onload.toString();

        QJSValue result = m_onload.callWithInstance(m_engine->newQObject(this));
        if (result.isError()) {
            qCWarning(l) << "JS error on onload handler:" << JSKitManager::describeError(result);
        }
    } else {
        qCDebug(l) << "No onload set";
    }
    invokeCallbacks("load", QJSValueList({m_engine->newQObject(this)}));

    if (m_onreadystatechange.isCallable()) {
        qCDebug(l) << "going to call onreadystatechange handler:" << m_onreadystatechange.toString();
        QJSValue result = m_onreadystatechange.callWithInstance(m_engine->newQObject(this));
        if (result.isError()) {
            qCWarning(l) << "JS error on onreadystatechange handler:" << JSKitManager::describeError(result);
        }
    }
    invokeCallbacks("readystatechange", QJSValueList({m_engine->newQObject(this)}));
}
Esempio n. 8
0
void CasparDevice::sendNotification()
{
    switch (AmcpDevice::command)
    {
        case AmcpDevice::CLS:
        {
            emit responseChanged(AmcpDevice::response.at(0), *this);

            AmcpDevice::response.removeFirst(); // First post is the header, 200 CLS OK.

            QList<CasparMedia> items;
            foreach (QString response, AmcpDevice::response)
            {
                QString name = response.split("\" ").at(0);
                name.replace("\\", "/");
                if (name.startsWith("\""))
                    name.remove(0, 1);

                if (name.endsWith("\""))
                    name.remove(name.length() - 1, 1);

                QString type = response.split("\" ").at(1).trimmed().split(" ").at(0);

                QString timecode;
                if (response.split("\" ").at(1).trimmed().split(" ").count() > 5)
                {
                    // Format:
                    // "AMB"  MOVIE  6445960 20121101160514 643 1/60
                    // "CG1080I50"  MOVIE  6159792 20121101150514 264 1/25
                    // "GO1080P25"  MOVIE  16694084 20121101150514 445 1/25
                    // "WIPE"  MOVIE  1268784 20121101150514 31 1/25
                    QString totalFrames = response.split("\" ").at(1).trimmed().split(" ").at(4);
                    QString timebase = response.split("\" ").at(1).trimmed().split(" ").at(5);

                    int frames = totalFrames.toInt();
                    int fps = timebase.split("/").at(1).toInt();

                    double time = frames * (1.0 / fps);
                    timecode = convertToTimecode(time, fps);
                }

                items.push_back(CasparMedia(name, type, timecode));
            }

            emit mediaChanged(items, *this);

            break;
        }
        case AmcpDevice::TLS:
        {
            emit responseChanged(AmcpDevice::response.at(0), *this);

            AmcpDevice::response.removeFirst(); // First post is the header, 200 TLS OK.

            QList<CasparTemplate> items;
            foreach (QString response, AmcpDevice::response)
            {
                QString name = response.split("\" ").at(0);
                name.replace("\\", "/");
                if (name.startsWith("\""))
                    name.remove(0, 1);

                if (name.endsWith("\""))
                    name.remove(name.length() - 1, 1);

                items.push_back(CasparTemplate(name));
            }

            emit templateChanged(items, *this);

            break;
        }       
void SslClient::appendString(const QString &line)
{
    // Update the 'response' property
    m_response += line;
    emit responseChanged();
}