Commit 2257ae9a authored by Sergio Luis Martins's avatar Sergio Luis Martins
Browse files

Store the respective imap collection inside the handler so we can ignore...

Store the respective imap collection inside the handler so we can ignore conflict resolution if we don't have enough ACLs.

svn path=/trunk/KDE/kdepim/runtime/; revision=1199119
parent a13e6d08
......@@ -30,7 +30,7 @@
#include <QBuffer>
AddressBookHandler::AddressBookHandler(): KolabHandler()
AddressBookHandler::AddressBookHandler( const Akonadi::Collection &imapCollection ) : KolabHandler( imapCollection )
{
m_mimeType = "application/x-vnd.kolab.contact";
}
......
......@@ -39,7 +39,7 @@ namespace Kolab {
*/
class AddressBookHandler : public KolabHandler {
public:
AddressBookHandler();
explicit AddressBookHandler( const Akonadi::Collection &imapCollection );
virtual ~AddressBookHandler();
......
......@@ -32,7 +32,7 @@
#include <QDomDocument>
CalendarHandler::CalendarHandler() : IncidenceHandler()
CalendarHandler::CalendarHandler( const Akonadi::Collection &imapCollection ) : IncidenceHandler( imapCollection )
{
m_mimeType = "application/x-vnd.kolab.event";
}
......
......@@ -29,7 +29,7 @@
class CalendarHandler : public IncidenceHandler {
Q_OBJECT
public:
CalendarHandler();
explicit CalendarHandler( const Akonadi::Collection &imapCollection );
virtual ~CalendarHandler();
virtual QStringList contentMimeTypes();
virtual QString iconName() const;
......
......@@ -38,11 +38,11 @@
#include <QDomDocument>
IncidenceHandler::IncidenceHandler() : KolabHandler(), m_calendar( QString::fromLatin1("UTC") )
IncidenceHandler::IncidenceHandler( const Akonadi::Collection &imapCollection )
: KolabHandler( imapCollection), m_calendar( QString::fromLatin1("UTC") )
{
}
IncidenceHandler::~IncidenceHandler()
{
}
......@@ -69,20 +69,20 @@ Akonadi::Item::List IncidenceHandler::translateItems(const Akonadi::Item::List &
<< " for imap item id = " << item.id()
<< " and the other imap item id is "
<< storedItem.id << "; imap collection is "
<< item.parentCollection().name()
<< item.parentCollection().id()
<< m_imapCollection.name()
<< m_imapCollection.id()
<< "; collection has rights "
<< item.parentCollection().rights();
<< m_imapCollection.rights();
/*
const Akonadi::Collection::Rights requiredRights = Akonadi::Collection::CanDeleteItem |
Akonadi::Collection::CanCreateItem;
if ( ( item.parentCollection().rights() & requiredRights ) != requiredRights ) {
if ( ( m_imapCollection.rights() & requiredRights ) != requiredRights ) {
kDebug() << "Skipping conflict resolution, no rights on collection " << item.parentCollection().name();
continue;
}
*/
}*/
ConflictResolution res = resolveConflict(incidencePtr);
kDebug() << "ConflictResolution " << res;
......
......@@ -31,7 +31,7 @@
class IncidenceHandler : public KolabHandler {
Q_OBJECT
public:
IncidenceHandler();
explicit IncidenceHandler( const Akonadi::Collection &imapCollection );
virtual ~IncidenceHandler();
......
......@@ -29,7 +29,7 @@
#include <QBuffer>
#include <QDomDocument>
JournalHandler::JournalHandler() : IncidenceHandler()
JournalHandler::JournalHandler( const Akonadi::Collection &imapCollection) : IncidenceHandler( imapCollection )
{
m_mimeType = "application/x-vnd.kolab.journal";
}
......
......@@ -29,7 +29,7 @@
*/
class JournalHandler : public IncidenceHandler {
public:
JournalHandler();
JournalHandler( const Akonadi::Collection &imapCollection );
virtual ~JournalHandler();
virtual QStringList contentMimeTypes();
......
......@@ -27,26 +27,26 @@
#include <KCalCore/Todo>
#include <KCalCore/Journal>
#include <akonadi/collection.h>
#include <kabc/addressee.h>
KolabHandler::KolabHandler()
KolabHandler::KolabHandler( const Akonadi::Collection &imapCollection ) : m_imapCollection( imapCollection )
{
}
KolabHandler *KolabHandler::createHandler(const QByteArray& type)
KolabHandler *KolabHandler::createHandler( const QByteArray& type,
const Akonadi::Collection &imapCollection )
{
if (type == "contact.default" || type == "contact") {
return new AddressBookHandler();
return new AddressBookHandler( imapCollection );
} else if (type == "event.default" || type == "event") {
return new CalendarHandler();
return new CalendarHandler( imapCollection );
} else if (type == "task.default" || type == "task") {
return new TasksHandler();
return new TasksHandler( imapCollection );
} else if (type == "journal.default" || type == "journal") {
return new JournalHandler();
return new JournalHandler( imapCollection );
} else if (type == "note.default" || type == "note") {
return new NotesHandler();
return new NotesHandler( imapCollection );
} else {
return 0;
}
......
......@@ -21,20 +21,16 @@
#define KOLABHANDLER_H
#include <akonadi/item.h>
#include <akonadi/collection.h>
#include <kmime/kmime_message.h>
namespace Akonadi {
class Collection;
}
/**
@author Andras Mantia <amantia@kde.org>
*/
class KolabHandler : public QObject{
Q_OBJECT
public:
static KolabHandler *createHandler(const QByteArray& type);
static KolabHandler *createHandler( const QByteArray& type, const Akonadi::Collection &imapCollection );
/**
Returns the Kolab folder type for the given collection.
......@@ -77,7 +73,7 @@ Q_SIGNALS:
void addItemToImap(const Akonadi::Item& item, Akonadi::Entity::Id collectionId);
protected:
explicit KolabHandler();
explicit KolabHandler( const Akonadi::Collection &imapCollection );
static KMime::Content *findContentByType(const KMime::Message::Ptr &data, const QByteArray &type);
static KMime::Content *findContentByName(const KMime::Message::Ptr &data, const QString &name, QByteArray &type);
......@@ -91,6 +87,7 @@ protected:
static KMime::Content* createAttachmentPart( const QString &mimeType, const QString &fileName, const QByteArray &decodedContent );
QByteArray m_mimeType;
Akonadi::Collection m_imapCollection;
};
#endif
......@@ -148,6 +148,7 @@ void KolabProxyResource::retrieveItems( const Collection &collection )
ItemFetchJob *job = new ItemFetchJob( kolabToImap( collection ) );
job->fetchScope().fetchFullPayload();
job->fetchScope().setAncestorRetrieval( ItemFetchScope::Parent );
connect(job, SIGNAL(result(KJob*)), this, SLOT(retrieveItemFetchDone(KJob *)));
}
......@@ -716,7 +717,7 @@ bool KolabProxyResource::registerHandlerForCollection(const Akonadi::Collection&
if ( annotationsAttribute ) {
QMap<QByteArray, QByteArray> annotations = annotationsAttribute->annotations();
KolabHandler *handler = KolabHandler::createHandler(annotations["/vendor/kolab/folder-type"]);
KolabHandler *handler = KolabHandler::createHandler(annotations["/vendor/kolab/folder-type"], imapCollection );
if ( handler ) {
connect(handler, SIGNAL(deleteItemFromImap(const Akonadi::Item&)), this, SLOT(deleteImapItem(const Akonadi::Item&)));
connect(handler, SIGNAL(addItemToImap(const Akonadi::Item&, Akonadi::Entity::Id)), this, SLOT(addImapItem(const Akonadi::Item&, Akonadi::Entity::Id)));
......
......@@ -23,7 +23,7 @@
#include <akonadi/item.h>
#include <QStringList>
NotesHandler::NotesHandler() : JournalHandler()
NotesHandler::NotesHandler( const Akonadi::Collection &imapCollection ) : JournalHandler( imapCollection )
{
m_mimeType = "application/x-vnd.kolab.note";
}
......
......@@ -25,7 +25,7 @@
class NotesHandler : public JournalHandler
{
public:
NotesHandler();
explicit NotesHandler( const Akonadi::Collection &imapCollection );
virtual Akonadi::Item::List translateItems(const Akonadi::Item::List & kolabItems);
virtual void toKolabFormat(const Akonadi::Item& item, Akonadi::Item &imapItem);
......
......@@ -28,7 +28,7 @@
#include <QDomDocument>
TasksHandler::TasksHandler() : IncidenceHandler()
TasksHandler::TasksHandler( const Akonadi::Collection &imapCollection ) : IncidenceHandler( imapCollection )
{
m_mimeType = "application/x-vnd.kolab.task";
}
......
......@@ -29,7 +29,7 @@
*/
class TasksHandler : public IncidenceHandler {
public:
TasksHandler();
explicit TasksHandler( const Akonadi::Collection &imapCollection );
virtual ~TasksHandler();
virtual QStringList contentMimeTypes();
virtual QString iconName() const;
......
......@@ -160,7 +160,7 @@ class KolabConverterTest : public QObject
QFETCH( QString, vcardFileName );
QFETCH( QString, mimeFileName );
KolabHandler *handler = KolabHandler::createHandler( "contact" );
KolabHandler *handler = KolabHandler::createHandler( "contact", Collection() );
QVERIFY( handler );
// mime -> vcard conversion
......@@ -229,7 +229,7 @@ class KolabConverterTest : public QObject
QFETCH( QString, icalFileName );
QFETCH( QString, mimeFileName );
KolabHandler *handler = KolabHandler::createHandler( type.toLatin1() );
KolabHandler *handler = KolabHandler::createHandler( type.toLatin1(), Collection() );
QVERIFY( handler );
// mime -> vcard conversion
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment