Exemplo 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";
    }
}
Exemplo n.º 2
0
void OcaOctaveController::runCommand( const QString& command, OcaTrackGroup* group )
{
  if( e_StateReady == m_state ) {
    m_state = e_StateWaiting;
    m_lastError = 0;
    m_lastErrorString.clear();
    QStringList list = command.split( '\n' );
    QString command_fixed;
    for( int i = 0; i < list.size(); i++ ) {
      QString s = list.at(i).trimmed();
      if( ! s.isEmpty() ) {
        if( ! command_fixed.isEmpty() ) {
          command_fixed.append( '\n' );
        }
        command_fixed.append( s );
      }
    }

    fprintf( stderr, "OcaOctaveController => WAITING\n" );
    addCommandToHistory( command_fixed );
    m_host->evalCommand( command_fixed, group );
    emit readyStateChanged( false, 0 );
  }
  else {
    emit outputReceived( "OcaOctaveController::runCommand failed: not ready", 128 );
    fprintf( stderr, "OcaOctaveController => ERROR (not ready)\n" );
  }
}
Exemplo n.º 3
0
void OcaOctaveController::onListenerStateChanged( int listener_state )
{
  if( ( e_StateReady != m_state ) && ( 1 == listener_state ) ) {
    m_state = e_StateReady;
#ifndef Q_OS_WIN32
    readStdout();
#endif
    if( 0 != m_lastError ) {
      emit outputReceived( m_lastErrorString, m_lastError );
    }
    fprintf( stderr, "OcaOctaveController => READY\n" );
    emit readyStateChanged( true, 0 );
  }
  else {
    Q_ASSERT( false );
  }
}
Exemplo n.º 4
0
void JSKitXMLHttpRequest::handleReplyError(QNetworkReply::NetworkError code)
{
    if (!_reply) {
        qCDebug(l) << "reply error too late";
        return;
    }

    qCDebug(l) << "reply error" << code;

    emit readyStateChanged();
    emit statusChanged();
    emit statusTextChanged();

    if (_onerror.isCallable()) {
        qCDebug(l) << "going to call onerror handler:" << _onload.toString();
        QJSValue result = _onerror.callWithInstance(_mgr->engine()->newQObject(this));
        if (result.isError()) {
            qCWarning(l) << "JS error on onerror handler:" << JSKitManager::describeError(result);
        }
    }
}
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)}));
}