Esempio n. 1
0
void SaveDraftJob::start()
{
    Akonadi::Item item;
    item.setPayload(mMsg);
    item.setMimeType(KMime::Message::mimeType());
    item.setFlag(Akonadi::MessageFlags::Seen);
    Akonadi::MessageFlags::copyMessageFlags(*mMsg, item);

    Akonadi::ItemCreateJob *createJob = new Akonadi::ItemCreateJob(item, mCollection);
    connect(createJob, &Akonadi::ItemCreateJob::result, this, &SaveDraftJob::slotStoreDone);
}
Esempio n. 2
0
Akonadi::Item getErrorItem(Kolab::FolderType folderType, const QString &remoteId)
{
    //TODO set title, text and icon
    Akonadi::Item item;
    item.setRemoteId(remoteId);
    switch (folderType) {
    case Kolab::EventType: {
        KCalCore::Event::Ptr event(new KCalCore::Event);
        //FIXME Use message creation date time
        event->setDtStart(KDateTime::currentUtcDateTime());
        event->setSummary(i18n("Corrupt Event"));
        event->setDescription(i18n("Event could not be read. Delete this event to remove it from the server."));
        item.setMimeType(KCalCore::Event::eventMimeType());
        item.setPayload(event);
    }
    break;
    case Kolab::TaskType: {
        KCalCore::Todo::Ptr task(new KCalCore::Todo);
        //FIXME Use message creation date time
        task->setDtStart(KDateTime::currentUtcDateTime());
        task->setSummary(i18n("Corrupt Task"));
        task->setDescription(i18n("Task could not be read. Delete this task to remove it from the server."));
        item.setMimeType(KCalCore::Todo::todoMimeType());
        item.setPayload(task);
    }
    break;
    case Kolab::JournalType: {
        KCalCore::Journal::Ptr journal(new KCalCore::Journal);
        //FIXME Use message creation date time
        journal->setDtStart(KDateTime::currentUtcDateTime());
        journal->setSummary(i18n("Corrupt journal"));
        journal->setDescription(i18n("Journal could not be read. Delete this journal to remove it from the server."));
        item.setMimeType(KCalCore::Journal::journalMimeType());
        item.setPayload(journal);
    }
    break;
    case Kolab::ContactType: {
        KContacts::Addressee addressee;
        addressee.setName(i18n("Corrupt Contact"));
        addressee.setNote(i18n("Contact could not be read. Delete this contact to remove it from the server."));
        item.setMimeType(KContacts::Addressee::mimeType());
        item.setPayload(addressee);
    }
    break;
    case Kolab::NoteType: {
        Akonadi::NoteUtils::NoteMessageWrapper note;
        note.setTitle(i18n("Corrupt Note"));
        note.setText(i18n("Note could not be read. Delete this note to remove it from the server."));
        item.setPayload(Akonadi::NoteUtils::noteMimeType());
        item.setPayload(note.message());
    }
    break;
    case Kolab::MailType:
    //We don't convert mails, so that should never fail.
    default:
        qCWarning(KOLABRESOURCE_LOG) << "unhandled folder type: " << folderType;
    }
    return item;
}
Esempio n. 3
0
Item Serializer::createItemFromNote(Domain::Note::Ptr note)
{
    NoteUtils::NoteMessageWrapper builder;
    builder.setTitle(note->title());
    builder.setText(note->text());

    KMime::Message::Ptr message = builder.message();

    if (!note->property("relatedUid").toString().isEmpty()) {
        auto relatedHeader = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid");
        relatedHeader->from7BitString(note->property("relatedUid").toString().toUtf8());
        message->appendHeader(relatedHeader);
    }

    Akonadi::Item item;
    if (note->property("itemId").isValid()) {
        item.setId(note->property("itemId").value<Akonadi::Item::Id>());
    }
    item.setMimeType(Akonadi::NoteUtils::noteMimeType());
    item.setPayload(message);
    return item;
}
Esempio n. 4
0
Akonadi::Item Serializer::createItemFromTask(Domain::Task::Ptr task)
{
    auto todo = KCalCore::Todo::Ptr::create();

    todo->setSummary(task->title());
    todo->setDescription(task->text());

    if (task->isDone())
        todo->setCompleted(KDateTime(task->doneDate()));
    else
        todo->setCompleted(task->isDone());

    todo->setDtStart(KDateTime(task->startDate()));
    todo->setDtDue(KDateTime(task->dueDate()));

    if (task->property("todoUid").isValid()) {
        todo->setUid(task->property("todoUid").toString());
    }

    if (task->property("relatedUid").isValid()) {
        todo->setRelatedTo(task->property("relatedUid").toString());
    }

    if (task->delegate().isValid()) {
        KCalCore::Attendee::Ptr attendee(new KCalCore::Attendee(task->delegate().name(),
                                                                task->delegate().email(),
                                                                true,
                                                                KCalCore::Attendee::Delegated));
        todo->addAttendee(attendee);
    }

    Akonadi::Item item;
    if (task->property("itemId").isValid()) {
        item.setId(task->property("itemId").value<Akonadi::Item::Id>());
    }
    item.setMimeType(KCalCore::Todo::todoMimeType());
    item.setPayload(todo);
    return item;
}
Esempio n. 5
0
Item Serializer::createItemFromProject(Domain::Project::Ptr project)
{
    auto todo = KCalCore::Todo::Ptr::create();

    todo->setSummary(project->name());
    todo->setCustomProperty("Zanshin", "Project", "1");

    if (project->property("todoUid").isValid()) {
        todo->setUid(project->property("todoUid").toString());
    }

    Akonadi::Item item;
    if (project->property("itemId").isValid()) {
        item.setId(project->property("itemId").value<Akonadi::Item::Id>());
    }
    if (project->property("parentCollectionId").isValid()) {
        auto parentId = project->property("parentCollectionId").value<Akonadi::Collection::Id>();
        item.setParentCollection(Akonadi::Collection(parentId));
    }
    item.setMimeType(KCalCore::Todo::todoMimeType());
    item.setPayload(todo);
    return item;
}