/** @short Data for the current message part are available now */
void MsgPartNetworkReply::slotMyDataChanged()
{
    if (part.data(Mailbox::RoleIsUnavailable).toBool()) {
        setError(TimeoutError, tr("Offline"));
        setFinished(true);
        emit error(TimeoutError);
        emit finished();
        return;
    }

    if (!part.data(Mailbox::RoleIsFetched).toBool())
        return;

    MsgPartNetAccessManager *netAccess = qobject_cast<MsgPartNetAccessManager*>(manager());
    Q_ASSERT(netAccess);
    QString mimeType = netAccess->translateToSupportedMimeType(part.data(Mailbox::RolePartMimeType).toString());
    QString charset = part.data(Mailbox::RolePartCharset).toString();
    if (mimeType.startsWith(QLatin1String("text/"))) {
        setHeader(QNetworkRequest::ContentTypeHeader,
                  charset.isEmpty() ? mimeType : QStringLiteral("%1; charset=%2").arg(mimeType, charset)
                 );
    } else {
        setHeader(QNetworkRequest::ContentTypeHeader, mimeType);
    }
    setFinished(true);
    emit readyRead();
    emit finished();
}
Example #2
0
int Sample::process_bg() {
    /*
    This function does the main thing: it stretches the original data as defined by the marker object.
    Therefore it reads data from odata and writes to data.
    */
    _processing=true;
    // setup data
    length=getGuessedLength();
    delete[] data;
    data=new float[length];
    switch (getStretchMode()) {
#ifdef MODE_RUBBERBAND
    case 1:
        RBprocess(olength, data, marker, this);
        break;
#endif
    default: {
        for (int i=0; i<length; ++i) {
            data[i]=getOld(marker->new2old(marker->nnew2new(i/(float)length)));
            setFinished(i/(float)length);
        }
    }
    }
    setFinished(1);
    _processing=false;
    return 0;
}
bool QuitGame::handleEvent(const sf::Input &Input) {
    if(Input.IsKeyDown(sf::Key::Y)) {
        setFinished();
        if(m_panel != NULL) {
            m_panel->setQuit();
        }
    }
    if(Input.IsKeyDown(sf::Key::N)) {
        setFinished();
    }
    return true;
}
void QGeoRouteReplyNokia::networkFinished()
{
    if (!m_reply)
        return;

    if (m_reply->error() != QNetworkReply::NoError) {
        // Removed because this is already done in networkError, which previously caused _two_ errors to be raised for every error.
        //setError(QGeoRouteReply::CommunicationError, m_reply->errorString());
        //m_reply->deleteLater();
        //m_reply = 0;
        return;
    }

    QGeoRouteXmlParser parser(request());

    if (parser.parse(m_reply)) {
        setRoutes(parser.results());
        setFinished(true);
    } else {
        // add a qWarning with the actual parser.errorString()
        setError(QGeoRouteReply::ParseError, "The response from the service was not in a recognisable format.");
    }

    m_reply->deleteLater();
    m_reply = 0;
}
void QGeoMapReplyOsm::networkReplyFinished()
{
    if (!m_reply)
        return;

    if (m_reply->error() != QNetworkReply::NoError)
        return;

    QByteArray a = m_reply->readAll();

    setMapImageData(a);
    switch (tileSpec().mapId()) {
    case 1:
        setMapImageFormat("png");
        break;
    case 2:
        setMapImageFormat("png");
        break;
    default:
        qWarning("Unknown map id %d", tileSpec().mapId());
    }

    setFinished(true);

    m_reply->deleteLater();
    m_reply = 0;
}
void QGeoMapReplyNokia::networkFinished()
{
    if (!m_reply)
        return;

    if (m_reply->error() != QNetworkReply::NoError)
        return;

    QVariant fromCache = m_reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute);
    setCached(fromCache.toBool());

    if (!isCached()) {
        QAbstractNetworkCache *cache = m_reply->manager()->cache();
        if (cache) {
            QNetworkCacheMetaData metaData = cache->metaData(m_reply->url());
            QDateTime exp = QDateTime::currentDateTime();
            exp = exp.addDays(14);
            metaData.setExpirationDate(exp);
            cache->updateMetaData(metaData);
        }
    }

    setMapImageData(m_reply->readAll());
    setMapImageFormat("PNG");
    setFinished(true);

    m_reply->deleteLater();
    m_reply = 0;
}
void QGeoCodeReplyNokia::networkFinished()
{
    if (!m_reply)
        return;

    if (m_reply->error() != QNetworkReply::NoError) {
        // Removed because this is already done in networkError, which previously caused _two_ errors to be raised for every error.
        //setError(QGeoCodeReply::CommunicationError, m_reply->errorString());
        //m_reply->deleteLater();
        //m_reply = 0;
        return;
    }

    QGeoCodeXmlParser parser;
    if (parser.parse(m_reply)) {
        QList<QGeoLocation> locations = parser.results();
        QGeoShape bounds = viewport();
        if (bounds.isValid()) {
            for (int i = locations.size() - 1; i >= 0; --i) {
                if (!bounds.contains(locations[i].coordinate()))
                    locations.removeAt(i);
            }
        }
        setLocations(locations);
        setFinished(true);
    } else {
        setError(QGeoCodeReply::ParseError, parser.errorString());
    }

    m_reply->deleteLater();
    m_reply = 0;
}
void RemoteLinuxEnvironmentReader::remoteProcessFinished()
{
    if (m_stop)
        return;

    m_env.clear();
    QString errorMessage;
    if (m_deviceProcess->exitStatus() != QProcess::NormalExit) {
        errorMessage = m_deviceProcess->errorString();
    } else if (m_deviceProcess->exitCode() != 0) {
        errorMessage = tr("Process exited with code %1.")
                .arg(m_deviceProcess->exitCode());
    }
    if (!errorMessage.isEmpty()) {
        errorMessage = tr("Error running 'env': %1").arg(errorMessage);
        const QString remoteStderr
                = QString::fromUtf8(m_deviceProcess->readAllStandardError()).trimmed();
        if (!remoteStderr.isEmpty())
            errorMessage += QLatin1Char('\n') + tr("Remote stderr was: \"%1\"").arg(remoteStderr);
        emit error(errorMessage);
    } else {
        QString remoteOutput = QString::fromUtf8(m_deviceProcess->readAllStandardOutput());
        if (!remoteOutput.isEmpty()) {
            m_env = Utils::Environment(remoteOutput.split(QLatin1Char('\n'),
                QString::SkipEmptyParts), Utils::OsTypeLinux);
        }
    }
    setFinished();
}
void QPlaceDetailsReplyImpl::setError(QPlaceReply::Error error_, const QString &errorString)
{
    QPlaceReply::setError(error_, errorString);
    emit error(error_, errorString);
    setFinished(true);
    emit finished();
}
Example #10
0
void PendingOperation::setFinishedWithError(const QVariantHash &details)
{
    qCDebug(c_pendingOperations) << this << "setFinishedWithError(" << details << ")";
    d->m_succeeded = false;
    d->m_errorDetails = details;
    setFinished();
}
Example #11
0
void ThreadedAssignment::checkInWithDomainServerOrExit() {
    if (NodeList::getInstance()->getNumNoReplyDomainCheckIns() == MAX_SILENT_DOMAIN_SERVER_CHECK_INS) {
        setFinished(true);
    } else {
        NodeList::getInstance()->sendDomainServerCheckIn();
    }
}
Example #12
0
/*!
    Sets the error state of this reply to \a error and the textual
    representation of the error to \a errorString.

    This will also cause error() and finished() signals to be emitted, in that
    order.
*/
void QGeoCodeReply::setError(QGeoCodeReply::Error error, const QString &errorString)
{
    d_ptr->error = error;
    d_ptr->errorString = errorString;
    emit this->error(error, errorString);
    setFinished(true);
}
void QPlaceContentReplyImpl::replyFinished()
{
    if (m_reply->isOpen()) {
        QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll());
        if (!document.isObject()) {
            setError(ParseError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, PARSE_ERROR));
            return;
        }

        QJsonObject object = document.object();

        QPlaceContent::Collection collection;
        int totalCount;
        QPlaceContentRequest previous;
        QPlaceContentRequest next;

        parseCollection(request().contentType(), object, &collection, &totalCount,
                        &previous, &next, m_engine);

        setTotalCount(totalCount);
        setContent(collection);
        setPreviousPageRequest(previous);
        setNextPageRequest(next);
    }

    m_reply->deleteLater();
    m_reply = 0;

    setFinished(true);
    emit finished();
}
Example #14
0
void RS_ActionDrawText::init(int status) {
    RS_ActionInterface::init(status);
    if (RS_DIALOGFACTORY) {

        switch (status) {
        case ShowDialog: {
                reset();

				RS_Text tmp(NULL, *data);
                if (RS_DIALOGFACTORY->requestTextDialog(&tmp)) {
					data.reset(new RS_TextData(tmp.getData()));
                    setStatus(SetPos);
                    showOptions();
                } else {
                    hideOptions();
                    setFinished();
                }
            }
            break;

        case SetPos:
            RS_DIALOGFACTORY->requestOptions(this, true, true);
            deletePreview();
            preview->setVisible(true);
            preparePreview();
            break;

        default:
            break;
        }
    }
}
void XTelepathyPasswordAuthOperation::onDialogFinished(int result)
{
    switch (result) {
    case QDialog::Rejected:
        qDebug() << "Authentication cancelled";
        m_saslIface->AbortSASL(Tp::SASLAbortReasonUserAbort, i18n("User cancelled auth"));
        setFinished();
        if (!m_dialog.isNull()) {
            m_dialog.data()->deleteLater();
        }
        return;
    case QDialog::Accepted:
        // save password in kwallet if necessary...
        if (!m_dialog.isNull()) {
            if (m_dialog.data()->savePassword()) {
                qDebug() << "Saving password in SSO";
                m_canFinish = false;
                storeCredentials(m_dialog.data()->password());
            } else {
                m_canFinish = true;
            }

            m_dialog.data()->deleteLater();

            m_saslIface->StartMechanismWithData(QLatin1String("X-TELEPATHY-PASSWORD"), m_dialog.data()->password().toUtf8());
        }
    }
}
Example #16
0
bool RbUtilQt::installAuto()
{
    QString file = RbSettings::value(RbSettings::ReleaseUrl).toString();
    file.replace("%MODEL%", RbSettings::value(RbSettings::CurBuildserverModel).toString());
    file.replace("%RELVERSION%", versmap.value("rel_rev"));
    buildInfo.open();
    QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
    buildInfo.close();

    // check installed Version and Target
    QString warning = check(false);
    if(!warning.isEmpty())
    {
        if(QMessageBox::warning(this, tr("Really continue?"), warning,
            QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort)
                == QMessageBox::Abort)
        {
            logger->addItem(tr("Aborted!"), LOGERROR);
            logger->setFinished();
            return false;
        }
    }

    // check version
    RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
    if(rbinfo.version() != "")
    {
        if(QMessageBox::question(this, tr("Installed Rockbox detected"),
           tr("Rockbox installation detected. Do you want to backup first?"),
           QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
        {
            logger->addItem(tr("Starting backup..."),LOGINFO);
            QString backupName = RbSettings::value(RbSettings::Mountpoint).toString()
                + "/.backup/rockbox-backup-" + rbinfo.version() + ".zip";

            //! create dir, if it doesnt exist
            QFileInfo backupFile(backupName);
            if(!QDir(backupFile.path()).exists())
            {
                QDir a;
                a.mkpath(backupFile.path());
            }

            //! create backup
            RbZip backup;
            connect(&backup,SIGNAL(zipProgress(int,int)),logger, SLOT(setProgress(int,int)));
            if(backup.createZip(backupName,
                RbSettings::value(RbSettings::Mountpoint).toString() + "/.rockbox") == Zip::Ok)
            {
                logger->addItem(tr("Backup successful"),LOGOK);
            }
            else
            {
                logger->addItem(tr("Backup failed!"),LOGERROR);
                logger->setFinished();
                return false;
            }
        }
    }
void REIXSXESScanController::onScanFinished() {

	scanProgressTimer_.stop();
	disconnect(&scanProgressTimer_, SIGNAL(timeout()), this, SLOT(onScanProgressCheck()));
	disconnect(REIXSBeamline::bl()->mcpDetector(), SIGNAL(imageDataChanged()), this, SLOT(onNewImageValues()));
	saveRawData();
	setFinished();
}
void RemoteLinuxEnvironmentReader::handleError()
{
    if (m_stop)
        return;

    emit error(tr("Error: %1").arg(m_deviceProcess->errorString()));
    setFinished();
}
void PendingClear::finish()
{
    if (errorName.isEmpty()) {
        setFinished();
    } else {
        setFinishedWithError(errorName, errorMessage);
    }
}
Example #20
0
void CoapReply::resend()
{
    m_retransmissions++;
    if (m_retransmissions > 5) {
        setError(CoapReply::TimeoutError);
        setFinished();
    }
}
//-----------------------------------------------------------------------------
void
QGeoTiledMapReplyQGC::cacheReply(QGCCacheTile* tile)
{
    setMapImageData(tile->img());
    setMapImageFormat(tile->format());
    setFinished(true);
    setCached(true);
    tile->deleteLater();
}
Example #22
0
void AccessManagerReply::emitFinished (bool state, Qt::ConnectionType type)
{
#if QT_VERSION >= 0x040800
    setFinished(state);
#else
    Q_UNUSED(state);
#endif
    emit QMetaObject::invokeMethod(this, "finished", type);
}
Example #23
0
void PendingOperation::finishLater()
{
    qCDebug(c_pendingOperations) << this << "startLater()";
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
    QMetaObject::invokeMethod(this, [this] (){ setFinished(); }, Qt::QueuedConnection);
#else
    QMetaObject::invokeMethod(this, "setFinished", Qt::QueuedConnection);
#endif
}
Example #24
0
int Sample::process() {
//  process_bg();
    if (_processing) return 1;
    setFinished(0);
    pthread_t thread;
    pthread_create(&thread, NULL, Sample::EntryPoint, (void*)this);
//  process_bg();
    return 0;
}
void ExplosionAnimation2D::finishAnimation(GraphicBlock *graphicBlock, bool collided)
{
    if (collided && graphicBlock)
    {
        ExplosionSpriteAnimator2D* anim = new ExplosionSpriteAnimator2D(graphicBlock->position(), graphicBlock->driver());
        graphicBlock->addAnimator(anim);
    }
    setFinished(true);
}
void EnginioDummyReply::abort()
{
    QNetworkReply::close();
    setError(OperationCanceledError, tr("Operation canceled"));
    setFinished(true);
    EnginioDummyReplyAbort fin = {EnginioClientConnectionPrivate::prepareNetworkManagerInThread().data(), this};
    QObject::connect(this, &EnginioDummyReply::finished, fin);
    QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
}
Example #27
0
void KonqRun::handleError(KJob *job)
{
    if (!m_mailto.isEmpty()) {
        setJob(0);
        setFinished(true);
        return;
    }
    KParts::BrowserRun::handleError(job);
}
Example #28
0
void EnginioFakeReply::init(QNetworkAccessManager *qnam)
{
    QIODevice::open(QIODevice::ReadOnly | QIODevice::Unbuffered);
    setError(ContentNotFoundError, QString::fromUtf8(_msg));
    setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 400);
    setFinished(true);
    FinishedFunctor fin = {qnam, this};
    QObject::connect(this, &EnginioFakeReply::finished, fin);
    QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
}
void QGeoMapReplyNokia::networkError(QNetworkReply::NetworkError error)
{
    if (!m_reply)
        return;

    if (error != QNetworkReply::OperationCanceledError)
        setError(QGeoTiledMapReply::CommunicationError, m_reply->errorString());
    setFinished(true);
    m_reply->deleteLater();
    m_reply = 0;
}
Example #30
0
		bool kill(int k = 6){
			if(!started()) return 0;
			DWORD dwDesiredAccess = PROCESS_TERMINATE;
			bool  bInheritHandle  = 0;
			HANDLE hProcess = OpenProcess(dwDesiredAccess, bInheritHandle, pid());
			if (hProcess == NULL) return 0;
			bool r = TerminateProcess(hProcess, 128+k);
			CloseHandle(hProcess);
			setFinished();
			return r;
		}