Commit 6e7768e6 authored by Shashwat Jolly's avatar Shashwat Jolly

Initialise new EteSync resource

parent cef835ef
......@@ -53,6 +53,7 @@ add_subdirectory( openxchange )
add_subdirectory( pop3 )
add_subdirectory( google-groupware )
add_subdirectory( etesync )
add_subdirectory( shared )
add_subdirectory( birthdays )
......
set(etesyncresource_SRCS
etesyncresource.cpp
)
ecm_qt_declare_logging_category(etesyncresource_SRCS
HEADER debug.h
IDENTIFIER log_etesyncresource
CATEGORY_NAME log_etesyncresource
)
kconfig_add_kcfg_files(etesyncresource_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/settings.kcfgc
)
kcfg_generate_dbus_interface(
${CMAKE_CURRENT_SOURCE_DIR}/settings.kcfg
org.kde.Akonadi.etesync.Settings
)
qt5_add_dbus_adaptor(etesyncresource_SRCS
${CMAKE_CURRENT_BINARY_DIR}/org.kde.Akonadi.etesync.Settings.xml
${CMAKE_CURRENT_BINARY_DIR}/settings.h
Settings
)
add_executable(akonadi_etesync_resource ${etesyncresource_SRCS})
set_target_properties(akonadi_etesync_resource PROPERTIES MACOSX_BUNDLE FALSE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(ETESYNC REQUIRED etesync)
target_link_libraries(akonadi_etesync_resource
${ETESYNC_LIBRARIES}
Qt5::DBus
KF5::AkonadiAgentBase
KF5::ConfigCore
)
install(TARGETS akonadi_etesync_resource ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES etesyncresource.desktop
DESTINATION ${KDE_INSTALL_DATAROOTDIR}/akonadi/agents
)
/*
* Copyright (C) 2020 by Shashwat Jolly <shashwat.jolly@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "etesyncresource.h"
#include "etesync/etesync.h"
#include "debug.h"
#include "settings.h"
#include "settingsadaptor.h"
#include <QDBusConnection>
using namespace Akonadi;
etesyncResource::etesyncResource(const QString &id) : ResourceBase(id) {
new SettingsAdaptor(Settings::self());
QDBusConnection::sessionBus().registerObject(QStringLiteral("/Settings"),
Settings::self(),
QDBusConnection::ExportAdaptors);
// TODO: you can put any resource specific initialization code here.
QLoggingCategory::setFilterRules(
QStringLiteral("log_etesyncresource.debug = true"));
qCDebug(log_etesyncresource) << "Resource started";
}
etesyncResource::~etesyncResource() {}
void etesyncResource::retrieveCollections() {
// TODO: this method is called when Akonadi wants to have all the
// collections your resource provides.
// Be sure to set the remote ID and the content MIME types
}
void etesyncResource::retrieveItems(const Akonadi::Collection &collection) {
// TODO: this method is called when Akonadi wants to know about all the
// items in the given collection. You can but don't have to provide all the
// data for each item, remote ID and MIME type are enough at this stage.
// Depending on how your resource accesses the data, there are several
// different ways to tell Akonadi when you are done.
}
bool etesyncResource::retrieveItem(const Akonadi::Item &item,
const QSet<QByteArray> &parts) {
// TODO: this method is called when Akonadi wants more data for a given item.
// You can only provide the parts that have been requested but you are allowed
// to provide all in one go
return true;
}
void etesyncResource::aboutToQuit() {
// TODO: any cleanup you need to do while there is still an active
// event loop. The resource will terminate after this method returns
}
void etesyncResource::configure(WId windowId) {
// TODO: this method is usually called when a new resource is being
// added to the Akonadi setup. You can do any kind of user interaction here,
// e.g. showing dialogs.
// The given window ID is usually useful to get the correct
// "on top of parent" behavior if the running window manager applies any kind
// of focus stealing prevention technique
//
// If the configuration dialog has been accepted by the user by clicking Ok,
// the signal configurationDialogAccepted() has to be emitted, otherwise, if
// the user canceled the dialog, configurationDialogRejected() has to be
// emitted.
}
void etesyncResource::itemAdded(const Akonadi::Item &item,
const Akonadi::Collection &collection) {
// TODO: this method is called when somebody else, e.g. a client application,
// has created an item in a collection managed by your resource.
// NOTE: There is an equivalent method for collections, but it isn't part
// of this template code to keep it simple
}
void etesyncResource::itemChanged(const Akonadi::Item &item,
const QSet<QByteArray> &parts) {
// TODO: this method is called when somebody else, e.g. a client application,
// has changed an item managed by your resource.
// NOTE: There is an equivalent method for collections, but it isn't part
// of this template code to keep it simple
}
void etesyncResource::itemRemoved(const Akonadi::Item &item) {
// TODO: this method is called when somebody else, e.g. a client application,
// has deleted an item managed by your resource.
// NOTE: There is an equivalent method for collections, but it isn't part
// of this template code to keep it simple
}
AKONADI_RESOURCE_MAIN(etesyncResource)
[Desktop Entry]
Name=Etesync Groupware Resource
Comment=An Akonadi resource plugin for etesync
Type=AkonadiResource
Exec=akonadi_etesync_resource
Icon=text-directory
X-Akonadi-MimeTypes=text/directory
X-Akonadi-Capabilities=Resource
X-Akonadi-Identifier=akonadi_etesync_resource
/*
* Copyright (C) 2020 by Shashwat Jolly <shashwat.jolly@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef ETESYNCRESOURCE_H
#define ETESYNCRESOURCE_H
#include <AkonadiAgentBase/ResourceBase>
class etesyncResource : public Akonadi::ResourceBase,
public Akonadi::AgentBase::Observer {
Q_OBJECT
public:
explicit etesyncResource(const QString &id);
~etesyncResource() override;
public Q_SLOTS:
void configure(WId windowId) override;
protected Q_SLOTS:
void retrieveCollections() override;
void retrieveItems(const Akonadi::Collection &col) override;
bool retrieveItem(const Akonadi::Item &item,
const QSet<QByteArray> &parts) override;
protected:
void aboutToQuit() override;
void itemAdded(const Akonadi::Item &item,
const Akonadi::Collection &collection) override;
void itemChanged(const Akonadi::Item &item,
const QSet<QByteArray> &parts) override;
void itemRemoved(const Akonadi::Item &item) override;
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:kcfg="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile/>
<group name="General">
<entry name="ReadOnly" type="Bool">
<label>Do not change the actual backend data.</label>
<default>false</default>
</entry>
</group>
</kcfg>
File=settings.kcfg
ClassName=Settings
Mutators=true
ItemAccessors=true
SetUserTexts=true
Singleton=true
#IncludeFiles=
GlobalEnums=true
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