Skip to content

Commit

Permalink
[sociald] Add Facebook Signon sync adapter. Contributes to JB#15021
Browse files Browse the repository at this point in the history
This commit adds a sync adapter which periodically forces a refresh
of the Facebook account credentials, to avoid the situation where
user interaction (via webview) is required to be able to continue
to use the account.

Contributes to JB#15021
  • Loading branch information
Chris Adams committed Apr 16, 2014
1 parent 42a6061 commit 4edb44a
Show file tree
Hide file tree
Showing 13 changed files with 506 additions and 4 deletions.
24 changes: 24 additions & 0 deletions rpm/sociald.spec
Expand Up @@ -190,6 +190,30 @@ rm -f /home/nemo/.cache/msyncd/sync/facebook.Posts.xml
systemctl-user restart msyncd.service || :


%package facebook-signon
Summary: Provides signon credentials refreshing with Facebook
License: TBD
Group: System/Libraries
BuildRequires: qt5-qttools-linguist
Requires: %{name} = %{version}-%{release}

%description facebook-signon
Provides signon credentials refreshing with Facebook

%files facebook-signon
/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

%pre facebook-signon
rm -f /home/nemo/.cache/msyncd/sync/client/facebook-signon.xml
rm -f /home/nemo/.cache/msyncd/sync/facebook.Signon.xml

%post facebook-signon
systemctl-user restart msyncd.service || :



%package google-calendars
Summary: Provides calendar synchronisation with Google
License: TBD
Expand Down
4 changes: 3 additions & 1 deletion src/common/socialnetworksyncadaptor.cpp
Expand Up @@ -60,7 +60,8 @@ namespace {
<< QStringLiteral("Videos")
<< QStringLiteral("Posts")
<< QStringLiteral("Messages")
<< QStringLiteral("Emails");
<< QStringLiteral("Emails")
<< QStringLiteral("Signon");
}
}

Expand Down Expand Up @@ -448,6 +449,7 @@ QString SocialNetworkSyncAdaptor::dataTypeName(SocialNetworkSyncAdaptor::DataTyp
case SocialNetworkSyncAdaptor::Posts: return QStringLiteral("Posts");
case SocialNetworkSyncAdaptor::Messages: return QStringLiteral("Messages");
case SocialNetworkSyncAdaptor::Emails: return QStringLiteral("Emails");
case SocialNetworkSyncAdaptor::Signon: return QStringLiteral("Signon");
default: break;
}

Expand Down
3 changes: 2 additions & 1 deletion src/common/socialnetworksyncadaptor.h
Expand Up @@ -49,7 +49,8 @@ class SocialNetworkSyncAdaptor : public QObject
Videos, // "Videos"
Posts, // "Posts"
Messages, // "Messages"
Emails // "Emails"
Emails, // "Emails"
Signon // "Signon" -- for refreshing AccessTokens etc.
};
static QStringList validDataTypes();
static QString dataTypeName(DataType t);
Expand Down
4 changes: 4 additions & 0 deletions src/facebook/facebook-signon/facebook-signon.pri
@@ -0,0 +1,4 @@
SOURCES += $$PWD/facebooksignonsyncadaptor.cpp
HEADERS += $$PWD/facebooksignonsyncadaptor.h
INCLUDEPATH += $$PWD

27 changes: 27 additions & 0 deletions src/facebook/facebook-signon/facebook-signon.pro
@@ -0,0 +1,27 @@
TEMPLATE = lib

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

include($$PWD/../../common.pri)
include($$PWD/../facebook-common.pri)
include($$PWD/facebook-signon.pri)

target.path += /usr/lib/buteo-plugins-qt5
facebook_signon_sync_profile.path = /etc/buteo/profiles/sync
facebook_signon_sync_profile.files = $$PWD/facebook.Signon.xml
facebook_signon_client_plugin_xml.path = /etc/buteo/profiles/client
facebook_signon_client_plugin_xml.files = $$PWD/facebook-signon.xml

HEADERS += facebooksignonplugin.h
SOURCES += facebooksignonplugin.cpp

OTHER_FILES += \
facebook_signon_sync_profile.files \
facebook_signon_client_plugin_xml.files

INSTALLS += \
target \
facebook_signon_sync_profile \
facebook_signon_client_plugin_xml
4 changes: 4 additions & 0 deletions src/facebook/facebook-signon/facebook-signon.xml
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<profile name="facebook-signon" type="client" >
<field name="Sync Direction" />
</profile>
15 changes: 15 additions & 0 deletions src/facebook/facebook-signon/facebook.Signon.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<profile name="facebook.Signon" type="sync" >
<key name="category" value="signon" />
<key name="enabled" value="true" />
<key name="use_accounts" value="false" />
<key name="destinationtype" value="online" />
<key name="hidden" value="true" />
<key name="displayname" value="Facebook Signon"/>

<schedule enabled="false" interval="90" days="1,2,3,4,5,6,7" syncconfiguredtime="" time="" />

<profile name="facebook-signon" type="client" >
<key name="Sync Direction" value="from-remote" />
</profile>
</profile>
40 changes: 40 additions & 0 deletions src/facebook/facebook-signon/facebooksignonplugin.cpp
@@ -0,0 +1,40 @@
/****************************************************************************
**
** Copyright (C) 2014 Jolla Ltd.
** Contact: Chris Adams <chris.adams@jolla.com>
**
****************************************************************************/

#include "facebooksignonplugin.h"
#include "facebooksignonsyncadaptor.h"
#include "socialnetworksyncadaptor.h"

extern "C" FacebookSignonPlugin* createPlugin(const QString& pluginName,
const Buteo::SyncProfile& profile,
Buteo::PluginCbInterface *callbackInterface)
{
return new FacebookSignonPlugin(pluginName, profile, callbackInterface);
}

extern "C" void destroyPlugin(FacebookSignonPlugin* plugin)
{
delete plugin;
}

FacebookSignonPlugin::FacebookSignonPlugin(const QString& pluginName,
const Buteo::SyncProfile& profile,
Buteo::PluginCbInterface *callbackInterface)
: SocialdButeoPlugin(pluginName, profile, callbackInterface,
QStringLiteral("facebook"),
SocialNetworkSyncAdaptor::dataTypeName(SocialNetworkSyncAdaptor::Signon))
{
}

FacebookSignonPlugin::~FacebookSignonPlugin()
{
}

SocialNetworkSyncAdaptor *FacebookSignonPlugin::createSocialNetworkSyncAdaptor()
{
return new FacebookSignonSyncAdaptor(this);
}
34 changes: 34 additions & 0 deletions src/facebook/facebook-signon/facebooksignonplugin.h
@@ -0,0 +1,34 @@
/****************************************************************************
**
** Copyright (C) 2014 Jolla Ltd.
** Contact: Chris Adams <chris.adams@jolla.com>
**
****************************************************************************/

#ifndef FACEBOOKSIGNONPLUGIN_H
#define FACEBOOKSIGNONPLUGIN_H

#include "socialdbuteoplugin.h"
#include <ClientPlugin.h>

class FacebookSignonPlugin : public SocialdButeoPlugin
{
Q_OBJECT

public:
FacebookSignonPlugin(const QString& pluginName,
const Buteo::SyncProfile& profile,
Buteo::PluginCbInterface *cbInterface);
~FacebookSignonPlugin();

protected:
SocialNetworkSyncAdaptor *createSocialNetworkSyncAdaptor();
};

extern "C" FacebookSignonPlugin* createPlugin(const QString& pluginName,
const Buteo::SyncProfile& profile,
Buteo::PluginCbInterface *cbInterface);

extern "C" void destroyPlugin(FacebookSignonPlugin* client);

#endif // FACEBOOKSIGNONPLUGIN_H

0 comments on commit 4edb44a

Please sign in to comment.