Skip to content

Commit

Permalink
[buteo-sync-plugins-social] Add OneDrive token refresh sync adaptor. …
Browse files Browse the repository at this point in the history
…Contributes to MER#1297

This commit adds a sync plugin to automatically refresh OneDrive
OAuth2 tokens.

Contributes to MER#1297
  • Loading branch information
Chris Adams committed Sep 11, 2015
1 parent a9bcd47 commit a434e67
Show file tree
Hide file tree
Showing 14 changed files with 949 additions and 1 deletion.
30 changes: 30 additions & 0 deletions rpm/sociald.spec
Expand Up @@ -315,6 +315,36 @@ rm -f /home/nemo/.cache/msyncd/sync/twitter.Posts.xml
systemctl-user try-restart msyncd.service || :




%package onedrive-signon
Summary: Provides signon credentials refreshing with OneDrive
License: LGPLv2.1
Group: System/Libraries
BuildRequires: qt5-qttools-linguist
Requires: %{name} = %{version}-%{release}

%description onedrive-signon
Provides signon credentials refreshing with OneDrive

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

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

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




%package ts-devel
Summary: Translation source for sociald
License: LGPLv2.1
Expand Down
3 changes: 3 additions & 0 deletions src/onedrive/onedrive-common.pri
@@ -0,0 +1,3 @@
INCLUDEPATH += $$PWD
SOURCES += $$PWD/onedrivedatatypesyncadaptor.cpp
HEADERS += $$PWD/onedrivedatatypesyncadaptor.h
4 changes: 4 additions & 0 deletions src/onedrive/onedrive-signon/onedrive-signon.pri
@@ -0,0 +1,4 @@
SOURCES += $$PWD/onedrivesignonsyncadaptor.cpp
HEADERS += $$PWD/onedrivesignonsyncadaptor.h
INCLUDEPATH += $$PWD

25 changes: 25 additions & 0 deletions src/onedrive/onedrive-signon/onedrive-signon.pro
@@ -0,0 +1,25 @@
TARGET = onedrive-signon-client
VERSION = 0.0.1

DEFINES += "CLASSNAME=OneDriveSignonPlugin"
DEFINES += CLASSNAME_H=\\\"onedrivesignonplugin.h\\\"
include($$PWD/../../common.pri)
include($$PWD/../onedrive-common.pri)
include($$PWD/onedrive-signon.pri)

onedrive_signon_sync_profile.path = /etc/buteo/profiles/sync
onedrive_signon_sync_profile.files = $$PWD/onedrive.Signon.xml
onedrive_signon_client_plugin_xml.path = /etc/buteo/profiles/client
onedrive_signon_client_plugin_xml.files = $$PWD/onedrive-signon.xml

HEADERS += onedrivesignonplugin.h
SOURCES += onedrivesignonplugin.cpp

OTHER_FILES += \
onedrive_signon_sync_profile.files \
onedrive_signon_client_plugin_xml.files

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

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

<profile name="onedrive-signon" type="client" >
<key name="Sync Direction" value="from-remote" />
</profile>
</profile>
54 changes: 54 additions & 0 deletions src/onedrive/onedrive-signon/onedrivesignonplugin.cpp
@@ -0,0 +1,54 @@
/****************************************************************************
**
** Copyright (C) 2015 Jolla Ltd.
** Contact: Chris Adams <chris.adams@jolla.com>
**
** This program/library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public License
** version 2.1 as published by the Free Software Foundation.
**
** This program/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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this program/library; if not, write to the Free
** Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
** 02110-1301 USA
**
****************************************************************************/

#include "onedrivesignonplugin.h"
#include "onedrivesignonsyncadaptor.h"
#include "socialnetworksyncadaptor.h"

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

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

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

OneDriveSignonPlugin::~OneDriveSignonPlugin()
{
}

SocialNetworkSyncAdaptor *OneDriveSignonPlugin::createSocialNetworkSyncAdaptor()
{
return new OneDriveSignonSyncAdaptor(this);
}
47 changes: 47 additions & 0 deletions src/onedrive/onedrive-signon/onedrivesignonplugin.h
@@ -0,0 +1,47 @@
/****************************************************************************
**
** Copyright (C) 2015 Jolla Ltd.
** Contact: Chris Adams <chris.adams@jolla.com>
**
** This program/library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public License
** version 2.1 as published by the Free Software Foundation.
**
** This program/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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this program/library; if not, write to the Free
** Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
** 02110-1301 USA
**
****************************************************************************/

#ifndef ONEDRIVESIGNONPLUGIN_H
#define ONEDRIVESIGNONPLUGIN_H

#include "socialdbuteoplugin.h"

class SOCIALDBUTEOPLUGIN_EXPORT OneDriveSignonPlugin : public SocialdButeoPlugin
{
Q_OBJECT

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

protected:
SocialNetworkSyncAdaptor *createSocialNetworkSyncAdaptor();
};

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

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

#endif // ONEDRIVESIGNONPLUGIN_H

0 comments on commit a434e67

Please sign in to comment.