Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major refactor of item handling code
The new implementation moves all actions specific to item type into a dedicated set of classes. This way the core resource code is generic and doesn't have to worry about type-specific actions.
- Loading branch information
Showing
34 changed files
with
1,310 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* This file is part of Akonadi EWS Resource | ||
Copyright (C) 2015-2016 Krzysztof Nowicki <krissn@op.pl> | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Library General Public | ||
License as published by the Free Software Foundation; either | ||
version 2 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Library General Public License for more details. | ||
You should have received a copy of the GNU Library General Public License | ||
along with this library; see the file COPYING.LIB. If not, write to | ||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#include "ewscalendarhandler.h" | ||
|
||
#include <KCalCore/Event> | ||
|
||
#include "ewsfetchcalendardetailjob.h" | ||
#include "ewsmodifycalendarjob.h" | ||
|
||
using namespace Akonadi; | ||
|
||
EwsCalendarHandler::EwsCalendarHandler() | ||
{ | ||
} | ||
|
||
EwsCalendarHandler::~EwsCalendarHandler() | ||
{ | ||
} | ||
|
||
EwsItemHandler *EwsCalendarHandler::factory() | ||
{ | ||
return new EwsCalendarHandler(); | ||
} | ||
|
||
EwsFetchItemDetailJob *EwsCalendarHandler::fetchItemDetailJob(EwsClient &client, QObject *parent, | ||
const Akonadi::Collection &collection) | ||
{ | ||
return new EwsFetchCalendarDetailJob(client, parent, collection); | ||
} | ||
|
||
void EwsCalendarHandler::setSeenFlag(Item &item, bool value) | ||
{ | ||
Q_UNUSED(item) | ||
Q_UNUSED(value) | ||
} | ||
|
||
QString EwsCalendarHandler::mimeType() | ||
{ | ||
return KCalCore::Event::eventMimeType(); | ||
} | ||
|
||
bool EwsCalendarHandler::setItemPayload(Akonadi::Item &item, const EwsItem &ewsItem) | ||
{ | ||
Q_UNUSED(item) | ||
Q_UNUSED(ewsItem) | ||
|
||
return true; | ||
} | ||
|
||
EwsModifyItemJob *EwsCalendarHandler::modifyItemJob(EwsClient& client, const Akonadi::Item &item, | ||
const QSet<QByteArray> &parts, QObject *parent) | ||
{ | ||
return new EwsModifyCalendarJob(client, item, parts, parent); | ||
} | ||
|
||
EWS_DECLARE_ITEM_HANDLER(EwsCalendarHandler, EwsItemTypeCalendarItem) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* This file is part of Akonadi EWS Resource | ||
Copyright (C) 2015-2016 Krzysztof Nowicki <krissn@op.pl> | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Library General Public | ||
License as published by the Free Software Foundation; either | ||
version 2 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Library General Public License for more details. | ||
You should have received a copy of the GNU Library General Public License | ||
along with this library; see the file COPYING.LIB. If not, write to | ||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifndef EWSCALENDARHANDLER_H | ||
#define EWSCALENDARHANDLER_H | ||
|
||
#include "ewsitemhandler.h" | ||
|
||
class EwsCalendarHandler : public EwsItemHandler | ||
{ | ||
public: | ||
EwsCalendarHandler(); | ||
virtual ~EwsCalendarHandler(); | ||
|
||
virtual EwsFetchItemDetailJob *fetchItemDetailJob(EwsClient &client, QObject *parent, | ||
const Akonadi::Collection &collection) Q_DECL_OVERRIDE; | ||
virtual void setSeenFlag(Akonadi::Item &item, bool value) Q_DECL_OVERRIDE; | ||
virtual QString mimeType() Q_DECL_OVERRIDE; | ||
virtual bool setItemPayload(Akonadi::Item &item, const EwsItem &ewsItem) Q_DECL_OVERRIDE; | ||
virtual EwsModifyItemJob *modifyItemJob(EwsClient& client, const Akonadi::Item &item, | ||
const QSet<QByteArray> &parts, QObject *parent) Q_DECL_OVERRIDE; | ||
|
||
static EwsItemHandler *factory(); | ||
private: | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* This file is part of Akonadi EWS Resource | ||
Copyright (C) 2015-2016 Krzysztof Nowicki <krissn@op.pl> | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Library General Public | ||
License as published by the Free Software Foundation; either | ||
version 2 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Library General Public License for more details. | ||
You should have received a copy of the GNU Library General Public License | ||
along with this library; see the file COPYING.LIB. If not, write to | ||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#include "ewsmodifycalendarjob.h" | ||
|
||
#include "ewsclient_debug.h" | ||
|
||
EwsModifyCalendarJob::EwsModifyCalendarJob(EwsClient& client, const Akonadi::Item &item, | ||
const QSet<QByteArray> &parts, QObject *parent) | ||
: EwsModifyItemJob(client, item, parts, parent) | ||
{ | ||
} | ||
EwsModifyCalendarJob::~EwsModifyCalendarJob() | ||
{ | ||
} | ||
|
||
void EwsModifyCalendarJob::start() | ||
{ | ||
qCWarning(EWSRES_LOG) << QStringLiteral("Calendar item modification not implemented!"); | ||
emitResult(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* This file is part of Akonadi EWS Resource | ||
Copyright (C) 2015-2016 Krzysztof Nowicki <krissn@op.pl> | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Library General Public | ||
License as published by the Free Software Foundation; either | ||
version 2 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Library General Public License for more details. | ||
You should have received a copy of the GNU Library General Public License | ||
along with this library; see the file COPYING.LIB. If not, write to | ||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifndef EWSMODIFYCALENDARJOB_H | ||
#define EWSMODIFYCALENDARJOB_H | ||
|
||
#include "ewsmodifyitemjob.h" | ||
|
||
class EwsModifyCalendarJob : public EwsModifyItemJob | ||
{ | ||
Q_OBJECT | ||
public: | ||
EwsModifyCalendarJob(EwsClient& client, const Akonadi::Item &item, const QSet<QByteArray> &parts, | ||
QObject *parent); | ||
virtual ~EwsModifyCalendarJob(); | ||
virtual void start() Q_DECL_OVERRIDE; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* This file is part of Akonadi EWS Resource | ||
Copyright (C) 2015-2016 Krzysztof Nowicki <krissn@op.pl> | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Library General Public | ||
License as published by the Free Software Foundation; either | ||
version 2 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Library General Public License for more details. | ||
You should have received a copy of the GNU Library General Public License | ||
along with this library; see the file COPYING.LIB. If not, write to | ||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#include "ewscontacthandler.h" | ||
|
||
#include <KContacts/Addressee> | ||
#include <KContacts/ContactGroup> | ||
|
||
#include "ewsfetchcontactdetailjob.h" | ||
#include "ewsmodifycontactjob.h" | ||
|
||
using namespace Akonadi; | ||
|
||
EwsContactHandler::EwsContactHandler() | ||
{ | ||
} | ||
|
||
EwsContactHandler::~EwsContactHandler() | ||
{ | ||
} | ||
|
||
EwsItemHandler *EwsContactHandler::factory() | ||
{ | ||
return new EwsContactHandler(); | ||
} | ||
|
||
EwsFetchItemDetailJob *EwsContactHandler::fetchItemDetailJob(EwsClient &client, QObject *parent, | ||
const Akonadi::Collection &collection) | ||
{ | ||
return new EwsFetchContactDetailJob(client, parent, collection); | ||
} | ||
|
||
void EwsContactHandler::setSeenFlag(Item &item, bool value) | ||
{ | ||
Q_UNUSED(item) | ||
Q_UNUSED(value) | ||
} | ||
|
||
QString EwsContactHandler::mimeType() | ||
{ | ||
return KContacts::Addressee::mimeType(); | ||
} | ||
|
||
bool EwsContactHandler::setItemPayload(Akonadi::Item &item, const EwsItem &ewsItem) | ||
{ | ||
Q_UNUSED(item) | ||
Q_UNUSED(ewsItem) | ||
|
||
return true; | ||
} | ||
|
||
EwsModifyItemJob *EwsContactHandler::modifyItemJob(EwsClient& client, const Akonadi::Item &item, | ||
const QSet<QByteArray> &parts, QObject *parent) | ||
{ | ||
return new EwsModifyContactJob(client, item, parts, parent); | ||
} | ||
|
||
EWS_DECLARE_ITEM_HANDLER(EwsContactHandler, EwsItemTypeTask) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* This file is part of Akonadi EWS Resource | ||
Copyright (C) 2015-2016 Krzysztof Nowicki <krissn@op.pl> | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Library General Public | ||
License as published by the Free Software Foundation; either | ||
version 2 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Library General Public License for more details. | ||
You should have received a copy of the GNU Library General Public License | ||
along with this library; see the file COPYING.LIB. If not, write to | ||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifndef EWSCONTACTHANDLER_H | ||
#define EWSCONTACTHANDLER_H | ||
|
||
#include "ewsitemhandler.h" | ||
|
||
class EwsContactHandler : public EwsItemHandler | ||
{ | ||
public: | ||
EwsContactHandler(); | ||
virtual ~EwsContactHandler(); | ||
|
||
virtual EwsFetchItemDetailJob *fetchItemDetailJob(EwsClient &client, QObject *parent, | ||
const Akonadi::Collection &collection) Q_DECL_OVERRIDE; | ||
virtual void setSeenFlag(Akonadi::Item &item, bool value) Q_DECL_OVERRIDE; | ||
virtual QString mimeType() Q_DECL_OVERRIDE; | ||
virtual bool setItemPayload(Akonadi::Item &item, const EwsItem &ewsItem) Q_DECL_OVERRIDE; | ||
virtual EwsModifyItemJob *modifyItemJob(EwsClient& client, const Akonadi::Item &item, | ||
const QSet<QByteArray> &parts, QObject *parent) Q_DECL_OVERRIDE; | ||
|
||
static EwsItemHandler *factory(); | ||
private: | ||
}; | ||
|
||
#endif |
Oops, something went wrong.