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
16class BookmarkSyncManager;
17class RouteSyncManager;
18
19class MARBLE_EXPORT CloudSyncManager : public QObject
20{
21 Q_OBJECT
22
23 Q_PROPERTY( bool workOffline READ workOffline WRITE setWorkOffline NOTIFY workOfflineChanged )
24 Q_PROPERTY( bool syncEnabled READ isSyncEnabled WRITE setSyncEnabled NOTIFY syncEnabledChanged )
25
26 Q_PROPERTY( QString owncloudUsername READ owncloudUsername WRITE setOwncloudUsername NOTIFY owncloudUsernameChanged )
27 Q_PROPERTY( QString owncloudPassword READ owncloudPassword WRITE setOwncloudPassword NOTIFY owncloudPasswordChanged )
28 Q_PROPERTY( QString owncloudServer READ owncloudServer WRITE setOwncloudServer NOTIFY owncloudServerChanged )
29 Q_PROPERTY( QUrl apiUrl READ apiUrl NOTIFY apiUrlChanged )
30
31 Q_PROPERTY( BookmarkSyncManager* bookmarkSyncManager READ bookmarkSyncManager NOTIFY bookmarkSyncManagerChanged )
32 Q_PROPERTY( RouteSyncManager* routeSyncManager READ routeSyncManager NOTIFY routeSyncManagerChanged )
33
34public:
35 explicit CloudSyncManager( QObject *parent = nullptr );
36 ~CloudSyncManager() override;
37
38 /**
39 * Status enumeration
40 */
41 enum Status { Unknown, Success, Error };
42
43 /**
44 * Getter for offline mode.
45 * @return true if offline mode enabled
46 */
47 bool workOffline() const;
48
49 /**
50 * Setter for offline mode.
51 * @param offline Status of offline mode
52 */
53 void setWorkOffline( bool offline );
54
55 /**
56 * Checks if the user enabled synchronization.
57 * @return true if synchronization enabled
58 */
59 bool isSyncEnabled() const;
60
61 /**
62 * Gets ownCloud server from settings.
63 * @return ownCloud server
64 */
65 QString owncloudServer() const;
66
67 /**
68 * Gets ownCloud username from settings.
69 * @return ownCloud username
70 */
71 QString owncloudUsername() const;
72
73 /**
74 * Gets ownCloud password from settings
75 * @return ownCloud password
76 */
77 QString owncloudPassword() const;
78
79 /**
80 * Setter for enabling/disabling synchronization.
81 * @param enabled Status of synchronization.
82 */
83 void setSyncEnabled( bool enabled );
84
85 /**
86 * Change owncloud server URL, username and password at once without emitting change
87 * signals like setOwncloudServer, setOwncloudUsername, setOwncloudPassword do.
88 * The apiUrlChanged signal is emitted, if needed, however.
89 * @brief setOwncloudCredentials
90 * @param server
91 * @param user
92 * @param password
93 */
94 void setOwncloudCredentials( const QString &server, const QString &user, const QString &password );
95
96 /**
97 * Setter for ownCloud server.
98 * @param server ownCloud server
99 */
100 void setOwncloudServer( const QString &owncloudServer );
101
102 /**
103 * Setter for ownCloud username.
104 * @param username ownCloud username
105 */
106 void setOwncloudUsername( const QString &owncloudUsername );
107
108 /**
109 * Setter for ownCloud password.
110 * @param password ownCloud password
111 */
112 void setOwncloudPassword( const QString &owncloudPassword );
113
114 /**
115 * Setter for authentication error.
116 * @param error authentication error
117 */
118 void setStatus( const QString &status, CloudSyncManager::Status status_type );
119
120 /**
121 * @return Last synchronization status
122 */
123 CloudSyncManager::Status status() const;
124
125 /**
126 * @return A human readable description of the last synchronization status
127 */
128 QString statusDescription() const;
129
130 /**
131 * Returns API path as a QString.
132 * @return API path
133 */
134 QString apiPath() const;
135
136 /**
137 * Returns an API url ready for use.
138 * @return API url as QString
139 */
140 QUrl apiUrl() const;
141
142 /**
143 * @return A ready to use BookmarkSyncManager instance
144 */
145 RouteSyncManager* routeSyncManager();
146
147 /**
148 * @return A ready to use BookmarkSyncManager instance
149 */
150 BookmarkSyncManager* bookmarkSyncManager();
151
152Q_SIGNALS:
153 void workOfflineChanged(bool workOffline);
154 void syncEnabledChanged(bool enabled);
155
156 void owncloudUsernameChanged(const QString &username);
157 void owncloudPasswordChanged(const QString &password);
158 void owncloudServerChanged(const QString &server);
159 void statusChanged(const QString &status);
160
161 void apiUrlChanged(const QUrl &url);
162 void routeSyncManagerChanged();
163 void bookmarkSyncManagerChanged();
164
165private:
166 class Private;
167 Private *d;
168};
169
170}
171
172#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 Fri Jun 21 2024 12:00:06 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.