Skip to content

Commit

Permalink
Merge branch 'jb52916-buteo-plugin-api' into 'master'
Browse files Browse the repository at this point in the history
[buteo-sync-plugin-carddav] Adapt to changes in Buteo plugin API. JB#52916

See merge request mer-core/buteo-sync-plugin-carddav!31
  • Loading branch information
blam committed Apr 2, 2021
2 parents 6cf5698 + 87b09d7 commit 8db3781
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 54 deletions.
9 changes: 3 additions & 6 deletions rpm/buteo-sync-plugin-carddav.spec
Expand Up @@ -13,7 +13,7 @@ BuildRequires: pkgconfig(Qt5Network)
BuildRequires: pkgconfig(Qt5Contacts)
BuildRequires: pkgconfig(Qt5Versit)
BuildRequires: pkgconfig(mlite5)
BuildRequires: pkgconfig(buteosyncfw5)
BuildRequires: pkgconfig(buteosyncfw5) >= 0.10.0
BuildRequires: pkgconfig(accounts-qt5) >= 1.13
BuildRequires: pkgconfig(libsignon-qt5)
BuildRequires: pkgconfig(libsailfishkeyprovider)
Expand All @@ -34,10 +34,7 @@ This package contains unit tests for the CardDAV Buteo sync plugin.

%files
%defattr(-,root,root,-)
#out-of-process-plugin
%{_libdir}/buteo-plugins-qt5/oopp/carddav-client
#in-process-plugin
#%%{_libdir}/buteo-plugins-qt5/libcarddav-client.so
%{_libdir}/buteo-plugins-qt5/oopp/libcarddav-client.so
%config %{_sysconfdir}/buteo/profiles/client/carddav.xml
%config %{_sysconfdir}/buteo/profiles/sync/carddav.Contacts.xml
%license LICENSE
Expand Down Expand Up @@ -82,7 +79,7 @@ This package contains unit tests for the CardDAV Buteo sync plugin.
%autosetup -n %{name}-%{version}

%build
%qmake5 "DEFINES+=BUTEO_OUT_OF_PROCESS_SUPPORT" "CONFIG+=build-tools"
%qmake5 "CONFIG+=build-tools"
%make_build

%pre
Expand Down
15 changes: 6 additions & 9 deletions src/carddavclient.cpp
@@ -1,7 +1,7 @@
/*
* This file is part of buteo-sync-plugin-carddav package
*
* Copyright (C) 2014 Jolla Ltd. and/or its subsidiary(-ies).
* Copyright (C) 2014 - 2021 Jolla Ltd. and/or its subsidiary(-ies).
*
* Contributors: Chris Adams <chris.adams@jolla.com>
*
Expand All @@ -28,17 +28,14 @@
#include <ProfileEngineDefs.h>
#include <ProfileManager.h>

extern "C" CardDavClient* createPlugin(const QString& aPluginName,
const Buteo::SyncProfile& aProfile,
Buteo::PluginCbInterface *aCbInterface)
Buteo::ClientPlugin* CardDavClientLoader::createClientPlugin(
const QString& pluginName,
const Buteo::SyncProfile& profile,
Buteo::PluginCbInterface* cbInterface)
{
return new CardDavClient(aPluginName, aProfile, aCbInterface);
return new CardDavClient(pluginName, profile, cbInterface);
}

extern "C" void destroyPlugin(CardDavClient *aClient)
{
delete aClient;
}

CardDavClient::CardDavClient(const QString& aPluginName,
const Buteo::SyncProfile& aProfile,
Expand Down
35 changes: 19 additions & 16 deletions src/carddavclient.h
@@ -1,7 +1,7 @@
/*
* This file is part of buteo-sync-plugin-carddav package
*
* Copyright (C) 2014 Jolla Ltd. and/or its subsidiary(-ies).
* Copyright (C) 2014 - 2021 Jolla Ltd. and/or its subsidiary(-ies).
*
* Contributors: Chris Adams <chris.adams@jolla.com>
*
Expand All @@ -27,6 +27,7 @@
#include <SyncProfile.h>
#include <SyncResults.h>
#include <SyncCommonDefs.h>
#include <SyncPluginLoader.h>

#include <QString>
#include <QObject>
Expand Down Expand Up @@ -71,21 +72,23 @@ private Q_SLOTS:
int m_accountId;
};

/*! \brief Creates CardDav client plugin
*
* @param aPluginName Name of this client plugin
* @param aProfile Profile to use
* @param aCbInterface Pointer to the callback interface
* @return Client plugin on success, otherwise NULL
*/
extern "C" CardDavClient* createPlugin(const QString &aPluginName,
const Buteo::SyncProfile &aProfile,
Buteo::PluginCbInterface *aCbInterface);
class CardDavClientLoader : public Buteo::SyncPluginLoader
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.sailfishos.plugins.sync.CardDavClientLoader")
Q_INTERFACES(Buteo::SyncPluginLoader)

/*! \brief Destroys CardDav client plugin
*
* @param aClient CardDav client plugin instance to destroy
*/
extern "C" void destroyPlugin(CardDavClient *aClient);
public:
/*! \brief Creates CardDav client plugin
*
* @param aPluginName Name of this client plugin
* @param aProfile Profile to use
* @param aCbInterface Pointer to the callback interface
* @return Client plugin on success, otherwise NULL
*/
Buteo::ClientPlugin* createClientPlugin(const QString& pluginName,
const Buteo::SyncProfile& profile,
Buteo::PluginCbInterface* cbInterface) override;
};

#endif // CARDDAVCLIENT_H
26 changes: 3 additions & 23 deletions src/src.pro
Expand Up @@ -7,29 +7,9 @@ QMAKE_CXXFLAGS = -Wall \
-Wno-cast-align \
-O2 -finline-functions

!contains (DEFINES, BUTEO_OUT_OF_PROCESS_SUPPORT) {
TEMPLATE = lib
CONFIG += plugin
target.path = $$[QT_INSTALL_LIBS]/buteo-plugins-qt5
}

contains (DEFINES, BUTEO_OUT_OF_PROCESS_SUPPORT) {
TEMPLATE = app
target.path = $$[QT_INSTALL_LIBS]/buteo-plugins-qt5/oopp
DEFINES += CLIENT_PLUGIN
DEFINES += "CLASSNAME=CardDavClient"
DEFINES += CLASSNAME_H=\\\"carddavclient.h\\\"
INCLUDE_DIR = $$system(pkg-config --cflags buteosyncfw5|cut -f2 -d'I')

HEADERS += $$INCLUDE_DIR/ButeoPluginIfaceAdaptor.h \
$$INCLUDE_DIR/PluginCbImpl.h \
$$INCLUDE_DIR/PluginServiceObj.h

SOURCES += $$INCLUDE_DIR/ButeoPluginIfaceAdaptor.cpp \
$$INCLUDE_DIR/PluginCbImpl.cpp \
$$INCLUDE_DIR/PluginServiceObj.cpp \
$$INCLUDE_DIR/plugin_main.cpp
}
TEMPLATE = lib
CONFIG += plugin
target.path = $$[QT_INSTALL_LIBS]/buteo-plugins-qt5/oopp

sync.path = /etc/buteo/profiles/sync
sync.files = carddav.Contacts.xml
Expand Down

0 comments on commit 8db3781

Please sign in to comment.