Commit 5c2331af authored by Karel Slaný's avatar Karel Slaný

Stub for opening ZFO files from command line.

parent 97a42643
......@@ -94,6 +94,7 @@ SOURCES += \
src/models/accountmodel.cpp \
src/models/filemodel.cpp \
src/models/messagemodel.cpp \
src/qml_interaction/interaction_zfo_file.cpp \
src/settings.cpp \
src/sqlite/account_db.cpp \
src/sqlite/dbs.cpp \
......@@ -123,6 +124,7 @@ HEADERS += \
src/models/accountmodel.h \
src/models/filemodel.h \
src/models/messagemodel.h \
src/qml_interaction/interaction_zfo_file.h \
src/settings.h \
src/sqlite/account_db.h \
src/sqlite/dbs.h \
......
......@@ -61,7 +61,9 @@ Component {
MouseArea {
anchors.fill: parent
onClicked: {
statusBar.visible = false
if (typeof(statusBar) != "undefined") {
statusBar.visible = false
}
files.clearFileModelZfo()
pageView.pop(StackView.Immediate)
}
......
......@@ -118,11 +118,12 @@ public:
bool deleteAttachmentsFromDb(const QString &userName, qint64 msgId);
/*!
* @brief Open ZFO file from path.
*
* @param[in] filePath File path with file name.
* @return true if success.
* @brief Open ZFO file from path.
*
* @param[in] filePath File path with file name.
* @return true if success.
*/
Q_INVOKABLE
bool openZfoFileFromStorage(const QString &filePath);
class File {
......
......@@ -41,6 +41,7 @@
#if defined(Q_OS_ANDROID)
#include "src/os_android.h"
#endif /* defined(Q_OS_ANDROID) */
#include "src/qml_interaction/interaction_zfo_file.h"
#include "src/settings.h"
#include "src/sqlite/db_tables.h"
#include "src/sqlite/account_db.h"
......@@ -244,6 +245,8 @@ int main(int argc, char *argv[])
/* Register types into QML. */
Messages::declareQML();
InteractionZfoFile interactionZfoFile;
/* register classes in QML */
ctx->setContextProperty("isds", &isds);
ctx->setContextProperty("messages", &messages);
......@@ -251,6 +254,7 @@ int main(int argc, char *argv[])
ctx->setContextProperty("files", &files);
ctx->setContextProperty("settings", &settings);
ctx->setContextProperty("locker", &locker);
ctx->setContextProperty("interactionZfoFile", &interactionZfoFile);
/* register and set models in QML */
ctx->setContextProperty(globAccountsModelPtr->objectName(),
......@@ -349,12 +353,12 @@ int main(int argc, char *argv[])
* TODO -- Modify the app to display the content.
*/
if (!cmdLineFileNames.isEmpty()) {
emit isds.showErrorMessageBox(QObject::tr("Requested opening ZFO"),
"These files should be opened:",
cmdLineFileNames.join(", "), false);
foreach (const QString &filePath, cmdLineFileNames) {
interactionZfoFile.openZfoFile(filePath);
}
}
#if defined(Q_OS_ANDROID)
IntentNotification intentNotification(isds);
IntentNotification intentNotification(interactionZfoFile);
QObject::connect(&app, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
&intentNotification, SLOT(scanIntentsForFiles(Qt::ApplicationState)));
#endif /* defined(Q_OS_ANDROID) */
......
......@@ -26,9 +26,10 @@
#include "src/os_android.h"
IntentNotification::IntentNotification(IsdsWrapper &iw, QObject *parent)
IntentNotification::IntentNotification(InteractionZfoFile &inter,
QObject *parent)
: QObject(parent),
m_iw(iw)
m_inter(inter)
{
}
......@@ -74,7 +75,7 @@ void IntentNotification::scanIntentsForFiles(Qt::ApplicationState newState)
return;
}
emit m_iw.showErrorMessageBox(QObject::tr("Requested opening ZFO"),
"These files should be opened from IntentNotification:",
fileList.join(", "), false);
foreach (const QString &filePath, fileList) {
m_inter.openZfoFile(filePath);
}
}
......@@ -26,7 +26,7 @@
#include <QObject>
#include "src/net/isds_wrapper.h" /* Experimental use, generates error dialogue. */
#include "src/qml_interaction/interaction_zfo_file.h"
/*!
* @brief Wraps Android intent retrieval.
......@@ -45,10 +45,10 @@ public:
/*!
* @brief Constructor.
*
* @param[in] iw Isds object.
* @param[in] inter ZFO file interaction object.
* @param[in] parent Parent object.
*/
explicit IntentNotification(IsdsWrapper &iw,
explicit IntentNotification(InteractionZfoFile &inter,
QObject *parent = Q_NULLPTR);
/*!
......@@ -68,7 +68,7 @@ public slots:
void scanIntentsForFiles(Qt::ApplicationState newState);
private:
IsdsWrapper &m_iw; /*!< ISDS wrapper object. */
InteractionZfoFile &m_inter; /*!< QML interaction object. */
};
#endif /* _OS_ANDROID_H_ */
/*
* Copyright (C) 2014-2017 CZ.NIC
*
* 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.
*/
#include <QFileInfo>
#include "src/qml_interaction/interaction_zfo_file.h"
InteractionZfoFile::InteractionZfoFile(QObject *parent)
: QObject(parent)
{
}
bool InteractionZfoFile::openZfoFile(const QString &filePath)
{
if (filePath.isEmpty()) {
return false;
}
{
QFileInfo fileInfo(filePath);
if (!fileInfo.isFile() || !fileInfo.isReadable()) {
return false;
}
}
/* TODO */
emit displayZfoFileContent(filePath);
return true;
}
/*
* Copyright (C) 2014-2017 CZ.NIC
*
* 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.
*/
#include <QObject>
/*!
* @brief Class encapsulates interaction with QML related to ZFO files.
*/
class InteractionZfoFile : public QObject {
Q_OBJECT
public:
/*!
* @brief Constructor.
*
* @Param[in] parent Patent object.
*/
InteractionZfoFile(QObject *parent = Q_NULLPTR);
/*!
* @brief Check ZFO file, prepares model and causes QML to display.
*
* @note Emits displayZfoFileContent().
*
* @param[in] filePath Path to ZFO file.
* @return False when an error occurs, true else.
*/
bool openZfoFile(const QString &filePath);
signals:
/*!
* @brief This signal is emitted whenever a message from a ZFO file
* should be emitted.
*
* @param[in] filePath Path to ZFO file.
*/
void displayZfoFileContent(QString filePath);
};
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