Commit 0f91a37d authored by Martin Straka's avatar Martin Straka

Removed timer and some global variables

parent e5d3af96
......@@ -24,11 +24,10 @@
#include <QList>
#include <QUrl>
#import "ios/src/doc_picker_controller.h"
#include "src/auxiliaries/icloud_helper.h"
#include "src/global.h"
// External globals for transporting of async result back to C++ and QML.
QList<QUrl> selectedFileUrls; // Url list of selected files
bool isControllerOpen; // holds information if DocumentPickerController is active.
#import "ios/src/doc_picker_controller.h"
@interface DocumentPickerController () <UIDocumentPickerDelegate>
......@@ -66,24 +65,23 @@ bool isControllerOpen; // holds information if DocumentPickerController is activ
if (controller.documentPickerMode == UIDocumentPickerModeImport) {
NSLog(@"SELECTED FILE URLs: %@", urls);
QList<QUrl> qurls;
QList<QUrl> qUrls;
// Convert NSURL on QUrl for all selected files
for (NSURL *url in urls) {
QUrl tmpUrl = QUrl::fromNSURL(url);
qurls.append(tmpUrl);
qUrls.append(tmpUrl);
}
selectedFileUrls = qurls;
GlobInstcs::iCloudHelperPtr->importFilesToAppInbox(qUrls);
} else if (controller.documentPickerMode == UIDocumentPickerModeExportToService) {
NSLog(@"STORAGE FILE URLs: %@", urls);
}
isControllerOpen = false;
}
- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller {
Q_UNUSED(controller);
isControllerOpen = false;
}
@end
......@@ -44,8 +44,7 @@ bool isSearchRunning;
ICloudHelper::ICloudHelper(QObject *parent)
: QObject(parent),
m_icloudTimer(new QTimer(this)),
m_dpcTimer(new QTimer(this))
m_icloudTimer(new QTimer(this))
{
}
......@@ -320,40 +319,16 @@ void ICloudHelper::openDocumentPickerController(void)
#ifdef Q_OS_IOS
if (isControllerOpen) {
return;
}
selectedFileUrls.clear();
isControllerOpen = ICloudIo::openDocumentPickerController(QStringList());
if (isControllerOpen) {
connect(m_dpcTimer, SIGNAL(timeout()),
this, SLOT(receivedSelectedFilePath()));
m_dpcTimer->start(200);
}
ICloudIo::openDocumentPickerController(QStringList());
#endif /* Q_OS_IOS */
}
void ICloudHelper::receivedSelectedFilePath(void)
void ICloudHelper::importFilesToAppInbox(QList<QUrl> selectedFileUrls)
{
#ifdef Q_OS_IOS
if (!isControllerOpen) {
m_dpcTimer->stop();
disconnect(m_dpcTimer, SIGNAL(timeout()),
this, SLOT(receivedSelectedFilePath()));
if (!selectedFileUrls.isEmpty()) {
foreach (const QUrl &fileUrl, selectedFileUrls) {
moveFileToSendDir(fileUrl);
}
selectedFileUrls.clear();
}
}
#endif
}
void ICloudHelper::moveFileToSendDir(const QUrl &sourceFileUrl)
......
......@@ -36,8 +36,6 @@
*/
extern QStringList iCloudFileList;
extern bool isSearchRunning;
extern QList<QUrl> selectedFileUrls;
extern bool isControllerOpen;
/*!
* @brief Provides iCloud interface for iOS.
......@@ -140,6 +138,13 @@ public:
Q_INVOKABLE
QString getShortSendFilePath(const QString &sandBoxFilePath);
/*!
* @brief Is activated when iCloud hierarchy has been received.
*
* @param[in] selectedFileUrls Path file list of iCloud for QML.
*/
void importFilesToAppInbox(QList<QUrl> selectedFileUrls);
signals:
/*!
......@@ -170,11 +175,6 @@ private slots:
*/
void receivedCloudHierarchy(void);
/*!
* @brief Is activated when a file has been chosen with document picker.
*/
void receivedSelectedFilePath(void);
private:
/*!
......@@ -186,6 +186,4 @@ private:
/* Detect moment when async search response with iCloud hierarchy finished. */
QTimer *m_icloudTimer;
/* Detect moment when a file was selected with document picker contorller. */
QTimer *m_dpcTimer;
};
......@@ -40,3 +40,5 @@ class RecordsManagementDb *GlobInstcs::recMgmtDbPtr = Q_NULLPTR;
class AccountsMap *GlobInstcs::acntMapPtr = Q_NULLPTR;
class ImageProvider *GlobInstcs::imgProvPtr = Q_NULLPTR;
class ICloudHelper *GlobInstcs::iCloudHelperPtr = Q_NULLPTR;
......@@ -43,6 +43,8 @@ class AccountsMap;
class ImageProvider;
class ICloudHelper;
/*!
* @brief The namespace holds pointers to all globally accessible structures.
*/
......@@ -75,4 +77,6 @@ namespace GlobInstcs {
extern
class ImageProvider *imgProvPtr; /*!< Image provider. */
extern
class ICloudHelper *iCloudHelperPtr; /*!< iCloud helper. */
}
......@@ -448,7 +448,6 @@ int main(int argc, char *argv[])
Messages messages;
Accounts accounts;
Files files;
ICloudHelper iCloudHelper;
Log log(&memLog);
IsdsWrapper isds;
GovWrapper gov(&isds);
......@@ -458,6 +457,14 @@ int main(int argc, char *argv[])
StringManipulation strManipulation;
Zfo zfo;
ICloudHelper iCloudHelper;
GlobInstcs::iCloudHelperPtr = new (std::nothrow) ICloudHelper;
if (GlobInstcs::iCloudHelperPtr == Q_NULLPTR) {
logErrorNL("%s", "Cannot create iCloud helper.");
return EXIT_FAILURE;
}
GlobInstcs::iCloudHelperPtr = &iCloudHelper;
/* Inicialize app delegate component for interaction with iOS
* Reaction on the iOS action "Open in..." */
#if defined Q_OS_IOS
......
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