Skip to content

Commit

Permalink
[sociald] Port sociald plugins to OOPP architecture. Contributes to J…
Browse files Browse the repository at this point in the history
…B#19903

This commit adds support for building the plugins in either in-process
or out-of-process mode.  Out-of-process plugins are actually standalone
executables which are started and stopped by msyncd to perform syncs,
with communication to msyncd via DBus.

Contributes to JB#19903
  • Loading branch information
Chris Adams committed Jun 11, 2014
1 parent 17a1d65 commit a1c7b85
Show file tree
Hide file tree
Showing 40 changed files with 144 additions and 90 deletions.
64 changes: 50 additions & 14 deletions rpm/sociald.spec
Expand Up @@ -12,10 +12,10 @@ BuildRequires: pkgconfig(Qt5DBus)
BuildRequires: pkgconfig(Qt5Sql)
BuildRequires: pkgconfig(Qt5Network)
BuildRequires: pkgconfig(mlite5)
BuildRequires: pkgconfig(buteosyncfw5) >= 0.6.33
BuildRequires: pkgconfig(buteosyncfw5) >= 0.6.36
BuildRequires: pkgconfig(libsignon-qt5)
BuildRequires: pkgconfig(accounts-qt5)
BuildRequires: pkgconfig(socialcache) >= 0.0.23
BuildRequires: pkgconfig(socialcache) >= 0.0.24
BuildRequires: pkgconfig(libsailfishkeyprovider)
BuildRequires: qt5-qttools-linguist
Requires: buteo-syncfw-qt5-msyncd
Expand All @@ -29,7 +29,10 @@ A Buteo plugin which provides data synchronization with various social services.

%files
%defattr(-,root,root,-)
/usr/lib/buteo-plugins-qt5/libsociald-client.so
#out-of-process-plugin form:
/usr/lib/buteo-plugins-qt5/oopp/sociald-client
#in-process-plugin form:
#/usr/lib/buteo-plugins-qt5/libsociald-client.so
%config %{_sysconfdir}/buteo/profiles/client/sociald.xml
%config %{_sysconfdir}/buteo/profiles/sync/sociald.All.xml

Expand Down Expand Up @@ -64,7 +67,10 @@ Requires: %{name} = %{version}-%{release}
Provides calendar synchronisation with Facebook

%files facebook-calendars
/usr/lib/buteo-plugins-qt5/libfacebook-calendars-client.so
#out-of-process-plugin form:
/usr/lib/buteo-plugins-qt5/oopp/facebook-calendars-client
#in-process-plugin form:
#/usr/lib/buteo-plugins-qt5/libfacebook-calendars-client.so
%config %{_sysconfdir}/buteo/profiles/client/facebook-calendars.xml
%config %{_sysconfdir}/buteo/profiles/sync/facebook.Calendars.xml

Expand All @@ -88,7 +94,10 @@ Requires: %{name} = %{version}-%{release}
Provides contact synchronisation with Facebook

%files facebook-contacts
/usr/lib/buteo-plugins-qt5/libfacebook-contacts-client.so
#out-of-process-plugin form:
/usr/lib/buteo-plugins-qt5/oopp/facebook-contacts-client
#in-process-plugin form:
#/usr/lib/buteo-plugins-qt5/libfacebook-contacts-client.so
%config %{_sysconfdir}/buteo/profiles/client/facebook-contacts.xml
%config %{_sysconfdir}/buteo/profiles/sync/facebook.Contacts.xml

Expand All @@ -110,7 +119,10 @@ Requires: %{name} = %{version}-%{release}
Provides image synchronisation with Facebook

%files facebook-images
/usr/lib/buteo-plugins-qt5/libfacebook-images-client.so
#out-of-process-plugin form:
/usr/lib/buteo-plugins-qt5/oopp/facebook-images-client
#in-process-plugin form:
#/usr/lib/buteo-plugins-qt5/libfacebook-images-client.so
%config %{_sysconfdir}/buteo/profiles/client/facebook-images.xml
%config %{_sysconfdir}/buteo/profiles/sync/facebook.Images.xml

Expand All @@ -135,7 +147,10 @@ Requires: %{name} = %{version}-%{release}
Provides notification synchronisation with Facebook

%files facebook-notifications
/usr/lib/buteo-plugins-qt5/libfacebook-notifications-client.so
#out-of-process-plugin form:
/usr/lib/buteo-plugins-qt5/oopp/facebook-notifications-client
#in-process-plugin form:
#/usr/lib/buteo-plugins-qt5/libfacebook-notifications-client.so
%config %{_sysconfdir}/buteo/profiles/client/facebook-notifications.xml
%config %{_sysconfdir}/buteo/profiles/sync/facebook.Notifications.xml
%{_datadir}/lipstick/notificationcategories/x-nemo.social.facebook.notification.conf
Expand Down Expand Up @@ -178,6 +193,9 @@ Provides post synchronisation with Facebook
%files facebook-posts
%{_datadir}/lipstick/notificationcategories/x-nemo.social.facebook.statuspost.conf
%{_datadir}/translations/lipstick-jolla-home-facebook_eng_en.qm
####out-of-process-plugin form:
###/usr/lib/buteo-plugins-qt5/oopp/facebook-posts-client
####in-process-plugin form:
###/usr/lib/buteo-plugins-qt5/libfacebook-posts-client.so
###%config %{_sysconfdir}/buteo/profiles/client/facebook-posts.xml
###%config %{_sysconfdir}/buteo/profiles/sync/facebook.Posts.xml
Expand All @@ -201,7 +219,10 @@ Requires: %{name} = %{version}-%{release}
Provides signon credentials refreshing with Facebook

%files facebook-signon
/usr/lib/buteo-plugins-qt5/libfacebook-signon-client.so
#out-of-process-plugin form:
/usr/lib/buteo-plugins-qt5/oopp/facebook-signon-client
#in-process-plugin form:
#/usr/lib/buteo-plugins-qt5/libfacebook-signon-client.so
%config %{_sysconfdir}/buteo/profiles/client/facebook-signon.xml
%config %{_sysconfdir}/buteo/profiles/sync/facebook.Signon.xml

Expand All @@ -226,7 +247,10 @@ Requires: %{name} = %{version}-%{release}
Provides calendar synchronisation with Google

%files google-calendars
/usr/lib/buteo-plugins-qt5/libgoogle-calendars-client.so
#out-of-process-plugin form:
/usr/lib/buteo-plugins-qt5/oopp/google-calendars-client
#in-process-plugin form:
#/usr/lib/buteo-plugins-qt5/libgoogle-calendars-client.so
%config %{_sysconfdir}/buteo/profiles/client/google-calendars.xml
%config %{_sysconfdir}/buteo/profiles/sync/google.Calendars.xml

Expand All @@ -250,7 +274,10 @@ Requires: %{name} = %{version}-%{release}
Provides contact synchronisation with Google

%files google-contacts
/usr/lib/buteo-plugins-qt5/libgoogle-contacts-client.so
#out-of-process-plugin form:
/usr/lib/buteo-plugins-qt5/oopp/google-contacts-client
#in-process-plugin form:
#/usr/lib/buteo-plugins-qt5/libgoogle-contacts-client.so
%config %{_sysconfdir}/buteo/profiles/client/google-contacts.xml
%config %{_sysconfdir}/buteo/profiles/sync/google.Contacts.xml

Expand All @@ -273,7 +300,10 @@ Requires: %{name} = %{version}-%{release}
Provides signon credentials refreshing with Google

%files google-signon
/usr/lib/buteo-plugins-qt5/libgoogle-signon-client.so
#out-of-process-plugin form:
/usr/lib/buteo-plugins-qt5/oopp/google-signon-client
#in-process-plugin form:
#/usr/lib/buteo-plugins-qt5/libgoogle-signon-client.so
%config %{_sysconfdir}/buteo/profiles/client/google-signon.xml
%config %{_sysconfdir}/buteo/profiles/sync/google.Signon.xml

Expand Down Expand Up @@ -301,7 +331,10 @@ Requires: %{name} = %{version}-%{release}
Provides notification synchronisation with Twitter

%files twitter-notifications
/usr/lib/buteo-plugins-qt5/libtwitter-notifications-client.so
#out-of-process-plugin form:
/usr/lib/buteo-plugins-qt5/oopp/twitter-notifications-client
#in-process-plugin form:
#/usr/lib/buteo-plugins-qt5/libtwitter-notifications-client.so
%config %{_sysconfdir}/buteo/profiles/client/twitter-notifications.xml
%config %{_sysconfdir}/buteo/profiles/sync/twitter.Notifications.xml
%{_datadir}/lipstick/notificationcategories/x-nemo.social.twitter.mention.conf
Expand Down Expand Up @@ -329,7 +362,10 @@ Requires: %{name} = %{version}-%{release}
Provides post synchronisation with Twitter

%files twitter-posts
/usr/lib/buteo-plugins-qt5/libtwitter-posts-client.so
#out-of-process-plugin form:
/usr/lib/buteo-plugins-qt5/oopp/twitter-posts-client
#in-process-plugin form:
#/usr/lib/buteo-plugins-qt5/libtwitter-posts-client.so
%config %{_sysconfdir}/buteo/profiles/client/twitter-posts.xml
%config %{_sysconfdir}/buteo/profiles/sync/twitter.Posts.xml
%{_datadir}/lipstick/notificationcategories/x-nemo.social.twitter.tweet.conf
Expand Down Expand Up @@ -383,7 +419,7 @@ Automatable tests for sociald
%setup -q -n %{name}-%{version}

%build
%qmake5
%qmake5 "DEFINES+=OUT_OF_PROCESS_PLUGIN"
make %{?jobs:-j%jobs}

%pre
Expand Down
28 changes: 28 additions & 0 deletions src/common.pri
Expand Up @@ -40,6 +40,34 @@ contains(DEFINES, 'SOCIALD_USE_QTPIM') {
HEADERS += $$PWD/common/constants_p.h
}

# don't pull in buteo plugin framework for unit test builds
!contains (DEFINES, 'SOCIALD_TEST_DEFINE') {
!contains (DEFINES, OUT_OF_PROCESS_PLUGIN) {
TEMPLATE = lib
CONFIG += plugin
target.path = /usr/lib/buteo-plugins-qt5
message("building" $$TARGET "as in-process plugin")
}
contains (DEFINES, OUT_OF_PROCESS_PLUGIN) {
TEMPLATE = app
target.path = /usr/lib/buteo-plugins-qt5/oopp
message("building" $$TARGET "as out-of-process plugin")

DEFINES += CLIENT_PLUGIN
BUTEO_OOPP_INCLUDE_DIR = $$system(pkg-config --cflags buteosyncfw5|cut -f2 -d'I')
INCLUDEPATH += $$BUTEO_OOPP_INCLUDE_DIR

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

SOURCES += $$BUTEO_OOPP_INCLUDE_DIR/ButeoPluginIfaceAdaptor.cpp \
$$BUTEO_OOPP_INCLUDE_DIR/PluginCbImpl.cpp \
$$BUTEO_OOPP_INCLUDE_DIR/PluginServiceObj.cpp \
$$BUTEO_OOPP_INCLUDE_DIR/plugin_main.cpp
}
}

#NOTE: This causes issues with the unit tests ?
#MOC_DIR = $$PWD/../.moc
#OBJECTS_DIR = $$PWD/../.obj
5 changes: 4 additions & 1 deletion src/common/socialdbuteoplugin.cpp
Expand Up @@ -186,7 +186,10 @@ void SocialdButeoPlugin::abortSync(Sync::SyncStatus)
bool SocialdButeoPlugin::cleanUp()
{
m_profileAccountId = profile().key(Buteo::KEY_ACCOUNT_ID).toInt();
m_socialNetworkSyncAdaptor = createSocialNetworkSyncAdaptor();
if (!m_socialNetworkSyncAdaptor) {
// might have already been initialized by the OOP framework via init().
m_socialNetworkSyncAdaptor = createSocialNetworkSyncAdaptor();
}

// TODO: ensure that this is ONLY called when the account is deleted,
// not when the plugin is unloaded.
Expand Down
9 changes: 8 additions & 1 deletion src/common/socialdbuteoplugin.h
Expand Up @@ -8,15 +8,22 @@
#ifndef SOCIALDBUTEOPLUGIN_H
#define SOCIALDBUTEOPLUGIN_H

#include <QtCore/qglobal.h>
#include "buteosyncfw_p.h"

#if defined(OUT_OF_PROCESS_PLUGIN)
# define SOCIALDBUTEOPLUGIN_EXPORT Q_DECL_EXPORT
#else
# define SOCIALDBUTEOPLUGIN_EXPORT Q_DECL_IMPORT
#endif

/*
Datatype-specific implementations of this class
allow per-account sync profiles for that data type.
*/

class SocialNetworkSyncAdaptor;
class SocialdButeoPlugin : public Buteo::ClientPlugin
class SOCIALDBUTEOPLUGIN_EXPORT SocialdButeoPlugin : public Buteo::ClientPlugin
{
Q_OBJECT

Expand Down
6 changes: 2 additions & 4 deletions src/facebook/facebook-calendars/facebook-calendars.pro
@@ -1,14 +1,12 @@
TEMPLATE = lib

TARGET = facebook-calendars-client
VERSION = 0.0.1
CONFIG += plugin

DEFINES += "CLASSNAME=FacebookCalendarsPlugin"
DEFINES += CLASSNAME_H=\\\"facebookcalendarsplugin.h\\\"
include($$PWD/../../common.pri)
include($$PWD/../facebook-common.pri)
include($$PWD/facebook-calendars.pri)

target.path += /usr/lib/buteo-plugins-qt5
facebook_calendars_sync_profile.path = /etc/buteo/profiles/sync
facebook_calendars_sync_profile.files = $$PWD/facebook.Calendars.xml
facebook_calendars_client_plugin_xml.path = /etc/buteo/profiles/client
Expand Down
2 changes: 1 addition & 1 deletion src/facebook/facebook-calendars/facebook.Calendars.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<profile name="facebook.Calendars" type="sync" >
<key name="category" value="facebook.Calendars" />
<key name="enabled" value="true" />
<key name="enabled" value="false" />
<key name="use_accounts" value="false" />
<key name="destinationtype" value="online" />
<key name="hidden" value="true" />
Expand Down
2 changes: 1 addition & 1 deletion src/facebook/facebook-calendars/facebookcalendarsplugin.h
Expand Up @@ -10,7 +10,7 @@

#include "socialdbuteoplugin.h"

class FacebookCalendarsPlugin : public SocialdButeoPlugin
class SOCIALDBUTEOPLUGIN_EXPORT FacebookCalendarsPlugin : public SocialdButeoPlugin
{
Q_OBJECT

Expand Down
6 changes: 2 additions & 4 deletions src/facebook/facebook-contacts/facebook-contacts.pro
@@ -1,15 +1,13 @@
TEMPLATE = lib

TARGET = facebook-contacts-client
VERSION = 0.0.1
CONFIG += plugin

DEFINES += "CLASSNAME=FacebookContactsPlugin"
DEFINES += CLASSNAME_H=\\\"facebookcontactsplugin.h\\\"
DEFINES += SOCIALD_USE_QTPIM
include($$PWD/../../common.pri)
include($$PWD/../facebook-common.pri)
include($$PWD/facebook-contacts.pri)

target.path += /usr/lib/buteo-plugins-qt5
facebook_contacts_sync_profile.path = /etc/buteo/profiles/sync
facebook_contacts_sync_profile.files = $$PWD/facebook.Contacts.xml
facebook_contacts_client_plugin_xml.path = /etc/buteo/profiles/client
Expand Down
2 changes: 1 addition & 1 deletion src/facebook/facebook-contacts/facebook.Contacts.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<profile name="facebook.Contacts" type="sync" >
<key name="category" value="facebook.Contacts" />
<key name="enabled" value="true" />
<key name="enabled" value="false" />
<key name="use_accounts" value="false" />
<key name="destinationtype" value="online" />
<key name="hidden" value="true" />
Expand Down
2 changes: 1 addition & 1 deletion src/facebook/facebook-contacts/facebookcontactsplugin.h
Expand Up @@ -10,7 +10,7 @@

#include "socialdbuteoplugin.h"

class FacebookContactsPlugin : public SocialdButeoPlugin
class SOCIALDBUTEOPLUGIN_EXPORT FacebookContactsPlugin : public SocialdButeoPlugin
{
Q_OBJECT

Expand Down
6 changes: 2 additions & 4 deletions src/facebook/facebook-images/facebook-images.pro
@@ -1,14 +1,12 @@
TEMPLATE = lib

TARGET = facebook-images-client
VERSION = 0.0.1
CONFIG += plugin

DEFINES += "CLASSNAME=FacebookImagesPlugin"
DEFINES += CLASSNAME_H=\\\"facebookimagesplugin.h\\\"
include($$PWD/../../common.pri)
include($$PWD/../facebook-common.pri)
include($$PWD/facebook-images.pri)

target.path += /usr/lib/buteo-plugins-qt5
facebook_images_sync_profile.path = /etc/buteo/profiles/sync
facebook_images_sync_profile.files = $$PWD/facebook.Images.xml
facebook_images_client_plugin_xml.path = /etc/buteo/profiles/client
Expand Down
2 changes: 1 addition & 1 deletion src/facebook/facebook-images/facebook.Images.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<profile name="facebook.Images" type="sync" >
<key name="category" value="facebook.Images" />
<key name="enabled" value="true" />
<key name="enabled" value="false" />
<key name="use_accounts" value="false" />
<key name="destinationtype" value="online" />
<key name="hidden" value="true" />
Expand Down
2 changes: 1 addition & 1 deletion src/facebook/facebook-images/facebookimagesplugin.h
Expand Up @@ -10,7 +10,7 @@

#include "socialdbuteoplugin.h"

class FacebookImagesPlugin : public SocialdButeoPlugin
class SOCIALDBUTEOPLUGIN_EXPORT FacebookImagesPlugin : public SocialdButeoPlugin
{
Q_OBJECT

Expand Down
@@ -1,14 +1,12 @@
TEMPLATE = lib

TARGET = facebook-notifications-client
VERSION = 0.0.1
CONFIG += plugin

DEFINES += "CLASSNAME=FacebookNotificationsPlugin"
DEFINES += CLASSNAME_H=\\\"facebooknotificationsplugin.h\\\"
include($$PWD/../../common.pri)
include($$PWD/../facebook-common.pri)
include($$PWD/facebook-notifications.pri)

target.path += /usr/lib/buteo-plugins-qt5
facebook_notifications_sync_profile.path = /etc/buteo/profiles/sync
facebook_notifications_sync_profile.files = $$PWD/facebook.Notifications.xml
facebook_notifications_client_plugin_xml.path = /etc/buteo/profiles/client
Expand Down
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<profile name="facebook.Notifications" type="sync" >
<key name="category" value="eventfeed" />
<key name="enabled" value="true" />
<key name="enabled" value="false" />
<key name="use_accounts" value="false" />
<key name="destinationtype" value="online" />
<key name="hidden" value="true" />
Expand Down
Expand Up @@ -10,7 +10,7 @@

#include "socialdbuteoplugin.h"

class FacebookNotificationsPlugin : public SocialdButeoPlugin
class SOCIALDBUTEOPLUGIN_EXPORT FacebookNotificationsPlugin : public SocialdButeoPlugin
{
Q_OBJECT

Expand Down
6 changes: 2 additions & 4 deletions src/facebook/facebook-posts/facebook-posts.pro
@@ -1,15 +1,13 @@
TEMPLATE = lib

TARGET = facebook-posts-client
VERSION = 0.0.1
CONFIG += plugin

DEFINES += "CLASSNAME=FacebookPostsPlugin"
DEFINES += CLASSNAME_H=\\\"facebookpostsplugin.h\\\"
DEFINES += SOCIALD_USE_QTPIM
include($$PWD/../../common.pri)
include($$PWD/../facebook-common.pri)
include($$PWD/facebook-posts.pri)

target.path += /usr/lib/buteo-plugins-qt5
facebook_posts_sync_profile.path = /etc/buteo/profiles/sync
facebook_posts_sync_profile.files = $$PWD/facebook.Posts.xml
facebook_posts_client_plugin_xml.path = /etc/buteo/profiles/client
Expand Down

0 comments on commit a1c7b85

Please sign in to comment.