Skip to content

Commit

Permalink
[buteo-sync-plugins-social] Implement OneDrive backup/restore sync pl…
Browse files Browse the repository at this point in the history
…ugin. Contributes to MER#1323

This commit implements a simple backup sync plugin for OneDrive.

Contributes to MER#1323
  • Loading branch information
Chris Adams committed Oct 9, 2015
1 parent c80097e commit 63beb7a
Show file tree
Hide file tree
Showing 11 changed files with 665 additions and 16 deletions.
25 changes: 25 additions & 0 deletions rpm/sociald.spec
Expand Up @@ -370,6 +370,31 @@ systemctl-user try-restart msyncd.service || :



%package onedrive-backup
Summary: Provides backup-blob synchronization for OneDrive
License: LGPLv2.1
Group: System/Libraries
BuildRequires: qt5-qttools-linguist
Requires: %{name} = %{version}-%{release}

%description onedrive-backup
Provides backup-blob synchronization for OneDrive

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

%pre onedrive-backup
rm -f /home/nemo/.cache/msyncd/sync/client/onedrive-backup.xml
rm -f /home/nemo/.cache/msyncd/sync/onedrive.Backup.xml

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


%package ts-devel
Summary: Translation source for sociald
Expand Down
7 changes: 7 additions & 0 deletions src/onedrive/onedrive-backup/onedrive-backup.pri
@@ -0,0 +1,7 @@
CONFIG += link_pkgconfig
PKGCONFIG += mlite5

SOURCES += $$PWD/onedrivebackupsyncadaptor.cpp
HEADERS += $$PWD/onedrivebackupsyncadaptor.h
INCLUDEPATH += $$PWD

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

DEFINES += "CLASSNAME=OneDriveBackupPlugin"
DEFINES += CLASSNAME_H=\\\"onedrivebackupplugin.h\\\"
include($$PWD/../../common.pri)
include($$PWD/../onedrive-common.pri)
include($$PWD/onedrive-backup.pri)

onedrive_backup_sync_profile.path = /etc/buteo/profiles/sync
onedrive_backup_sync_profile.files = $$PWD/onedrive.Backup.xml
onedrive_backup_client_plugin_xml.path = /etc/buteo/profiles/client
onedrive_backup_client_plugin_xml.files = $$PWD/onedrive-backup.xml

HEADERS += onedrivebackupplugin.h
SOURCES += onedrivebackupplugin.cpp

OTHER_FILES += \
onedrive_backup_sync_profile.files \
onedrive_backup_client_plugin_xml.files

INSTALLS += \
target \
onedrive_backup_sync_profile \
onedrive_backup_client_plugin_xml
4 changes: 4 additions & 0 deletions src/onedrive/onedrive-backup/onedrive-backup.xml
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<profile name="onedrive-backup" type="client" >
<field name="Sync Direction" />
</profile>
15 changes: 15 additions & 0 deletions src/onedrive/onedrive-backup/onedrive.Backup.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<profile name="onedrive.Backup" type="sync" >
<key name="category" value="onedrive.Backup" />
<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 Backup"/>

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

<profile name="onedrive-backup" type="client" >
<key name="Sync Direction" value="two-way" />
</profile>
</profile>
54 changes: 54 additions & 0 deletions src/onedrive/onedrive-backup/onedrivebackupplugin.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 "onedrivebackupplugin.h"
#include "onedrivebackupsyncadaptor.h"
#include "socialnetworksyncadaptor.h"

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

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

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

OneDriveBackupPlugin::~OneDriveBackupPlugin()
{
}

SocialNetworkSyncAdaptor *OneDriveBackupPlugin::createSocialNetworkSyncAdaptor()
{
return new OneDriveBackupSyncAdaptor(this);
}
47 changes: 47 additions & 0 deletions src/onedrive/onedrive-backup/onedrivebackupplugin.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 ONEDRIVEBACKUPPLUGIN_H
#define ONEDRIVEBACKUPPLUGIN_H

#include "socialdbuteoplugin.h"

class SOCIALDBUTEOPLUGIN_EXPORT OneDriveBackupPlugin : public SocialdButeoPlugin
{
Q_OBJECT

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

protected:
SocialNetworkSyncAdaptor *createSocialNetworkSyncAdaptor();
};

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

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

#endif // ONEDRIVEBACKUPPLUGIN_H

0 comments on commit 63beb7a

Please sign in to comment.