Marble

CloudSyncManager.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2013 Utku Aydın <utkuaydin34@gmail.com>
4//
5
6#ifndef CLOUDSYNCMANAGER_H
7#define CLOUDSYNCMANAGER_H
8
9#include <QObject>
10#include <QUrl>
11
12#include "marble_export.h"
13
14namespace Marble
15{
16
17class BookmarkSyncManager;
18class RouteSyncManager;
19
20class MARBLE_EXPORT CloudSyncManager : public QObject
21{
22 Q_OBJECT
23
24 Q_PROPERTY(bool workOffline READ workOffline WRITE setWorkOffline NOTIFY workOfflineChanged)
25 Q_PROPERTY(bool syncEnabled READ isSyncEnabled WRITE setSyncEnabled NOTIFY syncEnabledChanged)
26
27 Q_PROPERTY(QString owncloudUsername READ owncloudUsername WRITE setOwncloudUsername NOTIFY owncloudUsernameChanged)
28 Q_PROPERTY(QString owncloudPassword READ owncloudPassword WRITE setOwncloudPassword NOTIFY owncloudPasswordChanged)
29 Q_PROPERTY(QString owncloudServer READ owncloudServer WRITE setOwncloudServer NOTIFY owncloudServerChanged)
30 Q_PROPERTY(QUrl apiUrl READ apiUrl NOTIFY apiUrlChanged)
31
32 Q_PROPERTY(BookmarkSyncManager *bookmarkSyncManager READ bookmarkSyncManager NOTIFY bookmarkSyncManagerChanged)
33 Q_PROPERTY(RouteSyncManager *routeSyncManager READ routeSyncManager NOTIFY routeSyncManagerChanged)
34
35public:
36 explicit CloudSyncManager(QObject *parent = nullptr);
37 ~CloudSyncManager() override;
38
39 /**
40 * Status enumeration
41 */
42 enum Status {
43 Unknown,
44 Success,
45 Error
46 };
47
48 /**
49 * Getter for offline mode.
50 * @return true if offline mode enabled
51 */
52 bool workOffline() const;
53
54 /**
55 * Setter for offline mode.
56 * @param offline Status of offline mode
57 */
58 void setWorkOffline(bool offline);
59
60 /**
61 * Checks if the user enabled synchronization.
62 * @return true if synchronization enabled
63 */
64 bool isSyncEnabled() const;
65
66 /**
67 * Gets ownCloud server from settings.
68 * @return ownCloud server
69 */
70 QString owncloudServer() const;
71
72 /**
73 * Gets ownCloud username from settings.
74 * @return ownCloud username
75 */
76 QString owncloudUsername() const;
77
78 /**
79 * Gets ownCloud password from settings
80 * @return ownCloud password
81 */
82 QString owncloudPassword() const;
83
84 /**
85 * Setter for enabling/disabling synchronization.
86 * @param enabled Status of synchronization.
87 */
88 void setSyncEnabled(bool enabled);
89
90 /**
91 * Change owncloud server URL, username and password at once without emitting change
92 * signals like setOwncloudServer, setOwncloudUsername, setOwncloudPassword do.
93 * The apiUrlChanged signal is emitted, if needed, however.
94 * @brief setOwncloudCredentials
95 * @param server
96 * @param user
97 * @param password
98 */
99 void setOwncloudCredentials(const QString &server, const QString &user, const QString &password);
100
101 /**
102 * Setter for ownCloud server.
103 * @param server ownCloud server
104 */
105 void setOwncloudServer(const QString &owncloudServer);
106
107 /**
108 * Setter for ownCloud username.
109 * @param username ownCloud username
110 */
111 void setOwncloudUsername(const QString &owncloudUsername);
112
113 /**
114 * Setter for ownCloud password.
115 * @param password ownCloud password
116 */
117 void setOwncloudPassword(const QString &owncloudPassword);
118
119 /**
120 * Setter for authentication error.
121 * @param error authentication error
122 */
123 void setStatus(const QString &status, CloudSyncManager::Status status_type);
124
125 /**
126 * @return Last synchronization status
127 */
128 CloudSyncManager::Status status() const;
129
130 /**
131 * @return A human readable description of the last synchronization status
132 */
133 QString statusDescription() const;
134
135 /**
136 * Returns API path as a QString.
137 * @return API path
138 */
139 QString apiPath() const;
140
141 /**
142 * Returns an API url ready for use.
143 * @return API url as QString
144 */
145 QUrl apiUrl() const;
146
147 /**
148 * @return A ready to use BookmarkSyncManager instance
149 */
150 RouteSyncManager *routeSyncManager();
151
152 /**
153 * @return A ready to use BookmarkSyncManager instance
154 */
155 BookmarkSyncManager *bookmarkSyncManager();
156
157Q_SIGNALS:
158 void workOfflineChanged(bool workOffline);
159 void syncEnabledChanged(bool enabled);
160
161 void owncloudUsernameChanged(const QString &username);
162 void owncloudPasswordChanged(const QString &password);
163 void owncloudServerChanged(const QString &server);
164 void statusChanged(const QString &status);
165
166 void apiUrlChanged(const QUrl &url);
167 void routeSyncManagerChanged();
168 void bookmarkSyncManagerChanged();
169
170private:
171 class Private;
172 Private *const d;
173};
174
175}
176
177#endif // CLOUDSYNCMANAGER_H
Q_SCRIPTABLE CaptureState status()
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.