You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/02/24 21:52:11 UTC
[9/26] qt commit: Merge recent pull requests.
Merge recent pull requests.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/commit/aac85d28
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/tree/aac85d28
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/diff/aac85d28
Branch: refs/heads/master
Commit: aac85d285fad44ec024b1fa7d36abc89c9a3ccd9
Parents: 2d62e9f
Author: Jeff Tranter <jt...@ics.com>
Authored: Tue Feb 21 17:06:04 2012 -0500
Committer: Jeff Tranter <jt...@ics.com>
Committed: Tue Feb 21 17:06:04 2012 -0500
----------------------------------------------------------------------
cordovaqt.pro | 2 +
main.cpp | 2 +
src/cordova.cpp | 13 +++-
src/cordova.h | 4 +
src/plugins/events.cpp | 155 ++++++++++++++++++++++++++++++++++++++++++
src/plugins/events.h | 59 ++++++++++++++++
www/basic.js | 68 ++++++++++++++++++-
www/index.html | 2 +
www/js/accelerometer.js | 102 +++++++++++++++++++++++++++
www/js/cordova.js | 83 ++++++++++++++++++++---
xml/plugins.xml | 1 +
11 files changed, 477 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/aac85d28/cordovaqt.pro
----------------------------------------------------------------------
diff --git a/cordovaqt.pro b/cordovaqt.pro
index fcb0867..211454e 100644
--- a/cordovaqt.pro
+++ b/cordovaqt.pro
@@ -51,6 +51,7 @@ SOURCES += main.cpp \
src/plugins/connection.cpp \
src/plugins/compass.cpp \
src/plugins/accelerometer.cpp \
+ src/plugins/events.cpp \
src/cordova.cpp \
src/cplugin.cpp \
src/cwebpage.cpp
@@ -64,6 +65,7 @@ HEADERS += \
src/plugins/connection.h \
src/plugins/compass.h \
src/plugins/accelerometer.h \
+ src/plugins/events.h \
src/cordova.h \
src/cplugin.h \
src/cwebpage.h
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/aac85d28/main.cpp
----------------------------------------------------------------------
diff --git a/main.cpp b/main.cpp
index 5d3b21b..053abca 100644
--- a/main.cpp
+++ b/main.cpp
@@ -52,6 +52,7 @@ int main(int argc, char *argv[])
# else
QScopedPointer<QDeclarativeView> view(new QDeclarativeView());
# endif
+ Cordova::instance()->setTopLevelEventsReceiver(view.data());
view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
view->rootContext()->setContextProperty("cordova", Cordova::instance());
# ifdef MEEGO_EDITION_HARMATTAN
@@ -63,6 +64,7 @@ int main(int argc, char *argv[])
# endif
#else // QT_VERSION >= 0x050000
QQuickView view;
+ Cordova::instance()->setTopLevelEventsReceiver(&view);
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.rootContext()->setContextProperty("cordova", Cordova::instance());
view.setSource(QUrl(QString("%1/qml/main_qt5.qml").arg(Cordova::instance()->workingDir())));
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/aac85d28/src/cordova.cpp
----------------------------------------------------------------------
diff --git a/src/cordova.cpp b/src/cordova.cpp
index 747caa4..040a44f 100644
--- a/src/cordova.cpp
+++ b/src/cordova.cpp
@@ -27,8 +27,7 @@
Cordova *Cordova::m_instance = 0;
Cordova::Cordova(QObject *parent) : QObject(parent) {
-
-
+ m_topLevelEventsReceiver = 0;
// Determine index file path
m_workingDir = QApplication::applicationDirPath();
#ifdef MEEGO_EDITION_HARMATTAN
@@ -120,3 +119,13 @@ QString Cordova::mainUrl() const
{
return m_mainUrl;
}
+
+void Cordova::setTopLevelEventsReceiver(QObject *obj)
+{
+ m_topLevelEventsReceiver = obj;
+}
+
+QObject *Cordova::topLevelEventsReceiver()
+{
+ return m_topLevelEventsReceiver;
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/aac85d28/src/cordova.h
----------------------------------------------------------------------
diff --git a/src/cordova.h b/src/cordova.h
index 073d391..b9327f9 100644
--- a/src/cordova.h
+++ b/src/cordova.h
@@ -37,6 +37,8 @@ public:
QString workingDir() const;
QString mainUrl() const;
+ void setTopLevelEventsReceiver(QObject *obj);
+ QObject *topLevelEventsReceiver();
signals:
void javaScriptExecNeeded(const QString &js);
@@ -55,6 +57,8 @@ private:
static Cordova *m_instance;
+ QObject *m_topLevelEventsReceiver;
+
QDir m_workingDir;
QString m_mainUrl;
};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/aac85d28/src/plugins/events.cpp
----------------------------------------------------------------------
diff --git a/src/plugins/events.cpp b/src/plugins/events.cpp
new file mode 100644
index 0000000..d9db34a
--- /dev/null
+++ b/src/plugins/events.cpp
@@ -0,0 +1,155 @@
+#include "events.h"
+
+#include "../pluginregistry.h"
+#include "../cordova.h"
+
+#include <QKeyEvent>
+#include <QNetworkConfigurationManager>
+
+#include <QDebug>
+
+// Create static instance of ourself
+Events *Events::m_events = new Events();
+
+/**
+ * Constructor - NOTE: Never do anything except registering the plugin
+ */
+Events::Events() :
+ CPlugin()
+{
+ PluginRegistry::getRegistry()->registerPlugin( "com.cordova.Events", this );
+}
+
+/**
+ * Initialize the pugin
+ */
+void Events::init()
+{
+ m_previousPercent = 100;
+ qDebug() << Q_FUNC_INFO;
+#if QT_VERSION < 0x050000
+ m_batteryInfo = new QSystemBatteryInfo(this);
+ connect(m_batteryInfo, SIGNAL(remainingCapacityChanged(int)), this, SLOT(remainingCapacityChanged(int)));
+ connect(m_batteryInfo, SIGNAL(chargerTypeChanged(QSystemBatteryInfo::ChargerType)), this, SLOT(chargerTypeChanged(QSystemBatteryInfo::ChargerType)));
+#else
+ m_batteryInfo = new QBatteryInfo(this);
+ connect(m_batteryInfo, SIGNAL(remainingCapacityChanged(int,int)), this, SLOT(remainingCapacityChanged(int,int)));
+ connect(m_batteryInfo, SIGNAL(chargerTypeChanged(QBatteryInfo::ChargerType)), this, SLOT(chargerTypeChanged(QBatteryInfo::ChargerType)));
+#endif
+ if (Cordova::instance()->topLevelEventsReceiver())
+ Cordova::instance()->topLevelEventsReceiver()->installEventFilter(this);
+ m_networkConfigurationManager = new QNetworkConfigurationManager(this);
+ connect(m_networkConfigurationManager, SIGNAL(onlineStateChanged(bool)), this, SLOT(onlineStatusChanged(bool)));
+}
+
+bool Events::eventFilter(QObject *obj, QEvent *ev)
+{
+ if (obj == Cordova::instance()->topLevelEventsReceiver()) {
+ if (ev->type() == QEvent::KeyRelease) {
+ QKeyEvent *keyEvent = dynamic_cast<QKeyEvent *>(ev);
+ if (!keyEvent)
+ return false;
+ switch (keyEvent->key()) {
+ case Qt::Key_Menu:
+ Cordova::instance()->execJS( QString("Cordova.menuKeyPressed();"));
+ break;
+ case Qt::Key_Back:
+ Cordova::instance()->execJS( QString("Cordova.backKeyPressed();"));
+ break;
+ case Qt::Key_Search:
+ Cordova::instance()->execJS( QString("Cordova.searchKeyPressed();"));
+ break;
+ case Qt::Key_Call:
+ Cordova::instance()->execJS( QString("Cordova.callKeyPressed();"));
+ break;
+ case Qt::Key_Hangup:
+ Cordova::instance()->execJS( QString("Cordova.hangupKeyPressed();"));
+ break;
+ default:
+ break;
+ }
+ } else if (ev->type() == QEvent::KeyPress) {
+ QKeyEvent *keyEvent = dynamic_cast<QKeyEvent *>(ev);
+ if (!keyEvent)
+ return false;
+ switch (keyEvent->key()) {
+ case Qt::Key_VolumeUp:
+ Cordova::instance()->execJS( QString("Cordova.volumeUpKeyPressed();"));
+ break;
+ case Qt::Key_VolumeDown:
+ Cordova::instance()->execJS( QString("Cordova.volumeDownKeyPressed();"));
+ break;
+ default:
+ break;
+ }
+ } else if (ev->type() == QEvent::WindowActivate) {
+ Cordova::instance()->execJS( QString("Cordova.resumeOccured();"));
+ } else if (ev->type() == QEvent::WindowDeactivate) {
+ Cordova::instance()->execJS( QString("Cordova.pauseOccured();"));
+ }
+ }
+ return false;
+}
+
+#if QT_VERSION < 0x050000
+void Events::remainingCapacityChanged(int capacity)
+#else
+void Events::remainingCapacityChanged(int battery, int capacity)
+#endif
+{
+ qDebug() << Q_FUNC_INFO;
+ int newPercent;
+
+#if QT_VERSION < 0x050000
+ if (m_batteryInfo->nominalCapacity() < 1)
+ newPercent = 0;
+ newPercent = capacity/((double)m_batteryInfo->nominalCapacity()/100);
+#else
+ if (m_batteryInfo->maximumCapacity(battery) < 1)
+ newPercent = 0;
+ newPercent = capacity/((double)m_batteryInfo->maximumCapacity(battery)/100);
+#endif
+ if (m_previousPercent == newPercent)
+ return;
+ m_previousPercent = newPercent;
+#if QT_VERSION < 0x050000
+ bool onBattery = m_batteryInfo->chargerType() == QSystemBatteryInfo::UnknownCharger ||
+ m_batteryInfo->chargerType() == QSystemBatteryInfo::NoCharger ||
+ m_batteryInfo->chargerType() == QSystemBatteryInfo::VariableCurrentCharger;
+#else
+ bool onBattery = m_batteryInfo->chargerType() == QBatteryInfo::UnknownCharger ||
+ m_batteryInfo->chargerType() == QBatteryInfo::VariableCurrentCharger;
+#endif
+ Cordova::instance()->execJS( QString("Cordova.batteryStatusChanged(%1, %2, false);")
+ .arg(m_previousPercent)
+ .arg(!onBattery));
+}
+
+#if QT_VERSION < 0x050000
+void Events::chargerTypeChanged(QSystemBatteryInfo::ChargerType type)
+#else
+void Events::chargerTypeChanged(QBatteryInfo::ChargerType type)
+#endif
+{
+ Q_UNUSED(type);
+ qDebug() << Q_FUNC_INFO;
+#if QT_VERSION < 0x050000
+ bool isPlugged = m_batteryInfo->chargerType() == QSystemBatteryInfo::UnknownCharger ||
+ m_batteryInfo->chargerType() == QSystemBatteryInfo::NoCharger ||
+ m_batteryInfo->chargerType() == QSystemBatteryInfo::VariableCurrentCharger;
+#else
+ bool isPlugged = m_batteryInfo->chargerType() == QBatteryInfo::UnknownCharger ||
+ m_batteryInfo->chargerType() == QBatteryInfo::VariableCurrentCharger;
+#endif
+ Cordova::instance()->execJS( QString("Cordova.batteryStatusChanged(%1, %2, true);")
+ .arg(m_previousPercent)
+ .arg(isPlugged));
+}
+
+void Events::onlineStatusChanged(bool isOnline)
+{
+ if (isOnline)
+ Cordova::instance()->execJS( QString("Cordova.onlineOccured();"));
+ else
+ Cordova::instance()->execJS( QString("Cordova.offlineOccured();"));
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/aac85d28/src/plugins/events.h
----------------------------------------------------------------------
diff --git a/src/plugins/events.h b/src/plugins/events.h
new file mode 100644
index 0000000..9c2457b
--- /dev/null
+++ b/src/plugins/events.h
@@ -0,0 +1,59 @@
+#ifndef EVENTS_H
+#define EVENTS_H
+
+#include "../cplugin.h"
+
+#if QT_VERSION < 0x050000
+# include <QSystemNetworkInfo>
+# include <QSystemBatteryInfo>
+#else
+# include <QtSystemInfo>
+# include <QBatteryInfo>
+#endif
+
+#ifdef QTM_NAMESPACE
+QTM_USE_NAMESPACE
+#endif
+
+class QNetworkConfigurationManager;
+
+class Events : public CPlugin
+{
+ Q_OBJECT
+public:
+ explicit Events();
+
+ void init();
+
+signals:
+
+public slots:
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *ev);
+
+private slots:
+#if QT_VERSION < 0x050000
+ void remainingCapacityChanged(int capacity);
+ void chargerTypeChanged(QSystemBatteryInfo::ChargerType type);
+#else
+ void remainingCapacityChanged(int battery, int capacity);
+ void chargerTypeChanged(QBatteryInfo::ChargerType type);
+#endif
+ void onlineStatusChanged(bool isOnline);
+
+private:
+ static Events *m_events;
+
+#if QT_VERSION < 0x050000
+ QSystemBatteryInfo *m_batteryInfo;
+#else
+ QBatteryInfo *m_batteryInfo;
+#endif
+
+ int m_previousPercent;
+
+ QNetworkConfigurationManager *m_networkConfigurationManager;
+};
+
+#endif // EVENTS_H
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/aac85d28/www/basic.js
----------------------------------------------------------------------
diff --git a/www/basic.js b/www/basic.js
index 9f172f9..9920a0a 100644
--- a/www/basic.js
+++ b/www/basic.js
@@ -34,6 +34,22 @@ function test_vibra()
navigator.notification.beep(5);
}
+function test_alert_confirm()
+{
+ //native javascript alert and confirm only support showing message,
+ //title and button name are ignored.
+ navigator.notification.alert("This is an alert.",
+ function alertDismissed() {// do nothing here
+ }, "title", "buttonName");
+ navigator.notification.confirm("This is a confirm.",
+ function onConfirm(button) {
+ if ( button === 0) {
+ alert('User input: No');
+ } else {alert('User input: Yes');}
+ }, "title", "buttonName");
+}
+
+
function getCurrentPosition() {
navigator.geolocation.getCurrentPosition( function( position ) {
get( "position_val" ).innerHTML = position.coords.latitude + " / " + position.coords.longitude;
@@ -131,10 +147,56 @@ function fileError( p_fileError ) {
get("debug_output").innerHTML = p_filerError.code;
}
+
/*
* Register for the device ready event
*/
document.addEventListener( "deviceready", function() {
- get( "debug_output" ).innerHTML += "Device Ready!<br/>";
- }, false );
-
+ console.log("basicjs.deviceReady")
+ get( "debug_output" ).innerHTML = "Device Ready!<br/>";
+ }, false );
+
+document.addEventListener( "resume", function() {
+ console.log("basicjs.resume")
+ }, false );
+
+document.addEventListener( "pause", function() {
+ console.log("basicjs.pause")
+ }, false );
+
+document.addEventListener( "offline", function() {
+ console.log("basicjs.offline")
+ get( "debug_output" ).innerHTML += "We are offline :(<br/>";
+ }, false );
+
+document.addEventListener( "online", function() {
+ console.log("basicjs.online")
+ get( "debug_output" ).innerHTML += "We are online :)<br/>";
+ }, false );
+
+
+document.addEventListener("batterycritical", function (info) {
+ console.log("basicjs.batteryCritical")
+ get( "debug_output" ).innerHTML = "Battery Level Critical " + info.level + "%<br/>";
+ }, false)
+
+
+document.addEventListener("batterylow", function (info) {
+ console.log("basicjs.batteryLow")
+ get( "debug_output" ).innerHTML = "Battery Level Low " + info.level + "%<br/>";
+ }, false)
+
+document.addEventListener("batterystatus", function (info) {
+ console.log("basicjs.batteryStatus")
+ get( "debug_output" ).innerHTML = "Battery Level Changed " + info.level + "%<br/>";
+ }, false)
+
+document.addEventListener("volumedownbutton", function () {
+ console.log("basicjs.volumeDownKeyPressed")
+ get( "debug_output" ).innerHTML = "Volume Down Button<br/>";
+ }, false)
+
+document.addEventListener("volumeupbutton", function () {
+ console.log("basicjs.volumeUpKeyPressed")
+ get( "debug_output" ).innerHTML = "Volume Up Button<br/>";
+ }, false)
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/aac85d28/www/index.html
----------------------------------------------------------------------
diff --git a/www/index.html b/www/index.html
index 2b2aa0f..2e2d0a8 100644
--- a/www/index.html
+++ b/www/index.html
@@ -22,6 +22,8 @@
<br />
<input type="button" value="Vibrate!" onclick="test_vibra();"/>
<br />
+ <input type="button" value="Alert/Confirm" onclick="test_alert_confirm();">
+ <br />
<input type="button" value="Ping Google!" onclick="ping_google();">
<br />
<input type="button" value="RequestFileSystem" onclick="test_requestFileSystem();">
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/aac85d28/www/js/accelerometer.js
----------------------------------------------------------------------
diff --git a/www/js/accelerometer.js b/www/js/accelerometer.js
new file mode 100644
index 0000000..278e724
--- /dev/null
+++ b/www/js/accelerometer.js
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2011 Integrated Computer Solutions - http://www.ics.com
+ *
+ * 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.
+ */
+
+//accelerometer interface http://docs.phonegap.com/en/1.0.0/phonegap_accelerometer_accelerometer.md.html
+
+
+function Acceleration() {
+};
+
+Acceleration.cast = function( p_acceleration) {
+ var acceleration = new Acceleration();
+ acceleration.x = p_acceleration.x;
+ acceleration.y = p_acceleration.y;
+ acceleration.z = p_acceleration.z;
+ acceleration.timestamp = p_acceleration.timestamp;
+ return acceleration;
+};
+
+Acceleration.prototype.x = null;
+Acceleration.prototype.y = null;
+Acceleration.prototype.z = null;
+Acceleration.prototype.timestamp = null;
+
+Accelerometer.prototype.watchIds = [];
+
+/**
+ * Accelerometer interface
+ */
+function Accelerometer() {
+};
+
+
+Accelerometer.prototype.getCurrentAcceleration = function( successCallback, errorCallback) {
+ // Check the callbacks
+ if( typeof successCallback !== "function" ) return;
+ if( typeof errorCallback !== "function" ) errorCallback = function() {};
+
+ // Call the native function and query for the new x,y,z accel values
+ var me = this;
+ Cordova.exec( function( p_acceleration ) {
+ successCallback( p_acceleration );
+ }, errorCallback, "com.cordova.Accelerometer", "getCurrentAcceleration", [ {} ] );
+};
+
+Accelerometer.prototype.watchAcceleration = function( successCallback, errorCallback, options ) {
+ // Check the callbacks
+ if( typeof successCallback !== "function" ) return;
+ if( typeof errorCallback !== "function" ) errorCallback = function() {};
+
+ var watchId = this.watchIds.length + 1; // +1 in order to avoid 0 as watchId
+ this.watchIds[watchId] = true;
+ var me = this;
+
+ var frequency=10000;
+
+ if(options.frequency != null){frequency=options.frequency;}
+
+ function doWatch() {
+ me.getCurrentAcceleration( function( p_acceleration ) {
+ if( !me.watchIds[watchId] ) return;
+
+ successCallback( p_acceleration );
+
+ // Wait some time before starting again
+ setTimeout( doWatch, frequency );
+ }, function( p_accelerationError ) {
+ if( !me.watchIds[watchId] ) return;
+
+ errorCallback( p_accelerationError );
+ // Wait some time before starting again
+ setTimeout( doWatch, frequency );
+ });
+ }
+
+ setTimeout( doWatch, frequency );
+
+ return watchId;
+ };
+
+Accelerometer.prototype.clearWatch = function( watchId ) {
+ this.watchIds[watchId] = false;
+};
+
+/**
+ * Add the accelerometer object to the navigator
+ */
+Cordova.addConstructor( "com.cordova.Accelerometer", function () {
+ navigator.accelerometer = new Accelerometer();
+ } );
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/aac85d28/www/js/cordova.js
----------------------------------------------------------------------
diff --git a/www/js/cordova.js b/www/js/cordova.js
index 7e7f1ab..8c32991 100644
--- a/www/js/cordova.js
+++ b/www/js/cordova.js
@@ -94,7 +94,8 @@ Cordova.Event.prototype.initEvent = function( eventTypeArg, canBubbleArg, cancel
* Not W3C defined, but required in order to handle our custom events
*/
Cordova.EventHandler = function( p_type ) {
- this.type = p_type;
+ this.type = p_type
+ this.listeners = []
}
Cordova.EventHandler.prototype.type = "unknown";
@@ -123,25 +124,32 @@ Cordova.EventHandler.prototype.dispatchEvent = function() {
var event = new Cordova.Event();
event.initEvent( this.type, false, false );
- // Translate arguments into an array including the custom event as first element
- var parameters = [ event ];
- for( var i = 0; i < arguments.length; i++ ) {
- parameters[i+1] = arguments[i];
- }
-
// Notify all listeners about this event
for( var i = 0; i < this.listeners.length; i++ ) {
- this.listeners[i].apply(Cordova, parameters);
+ this.listeners[i].apply(Cordova, arguments);
}
};
/*
* Create the custom Cordova events
*/
+
Cordova.events = {
deviceready: new Cordova.EventHandler( "deviceready" ),
resume: new Cordova.EventHandler( "resume" ),
- pause: new Cordova.EventHandler( "pause" )
+ pause: new Cordova.EventHandler( "pause" ),
+ online: new Cordova.EventHandler( "online" ),
+ offline: new Cordova.EventHandler( "offline" ),
+ backbutton: new Cordova.EventHandler( "backbutton" ),
+ batterycritical: new Cordova.EventHandler( "batterycritical" ),
+ batterylow: new Cordova.EventHandler( "batterylow" ),
+ batterystatus: new Cordova.EventHandler( "batterystatus" ),
+ menubutton: new Cordova.EventHandler( "menubutton" ),
+ searchbutton: new Cordova.EventHandler( "searchbutton" ),
+ startcallbutton: new Cordova.EventHandler( "startcallbutton" ),
+ endcallbutton: new Cordova.EventHandler( "endcallbutton" ),
+ volumedownbutton: new Cordova.EventHandler( "volumedownbutton" ),
+ volumeupbutton: new Cordova.EventHandler( "volumeupbutton" )
};
/*
@@ -185,3 +193,60 @@ document.dispatchEvent = function( evt ) {
Cordova.deviceready = function() {
Cordova.events.deviceready.dispatchEvent();
}
+
+
+Cordova.resumeOccured = function() {
+ console.log("Cordova.resumeOccured")
+ Cordova.events.resume.dispatchEvent();
+ }
+Cordova.pauseOccured = function() {
+ console.log("Cordova.pauseOccured")
+ Cordova.events.pause.dispatchEvent();
+ }
+Cordova.onlineOccured = function() {
+ console.log("Cordova.onlineOccured")
+ Cordova.events.online.dispatchEvent();
+ }
+Cordova.offlineOccured = function() {
+ console.log("Cordova.offlineOccured")
+ Cordova.events.offline.dispatchEvent();
+ }
+
+
+Cordova.batteryStatusChanged = function(level, isPlugged, forceStatus) {
+ console.log("Cordova.batteryStatusChanged: " + level + ", " + isPlugged + ", " + forceStatus)
+ if (level < 3 && !forceStatus)
+ Cordova.events.batterycritical.dispatchEvent({level: level, isPlugged: isPlugged})
+ else if (level < 40 && !forceStatus)
+ Cordova.events.batterylow.dispatchEvent({level: level, isPlugged: isPlugged})
+ Cordova.events.batterystatus.dispatchEvent({level: level, isPlugged: isPlugged})
+}
+
+Cordova.menuKeyPressed = function() {
+ console.log("Cordova.menuKeyPressed")
+ Cordova.events.menubutton.dispatchEvent();
+ }
+Cordova.backKeyPressed = function() {
+ console.log("Cordova.backKeyPressed")
+ Cordova.events.backbutton.dispatchEvent();
+ }
+Cordova.searchKeyPressed = function() {
+ console.log("Cordova.searchKeyPressed")
+ Cordova.events.searchbutton.dispatchEvent();
+ }
+Cordova.callKeyPressed = function() {
+ console.log("Cordova.callKeyPressed")
+ Cordova.events.startcallbutton.dispatchEvent();
+ }
+Cordova.hangupKeyPressed = function() {
+ console.log("Cordova.hangupKeyPressed")
+ Cordova.events.endcallbutton.dispatchEvent();
+ }
+Cordova.volumeUpKeyPressed = function() {
+ console.log("Cordova.volumeUpKeyPressed")
+ Cordova.events.volumeupbutton.dispatchEvent();
+ }
+Cordova.volumeDownKeyPressed = function() {
+ console.log("Cordova.volumeDownKeyPressed")
+ Cordova.events.volumedownbutton.dispatchEvent();
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/aac85d28/xml/plugins.xml
----------------------------------------------------------------------
diff --git a/xml/plugins.xml b/xml/plugins.xml
index ac1d660..0b1cc45 100644
--- a/xml/plugins.xml
+++ b/xml/plugins.xml
@@ -3,6 +3,7 @@
<plugin name="File" value="com.cordova.File"/>
<plugin name="Notification" value="com.cordova.Notification"/>
<plugin name="Accelerometer" value="com.cordova.Accelerometer"/>
+ <plugin name="Events" value="com.cordova.Events"/>
<plugin name="Geolocation" value="com.cordova.Geolocation"/>
<plugin name="Device" value="com.cordova.Device"/>
<plugin name="Console" value="com.cordova.Console"/>