File indexing completed on 2024-05-19 07:37:37
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2013 Utku Aydın <utkuaydin34@gmail.com> 0004 // 0005 0006 #ifndef OWNCLOUDSYNCBACKEND_H 0007 #define OWNCLOUDSYNCBACKEND_H 0008 0009 #include <QObject> 0010 #include <QVector> 0011 #include <QNetworkReply> 0012 0013 class QUrl; 0014 class QDir; 0015 0016 namespace Marble { 0017 0018 class CloudSyncManager; 0019 class RouteItem; 0020 0021 class OwncloudSyncBackend : public QObject 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 explicit OwncloudSyncBackend( CloudSyncManager* cloudSyncManager ); 0027 ~OwncloudSyncBackend() override; 0028 0029 /** 0030 * Generates an endpoint URL by appending endpoint name to API URL 0031 * @param endpoint Endpoint name which will be appended to API URL 0032 * @return QUrl which can be used for interactions with API 0033 */ 0034 QUrl endpointUrl( const QString &endpoint ) const; 0035 0036 /** 0037 * Generates an endpoint URL by appending endpoint name and parameter to API URL 0038 * @param endpoint Endpoint name which will be appended to API URL 0039 * @param parameter Parameter which will be appended to API URL right after endpoint 0040 * @return QUrl which can be used for interactions with API 0041 */ 0042 QUrl endpointUrl( const QString &endpoint, const QString ¶meter ) const; 0043 0044 /** 0045 * Removes route with given timestamp from cache 0046 * @param cacheDir Local synchronization cache directory 0047 * @param timestamp Timestamp of the route which will be deleted 0048 */ 0049 void removeFromCache( const QDir &cacheDir, const QString ×tamp ); 0050 0051 void uploadRoute( const QString ×tamp ); 0052 void downloadRouteList(); 0053 void downloadRoute( const QString ×tamp ); 0054 void deleteRoute( const QString ×tamp ); 0055 QPixmap createPreview( const QString ×tamp ) const; 0056 QString routeName( const QString ×tamp ) const; 0057 0058 public Q_SLOTS: 0059 void cancelUpload(); 0060 0061 private Q_SLOTS: 0062 void checkAuthReply(); 0063 void checkAuthError(QNetworkReply::NetworkError error); 0064 void prepareRouteList(); 0065 void saveDownloadedRoute(); 0066 void validateSettings(); 0067 0068 Q_SIGNALS: 0069 void routeListDownloaded( const QVector<RouteItem> &routeList ); 0070 void routeDownloaded(); 0071 void routeDeleted(); 0072 void routeUploadProgress( qint64 sent, qint64 total ); 0073 void routeDownloadProgress( qint64 received, qint64 total ); 0074 void routeListDownloadProgress( qint64 received, qint64 total ); 0075 void removedFromCache( const QString ×tamp ); 0076 0077 private: 0078 class Private; 0079 Private *d; 0080 }; 0081 0082 } 0083 0084 #endif // OWNCLOUDSYNCBACKEND_H