icloud_io.h 2.92 KB
Newer Older
1
/*
2
 * Copyright (C) 2014-2019 CZ.NIC
3 4 5 6 7 8 9 10
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Martin Straka's avatar
Martin Straka committed
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 13 14
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
Martin Straka's avatar
Martin Straka committed
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 17 18 19 20 21 22 23 24 25 26 27
 *
 * In addition, as a special exception, the copyright holders give
 * permission to link the code of portions of this program with the
 * OpenSSL library under certain conditions as described in each
 * individual source file, and distribute linked combinations including
 * the two.
 */

#pragma once

#include <QString>
#include <QStringList>
28
#include <QUrl>
29 30 31 32

/*!
 * @brief Provides objective-C IO methods for interaction with iCLoud.
 */
33
class ICloudIo {
34 35 36 37 38 39 40 41 42 43 44 45
public:
	/*!
	 * @brief Return state describing what happened.
	 */
	enum ICloudResult {
		ICLOUD_NOT_ON = 0, /*!< iCloud is not avalilable/turn on. */
		ICLOUD_FILE_UPLOAD_SUCCESS, /*!< File upload was successful. */
		ICLOUD_FILE_EXISTS, /*!< File exists on iCloud. */
		ICLOUD_FILE_UPLOAD_ERROR, /*!< File upload failed. */
		ICLOUD_TARGET_SAVE_DIR_ERROR /*!< Target dir is missing or not created. */
	};

Karel Slaný's avatar
Karel Slaný committed
46
private:
47 48 49
	/*!
	 * @brief Constructor.
	 */
50
	ICloudIo(void);
51

Karel Slaný's avatar
Karel Slaný committed
52
public:
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
	/*!
	 * @brief Test if iCloud is on.
	 *
	 * @return Return true if iCloud is on.
	 */
	static
	bool isCloudOn(void);

	/*!
	 * @brief Upload single file into iCloud.
	 *
	 * @param[in] srcFilePath Source file path.
	 * @param[in] destFilePath iCloud target path.
	 * @return Return operation error/success code.
	 */
	static
	ICloudResult moveFileToCloud(const QString &srcFilePath,
	    const QString &destFilePath);

72
	/*!
73
	 * @brief Create and open document picker controller for export.
74
	 *
75
	 * @param[in] exportFilesPath File paths for export (can be empty).
76 77 78
	 * @return True if document picker controller is created and opened.
	 */
	static
79 80 81 82 83
	bool openDocumentPickerControllerForExport(const QStringList &exportFilesPath);

	/*!
	 * @brief Create and open document picker controller for import.
	 *
84
	 * @param[in] allowedUtis Allowed iOS mime extensions (can be empty).
85 86 87
	 * @return True if document picker controller is created and opened.
	 */
	static
88
	bool openDocumentPickerControllerForImport(const QStringList &allowedUtis);
89 90 91 92

	/*!
	 * @brief Move file from app temporary inbox to local app sandbox.
	 *
93
	 * @param[in] sourceFileUrl Source file url from inbox.
94 95 96 97
	 * @param[in] newFilePath Target path to local app sandbox.
	 * @return Full path where file was moved.
	 */
	static
98
	QUrl moveFile(const QUrl &sourceFileUrl, const QString &newFilePath);
99
};