6#include "CloudSyncManager.h"
7#include "BookmarkSyncManager.h"
8#include "RouteSyncManager.h"
13class Q_DECL_HIDDEN CloudSyncManager::Private
28 CloudSyncManager::Status m_status_type;
30 RouteSyncManager *m_routeSyncManager =
nullptr;
31 BookmarkSyncManager *m_bookmarkSyncManager =
nullptr;
34CloudSyncManager::Private::~Private()
36 delete m_routeSyncManager;
37 delete m_bookmarkSyncManager;
40CloudSyncManager::Private::Private()
41 : m_workOffline(false)
42 , m_syncEnabled(false)
43 , m_owncloudProtocol(QStringLiteral(
"http"))
45 , m_owncloudUsername()
46 , m_owncloudPassword()
48 , m_status_type(CloudSyncManager::Unknown)
52CloudSyncManager::CloudSyncManager(
QObject *parent)
58CloudSyncManager::~CloudSyncManager()
63bool CloudSyncManager::workOffline()
const
65 return d->m_workOffline;
68void CloudSyncManager::setWorkOffline(
bool offline)
70 if (offline != d->m_workOffline) {
71 d->m_workOffline = offline;
72 Q_EMIT workOfflineChanged(d->m_workOffline);
76bool CloudSyncManager::isSyncEnabled()
const
78 return d->m_syncEnabled;
81QString CloudSyncManager::owncloudServer()
const
83 return d->m_owncloudProtocol + d->m_ownloudServer;
86QString CloudSyncManager::owncloudUsername()
const
88 return d->m_owncloudUsername;
91QString CloudSyncManager::owncloudPassword()
const
93 return d->m_owncloudPassword;
96void CloudSyncManager::setSyncEnabled(
bool enabled)
98 if (d->m_syncEnabled != enabled) {
99 d->m_syncEnabled = enabled;
100 Q_EMIT syncEnabledChanged(d->m_syncEnabled);
104void CloudSyncManager::setOwncloudCredentials(
const QString &server,
const QString &user,
const QString &password)
106 QUrl const oldApiUrl = apiUrl();
108 setOwncloudServer(server);
109 setOwncloudUsername(user);
110 setOwncloudPassword(password);
112 if (oldApiUrl != apiUrl()) {
113 Q_EMIT apiUrlChanged(apiUrl());
117void CloudSyncManager::setOwncloudServer(
const QString &server)
119 QString const oldProtocol = d->m_owncloudProtocol;
120 QString const oldServer = d->m_ownloudServer;
123 d->m_owncloudProtocol = QStringLiteral(
"http://");
124 d->m_ownloudServer = server.
mid(7);
126 d->m_owncloudProtocol = QStringLiteral(
"https://");
127 d->m_ownloudServer = server.
mid(8);
129 d->m_owncloudProtocol = QStringLiteral(
"http://");
130 d->m_ownloudServer = server;
133 if (oldServer != d->m_ownloudServer) {
134 Q_EMIT owncloudServerChanged(owncloudServer());
135 Q_EMIT apiUrlChanged(apiUrl());
136 }
else if (oldProtocol != d->m_owncloudProtocol) {
137 Q_EMIT apiUrlChanged(apiUrl());
141void CloudSyncManager::setOwncloudUsername(
const QString &username)
143 if (d->m_owncloudUsername != username) {
144 d->m_owncloudUsername = username;
145 Q_EMIT owncloudUsernameChanged(d->m_owncloudUsername);
146 Q_EMIT apiUrlChanged(apiUrl());
150void CloudSyncManager::setOwncloudPassword(
const QString &password)
152 if (d->m_owncloudPassword != password) {
153 d->m_owncloudPassword = password;
154 Q_EMIT owncloudPasswordChanged(d->m_owncloudPassword);
155 Q_EMIT apiUrlChanged(apiUrl());
159void CloudSyncManager::setStatus(
const QString &
status, CloudSyncManager::Status status_type)
161 if (d->m_status !=
status && d->m_status_type != status_type) {
163 d->m_status_type = status_type;
164 Q_EMIT statusChanged(d->m_status);
168CloudSyncManager::Status CloudSyncManager::status()
const
170 return d->m_status_type;
173QString CloudSyncManager::statusDescription()
const
178QString CloudSyncManager::apiPath()
const
180 return QStringLiteral(
"index.php/apps/marble/api/v1");
183QUrl CloudSyncManager::apiUrl()
const
185 return QUrl(QStringLiteral(
"%1%2:%3@%4/%5")
186 .arg(d->m_owncloudProtocol)
187 .arg(d->m_owncloudUsername)
188 .arg(d->m_owncloudPassword)
189 .arg(d->m_ownloudServer)
193RouteSyncManager *CloudSyncManager::routeSyncManager()
195 if (!d->m_routeSyncManager) {
196 d->m_routeSyncManager =
new RouteSyncManager(
this);
199 return d->m_routeSyncManager;
202BookmarkSyncManager *CloudSyncManager::bookmarkSyncManager()
204 if (!d->m_bookmarkSyncManager) {
205 d->m_bookmarkSyncManager =
new BookmarkSyncManager(
this);
208 return d->m_bookmarkSyncManager;
213#include "moc_CloudSyncManager.cpp"
Q_SCRIPTABLE CaptureState status()
Binds a QML item to a specific geodetic location in screen coordinates.
QString mid(qsizetype position, qsizetype n) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const