void HtmlInfo::parseHtmlFile(const QString &fileName)
{
    QFile file(fileName);

    // Reset the error flag
    m_error.clear();
    emit errorChanged();

    // Try to open the XHTML document and report an error if it fails
    if (!file.open(QIODevice::ReadOnly)) {
        m_error = tr("Couldn't open the file.");
        emit errorChanged();
        return;
    }

//! [0]
    // Create a XML stream reader on the file
    QXmlStreamReader reader(&file);
//! [0]

//! [1]
    int paragraphCount = 0;
    QStringList links;
    QString title;
    /**
     * Read the XHTML document token by token until the end is reached.
     * For every token check whether it's one we are interested in and extract
     * the needed information.
     */
    while (!reader.atEnd()) {
        reader.readNext();
        if (reader.isStartElement()) {
            if (reader.name() == "title")
                title = reader.readElementText();
            else if (reader.name() == "a")
                links.append(reader.attributes().value("href").toString());
            else if (reader.name() == "p")
                ++paragraphCount;
        }
    }
//! [1]

//! [2]
    // If the XML stream reader signaled an error, report it to the UI
    if (reader.hasError()) {
        m_error = tr("The HTML file isn't well-formed: %1").arg(reader.errorString());
        emit errorChanged();
        return;
    }
//! [2]

    // Update the properties with the extracted information
    m_title = title.simplified();
    m_paragraphs = paragraphCount;
    m_links = links.size();
    m_linksContent = links.join("\n");

    // Notify the UI that the properties have changed
    emit infoChanged();
}
Example #2
0
QIODevice *QOpenSLESAudioInput::start()
{
    if (m_deviceState != QAudio::StoppedState)
        stopRecording();

    m_audioSource = 0;

    if (!m_pullMode && m_bufferIODevice) {
        m_bufferIODevice->close();
        delete m_bufferIODevice;
    }

    m_pullMode = false;
    m_pushBuffer.clear();
    m_bufferIODevice = new QBuffer(&m_pushBuffer);
    m_bufferIODevice->open(QIODevice::ReadOnly);

    if (startRecording()) {
        m_deviceState = QAudio::IdleState;
    } else {
        m_deviceState = QAudio::StoppedState;
        Q_EMIT errorChanged(m_errorState);
        m_bufferIODevice->close();
        delete m_bufferIODevice;
        m_bufferIODevice = 0;
    }

    Q_EMIT stateChanged(m_deviceState);
    return m_bufferIODevice;
}
Example #3
0
void QOpenSLESAudioInput::processBuffer()
{
    if (m_deviceState == QAudio::StoppedState || m_deviceState == QAudio::SuspendedState)
        return;

    if (m_deviceState != QAudio::ActiveState) {
        m_errorState = QAudio::NoError;
        m_deviceState = QAudio::ActiveState;
        emit stateChanged(m_deviceState);
    }

    QByteArray *processedBuffer = &m_buffers[m_currentBuffer];
    writeDataToDevice(processedBuffer->constData(), processedBuffer->size());

    // Re-enqueue the buffer
    SLresult result = (*m_bufferQueue)->Enqueue(m_bufferQueue,
                                                processedBuffer->data(),
                                                processedBuffer->size());

    m_currentBuffer = (m_currentBuffer + 1) % NUM_BUFFERS;

    // If the buffer queue is empty (shouldn't happen), stop recording.
#ifdef ANDROID
    SLAndroidSimpleBufferQueueState state;
#else
    SLBufferQueueState state;
#endif
    result = (*m_bufferQueue)->GetState(m_bufferQueue, &state);
    if (result != SL_RESULT_SUCCESS || state.count == 0) {
        stop();
        m_errorState = QAudio::FatalError;
        Q_EMIT errorChanged(m_errorState);
    }
}
QT_BEGIN_NAMESPACE

void QDeclarativeCamera::_q_error(QCamera::Error errorCode)
{
    emit error(Error(errorCode), errorString());
    emit errorChanged();
}
void QDeclarativeFeedbackEffect::_error(QFeedbackEffect::ErrorType err)
{
    if (static_cast<ErrorType>(err) != m_error) {
        m_error = static_cast<ErrorType>(err);
        emit errorChanged();
    }
}
void StationScheduleModel::setError(const QString &error)
{
    if (error != m_error) {
        m_error = error;
        emit errorChanged();
    }
}
void QDeclarativeAudio::setSource(const QUrl &url)
{
    if (url == m_source)
        return;

    m_source = url;
    m_content = m_source.isEmpty() ? QMediaContent() : m_source;
    m_loaded = false;
    if (m_complete && (m_autoLoad || m_content.isNull() || m_autoPlay)) {
        if (m_error != QMediaPlayer::ServiceMissingError && m_error != QMediaPlayer::NoError) {
            m_error = QMediaPlayer::NoError;
            m_errorString = QString();

            emit errorChanged();
        }

        m_player->setMedia(m_content, 0);
        m_loaded = true;
    }
    else
        emit sourceChanged();

    if (m_autoPlay)
        m_player->play();
}
void ReadabilityArticle::tryLoad()
{
    if (!m_api) {
        m_error = "Cannot access article content (Invalid API Configuration)";
    }
    else if (!m_url.isValid()) {
        m_error = "Cannot access article content (Invalid URL)";
    }
    else {
        m_error.clear();
        if (m_request) {
            disconnect(m_request);
            m_request->disconnect(this);
            m_request->cancel();
            m_request->deleteLater();
        }

        m_request = m_api->getParseRequest(m_url);
        connect(m_request, SIGNAL(responseReady(QJsonObject)),
                this, SLOT(onResponseReceived(QJsonObject)));
        connect(m_request, SIGNAL(requestError(QNetworkReply::NetworkError,QString)),
                this, SLOT(onRequestError(QNetworkReply::NetworkError,QString)));
        m_request->send();
        emit startedLoading();
    }
    emit loadingChanged();
    emit errorChanged(m_error);
}
void QConnectionManager::updateServicesMap()
{
    qDebug() << Q_FUNC_INFO;
    QStringList oldServices = orderedServicesList;
    orderedServicesList.clear();

    Q_FOREACH (const QString &tech,techPreferenceList) {
        QVector<NetworkService*> services = netman->getServices(tech);

        Q_FOREACH (NetworkService *serv, services) {

            servicesMap.insert(serv->path(), serv);
            orderedServicesList << serv->path();

            if (!oldServices.contains(serv->path())) {
                //new!
                qDebug() <<"new service"
                         << serv->path();

                QObject::connect(serv, SIGNAL(stateChanged(QString)),
                                 this,SLOT(serviceStateChanged(QString)), Qt::UniqueConnection);
                QObject::connect(serv, SIGNAL(connectRequestFailed(QString)),
                                 this,SLOT(serviceErrorChanged(QString)), Qt::UniqueConnection);

                QObject::connect(serv, SIGNAL(errorChanged(QString)),
                                 this,SLOT(servicesError(QString)), Qt::UniqueConnection);
                QObject::connect(serv, SIGNAL(strengthChanged(uint)),
                                 this,SLOT(onServiceStrengthChanged(uint)), Qt::UniqueConnection);
                QObject::connect(serv, SIGNAL(serviceConnectionStarted()),
                                 this,SLOT(onServiceConnectionStarted()), Qt::UniqueConnection);
                QObject::connect(serv, SIGNAL(serviceDisconnectionStarted()),
                                 this,SLOT(onServiceDisconnectionStarted()), Qt::UniqueConnection);
                QObject::connect(serv, SIGNAL(autoConnectChanged(bool)),
                                 this,SLOT(serviceAutoconnectChanged(bool)), Qt::UniqueConnection);
            }
Example #10
0
void QOpenSLESAudioInput::writeDataToDevice(const char *data, int size)
{
    m_processedBytes += size;

    if (m_pullMode) {
        // write buffer to the QIODevice
        if (m_audioSource->write(data, size) < 0) {
            stop();
            m_errorState = QAudio::IOError;
            Q_EMIT errorChanged(m_errorState);
        }
    } else {
        // emits readyRead() so user will call read() on QIODevice to get some audio data
        if (m_bufferIODevice != 0) {
            m_pushBuffer.append(data, size);
            Q_EMIT m_bufferIODevice->readyRead();
        }
    }

    // Send notify signal if needed
    qint64 processedMsecs = processedUSecs() / 1000;
    if (m_intervalTime && (processedMsecs - m_lastNotifyTime) >= m_intervalTime) {
        Q_EMIT notify();
        m_lastNotifyTime = processedMsecs;
    }
}
Example #11
0
void QPulseAudioInput::setError(QAudio::Error error)
{
    if (m_errorState == error)
        return;

    m_errorState = error;
    emit errorChanged(error);
}
Example #12
0
void QnxAudioInput::setError(QAudio::Error error)
{
    if (m_error == error)
        return;

    m_error = error;
    emit errorChanged(m_error);
}
Example #13
0
/*!
    \internal
    Sets the error condition of the reply to \a error, indicating that processing of
    the associated request has encountered a problem.

    Note that this is a private slot, and should be called by a queued connection, so
    that any data modification is only done in the objects own thread.
*/
void QServiceReplyBase::setError(QServiceManager::Error error)
{
    Q_ASSERT_X(thread() == QThread::currentThread(), Q_FUNC_INFO, "Reply object access violation!");
    if (d->error != error) {
        d->error = error;
        emit errorChanged();
    }
}
inline void QOpenSLESAudioOutput::setError(QAudio::Error error)
{
    if (m_error == error)
        return;

    m_error = error;
    Q_EMIT errorChanged(m_error);
}
Example #15
0
void QDeclarativeVideo::_q_error(int errorCode, const QString &errorString)
{
    m_error = QMediaPlayer::Error(errorCode);
    m_errorString = errorString;

    emit error(Error(errorCode), errorString);
    emit errorChanged();
}
void QDeclarativeGeoMap::setError(QGeoServiceProvider::Error error, const QString &errorString)
{
    if (m_error == error && m_errorString == errorString)
        return;
    m_error = error;
    m_errorString = errorString;
    emit errorChanged();
}
Example #17
0
void QDeclarativeGeoRoutingModel::setError(const QString &error)
{
    if (error_ == error)
        return;

    error_ = error;

    emit errorChanged(error_);
}
void ESURegistration::setError(ESURegistration::Error error)
{
    if( d->error != error ) {
        d->error = error;
        Q_EMIT errorChanged();
        Q_EMIT hasErrorChanged();
        Q_EMIT errorEvent(error);
    }
}
void QDeclarativeBluetoothDiscoveryModel::errorDeviceDiscovery(QBluetoothDeviceDiscoveryAgent::Error error)
{
    d->m_error = static_cast<QDeclarativeBluetoothDiscoveryModel::Error>(error);
    emit errorChanged();

    //QBluetoothDeviceDiscoveryAgent::finished() signal is not emitted in case of an error
    //Note that this behavior is different from QBluetoothServiceDiscoveryAgent.
    //This reset the models running flag.
    setRunning(false);
}
void ReadabilityArticle::onRequestError(QNetworkReply::NetworkError error, QString description)
{
    Q_UNUSED(error);
    qWarning("Readability Article Error: Failed to parse url '%s' (%s)",
             qPrintable(m_url.toString()),
             qPrintable(description));
    m_error = QString("Cannot access article content (%1)").arg(description);
    emit errorChanged(description);
    if (!m_request->isLoading())
        emit finishedLoading();
}
    void setObject(QGalleryQueryModel *object)
    {
        q_ptr = object;

        QObject::connect(&query, SIGNAL(resultSetChanged(QGalleryResultSet*)),
                q_ptr, SLOT(_q_resultSetChanged(QGalleryResultSet*)));
        QObject::connect(&query, SIGNAL(stateChanged(QGalleryAbstractRequest::State)),
                q_ptr, SIGNAL(stateChanged(QGalleryAbstractRequest::State)));
        QObject::connect(&query, SIGNAL(finished()), q_ptr, SIGNAL(finished()));
        QObject::connect(&query, SIGNAL(canceled()), q_ptr, SIGNAL(canceled()));
        QObject::connect(&query, SIGNAL(errorChanged()), q_ptr, SIGNAL(errorChanged()));
        QObject::connect(&query, SIGNAL(error(int,QString)), q_ptr, SIGNAL(error(int,QString)));
        QObject::connect(&query, SIGNAL(galleryChanged()), q_ptr, SIGNAL(galleryChanged()));
        QObject::connect(&query, SIGNAL(sortPropertyNamesChanged()), q_ptr, SIGNAL(sortPropertyNamesChanged()));
        QObject::connect(&query, SIGNAL(autoUpdateChanged()), q_ptr, SIGNAL(autoUpdateChanged()));
        QObject::connect(&query, SIGNAL(offsetChanged()), q_ptr, SIGNAL(offsetChanged()));
        QObject::connect(&query, SIGNAL(limitChanged()), q_ptr, SIGNAL(limitChanged()));
        QObject::connect(&query, SIGNAL(rootTypeChanged()), q_ptr, SIGNAL(rootTypeChanged()));
        QObject::connect(&query, SIGNAL(rootItemChanged()), q_ptr, SIGNAL(rootItemChanged()));
        QObject::connect(&query, SIGNAL(scopeChanged()), q_ptr, SIGNAL(scopeChanged()));
        QObject::connect(&query, SIGNAL(filterChanged()), q_ptr, SIGNAL(filterChanged()));
    }
Example #22
0
void QApplicationConfig::updateError(QApplicationConfig::ConnectionError error, QString errorString)
{
    if (m_errorString != errorString)
    {
        m_errorString = errorString;
        emit errorStringChanged(m_errorString);
    }

    if (m_error != error)
    {
        m_error = error;
        emit errorChanged(m_error);
    }
}
Example #23
0
int QAudioOutputPrivate::xrun_recovery(int err)
{
    int  count = 0;
    bool reset = false;

    if(err == -EPIPE) {
        errorState = QAudio::UnderrunError;
        emit errorChanged(errorState);
        err = snd_pcm_prepare(handle);
        if(err < 0)
            reset = true;

    } else if((err == -ESTRPIPE)||(err == -EIO)) {
        errorState = QAudio::IOError;
        emit errorChanged(errorState);
        while((err = snd_pcm_resume(handle)) == -EAGAIN) {
            usleep(100);
            count++;
            if(count > 5) {
                reset = true;
                break;
            }
        }
        if(err < 0) {
            err = snd_pcm_prepare(handle);
            if(err < 0)
                reset = true;
        }
    }
    if(reset) {
        close();
        open();
        snd_pcm_prepare(handle);
        return 0;
    }
    return err;
}
Example #24
0
void QDeclarativeBluetoothSocket::socket_error(QBluetoothSocket::SocketError err)
{
    if(err == QBluetoothSocket::ConnectionRefusedError)
        d->m_error = QLatin1String("Connection Refused");
    else if(err == QBluetoothSocket::RemoteHostClosedError)
        d->m_error = QLatin1String("Connection Closed by Remote Host");
    else if(err == QBluetoothSocket::HostNotFoundError)
        d->m_error = QLatin1String("Host Not Found");
    else if(err == QBluetoothSocket::ServiceNotFoundError)
        d->m_error = QLatin1String("Could not find service at remote host");
    else
        d->m_error = QLatin1String("Unknown Error");

    emit errorChanged();
}
QT_BEGIN_NAMESPACE


/*!
    \qmlclass Audio QDeclarativeAudio
    \brief The Audio element allows you to add audio playback to a scene.

    This element is part of the \bold{QtMultimediaKit 1.1} module.

    \qml
    import Qt 4.7
    import QtMultimediaKit 1.1

    Text {
        text: "Click Me!";
        font.pointSize: 24;
        width: 150; height: 50;

        Audio {
            id: playMusic
            source: "music.wav"
        }
        MouseArea {
            id: playArea
            anchors.fill: parent
            onPressed:  { playMusic.play() }
        }
    }
    \endqml

    \sa Video
*/

/*!
    \internal
    \class QDeclarativeAudio
    \brief The QDeclarativeAudio class provides an audio item that you can add to a QDeclarativeView.
*/

void QDeclarativeAudio::_q_error(int errorCode, const QString &errorString)
{
    m_error = QMediaPlayer::Error(errorCode);
    m_errorString = errorString;

    emit error(Error(errorCode), errorString);
    emit errorChanged();
}
void QDeclarativeBluetoothDiscoveryModel::errorDiscovery(QBluetoothServiceDiscoveryAgent::Error error)
{
    switch (error) {
    case QBluetoothServiceDiscoveryAgent::InvalidBluetoothAdapterError:
        d->m_error = QDeclarativeBluetoothDiscoveryModel::InvalidBluetoothAdapterError; break;
    case QBluetoothServiceDiscoveryAgent::NoError:
        d->m_error = QDeclarativeBluetoothDiscoveryModel::NoError; break;
    case QBluetoothServiceDiscoveryAgent::InputOutputError:
        d->m_error = QDeclarativeBluetoothDiscoveryModel::InputOutputError; break;
    case QBluetoothServiceDiscoveryAgent::PoweredOffError:
        d->m_error = QDeclarativeBluetoothDiscoveryModel::PoweredOffError; break;
    case QBluetoothServiceDiscoveryAgent::UnknownError:
        d->m_error = QDeclarativeBluetoothDiscoveryModel::UnknownError; break;
    }

    emit errorChanged();
}
QT_BEGIN_NAMESPACE

/*!
    \qmltype Audio
    \instantiates QDeclarativeAudio
    \brief Add audio playback to a scene.

    \inqmlmodule QtMultimedia
    \ingroup multimedia_qml
    \ingroup multimedia_audio_qml

    This type is part of the \b{QtMultimedia 5.0} module.

    \qml
    import QtQuick 2.0
    import QtMultimedia 5.0

    Text {
        text: "Click Me!";
        font.pointSize: 24;
        width: 150; height: 50;

        Audio {
            id: playMusic
            source: "music.wav"
        }
        MouseArea {
            id: playArea
            anchors.fill: parent
            onPressed:  { playMusic.play() }
        }
    }
    \endqml

    \sa Video
*/

void QDeclarativeAudio::_q_error(QMediaPlayer::Error errorCode)
{
    m_error = errorCode;
    m_errorString = m_player->errorString();

    emit error(Error(errorCode), m_errorString);
    emit errorChanged();
}
void QApplicationCommand::updateError(QApplicationCommand::ConnectionError error, const QString &errorString)
{
    if (m_errorString != errorString)
    {
        m_errorString = errorString;
        emit errorStringChanged(m_errorString);
    }

    if (m_error != error)
    {
        if (error != NoError)
        {
            cleanup();
        }
        m_error = error;
        emit errorChanged(m_error);
    }
}
void QApplicationLauncher::updateError(Service::ConnectionError error, QString errorString)
{
    if (m_errorString != errorString)
    {
        m_errorString = errorString;
        emit errorStringChanged(m_errorString);
    }

    if (m_error != error)
    {
        if (error != Service::NoError)
        {
            cleanup();
        }
        m_error = error;
        emit errorChanged(m_error);
    }
}
/*! \reimp */
void IdentifiableContentItemInterface::emitPropertyChangeSignals(const QVariantMap &oldData, const QVariantMap &newData)
{
    Q_D(IdentifiableContentItemInterface);
    // most derived types will do:
    // {
    //     foreach (key, propKeys) {
    //         if (newData.value(key) != oldData.value(key)) {
    //             emit thatPropertyChanged();
    //         }
    //     }
    //     SuperClass::emitPropertyChangeSignals(oldData, newData);
    // }
    // But this one is a bit special, since if the id changed, it's a terrible error.

    // check identifier - NOTE: derived types MUST fill out this field before calling this class' implementation of emitPropertyChangeSignals.
    QString oldId = oldData.value(NEMOQMLPLUGINS_SOCIAL_CONTENTITEMID).toString();
    QString newId = newData.value(NEMOQMLPLUGINS_SOCIAL_CONTENTITEMID).toString();
    if (newId.isEmpty() && oldId.isEmpty()) {
        // this will fall through to being reported as an error due to identifier change (to empty) below.
        qWarning() << Q_FUNC_INFO << "ERROR: derived types MUST set the NEMOQMLPLUGINS_SOCIAL_CONTENTITEMID field appropriately prior to calling the superclass emitPropertyChangeSignals() function!";
    }

    if (oldId.isEmpty())
        oldId = d->identifier; // might have been set directly by client via icii.setIdentifier() which sets dd->identifier.

    if (oldId.isEmpty() && !newId.isEmpty()) {
        // this must be a new object created by the model.  We now have an identifier; set it and update.
        d->identifier = newId;
        emit identifierChanged();
    } else if (newId.isEmpty() || oldId != newId) {
        // the identifier changed.  This shouldn't happen in real life.  Must be an error.
        d->status = SocialNetworkInterface::Invalid;
        d->error = SocialNetworkInterface::DataUpdateError;
        d->errorMessage = QString(QLatin1String("identifier changed during data update from %1 to %2")).arg(oldId).arg(newId);
        d->s = 0;
        emit statusChanged();
        emit errorChanged();
        emit errorMessageChanged();
        emit socialNetworkChanged();
    }

    // finally, as all derived classes must do, call super class implementation.
    ContentItemInterface::emitPropertyChangeSignals(oldData, newData);
}