'cordova_dialog_api.js',
'cordova_dialog_extension.cc',
'cordova_dialog_extension.h',
+ 'cordova_dialog_instance.cc',
+ 'cordova_dialog_instance.h',
],
'include_dirs': [
'../',
* limitations under the License.
*/
+var utils_ = xwalk.utils;
+var native_ = new utils_.NativeManager(extension);
+
// TODO: remove when added to public cordova repository -> begin
var plugin_name = 'cordova-plugin-dialogs.tizen.Notification';
var soundElement;
var counter = 1;
- tizen.systemsetting && tizen.systemsetting.getProperty("NOTIFICATION_EMAIL", function(v) {
- soundElement = new Audio(v);
- soundElement.addEventListener('ended', function() {
- if (--counter > 0) {
- soundElement.play();
- }
+ var result = native_.callSync('CordovaDialog_getProfile', {});
+
+ result = native_.getResultObject(result);
+
+ if ("TV" == result.profile) {
+ tizen.filesystem.resolve('/usr/share/feedback/sound/operation/operation.wav', function(file) {
+ soundElement = new Audio(file.toURI());
+ soundElement.addEventListener('ended', function() {
+ if (--counter > 0) {
+ soundElement.play();
+ }
+ });
+ }, function(e) {
+ console.error('Failed to get the notification sound: ' + e);
+ }, "r");
+ } else {
+ tizen.systemsetting && tizen.systemsetting.getProperty("NOTIFICATION_EMAIL", function(v) {
+ soundElement = new Audio(v);
+ soundElement.addEventListener('ended', function() {
+ if (--counter > 0) {
+ soundElement.play();
+ }
+ });
+ }, function(e) {
+ console.error('Failed to get the notification sound: ' + e);
});
- }, function(e) {
- console.error('Failed to get the notification sound: ' + e);
- });
+ }
+
function beep(times) {
counter = times || 1;
*/
#include "dialog/cordova_dialog_extension.h"
+#include "dialog/cordova_dialog_instance.h"
// This will be generated from cordova_dialog_api.js
extern const char kSource_cordova_dialog_api[];
CordovaDialogExtension::~CordovaDialogExtension() {}
+common::Instance* CordovaDialogExtension::CreateInstance() {
+ LoggerD("Entered");
+ return new extension::cordova::dialog::CordovaDialogInstance();
+}
+
} // dialog
} // cordova
} // extension
public:
CordovaDialogExtension();
virtual ~CordovaDialogExtension();
+
+ private:
+ // common::Extension implementation.
+ virtual common::Instance* CreateInstance();
};
} // dialog
--- /dev/null
+/*
+ * Copyright (c) 2016 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 "dialog/cordova_dialog_instance.h"
+#include <common/logger.h>
+#include <common/picojson.h>
+#include <common/platform_result.h>
+
+namespace extension {
+namespace cordova {
+namespace dialog {
+
+CordovaDialogInstance::CordovaDialogInstance() {
+ using std::placeholders::_1;
+ using std::placeholders::_2;
+
+ LoggerD("Entered");
+
+#define REGISTER_SYNC(c, x) \
+ RegisterSyncHandler(c, std::bind(&CordovaDialogInstance::x, this, _1, _2));
+
+ REGISTER_SYNC("CordovaDialog_getProfile", GetProfile);
+
+#undef REGISTER_SYNC
+}
+
+CordovaDialogInstance::~CordovaDialogInstance() {
+ LoggerD("Entered");
+}
+
+void CordovaDialogInstance::GetProfile(const picojson::value& args,
+ picojson::object& out) {
+ LoggerD("Entered");
+ std::string profile = "MobileOrWearable";
+#ifdef TIZEN_TV
+ profile = "TV";
+#endif
+ picojson::value result = picojson::value(picojson::object());
+ picojson::object& result_obj = result.get<picojson::object>();
+ result_obj.insert(std::make_pair("profile", picojson::value(profile)));
+
+ ReportSuccess(result, out);
+}
+
+} // dialog
+} // cordova
+} // extension
--- /dev/null
+/*
+ * Copyright (c) 2016 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 DIALOG_CORDOVA_DIALOG_INSTANCE_H_
+#define DIALOG_CORDOVA_DIALOG_INSTANCE_H_
+
+#include <common/extension.h>
+#include <common/picojson.h>
+
+namespace extension {
+namespace cordova {
+namespace dialog {
+
+class CordovaDialogInstance : public common::ParsedInstance {
+ public:
+ CordovaDialogInstance();
+ virtual ~CordovaDialogInstance();
+
+ private:
+ void GetProfile(const picojson::value& args, picojson::object& out);
+};
+} // dialog
+} // cordova
+} // extension
+
+#endif // DIALOG_CORDOVA_DIALOG_INSTANCE_H_