File indexing completed on 2024-11-24 04:18:47
0001 #include <QDateTime> 0002 #include <QDebug> 0003 #include <QIODevice> 0004 #include <QString> 0005 #include <QTextStream> 0006 0007 #include "../WebDAV.hpp" 0008 #include "../utils/WebDAVReply.hpp" 0009 #include "WebDAVItem.hpp" 0010 0011 WebDAVItem::WebDAVItem(WebDAV* webdavClient, QString href, QString creationDate, 0012 QString lastModified, QString displayName, 0013 QString contentType, QString contentLength, 0014 bool isCollection) { 0015 this->webdavClient = webdavClient; 0016 this->href = href; 0017 this->creationDate = 0018 QDateTime::fromString(creationDate, Qt::DateFormat::ISODate); 0019 this->lastModified = lastModified; 0020 this->displayName = displayName; 0021 this->contentType = contentType; 0022 this->contentLength = contentLength.toInt(); 0023 this->flagIsCollection = isCollection; 0024 } 0025 0026 bool WebDAVItem::isCollection() { return this->flagIsCollection; } 0027 0028 bool WebDAVItem::isFile() { return !this->flagIsCollection; } 0029 0030 WebDAVReply* WebDAVItem::download() { 0031 return this->webdavClient->downloadFrom(this->href); 0032 } 0033 0034 WebDAVReply* WebDAVItem::upload(QString filename, QIODevice* file) { 0035 return this->webdavClient->uploadTo(this->href, filename, file); 0036 } 0037 0038 WebDAVReply* WebDAVItem::createDir(QString dirName) { 0039 return this->webdavClient->createDir(this->href, dirName); 0040 } 0041 0042 WebDAVReply* WebDAVItem::copy(QString destination) { 0043 return this->webdavClient->copy(this->href, destination); 0044 } 0045 0046 WebDAVReply* WebDAVItem::move(QString destination, bool overwrite) { 0047 return this->webdavClient->move(this->href, destination, overwrite); 0048 } 0049 0050 WebDAVReply* WebDAVItem::remove() { 0051 return this->webdavClient->remove(this->href); 0052 } 0053 0054 WebDAVReply* WebDAVItem::listDir() { 0055 return this->webdavClient->listDir(this->href); 0056 } 0057 0058 QString WebDAVItem::toString() { 0059 QString s; 0060 QTextStream out(&s); 0061 0062 out << "HREF : " << this->href << "," << endl 0063 << "CREATION_DATE : " << this->creationDate.toString() << "," << endl 0064 << "LAST_MODIFIED : " << this->lastModified << "," << endl 0065 << "DISPLAY_NAME : " << this->displayName << "," << endl 0066 << "CONTENT_TYPE : " << this->contentType << "," << endl 0067 << "CONTENT_LENGTH : " << this->contentLength << "," << endl 0068 << "IS_COLLECTION : " << this->flagIsCollection; 0069 0070 return s; 0071 } 0072 0073 QString WebDAVItem::getHref() { return this->href; } 0074 0075 QDateTime WebDAVItem::getCreationDate() { return this->creationDate; } 0076 0077 QString WebDAVItem::getLastModified() { return this->lastModified; } 0078 0079 QString WebDAVItem::getDisplayName() { return this->displayName; } 0080 0081 QString WebDAVItem::getContentType() { return this->contentType; } 0082 0083 int WebDAVItem::getContentLength() { return this->contentLength; }