File indexing completed on 2024-04-28 04:44:40

0001 #ifndef WEBDAV_HPP
0002 #define WEBDAV_HPP
0003 
0004 #include <QIODevice>
0005 #include <QList>
0006 #include <QNetworkAccessManager>
0007 #include <QNetworkReply>
0008 #include <QSslError>
0009 #include <QString>
0010 
0011 #include "utils/NetworkHelper.hpp"
0012 #include "utils/WebDAVReply.hpp"
0013 #include "utils/XMLHelper.hpp"
0014 
0015 enum ListDepthEnum { Zero, One, Two, Infinity };
0016 
0017 class WebDAV : public QObject {
0018   Q_OBJECT
0019 
0020  public:
0021   WebDAV(QString host, QString username, QString password);
0022 
0023   WebDAVReply* testConnection();
0024 
0025   WebDAVReply* listDir(QString path = "/");
0026   WebDAVReply* listDir(QString path, ListDepthEnum depth);
0027 
0028   WebDAVReply* downloadFrom(QString path);
0029   WebDAVReply* downloadFrom(QString path, qint64 startByte, qint64 endByte);
0030 
0031   WebDAVReply* uploadTo(QString path, QString filename, QIODevice* file);
0032 
0033   WebDAVReply* createDir(QString path, QString dirName);
0034 
0035   WebDAVReply* copy(QString source, QString destination);
0036 
0037   WebDAVReply* move(QString source, QString destination,
0038                     bool overwrite = false);
0039 
0040   WebDAVReply* remove(QString path);
0041 
0042   ~WebDAV();
0043 
0044  private:
0045   NetworkHelper* networkHelper;
0046   XMLHelper* xmlHelper;
0047 
0048   void errorReplyHandler(WebDAVReply* reply, QNetworkReply::NetworkError err);
0049 };
0050 
0051 #endif