Native implementation still needs to be added.
Change-Id: I23bab24d55306e6f3bbb349a197ba4d7cb6a80e6
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
'cordova/cordova.gyp:*',
'device/cordova_device.gyp:*',
'dialog/cordova_dialog.gyp:*',
+ 'events/cordova_events.gyp:*',
'file/cordova_file.gyp:*',
'globalization/cordova_globalization.gyp:*',
'networkinformation/cordova_networkinformation.gyp:*',
--- /dev/null
+{
+ 'includes':[
+ '/usr/include/webapi-plugins/src/common/common.gypi',
+ ],
+ 'targets': [
+ {
+ 'target_name': 'tizen_cordova_events',
+ 'type': 'loadable_module',
+ 'sources': [
+ 'cordova_events_api.js',
+ 'cordova_events_extension.cc',
+ 'cordova_events_extension.h',
+ ],
+ 'include_dirs': [
+ '../',
+ '<(SHARED_INTERMEDIATE_DIR)',
+ ],
+ 'variables': {
+ 'packages': [
+ 'webapi-plugins',
+ ],
+ },
+ },
+ ],
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+// TODO: remove when added to public cordova repository -> begin
+var plugin_name = 'cordova-plugin-events.tizen.Events';
+
+cordova.define(plugin_name, function(require, exports, module) {
+// TODO: remove -> end
+
+exports = {
+ startListener: function(successCallback, errorCallback, args) {
+ var e = args[0];
+ },
+ stopListener: function(successCallback, errorCallback, args) {
+ var e = args[0];
+ }
+};
+
+require('cordova/exec/proxy').add('Events', exports);
+
+console.log('Loaded cordova.events API');
+
+// TODO: remove when added to public cordova repository -> begin
+});
+
+exports = function(require) {
+ require('cordova-tizen').addPlugin('cordova-plugin-events.register', plugin_name, 'runs');
+};
+// TODO: remove -> end
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "events/cordova_events_extension.h"
+
+// This will be generated from cordova_events_api.js
+extern const char kSource_cordova_events_api[];
+
+common::Extension* CreateExtension() {
+ return new extension::cordova::events::CordovaEventsExtension();
+}
+
+namespace extension {
+namespace cordova {
+namespace events {
+
+CordovaEventsExtension::CordovaEventsExtension() {
+ SetExtensionName("tizen.cordova.events");
+ SetJavaScriptAPI(kSource_cordova_events_api);
+}
+
+CordovaEventsExtension::~CordovaEventsExtension() {}
+
+} // events
+} // cordova
+} // extension
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef EVENTS_CORDOVA_EVENTS_EXTENSION_H_
+#define EVENTS_CORDOVA_EVENTS_EXTENSION_H_
+
+#include <common/extension.h>
+
+namespace extension {
+namespace cordova {
+namespace events {
+
+class CordovaEventsExtension : public common::Extension {
+ public:
+ CordovaEventsExtension();
+ virtual ~CordovaEventsExtension();
+};
+
+} // events
+} // cordova
+} // extension
+
+#endif // EVENTS_CORDOVA_EVENTS_EXTENSION_H_
]
},
{
+ "file": "plugins/cordova-plugin-events/www/register.js",
+ "id": "cordova-plugin-events.register",
+ "runs": true
+ },
+ {
"file": "plugins/cordova-plugin-file/www/DirectoryEntry.js",
"id": "cordova-plugin-file.DirectoryEntry",
"clobbers": [
"cordova-plugin-console": "1.0.1",
"cordova-plugin-device": "1.0.1",
"cordova-plugin-dialogs": "1.1.1",
+ "cordova-plugin-events": "0.0.1",
"cordova-plugin-file": "3.0.0",
"cordova-plugin-file-transfer": "1.3.0",
"cordova-plugin-network-information": "1.0.1",
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+cordova.define("cordova-plugin-events.register", function(require, exports, module) {
+
+var cordova = require('cordova');
+var channel = require('cordova/channel');
+var exec = require('cordova/exec');
+
+var PLUGIN_NAME = 'Events';
+
+var handled_events = {};
+
+function fireEventListener(e) {
+ if (handled_events[e]) {
+ cordova.fireDocumentEvent(e);
+ } else {
+ console.error('Unknown event: ' + e);
+ }
+}
+
+function addChannelListener(ch, event_name) {
+ ch.onHasSubscribersChange = function() {
+ var start = this.numHandlers > 0;
+ var method = start ? 'startListener' : 'stopListener';
+ var callback = start ? fireEventListener : null;
+ exec(callback, null, PLUGIN_NAME, method, [event_name]);
+ };
+ handled_events[event_name] = event_name;
+}
+
+function createChannelForButton(button) {
+ var ch = cordova.addDocumentEventHandler(button);
+ addChannelListener(ch, button);
+}
+
+var buttons = [
+ 'backbutton',
+ 'menubutton',
+ 'searchbutton',
+ 'startcallbutton',
+ 'endcallbutton',
+ 'volumedownbutton',
+ 'volumeupbutton'
+];
+
+for (var i = 0; i < buttons.length; ++i) {
+ createChannelForButton(buttons[i]);
+}
+
+var events = {
+ pause: channel.onPause,
+ resume: channel.onResume
+};
+
+for (var e in events) {
+ if (events.hasOwnProperty(e)) {
+ addChannelListener(events[e], e);
+ }
+}
+
+});