icloud_io.h 2.69 KB
Newer Older
1
/*
2
 * Copyright (C) 2014-2019 CZ.NIC
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
 *
 * 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
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * 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 <QObject>
#include <QString>
#include <QStringList>
29
#include <QUrl>
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75

/*!
 * @brief Provides objective-C IO methods for interaction with iCLoud.
 */
class ICloudIo : public QObject {
	Q_OBJECT

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. */
	};

	/*!
	 * @brief Constructor.
	 *
	 * @param[in] parent Parent object.
	 */
	ICloudIo(QObject *parent = Q_NULLPTR);

	/*!
	 * @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);

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

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