예제 #1
0
void NotesRepository::loadNotes()
{
    //kDebug() << "Loading" << mNotesCollection.statistics().count() << "notes";

    // load notes
    Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(mNotesCollection, this);
    configureItemFetchScope(job->fetchScope());
    connect(job, SIGNAL(itemsReceived(Akonadi::Item::List)),
            this, SLOT(slotNotesReceived(Akonadi::Item::List)));
}
예제 #2
0
void SentActionHandler::runAction(const SentActionAttribute::Action &action)
{
    if (action.type() == SentActionAttribute::Action::MarkAsReplied ||
            action.type() == SentActionAttribute::Action::MarkAsForwarded) {

        const Akonadi::Item item(action.value().toLongLong());
        Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(item);
        connect(job, &Akonadi::ItemFetchJob::result, this, &SentActionHandler::itemFetchResult);
        job->setProperty("type", static_cast<int>(action.type()));
    }
}
예제 #3
0
void EventModel::initialCollectionFetchFinished(KJob *job)
{
    if (job->error()) {
        kDebug() << "Initial collection fetch failed!";
    } else {
        Akonadi::CollectionFetchJob *cJob = qobject_cast<Akonadi::CollectionFetchJob *>(job);
        Akonadi::Collection::List collections = cJob->collections();
        foreach (const Akonadi::Collection &collection, collections) {
            m_collections.insert(collection.id(), collection);
            Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(collection);
            job->fetchScope().fetchFullPayload();
            job->fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
            
            connect(job, SIGNAL(result(KJob *)), this, SLOT(initialItemFetchFinished(KJob *)));
            job->start();
        }
    }
예제 #4
0
void EmptyTrashCommand::slotExpungeJob(KJob *job)
{
    if (job->error()) {
        Util::showJobError(job);
        emitResult(Failed);
        return;
    }
    Akonadi::ItemFetchJob *fjob = qobject_cast<Akonadi::ItemFetchJob *>(job);
    if (!fjob) {
        emitResult(Failed);
        return;
    }
    const Akonadi::Item::List lstItem = fjob->items();
    if (lstItem.isEmpty()) {
        emitResult(OK);
        return;
    }
    Akonadi::ItemDeleteJob *jobDelete = new Akonadi::ItemDeleteJob(lstItem, this);
    connect(jobDelete, &Akonadi::ItemDeleteJob::result, this, &EmptyTrashCommand::slotDeleteJob);
}
예제 #5
0
//----------------------------------------------------------------------------
void CollectionMailingListPage::slotDetectMailingList()
{
    if (!mFolder) {
        return;    // in case the folder was just created
    }

    qCDebug(KMAIL_LOG) << "Detecting mailing list";

    // next try the 5 most recently added messages
    if (!(mMailingList.features() & MailingList::Post)) {
        //FIXME not load all folder
        Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(mFolder->collection(), this);
        job->fetchScope().fetchPayloadPart(Akonadi::MessagePart::Header);
        connect(job, &Akonadi::ItemFetchJob::result, this, &CollectionMailingListPage::slotFetchDone);
        //Don't allow to reactive it
        mDetectButton->setEnabled(false);
    } else {
        mMLId->setText((mMailingList.id().isEmpty() ? i18n("Not available.") : mMailingList.id()));
        fillEditBox();
    }
}
예제 #6
0
void SentActionHandler::itemFetchResult(KJob *job)
{
    if (job->error()) {
        qCWarning(MAILDISPATCHER_LOG) << job->errorText();
        return;
    }

    Akonadi::ItemFetchJob *fetchJob = qobject_cast<Akonadi::ItemFetchJob *>(job);
    if (fetchJob->items().isEmpty()) {
        return;
    }

    Akonadi::Item item = fetchJob->items().at(0);

    const SentActionAttribute::Action::Type type = static_cast<SentActionAttribute::Action::Type>(job->property("type").toInt());
    if (type == SentActionAttribute::Action::MarkAsReplied) {
        item.setFlag(Akonadi::MessageFlags::Replied);
    } else if (type == SentActionAttribute::Action::MarkAsForwarded) {
        item.setFlag(Akonadi::MessageFlags::Forwarded);
    }

    Akonadi::ItemModifyJob *modifyJob = new Akonadi::ItemModifyJob(item);
    modifyJob->setIgnorePayload(true);
}
예제 #7
0
void CollectionMailingListPage::slotFetchDone(KJob *job)
{
    mDetectButton->setEnabled(true);
    if (MailCommon::Util::showJobErrorMessage(job)) {
        return;
    }
    Akonadi::ItemFetchJob *fjob = qobject_cast<Akonadi::ItemFetchJob *>(job);
    Q_ASSERT(fjob);
    Akonadi::Item::List items = fjob->items();
    const int maxchecks = 5;
    int num = items.size();
    for (int i = --num; (i > num - maxchecks) && (i >= 0); --i) {
        Akonadi::Item item = items[i];
        if (item.hasPayload<KMime::Message::Ptr>()) {
            KMime::Message::Ptr message = item.payload<KMime::Message::Ptr>();
            mMailingList = MessageCore::MailingList::detect(message);
            if (mMailingList.features() & MailingList::Post) {
                break;
            }
        }
    }
    if (!(mMailingList.features() & MailingList::Post)) {
        if (mMailingList.features() == MailingList::None) {
            KMessageBox::error(this,
                               i18n("KMail was unable to detect any mailing list in this folder."));
        } else {
            KMessageBox::error(this,
                               i18n("KMail was unable to fully detect a mailing list in this folder. "
                                    "Please fill in the addresses by hand."));
        }
    } else {
        mMLId->setText((mMailingList.id().isEmpty() ? i18n("Not available.") : mMailingList.id()));
        fillEditBox();
    }

}