From f875bb0c7de6289c1aefaef39de53aa69344fada Mon Sep 17 00:00:00 2001 From: Pawel Andruszkiewicz Date: Thu, 7 Apr 2016 12:42:29 +0200 Subject: [PATCH] [Dialog] Native code removed, use Tizen Web API to get profile of the device. Change-Id: I6c3c95a604fc4da5eb49439485b913b06d244a9f Signed-off-by: Pawel Andruszkiewicz --- src/dialog/cordova_dialog.gyp | 2 -- src/dialog/cordova_dialog_api.js | 41 +++++++++-------------- src/dialog/cordova_dialog_extension.cc | 6 ---- src/dialog/cordova_dialog_extension.h | 4 --- src/dialog/cordova_dialog_instance.cc | 60 ---------------------------------- src/dialog/cordova_dialog_instance.h | 39 ---------------------- 6 files changed, 15 insertions(+), 137 deletions(-) delete mode 100644 src/dialog/cordova_dialog_instance.cc delete mode 100644 src/dialog/cordova_dialog_instance.h diff --git a/src/dialog/cordova_dialog.gyp b/src/dialog/cordova_dialog.gyp index 9a0f0c7..8f13ec3 100644 --- a/src/dialog/cordova_dialog.gyp +++ b/src/dialog/cordova_dialog.gyp @@ -10,8 +10,6 @@ 'cordova_dialog_api.js', 'cordova_dialog_extension.cc', 'cordova_dialog_extension.h', - 'cordova_dialog_instance.cc', - 'cordova_dialog_instance.h', ], 'include_dirs': [ '../', diff --git a/src/dialog/cordova_dialog_api.js b/src/dialog/cordova_dialog_api.js index f2ca43e..67fc46f 100755 --- a/src/dialog/cordova_dialog_api.js +++ b/src/dialog/cordova_dialog_api.js @@ -14,9 +14,6 @@ * 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'; @@ -29,35 +26,27 @@ var playback = (function() { var soundElement; var counter = 1; - var result = native_.callSync('CordovaDialog_getProfile', {}); + function win(v) { + soundElement = new Audio(v); + soundElement.addEventListener('ended', function() { + if (--counter > 0) { + soundElement.play(); + } + }); + } - result = native_.getResultObject(result); + function fail(e) { + console.error('Failed to get the notification sound: ' + e); + } - if ("TV" == result.profile) { + if ('tv' === tizen.systeminfo.getCapability('http://tizen.org/feature/profile').toLowerCase()) { 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"); + win(file.toURI()); + }, fail, '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); - }); + tizen.systemsetting.getProperty('NOTIFICATION_EMAIL', win, fail); } - function beep(times) { counter = times || 1; if (soundElement) { diff --git a/src/dialog/cordova_dialog_extension.cc b/src/dialog/cordova_dialog_extension.cc index 23c92ee..a375d3a 100755 --- a/src/dialog/cordova_dialog_extension.cc +++ b/src/dialog/cordova_dialog_extension.cc @@ -15,7 +15,6 @@ */ #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[]; @@ -35,11 +34,6 @@ CordovaDialogExtension::CordovaDialogExtension() { CordovaDialogExtension::~CordovaDialogExtension() {} -common::Instance* CordovaDialogExtension::CreateInstance() { - LoggerD("Entered"); - return new extension::cordova::dialog::CordovaDialogInstance(); -} - } // dialog } // cordova } // extension diff --git a/src/dialog/cordova_dialog_extension.h b/src/dialog/cordova_dialog_extension.h index 8d2653b..613653b 100755 --- a/src/dialog/cordova_dialog_extension.h +++ b/src/dialog/cordova_dialog_extension.h @@ -27,10 +27,6 @@ class CordovaDialogExtension : public common::Extension { public: CordovaDialogExtension(); virtual ~CordovaDialogExtension(); - - private: - // common::Extension implementation. - virtual common::Instance* CreateInstance(); }; } // dialog diff --git a/src/dialog/cordova_dialog_instance.cc b/src/dialog/cordova_dialog_instance.cc deleted file mode 100644 index 58a2b96..0000000 --- a/src/dialog/cordova_dialog_instance.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 -#include -#include - -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(); - result_obj.insert(std::make_pair("profile", picojson::value(profile))); - - ReportSuccess(result, out); -} - -} // dialog -} // cordova -} // extension diff --git a/src/dialog/cordova_dialog_instance.h b/src/dialog/cordova_dialog_instance.h deleted file mode 100644 index 1d71a0f..0000000 --- a/src/dialog/cordova_dialog_instance.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 -#include - -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_ -- 2.7.4