31 #include "templates/learnspellings/learnspellingscore.h"
33 #include "templates/learnspellings/learnspellingseditor.h"
34 #include "templates/learnspellings/learnspellingssimulator.h"
35 #include "definitions/definitions.h"
36 #include "miscellaneous/application.h"
37 #include "miscellaneous/iofactory.h"
38 #include "core/templatefactory.h"
39 #include "core/templategenerator.h"
40 #include "core/templateentrypoint.h"
43 #include <QTextStream>
48 LearnSpellingsCore::LearnSpellingsCore(
TemplateEntryPoint *entry_point, QObject *parent)
54 LearnSpellingsCore::~LearnSpellingsCore() {
60 qApp->templateManager()->generator()->cleanWorkspace();
67 if (quiz_data.isEmpty()) {
72 QString temp_folder = qApp->templateManager()->tempDirectory();
73 QDir temp_directory(temp_folder);
74 QString base_folder = temp_folder +
"/" + APP_LOW_NAME;
75 QDir base_directory(base_folder);
80 temp_directory.mkdir(APP_LOW_NAME);
81 base_directory.mkdir(
"assets");
83 QFile index_file(base_folder +
"/assets/spelling_content.xml");
84 index_file.open(QIODevice::WriteOnly | QIODevice::Text);
88 QTextStream out(&index_file);
97 QString new_apk_name = input_apk_file;
98 if (!QFile::copy(APP_TEMPLATES_PATH +
"/" +
entryPoint()->baseFolder() +
"/" +
entryPoint()->mobileApplicationApkFile(),
99 base_folder +
"/" + new_apk_name)) {
100 qApp->templateManager()->generator()->cleanWorkspace();
109 zip.setWorkingDirectory(base_folder);
110 zip.start(qApp->zipUtilityPath(), QStringList() <<
"-m" <<
"-r" << new_apk_name <<
"assets");
111 zip.waitForFinished();
113 if (zip.exitCode() != EXIT_STATUS_ZIP_NORMAL) {
115 qApp->templateManager()->generator()->cleanWorkspace();
122 QString pem_certificate = QDir::toNativeSeparators(APP_CERT_PATH +
"/" + CERTIFICATE_PATH);
123 QString pk_certificate = QDir::toNativeSeparators(APP_CERT_PATH +
"/" + KEY_PATH);
126 signapk.setWorkingDirectory(base_folder);
127 signapk.start(qApp->javaInterpreterPath(), QStringList() <<
"-jar" << qApp->signApkUtlityPath() <<
128 pem_certificate << pk_certificate << new_apk_name <<
129 QDir::toNativeSeparators(new_apk_name +
".new"));
130 signapk.waitForFinished();
132 if (signapk.exitCode() != EXIT_STATUS_SIGNAPK_WORKING) {
133 qApp->templateManager()->generator()->cleanWorkspace();
134 return SignApkProblem;
141 qApp->templateManager()->outputDirectory() +
"/" + new_apk_name)) {
142 qApp->templateManager()->generator()->cleanWorkspace();
146 output_file = QDir(qApp->templateManager()->outputDirectory()).filePath(new_apk_name);
149 qApp->templateManager()->generator()->cleanWorkspace();
virtual TemplateEditor * editor() const
Access to editor widget of the template.
Editor widget of Learn Spellings template.
static bool copyFile(const QString &source, const QString &destination)
Copies source file into destination path.
virtual TemplateSimulator * simulator() const
Access to simulator widget of the template.
void generationProgress(int percent_completed, const QString &progress_info)
Emitted when there is something new concerning generating of mobile APK application.
Simulator widget for Learn Spellings template.
virtual TemplateEntryPoint * entryPoint() const
Access to entry point of the template.
The entry point for a template.
The core class container for single template.
GenerationResult
Possible results of generation of bundle data.
GenerationResult generateMobileApplication(const QString &input_apk_file, QString &output_file)
Generates APK file from current project with active settings.
virtual QString generateBundleData()=0
Generates RAW data which represent data of this template.