Commit ca609eb3 authored by Martin Straka's avatar Martin Straka

Added upload files to iCloud

parent b06da449
...@@ -27,9 +27,11 @@ ...@@ -27,9 +27,11 @@
#include <QQmlEngine> #include <QQmlEngine>
#include <QStringBuilder> #include <QStringBuilder>
#if defined (Q_OS_ANDROID) #if defined (Q_OS_ANDROID)
#include "android/src/android_io.h" #include "android/src/android_io.h"
#endif #endif
#include "ios/src/icloud_helper.h"
#include "ios/src/url_opener.h" #include "ios/src/url_opener.h"
#include "src/auxiliaries/email_helper.h" #include "src/auxiliaries/email_helper.h"
#include "src/common.h" #include "src/common.h"
...@@ -706,13 +708,27 @@ void Files::saveMsgFilesToDisk(const QString &userName, ...@@ -706,13 +708,27 @@ void Files::saveMsgFilesToDisk(const QString &userName,
QString filePath(appMsgAttachDirPath(msgIdStr)); QString filePath(appMsgAttachDirPath(msgIdStr));
QString destPath; QString destFilePath;
QStringList destFilePaths;
foreach (const Isds::Document &document, documents) { foreach (const Isds::Document &document, documents) {
destPath = writeFile(filePath, document.fileDescr(), destFilePath = writeFile(filePath, document.fileDescr(),
document.binaryContent()); document.binaryContent());
if (!destFilePath.isEmpty()) {
destFilePaths.append(destFilePath);
}
} }
attachmentSavingNotification(destPath); #ifndef Q_OS_IOS
attachmentSavingNotification(destFilePath);
#else
ICloudHelper iCloudHelper;
iCloudHelper.storeFilesToCloud(destFilePaths, joinDirs(userName,
msgIdStr));
#endif
} }
void Files::saveAttachmentsToDiskZfo(const QVariant &attachModelVariant, void Files::saveAttachmentsToDiskZfo(const QVariant &attachModelVariant,
...@@ -730,16 +746,29 @@ void Files::saveAttachmentsToDiskZfo(const QVariant &attachModelVariant, ...@@ -730,16 +746,29 @@ void Files::saveAttachmentsToDiskZfo(const QVariant &attachModelVariant,
QString targetPath(appMsgAttachDirPath(msgIdStr)); QString targetPath(appMsgAttachDirPath(msgIdStr));
QString destPath; QString destFilePath;
QStringList destFilePaths;
for (int row = 0; row < attachModel->rowCount(); ++row) { for (int row = 0; row < attachModel->rowCount(); ++row) {
QModelIndex idx(attachModel->index(row)); QModelIndex idx(attachModel->index(row));
destPath = writeFile(targetPath, attachModel->data(idx, destFilePath = writeFile(targetPath, attachModel->data(idx,
FileListModel::ROLE_FILE_NAME).toString(), FileListModel::ROLE_FILE_NAME).toString(),
attachModel->data(idx, attachModel->data(idx,
FileListModel::ROLE_BINARY_DATA).toByteArray()); FileListModel::ROLE_BINARY_DATA).toByteArray());
if (!destFilePath.isEmpty()) {
destFilePaths.append(destFilePath);
} }
}
#ifndef Q_OS_IOS
attachmentSavingNotification(destPath); attachmentSavingNotification(destFilePath);
#else
ICloudHelper iCloudHelper;
iCloudHelper.storeFilesToCloud(destFilePaths, msgIdStr);
#endif
} }
void Files::deleteTmpFileFromStorage(const QString &filePath) void Files::deleteTmpFileFromStorage(const QString &filePath)
......
...@@ -40,10 +40,9 @@ ...@@ -40,10 +40,9 @@
*/ */
#define ILL_FNAME_REP "_" #define ILL_FNAME_REP "_"
QString appAttachDirPath(void) QString joinDirs(const QString &dirName1, const QString &dirName2)
{ {
return dfltAttachSavingLoc() + QDir::separator() + return dirName1 + QDir::separator() + dirName2;
QLatin1String(DATOVKA_BASE_DIR_NAME);
} }
QString appCertDirPath(void) QString appCertDirPath(void)
......
...@@ -41,11 +41,12 @@ ...@@ -41,11 +41,12 @@
#define DATOVKA_MAX_LOG_FILES 5 #define DATOVKA_MAX_LOG_FILES 5
/*! /*!
* @brief Return path to location where the application stores the attachments. * @brief Join two directoris to path.
* * @param[in] dirName1 First directory name.
* @return Full path. * @param[in] dirName2 Second irectory name.
* @return Directory path.
*/ */
QString appAttachDirPath(void); QString joinDirs(const QString &dirName1, const QString &dirName2);
/*! /*!
* @brief Return path to location where the application stores certificates. * @brief Return path to location where the application stores certificates.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment