Commit ca609eb3 authored by Martin Straka's avatar Martin Straka

Added upload files to iCloud

parent b06da449
......@@ -27,9 +27,11 @@
#include <QQmlEngine>
#include <QStringBuilder>
#if defined (Q_OS_ANDROID)
#include "android/src/android_io.h"
#endif
#include "ios/src/icloud_helper.h"
#include "ios/src/url_opener.h"
#include "src/auxiliaries/email_helper.h"
#include "src/common.h"
......@@ -706,13 +708,27 @@ void Files::saveMsgFilesToDisk(const QString &userName,
QString filePath(appMsgAttachDirPath(msgIdStr));
QString destPath;
QString destFilePath;
QStringList destFilePaths;
foreach (const Isds::Document &document, documents) {
destPath = writeFile(filePath, document.fileDescr(),
destFilePath = writeFile(filePath, document.fileDescr(),
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,
......@@ -730,16 +746,29 @@ void Files::saveAttachmentsToDiskZfo(const QVariant &attachModelVariant,
QString targetPath(appMsgAttachDirPath(msgIdStr));
QString destPath;
QString destFilePath;
QStringList destFilePaths;
for (int row = 0; row < attachModel->rowCount(); ++row) {
QModelIndex idx(attachModel->index(row));
destPath = writeFile(targetPath, attachModel->data(idx,
destFilePath = writeFile(targetPath, attachModel->data(idx,
FileListModel::ROLE_FILE_NAME).toString(),
attachModel->data(idx,
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)
......
......@@ -40,10 +40,9 @@
*/
#define ILL_FNAME_REP "_"
QString appAttachDirPath(void)
QString joinDirs(const QString &dirName1, const QString &dirName2)
{
return dfltAttachSavingLoc() + QDir::separator() +
QLatin1String(DATOVKA_BASE_DIR_NAME);
return dirName1 + QDir::separator() + dirName2;
}
QString appCertDirPath(void)
......
......@@ -41,11 +41,12 @@
#define DATOVKA_MAX_LOG_FILES 5
/*!
* @brief Return path to location where the application stores the attachments.
*
* @return Full path.
* @brief Join two directoris to path.
* @param[in] dirName1 First directory name.
* @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.
......
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