1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
/*
* This file is part of buteo-syncfw package
*
* Copyright (C) 2019-2021 Damien Caliste.
*
* Contact: Damien Caliste <dcaliste@free.fr>
*
* This 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 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 library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef SYNCPROFILEWATCHER_H
#define SYNCPROFILEWATCHER_H
#include <QObject>
#include <QVariant>
#include "profile/ProfileManager.h"
#include "clientfw/SyncClientInterface.h"
#include "common/SyncCommonDefs.h"
using namespace Buteo;
class Q_DECL_EXPORT SyncProfileWatcher: public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QString displayName READ displayName NOTIFY displayNameChanged)
Q_PROPERTY(bool enabled READ enabled NOTIFY enabledChanged)
Q_PROPERTY(QVariantList log READ log NOTIFY logChanged)
Q_PROPERTY(SyncSchedule schedule READ schedule NOTIFY scheduleChanged)
Q_PROPERTY(QVariantMap keys READ keys NOTIFY keysChanged)
Q_PROPERTY(Status syncStatus READ syncStatus NOTIFY syncStatusChanged)
Q_PROPERTY(bool synchronizing READ synchronizing NOTIFY syncStatusChanged)
public:
enum Status {
Queued = Sync::SYNC_QUEUED,
Started,
Progress,
Error,
Done,
Aborted,
Cancelled,
Stopping,
NotPossible,
AuthenticationFailure,
DatabaseFailure,
ConnectionError,
ServerFailure,
BadRequest,
PluginError,
PluginTimeout
};
Q_ENUM(Status)
SyncProfileWatcher(QObject *parent = nullptr);
~SyncProfileWatcher();
QString name() const;
void setName(const QString &aName);
QString displayName() const;
bool enabled() const;
QVariantList log();
SyncSchedule schedule() const;
QVariantMap keys() const;
Status syncStatus() const;
bool synchronizing() const;
Q_INVOKABLE void startSync();
Q_INVOKABLE void abortSync() const;
signals:
void nameChanged();
void displayNameChanged();
void enabledChanged();
void logChanged();
void scheduleChanged();
void keysChanged();
void syncStatusChanged();
private slots:
void onProfileChanged(QString aProfileName, int aChangeType,
QString aProfileAsXml);
void onSyncStatus(QString aProfileId, int aStatus,
QString aMessage, int aStatusDetails);
private:
void setKeys();
protected:
ProfileManager mManager;
QSharedPointer<SyncClientInterface> mSyncClient;
SyncProfile *mSyncProfile;
QVariantMap mKeys;
Status mSyncStatus;
};
#endif
|