void PendingTpLoggerLogs::logsRetrieved(Tpl::PendingOperation *op)
{
    Tpl::PendingEvents *pe = qobject_cast<Tpl::PendingEvents*>(op);
    Q_ASSERT(pe);

    if (pe->isError()) {
        setError(pe->errorName() + QLatin1String(": ") + pe->errorMessage());
        emitFinished();
        return;
    }

    QList<Tpl::EventPtr> events = pe->events();
    QList<KTp::LogMessage> logs;
    Q_FOREACH (const Tpl::EventPtr &event, events) {
        const Tpl::TextEventPtr textEvent = event.dynamicCast<Tpl::TextEvent>();
        if (textEvent.isNull()) {
            qWarning() << "Received a null TextEvent!";
            continue;
        }

        logs << KTp::LogMessage(Utils::fromTplEntity(event->sender()),
                                account(), event->timestamp(), textEvent->message(),
                                textEvent->messageToken());
    }

    appendLogs(logs);
    emitFinished();
}
/*!
    This function runs the dialog asynchronously. Use the setters to
    configure the dialog before running. After the dialog has been closed
    (accepted or cancelled), the signal finished() is emitted.
 */
void CmApplSettingsUiPrivate::open()
{
    OstTraceFunctionEntry0(CMAPPLSETTINGSUIPRIVATE_OPEN_ENTRY);

    // Fetch filtered Destinations and Connection Methods
    bool settingsRead = true;
    if (mListItems.testFlag(CmApplSettingsUi::ShowDestinations)) {
        settingsRead = mSettingData.fetchDestinations(mDestinations);
    }
    if (mListItems.testFlag(CmApplSettingsUi::ShowConnectionMethods)) {
        settingsRead &= mSettingData.fetchConnMethods(mConnMethods);
    }

    if (!settingsRead) {
        // Settings reading failed
        emitFinished(CmApplSettingsUi::ApplSettingsErrorSettingsRead);
    } else if (mListItems.testFlag(CmApplSettingsUi::ShowDestinations)) {
        // Start with destination view
        runDestinationDialog();
    } else if (mListItems.testFlag(CmApplSettingsUi::ShowConnectionMethods)) {
        // Start directly with connection method view
        runConnectionMethodDialog();
    } else {
        // Nothing to show, so finish
        emitFinished(CmApplSettingsUi::ApplSettingsErrorNoContent);
    }
    
    OstTraceFunctionExit0(CMAPPLSETTINGSUIPRIVATE_OPEN_EXIT);
}
Esempio n. 3
0
void Find::start() {
  QString message;
  QVariant result = page()->invokeCapybaraFunction("find", arguments());

  if (result.isValid()) {
    message = result.toString();
    emitFinished(true, message);
  } else {
    emitFinished(false, QString("Invalid XPath expression"));
  }
}
void NotebookSyncAgent::processETags()
{

    NOTEBOOK_FUNCTION_CALL_TRACE;

    Report *report = qobject_cast<Report*>(sender());
    mRequests.remove(report);
    report->deleteLater();

    if (report->errorCode() == Buteo::SyncResults::NO_ERROR) {
        LOG_DEBUG("Process tags for server path" << mServerPath);
        QHash<QString, Reader::CalendarResource> map = report->receivedCalendarResources();

        // Incidences must be loaded with ExtendedStorage::allIncidences() rather than
        // ExtendedCalendar::incidences(), because the latter will load incidences from all
        // notebooks, rather than just the one for this report.
        // Note that storage incidence references cannot be used with ExtendedCalendar::deleteEvent()
        // etc. Those methods only work for references created by ExtendedCalendar.
        KCalCore::Incidence::List storageIncidenceList;
        if (!mStorage->allIncidences(&storageIncidenceList, mNotebook->uid())) {
            emitFinished(Buteo::SyncResults::DATABASE_FAILURE, QString("Unable to load storage incidences for notebook: %1").arg(mNotebook->uid()));
            return;
        }

        KCalCore::Incidence::List deletions;
        if (!mStorage->deletedIncidences(&deletions, KDateTime(mChangesSinceDate), mNotebook->uid())) {
            LOG_CRITICAL("mKCal::ExtendedStorage::deletedIncidences() failed");
        }

        QStringList eventIdList;

        Q_FOREACH (KCalCore::Incidence::Ptr incidence, storageIncidenceList) {
            QString uri = incidence->customProperty("buteo", "uri");
            if (uri.isEmpty()) {
                //Newly added to Local DB -- Skip this incidence
                continue;
            }
            if (!map.contains(uri)) {
                // we have an incidence that's not on the remote server, so delete it
                switch (incidence->type()) {
                case KCalCore::IncidenceBase::TypeEvent:
                case KCalCore::IncidenceBase::TypeTodo:
                case KCalCore::IncidenceBase::TypeJournal:
                    mIncidenceUidsToDelete.append(incidence->uid());
                    break;
                case KCalCore::IncidenceBase::TypeFreeBusy:
                case KCalCore::IncidenceBase::TypeUnknown:
                    break;
                }
                continue;
            } else {
                Reader::CalendarResource resource = map.take(uri);
                if (mLocalETags.value(incidence->uid()) != resource.etag) {
                    LOG_DEBUG("Will fetch update for" << resource.href
                              << "tag changed from" << mLocalETags.value(incidence->uid())
                              << "to" << resource.etag);
                    eventIdList.append(resource.href);
                }
            }
        }
/*
    Quick sync mode:

    1) Get all remote calendar etags and updated calendar data from the server using Report::getAllETags()
    2) Get all local changes since the last sync
    3) Filter out local changes that were actually remote changes written by step 5) of this
       sequence from a previous sync
    4) Send the local changes to the server using Put and Delete requests
    5) Write the remote calendar changes to disk.

    Step 5) is triggered by CalDavClient once *all* notebook syncs have finished.
 */
void NotebookSyncAgent::startQuickSync(mKCal::Notebook::Ptr notebook,
                                       const QDateTime &changesSinceDate,
                                       const KCalCore::Incidence::List &allCalendarIncidences,
                                       const QDateTime &fromDateTime,
                                       const QDateTime &toDateTime)
{
    NOTEBOOK_FUNCTION_CALL_TRACE;

    LOG_DEBUG("Start quick sync for notebook:" << notebook->uid()
              << "between" << fromDateTime << "to" << toDateTime
              << ", sync changes since" << changesSinceDate);

    mSyncMode = QuickSync;
    mNotebook = notebook;
    mCalendarIncidencesBeforeSync = allCalendarIncidences;
    mChangesSinceDate = changesSinceDate;
    mFromDateTime = fromDateTime;
    mToDateTime = toDateTime;

    bool ok = false;
    mLocalETags = mDatabase->eTags(mNotebook->uid(), &ok);
    if (!ok) {
        emitFinished(Buteo::SyncResults::DATABASE_FAILURE, QString("Unable to load etags for notebook: %1").arg(mNotebook->uid()));
        return;
    }

    sendReportRequest();
}
/*
    Slow sync mode:

    1) Get all calendars on the server using Report::getAllEvents()
    2) Save all received calendar data to disk.

    Step 2) is triggered by CalDavClient once *all* notebook syncs have finished.
 */
void NotebookSyncAgent::startSlowSync(const QString &notebookName,
                                      const QString &notebookAccountId,
                                      const QString &pluginName,
                                      const QString &syncProfile,
                                      const QString &color,
                                      const QDateTime &fromDateTime,
                                      const QDateTime &toDateTime)
{
    NOTEBOOK_FUNCTION_CALL_TRACE;

    LOG_DEBUG("Start slow sync for notebook:" << notebookName << "for account" << notebookAccountId
              << "between" << fromDateTime << "to" << toDateTime);

    mSyncMode = SlowSync;
    mFromDateTime = fromDateTime;
    mToDateTime = toDateTime;

    mNotebook = mKCal::Notebook::Ptr(new mKCal::Notebook(notebookName, QString()));
    mNotebook->setAccount(notebookAccountId);
    mNotebook->setPluginName(pluginName);
    mNotebook->setSyncProfile(syncProfile);
    mNotebook->setColor(color);

    if (!mStorage->addNotebook(mNotebook)) {
        emitFinished(Buteo::SyncResults::INTERNAL_ERROR, "unable to add notebook "
                     + mNotebook->uid() + " for account/calendar " + mNotebook->account());
        return;
    }
    LOG_DEBUG("NOTEBOOK created" << mNotebook->uid() << "account:" << mNotebook->account());

    sendReportRequest();
}
Esempio n. 7
0
void QOFonoUtil::watchCall(QOFonoDBusPendingCall & call,
                         QObject * receiver,
                         const char * finishedMethod)
{
    bool oldNotified = pendingNotified;
    QOFonoDBusPendingCall oldCall = pendingCall;
    QObject *oldReceiver = pendingReceiver;
    const char *oldFinished = pendingFinished;

    pendingNotified = false;
    pendingCall = call;
    pendingReceiver = receiver;
    pendingFinished = finishedMethod;

    checkInterval = 10;
    QTimer::singleShot(checkInterval, this, SLOT(pendingCheck()));

    if(!oldNotified)
    {
        qDebug() << "watchCall: waiting for finish of " << oldCall.methodCall;
        oldCall.waitForFinished();
        qDebug() << "watchCall: " << oldCall.methodCall << " finished";
        emitFinished(oldReceiver, oldFinished, oldCall);
    }
}
Esempio n. 8
0
void InternalBuildJob::build(const TopLevelProjectPtr &project,
        const QList<ResolvedProductPtr> &products, const BuildOptions &buildOptions)
{
    setup(project, products, buildOptions.dryRun());
    setTimed(buildOptions.logElapsedTime());

    m_executor = new Executor(logger());
    m_executor->setProject(project);
    m_executor->setProducts(products);
    m_executor->setBuildOptions(buildOptions);
    m_executor->setProgressObserver(observer());

    QThread * const executorThread = new QThread(this);
    m_executor->moveToThread(executorThread);
    connect(m_executor, SIGNAL(reportCommandDescription(QString,QString)),
            this, SIGNAL(reportCommandDescription(QString,QString)));
    connect(m_executor, SIGNAL(reportProcessResult(qbs::ProcessResult)),
            this, SIGNAL(reportProcessResult(qbs::ProcessResult)));

    connect(executorThread, SIGNAL(started()), m_executor, SLOT(build()));
    connect(m_executor, SIGNAL(finished()), SLOT(handleFinished()));
    connect(m_executor, SIGNAL(destroyed()), executorThread, SLOT(quit()));
    connect(executorThread, SIGNAL(finished()), this, SLOT(emitFinished()));
    executorThread->start();
}
Esempio n. 9
0
void QScriptCompletionTaskPrivate::completeScriptExpression()
{
    int pos = cursorPosition;
    if ((pos > 0) && contents.at(pos-1).isNumber()) {
        // completion of numbers is pointless
        emitFinished();
        return;
    }

    while ((pos > 0) && isIdentChar(contents.at(pos-1)))
        --pos;
    int pos2 = cursorPosition - 1;
    while ((pos2+1 < contents.size()) && isIdentChar(contents.at(pos2+1)))
        ++pos2;
    QString ident = contents.mid(pos, pos2 - pos + 1);
    position = pos;

    QStringList path;
    path.append(ident);
    while ((pos > 0) && (contents.at(pos-1) == QLatin1Char('.'))) {
        --pos;
        pos2 = pos;
        while ((pos > 0) && isIdentChar(contents.at(pos-1)))
            --pos;
        path.prepend(contents.mid(pos, pos2 - pos));
    }

    length = path.last().length();
    type = QScriptCompletionTask::ScriptIdentifierCompletion;

    QScriptDebuggerJob *job = new QScriptCompleteExpressionJob(frameIndex, path, this, commandScheduler);
    jobScheduler->scheduleJob(job);
}
Esempio n. 10
0
void TestExpectation::verify(Event event, const QList<QContact> &contacts)
{
    Q_UNUSED(event);
    Q_UNUSED(contacts);

    emitFinished();
}
Esempio n. 11
0
void OpenCalaisTextMatchPlugin::doGetPossibleMatches( const QString& text )
{
    kDebug();
    // cancel previous jobs
    delete m_lookupJob;
    m_lookupJob = 0;

    if ( OpenCalais::Config::licenseKey().isEmpty() ) {
        kDebug() << "no key";
        if ( OpenCalais::Config::showKeyWarning() ) {
            KNotification* n = KNotification::event( KNotification::Warning,
                               i18n( "No OpenCalais API key configured." ) );
            n->setActions( QStringList() << i18n( "Configure..." ) );
            connect( n, SIGNAL( action1Activated() ), this, SLOT( slotConfigure() ) );
            OpenCalais::Config::self()->findItem( "ShowKeyWarning" )->setProperty( false );
            OpenCalais::Config::self()->writeConfig();
        }
        emitFinished();
    }
    else {
        // do the lookup
        m_lookupJob = new OpenCalais::LookupJob( this );
        connect( m_lookupJob, SIGNAL( result( KJob* ) ),
                 this, SLOT( slotResult( KJob* ) ) );
        m_lookupJob->setContent( text );
        m_lookupJob->start();
    }
}
void converter_ffmpeg::startConversion(QByteArray* data, QString target, int mode)
{
    QString ffmpegCall;
    switch (mode)
    {
    case 0:
        ffmpegCall = "ffmpeg -i - -y -qscale 0.1 -vcodec mpeg4 \""+target+".mp4\"";
        break;
    case 1:
        ffmpegCall = "ffmpeg -i - -y -qscale 0.1 -acodec wmav2 -ab 300k -vcodec wmv2 \""+target+".wmv\"";
        break;
    case 2:
        ffmpegCall = "ffmpeg -i - -y -qscale 0.1 -vcodec libtheora -acodec libvorbis -ac 2  \""+target+".ogg\"";
        break;
    case 3:
        ffmpegCall = "ffmpeg -i - -y -acodec libmp3lame -ab 300k \""+target+".mp3\"";
        break;
    case 4:
        ffmpegCall = "ffmpeg -i - -y -vn -acodec libvorbis -ac 2 \""+target+".ogg\"";
        break;
    }
    #ifdef Q_WS_MAC
        ffmpegCall.prepend(QApplication::applicationDirPath()+"/");
    #endif
    ffmpeg.data = *data;
    ffmpeg.ffmpegCall = ffmpegCall;
    connect(&ffmpeg, SIGNAL(finished()), this, SLOT(emitFinished()));
    ffmpeg.start();

}
/*!
    Connection method dialog result handling slot.
    
    @param success Connection method dialog result - TRUE if accepted.
 */
void CmApplSettingsUiPrivate::connMethodDialogResult(bool success)
{
    OstTraceFunctionEntry0(CMAPPLSETTINGSUIPRIVATE_CONNMETHODDIALOGRESULT_ENTRY);
    
    if (success) {
        // Dialog was accepted - user clicked "OK"
        int index = mConnMethodDialog->selected();
        mSelection.result = CmApplSettingsUi::SelectionTypeConnectionMethod;
        mSelection.id = mConnMethods[index]->id;
        emitFinished(CmApplSettingsUi::ApplSettingsErrorNone);
    } else {
        // Dialog was cancelled - user clicked "Cancel"
        emitFinished(CmApplSettingsUi::ApplSettingsErrorCancel);
    }
    
    OstTraceFunctionExit0(CMAPPLSETTINGSUIPRIVATE_CONNMETHODDIALOGRESULT_EXIT);
}
Esempio n. 14
0
void FrameFocus::focusParent() {
  if (page()->currentFrame()->parentFrame() == 0) {
    emitFinished(false, QString("Already at parent frame."));
  } else {
    page()->currentFrame()->parentFrame()->setFocus();
    success();
  }
}
Esempio n. 15
0
void TestExpectation::verify(Event event, const QList<ContactIdType> &contactIds, QContactManager::Error error)
{
    Q_UNUSED(event);
    Q_UNUSED(contactIds);
    Q_UNUSED(error);

    QVERIFY2(false, "Error fetching contacts");
    emitFinished();
}
Esempio n. 16
0
void K3bAudioMaxSpeedJob::WorkThread::run()
{
  kdDebug() << k_funcinfo << endl;
  m_canceled = false;

  emitStarted();

  K3bAudioDataSourceIterator it( m_doc );

  // count sources for minimal progress info
  int numSources = 0;
  int sourcesDone = 0;
  while( it.current() ) {
    ++numSources;
    it.next();
  }

  bool success = true;
  maxSpeed = 175*1000;
  it.first();

  while( it.current() && !m_canceled ) {
    if( !it.current()->seek(0) ) {
      kdDebug() << "(K3bAudioMaxSpeedJob) seek failed." << endl;
      success = false;
      break;
    }
      
    // read some data
    int speed = speedTest( it.current() );

    ++sourcesDone;
    emitPercent( 100*numSources/sourcesDone );

    if( speed < 0 ) {
      success = false;
      break;
    }
    else if( speed > 0 ) {
      // update the max speed
      maxSpeed = QMIN( maxSpeed, speed );
    }
      
    it.next();
  }

  if( m_canceled ) {
    emitCanceled();
    success = false;
  }

  if( success )
    kdDebug() << "(K3bAudioMaxSpeedJob) max speed: " << maxSpeed << endl;

  emitFinished( success );
}
Esempio n. 17
0
  void run() {
    emitStarted();

    QStringList l;
    for( KURL::List::const_iterator it = urls.begin();
	 it != urls.end(); ++it ) {
      const KURL& url = *it;

      if( !url.isLocalFile() ) {
	kdDebug() << "(K3bDirSizeJob) no remote support." << endl;
	emitFinished( false );
	return;
      }

      l.append( url.path() );
    }

    emitFinished( countFiles( l, QString() ) );
  }
Esempio n. 18
0
void OpenCalaisTextMatchPlugin::slotResult( KJob* job )
{
    kDebug();
    if ( !job->error() ) {
        // cancel previous worker start
        m_worker->disconnect( this );
        m_worker->cancel();

        // restart the worker
        m_worker->setData( static_cast<OpenCalais::LookupJob*>( job )->resultGraph() );
        connect( m_worker, SIGNAL( finished() ), this, SLOT( emitFinished() ) );
        connect( m_worker, SIGNAL( newMatch( Scribo::TextMatch ) ),
                 this, SLOT( addNewMatch( Scribo::TextMatch ) ),
                 Qt::QueuedConnection );
        m_worker->start();
    }
    else {
        emitFinished();
    }
}
Esempio n. 19
0
void Render::start() {
  QString imagePath = arguments()[0];
  int width = arguments()[1].toInt();
  int height = arguments()[2].toInt();

  QSize size(width, height);

  bool result = page()->render( imagePath, size );

  emitFinished(result);
}
Esempio n. 20
0
void AccessManagerReply::slotStatResult(KJob* kJob)
{
    if (jobError(kJob)) {
        emit error (error());
        emitFinished(true);
        return;
    }

    KIO::StatJob* statJob = qobject_cast<KIO::StatJob*>(kJob);
    Q_ASSERT(statJob);

    KIO::UDSEntry entry =  statJob->statResult();
    QString mimeType = entry.stringValue(KIO::UDSEntry::UDS_MIME_TYPE);
    if (mimeType.isEmpty() && entry.isDir())
        mimeType = QL1S("inode/directory");

    if (!mimeType.isEmpty())
        setHeader(QNetworkRequest::ContentTypeHeader, mimeType.toUtf8());

    emitFinished(true);
}
void Nepomuk::DbpediaAnnotationPlugin::doGetPossibleAnnotations( const AnnotationRequest& request )
{
    if ( !request.filter().isEmpty() ) {
        runQuery( request.filter() );
    }
    else if ( request.resource().isValid() ) {
        runQuery( request.resource().genericLabel() );
    }
    else {
        emitFinished();
    }
}
void NotebookSyncAgent::sendLocalChanges()
{
    NOTEBOOK_FUNCTION_CALL_TRACE;

    KCalCore::Incidence::List inserted;
    KCalCore::Incidence::List modified;
    KCalCore::Incidence::List deleted;
    if (!loadLocalChanges(mChangesSinceDate, &inserted, &modified, &deleted)) {
        emitFinished(Buteo::SyncResults::INTERNAL_ERROR, "Unable to load changes for calendar: " + mServerPath);
        return;
    }
    if (inserted.isEmpty() && modified.isEmpty() && deleted.isEmpty()) {
        LOG_DEBUG("No changes to send!");
        emitFinished(Buteo::SyncResults::NO_ERROR, "Done, no local changes for " + mServerPath);
        return;
    }
    LOG_DEBUG("Total changes for" << mServerPath << ":"
              << "inserted = " << inserted.count()
              << "modified = " << modified.count()
              << "deleted = " << deleted.count());

    for (int i=0; i<inserted.count(); i++) {
        Put *put = new Put(mNAManager, mSettings);
        mRequests.insert(put);
        connect(put, SIGNAL(finished()), this, SLOT(nonReportRequestFinished()));
        put->createEvent(mServerPath, inserted[i]);
    }
    for (int i=0; i<modified.count(); i++) {
        Put *put = new Put(mNAManager, mSettings);
        mRequests.insert(put);
        connect(put, SIGNAL(finished()), this, SLOT(nonReportRequestFinished()));
        put->updateEvent(mServerPath, modified[i], mLocalETags.value(modified[i]->uid()));
    }
    for (int i=0; i<deleted.count(); i++) {
        Delete *del = new Delete(mNAManager, mSettings);
        mRequests.insert(del);
        connect(del, SIGNAL(finished()), this, SLOT(nonReportRequestFinished()));
        del->deleteEvent(mServerPath, deleted[i]);
    }
}
Esempio n. 23
0
void Jungle::NetworkImageFetchJob::slotNetworkReply()
{
    QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
    const QString dataDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);

    QString name = QUuid::createUuid().toString();
    QString type = m_input.value("type").toString();
    QString url = QString::fromLatin1("%1/jungle/%2-%3")
                  .arg(dataDir).arg(type).arg(name);

    QByteArray data = reply->readAll();

    if (data.size() < 100 || data.contains("Format not Supported")) {
        m_input.clear();
        emitFinished();
        return;
    }

    QFile file(url);
    file.open(QIODevice::WriteOnly);
    file.write(data);
    file.close();

    for (auto it = m_input.begin(); it != m_input.end(); it++) {
        if (it.value().type() != QVariant::String) {
            continue;
        }

        QString val = it.value().toString();
        if (val == reply->url().toString()) {
            it.value() = url;
        }
    }

    m_networkRequests--;
    if (m_networkRequests == 0) {
        emitFinished();
    }
}
/*!
    Destination dialog result handling slot.
    
    @param success Destination dialog result - TRUE if accepted.
 */
void CmApplSettingsUiPrivate::destinationDialogResult(bool success)
{
    OstTraceFunctionEntry0(CMAPPLSETTINGSUIPRIVATE_DESTINATIONDIALOGRESULT_ENTRY);
    
    if (success) {
        // Dialog was accepted - user clicked "OK"
        int index = mDestinationDialog->selected();    
        if (mListItems.testFlag(CmApplSettingsUi::ShowConnectionMethods)
            && index == mDestinations.count()) {
            // Dedicated access point was selected
            runConnectionMethodDialog();
        } else {
            // Destination was selected
            mSelection.result = CmApplSettingsUi::SelectionTypeDestination;
            mSelection.id = mDestinations[index]->id;
            emitFinished(CmApplSettingsUi::ApplSettingsErrorNone);
        }
    } else {
        // Dialog was cancelled - user clicked "Cancel"
        emitFinished(CmApplSettingsUi::ApplSettingsErrorCancel);
    }
    
    OstTraceFunctionExit0(CMAPPLSETTINGSUIPRIVATE_DESTINATIONDIALOGRESULT_EXIT);
}
Esempio n. 25
0
void Nepomuk::TagAnnotation::doCreate( Nepomuk::Resource resource )
{
    kDebug() << "tagging" << resource.resourceUri() << "with" << d->m_tag;
    Nepomuk::Tag tag;
    if( d->m_tagUri.isValid() )
        tag = d->m_tagUri;
    else
        tag = d->m_tag;
    if ( tag.label().isEmpty() &&
         !tag.identifiers().isEmpty() ) {
        tag.setLabel( d->m_tag );
    }
    resource.addTag( tag );
    emitFinished();
}
Esempio n. 26
0
void SetProxy::start()
{
  // default to empty proxy
  QNetworkProxy proxy;

  if (arguments().size() > 0)
    proxy = QNetworkProxy(QNetworkProxy::HttpProxy,
                          arguments()[0],
                          (quint16)(arguments()[1].toInt()),
                          arguments()[2],
                          arguments()[3]);

  page()->networkAccessManager()->setProxy(proxy);
  emitFinished(true);
}
void Nepomuk::DbpediaAnnotationPlugin::slotQueryFinished( Soprano::Util::AsyncResult* result )
{
    m_currentResult = 0;

    kDebug() << result->lastError();

    Soprano::QueryResultIterator it = result->queryResultIterator();
    while ( it.next() ) {
        kDebug() << it.current();
    }

    // TODO: create annotations either as new pimo things that are related to the resource or as
    //       being the resource (ie. an occurrence of resource().pimoThing())

    emitFinished();
}
void PendingTpLoggerEntities::entitiesRetrieved(Tpl::PendingOperation *op)
{
    if (op->isError()) {
        setError(op->errorName() + QLatin1String(": ") + op->errorMessage());
        emitFinished();
        return;
    }

    Tpl::PendingEntities *pe = qobject_cast<Tpl::PendingEntities*>(op);
    Q_ASSERT(pe);

    Tpl::EntityPtrList entities = pe->entities();
    QList<KTp::LogEntity> logEntities;
    Q_FOREACH (const Tpl::EntityPtr entity, entities) {
        logEntities << Utils::fromTplEntity(entity);
    }
void Nepomuk::ContextAnnotationPlugin::doGetPossibleAnnotations( const AnnotationRequest& request )
{
    if ( request.filter().isEmpty() &&
         Nepomuk::ContextServiceInterface::isAvailable() ) {
        Resource contextRes = Nepomuk::ContextServiceInterface::instance()->currentContext();
        if ( contextRes.isValid() ) {
            kDebug() << "Creating annotation suggestion for the current context";
            SimplePimoAnnotation* anno = new SimplePimoAnnotation( Vocabulary::PIMO::isRelated(), contextRes, this );
            anno->setComment( i18n( "Relate to '%1 (%2)'",
                                    contextRes.genericLabel(),
                                    Nepomuk::Types::Class( contextRes.resourceType() ).label() ) );
            addNewAnnotation(anno);
        }
    }

    emitFinished();
}
void EnginioClientConnectionPrivate::replyFinished(QNetworkReply *nreply)
{
    EnginioReplyState *ereply = _replyReplyMap.take(nreply);

    if (!ereply)
        return;

    if (nreply->error() != QNetworkReply::NoError) {
        QPair<QIODevice *, qint64> deviceState = _chunkedUploads.take(nreply);
        delete deviceState.first;
        emitError(ereply);
    }

    // continue chunked upload
    else if (_chunkedUploads.contains(nreply)) {
        QPair<QIODevice *, qint64> deviceState = _chunkedUploads.take(nreply);
        QString status = ereply->data().value(EnginioString::status).toString();
        if (status == EnginioString::empty || status == EnginioString::incomplete) {
            Q_ASSERT(ereply->data().value(EnginioString::objectType).toString() == EnginioString::files);
            uploadChunk(ereply, deviceState.first, deviceState.second);
            return;
        }
        // should never get here unless upload was successful
        Q_ASSERT(status == EnginioString::complete);
        delete deviceState.first;
        if (_connections.count() * 2 > _chunkedUploads.count()) {
            _connections.removeAll(QMetaObject::Connection());
        }
    }

    if (Q_UNLIKELY(ereply->delayFinishedSignal())) {
        // delay emittion of finished signal for autotests
        _delayedReplies.insert(ereply);
    } else {
        ereply->dataChanged();
        EnginioReplyStatePrivate::get(ereply)->emitFinished();
        emitFinished(ereply);
        if (gEnableEnginioDebugInfo)
            _requestData.remove(nreply);
    }

    if (Q_UNLIKELY(_delayedReplies.count())) {
        finishDelayedReplies();
    }
}