arnaucube
arnaucube/openEventsPlatformAppPublic Self-hosted repository
openEventsPlatformApp/plugins/cordova-plugin-file/src/ubuntu/file.h
plugins/cordova-plugin-file/src/ubuntu/file.hRaw
 1/*
 2 *  Licensed under the Apache License, Version 2.0 (the "License");
 3 *  you may not use this file except in compliance with the License.
 4 *  You may obtain a copy of the License at
 5 *
 6 *      http://www.apache.org/licenses/LICENSE-2.0
 7 *
 8 *  Unless required by applicable law or agreed to in writing, software
 9 *  distributed under the License is distributed on an "AS IS" BASIS,
10 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 *  See the License for the specific language governing permissions and
12 *  limitations under the License.
13 */
14
15#ifndef FILEAPI_H_SDASDASDAS
16#define FILEAPI_H_SDASDASDAS
17
18#include <QNetworkReply>
19#include <QtCore>
20
21#include <cplugin.h>
22#include <cordova.h>
23
24class File: public CPlugin {
25    Q_OBJECT
26public:
27    explicit File(Cordova *cordova);
28
29    virtual const QString fullName() override {
30        return File::fullID();
31    }
32
33    virtual const QString shortName() override {
34        return "File";
35    }
36
37    static const QString fullID() {
38        return "File";
39    }
40    QPair<bool, QFileInfo> resolveURI(const QString &uri);
41    QPair<bool, QFileInfo> resolveURI(int ecId, const QString &uri);
42    QVariantMap file2map(const QFileInfo &dir);
43
44public slots:
45    void requestFileSystem(int scId, int ecId, unsigned short type, unsigned long long size);
46    void resolveLocalFileSystemURI(int scId, int ecId, const QString&);
47    void getDirectory(int scId, int ecId, const QString&, const QString&, const QVariantMap&);
48    void getFile(int scId, int ecId, const QString &parentPath, const QString &rpath, const QVariantMap &options);
49    void readEntries(int scId, int ecId, const QString &uri);
50    void getParent(int scId, int ecId, const QString &uri);
51    void copyTo(int scId, int ecId, const QString& source, const QString& destinationDir, const QString& newName);
52    void moveTo(int scId, int ecId, const QString& source, const QString& destinationDir, const QString& newName);
53    void getFileMetadata(int scId, int ecId, const QString &);
54    void getMetadata(int scId, int ecId, const QString &);
55    void remove(int scId, int ecId, const QString &);
56    void removeRecursively(int scId, int ecId, const QString&);
57    void write(int scId, int ecId, const QString&, const QString&, unsigned long long position, bool binary);
58    void readAsText(int scId, int ecId, const QString&, const QString &encoding, int sliceStart, int sliceEnd);
59    void readAsDataURL(int scId, int ecId, const QString&, int sliceStart, int sliceEnd);
60    void readAsArrayBuffer(int scId, int ecId, const QString&, int sliceStart, int sliceEnd);
61    void readAsBinaryString(int scId, int ecId, const QString&, int sliceStart, int sliceEnd);
62    void truncate(int scId, int ecId, const QString&, unsigned long long size);
63
64    void _getLocalFilesystemPath(int scId, int ecId, const QString&);
65private:
66    void moveFile(int scId, int ecId,const QString&, const QString&, const QString&);
67    void moveDir(int scId, int ecId,const QString&, const QString&, const QString&);
68    bool copyFile(int scId, int ecId, const QString&, const QString&, const QString&);
69    void copyDir(int scId, int ecId, const QString&, const QString&, const QString&);
70    bool rmDir(const QDir &dir);
71    bool copyFolder(const QString&, const QString&);
72
73    QPair<QString, QString> GetRelativePath(const QFileInfo &fileInfo);
74    QVariantMap dir2map(const QDir &dir);
75
76    QMimeDatabase _db;
77    const QDir _persistentDir;
78    QNetworkAccessManager _manager;
79};
80
81#endif