I have made the following changes intended for : CE:MW:Shared / incubator-cordova-qt
Please review and accept or decline. BOSS has already run some checks on this request. See the "Messages from BOSS" section below. https://build.pub.meego.com//request/show/7186 Thank You, jake9xx [This message was auto-generated] --- Request # 7186: Messages from BOSS: State: review at 2012-10-29T20:47:49 by bossbot Reviews: accepted by bossbot : Prechecks succeeded. new for CE-maintainers : Please replace this text with a review and approve/reject the review (not the SR). BOSS will take care of the rest Changes: submit: home:jake9xx:branches:CE:MW:Shared / incubator-cordova-qt -> CE:MW:Shared / incubator-cordova-qt changes files: -------------- --- incubator-cordova-qt.changes +++ incubator-cordova-qt.changes @@ -0,0 +1,2 @@ +* Mon Oct 29 2012 Jarko Vihriala <[email protected]> - 1.7.1 +- cordovaqt did not open the right direcory in app launch so it's fixed. old: ---- incubator-cordova-qt-1.7.0.tar.gz new: ---- incubator-cordova-qt-1.7.1.tar.gz spec files: ----------- --- incubator-cordova-qt.spec +++ incubator-cordova-qt.spec @@ -1,5 +1,5 @@ Name: incubator-cordova-qt -Version: 1.7.0 +Version: 1.7.1 Release: 1%{?dist} Summary: PhoneGap harness for Qt4 and Qt5 systems @@ -21,7 +21,7 @@ %setup -q -n %{name}-%{version} %build -qmake -r CONFIG+=mer +qmake -r CONFIG+=mer DEFINES+=MER_RELEASE=1 make %{?_smp_mflags} other changes: -------------- ++++++ incubator-cordova-qt-1.7.0.tar.gz -> incubator-cordova-qt-1.7.1.tar.gz --- .gitignore +++ .gitignore @@ -1,2 +0,0 @@ -cordovaqt.pro.user* -/qtc_packaging/debian_harmattan/* Binary files WebpageIcons.db added --- cordovaqt.pro +++ cordovaqt.pro @@ -8,6 +8,7 @@ mer { MEEGO_VERSION_MAJOR = 2 +MEEGO_EDITION_HARMATTAN = 1 } DEPLOYMENTFOLDERS = wwwDir xmlDir qmlDir# file1 dir1 --- cordovaqt.pro.user +++ cordovaqt.pro.user @@ -1,265 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE QtCreatorProject> -<!-- Written by Qt Creator 2.4.1, 2012-10-11T14:15:30. --> -<qtcreator> - <data> - <variable>ProjectExplorer.Project.ActiveTarget</variable> - <value type="int">0</value> - </data> - <data> - <variable>ProjectExplorer.Project.EditorSettings</variable> - <valuemap type="QVariantMap"> - <value type="bool" key="EditorConfiguration.AutoIndent">true</value> - <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value> - <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0"> - <value type="QString" key="language">Cpp</value> - <valuemap type="QVariantMap" key="value"> - <value type="QString" key="CurrentPreferences">CppGlobal</value> - </valuemap> - </valuemap> - <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1"> - <value type="QString" key="language">QmlJS</value> - <valuemap type="QVariantMap" key="value"> - <value type="QString" key="CurrentPreferences">QmlJSGlobal</value> - </valuemap> - </valuemap> - <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value> - <value type="QByteArray" key="EditorConfiguration.Codec">System</value> - <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value> - <value type="int" key="EditorConfiguration.IndentSize">4</value> - <value type="bool" key="EditorConfiguration.MouseNavigation">true</value> - <value type="int" key="EditorConfiguration.PaddingMode">1</value> - <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value> - <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value> - <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value> - <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value> - <value type="int" key="EditorConfiguration.TabSize">8</value> - <value type="bool" key="EditorConfiguration.UseGlobal">true</value> - <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value> - <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value> - <value type="bool" key="EditorConfiguration.cleanIndentation">true</value> - <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value> - <value type="bool" key="EditorConfiguration.inEntireDocument">false</value> - </valuemap> - </data> - <data> - <variable>ProjectExplorer.Project.PluginSettings</variable> - <valuemap type="QVariantMap"/> - </data> - <data> - <variable>ProjectExplorer.Project.Target.0</variable> - <valuemap type="QVariantMap"> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt Simulator</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt Simulator</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.QtSimulatorTarget</value> - <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> - <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> - <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> - <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> - <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.gdb</value> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> - <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> - <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> - <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> - <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> - </valuemap> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> - <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> - </valuemap> - <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> - </valuemap> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> - <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> - </valuemap> - <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> - </valuemap> - <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> - <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> - <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Simulator Qt for GCC (Qt SDK) Release</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> - <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> - <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/jvihrial/Desktop/experimental/cordovaqt-build-simulator-Simulator_Qt_for_GCC__Qt_SDK__Release</value> - <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">2</value> - <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> - </valuemap> - <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> - <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.gdb</value> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> - <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> - <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> - <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> - <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> - </valuemap> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> - <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> - </valuemap> - <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> - </valuemap> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> - <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> - </valuemap> - <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> - </valuemap> - <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> - <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> - <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Simulator Qt for GCC (Qt SDK) Debug</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> - <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value> - <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/jvihrial/Desktop/experimental/cordovaqt-build-simulator-Simulator_Qt_for_GCC__Qt_SDK__Debug</value> - <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">2</value> - <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> - </valuemap> - <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value> - <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> - <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> - </valuemap> - <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> - </valuemap> - <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> - <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> - <value type="bool" key="Analyzer.Project.UseGlobal">true</value> - <value type="bool" key="Analyzer.Project.UseGlobal">true</value> - <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> - <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/> - <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> - <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value> - <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> - <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value> - <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> - <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value> - <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> - <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value> - <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> - <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value> - <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> - <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value> - <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> - <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value> - <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> - <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value> - <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> - <value type="int" key="Analyzer.Valgrind.NumCallers">25</value> - <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> - <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/> - <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> - <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value> - <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> - <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value> - <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> - <value type="int">0</value> - <value type="int">1</value> - <value type="int">2</value> - <value type="int">3</value> - <value type="int">4</value> - <value type="int">5</value> - <value type="int">6</value> - <value type="int">7</value> - <value type="int">8</value> - <value type="int">9</value> - <value type="int">10</value> - <value type="int">11</value> - <value type="int">12</value> - <value type="int">13</value> - <value type="int">14</value> - </valuelist> - <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> - <value type="int">0</value> - <value type="int">1</value> - <value type="int">2</value> - <value type="int">3</value> - <value type="int">4</value> - <value type="int">5</value> - <value type="int">6</value> - <value type="int">7</value> - <value type="int">8</value> - <value type="int">9</value> - <value type="int">10</value> - <value type="int">11</value> - <value type="int">12</value> - <value type="int">13</value> - <value type="int">14</value> - </valuelist> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">cordovaqt</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration</value> - <value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value> - <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> - <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">cordovaqt.pro</value> - <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> - <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value> - <valuelist type="QVariantList" key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"/> - <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> - <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> - <value type="bool" key="RunConfiguration.UseCppDebugger">true</value> - <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> - <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value> - </valuemap> - <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> - </valuemap> - </data> - <data> - <variable>ProjectExplorer.Project.TargetCount</variable> - <value type="int">1</value> - </data> - <data> - <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable> - <value type="QString">{5553d527-449e-445d-b5ee-a5e979463537}</value> - </data> - <data> - <variable>ProjectExplorer.Project.Updater.FileVersion</variable> - <value type="int">10</value> - </data> -</qtcreator> --- main.cpp +++ main.cpp @@ -31,6 +31,7 @@ #endif #include <qplatformdefs.h> +#include <QDebug> #ifdef MEEGO_EDITION_HARMATTAN # include <MDeclarativeCache> @@ -68,7 +69,21 @@ view->setSource(QUrl(QString("%1/qml/main_qt4.qml").arg(Cordova::instance()->workingDir()))); view->showFullScreen(); # else - view->setSource(QUrl(QString("%1/qml/main.qml").arg(Cordova::instance()->workingDir()))); + + qDebug() << "Mer config"; + const QString currentPath = QString("%1/www").arg(QDir::currentPath()); + QDir dir = QDir(currentPath); + if( dir.exists() ) { + qDebug() << "Using qml from current directory"; + view->setSource(QUrl(QString("%1/qml/main.qml").arg(QDir::currentPath()))); + } else { + qDebug() << "Loading qml/main.qml"; + QString cordovaPath = Cordova::instance()->workingDir(); + QDir cordovaDir = QDir(cordovaPath); + qDebug() << "qml loaded from :" << cordovaDir.path(); + view->setSource(QUrl(QString("%1/qml/main.qml").arg(cordovaDir.path()))); + } + # if defined(Q_OS_SYMBIAN) || defined(QT_SIMULATOR) view->showFullScreen(); # else --- src/cordova.cpp +++ src/cordova.cpp @@ -30,9 +30,25 @@ m_topLevelEventsReceiver = 0; // Determine index file path m_workingDir = QApplication::applicationDirPath(); + + bool hasOwnWwwRoot = false; +#if defined(MER_RELEASE) + QString currentPath = QString("%1/www").arg(QDir::currentPath()); + qDebug() << currentPath; + QDir dir = QDir(currentPath); + if( dir.exists() ) { + hasOwnWwwRoot = true; + qDebug() << "www exists, let's use current application path"; + m_workingDir = QDir::currentPath(); + } +#endif + + //#ifdef MEEGO_EDITION_HARMATTAN -#if defined(MEEGO_EDITION_HARMATTAN) || (defined(QT_SIMULATOR) && defined(Q_OS_WIN) ) - m_workingDir.cdUp(); +#if defined(MEEGO_EDITION_HARMATTAN) || defined(MER_RELEASE) || (defined(QT_SIMULATOR) && defined(Q_OS_WIN) ) + + if(!hasOwnWwwRoot) m_workingDir.cdUp(); + #endif qDebug() << "Using" << m_workingDir.absolutePath() << "as working dir"; QDir wwwDir( m_workingDir ); --- src/cordova.cpp~ +++ src/cordova.cpp~ @@ -0,0 +1,147 @@ +/* + * Copyright 2011 Wolfgang Koller - http://www.gofg.at/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "cordova.h" +#include "pluginregistry.h" + +#include <qplatformdefs.h> + +#include <QDebug> +#include <QXmlStreamReader> +#include <QApplication> +#include <QUrl> + +Cordova *Cordova::m_instance = 0; + +Cordova::Cordova(QObject *parent) : QObject(parent) { + m_topLevelEventsReceiver = 0; + // Determine index file path + m_workingDir = QApplication::applicationDirPath(); + + bool hasOwnWwwRoot = false; +#if defined(MER_RELEASE) + QString currentPath = QString("%1/www").arg(QDir::currentPath()); + qDebug() << currentPath; + QDir dir = QDir(currentPath); + if( dir.exists() ) { + qDebug() << "www exists, let's use current application path"; + m_workingDir = QDir::currentPath(); + } +#endif + + +//#ifdef MEEGO_EDITION_HARMATTAN +#if defined(MEEGO_EDITION_HARMATTAN) || defined(MER_RELEASE) || (defined(QT_SIMULATOR) && defined(Q_OS_WIN) ) + + if(!hasOwnWwwRoot) m_workingDir.cdUp(); + +#endif + qDebug() << "Using" << m_workingDir.absolutePath() << "as working dir"; + QDir wwwDir( m_workingDir ); + wwwDir.cd( "www" ); + +#if QT_VERSION < 0x050000 + m_mainUrl = QUrl::fromUserInput(wwwDir.absoluteFilePath("index.html")).toString(); +#else + m_mainUrl = QUrl::fromUserInput(wwwDir.absoluteFilePath("index_qt5.html")).toString(); +#endif +} + +Cordova *Cordova::instance() +{ + if (!m_instance) + m_instance = new Cordova; + return m_instance; +} + +/** + * Called when the webview finished loading a new page + */ +void Cordova::loadFinished( bool ok ) { + Q_UNUSED(ok) + + // Change into the xml-directory + QDir xmlDir( m_workingDir ); + xmlDir.cd( "xml" ); + + // Try to open the plugins configuration + QFile pluginsXml( xmlDir.filePath("plugins.xml") ); + if( !pluginsXml.open( QIODevice::ReadOnly | QIODevice::Text ) ) { + qDebug() << "Error loading plugins config!"; + return; + } + + // Start reading the file as a stream + QXmlStreamReader plugins; + plugins.setDevice( &pluginsXml ); + + // Iterate over plugins-configuration and load all according plugins + while(!plugins.atEnd()) { + if( plugins.readNext() == QXmlStreamReader::StartElement ) { + // Check if we have a plugin element + if( plugins.name() == "plugin" ) { + QXmlStreamAttributes attribs = plugins.attributes(); + // Check for name & value attributes + if( attribs.hasAttribute("name") && attribs.hasAttribute("value") ) { + // Construct object & attribute names + QString attribName = attribs.value( "name" ).toString(); + QString attribValue = attribs.value( "value" ).toString(); + + qDebug() << "Adding Plugin " << attribName << " with " << attribValue; + // Check for such a plugin + CPlugin *currPlugin = PluginRegistry::getRegistry()->getPlugin( attribValue ); + if(currPlugin) { + currPlugin->init(); + emit pluginWantsToBeAdded(attribValue, currPlugin, attribName); + execJS( "Cordova.enablePlugin( '" + attribValue + "' )" ); + } + else { + qDebug() << "Unknown Plugin " << attribName; + } + } + } + } + } + + // Device is now ready to rumble + execJS( "Cordova.deviceready();" ); +} + + +QString Cordova::workingDir() const +{ + return m_workingDir.absolutePath(); +} + +void Cordova::execJS(const QString &js) +{ + emit javaScriptExecNeeded(js); +} + +QString Cordova::mainUrl() const +{ + return m_mainUrl; +} + +void Cordova::setTopLevelEventsReceiver(QObject *obj) +{ + m_topLevelEventsReceiver = obj; +} + +QObject *Cordova::topLevelEventsReceiver() +{ + return m_topLevelEventsReceiver; +}
