[Dialog] Native code removed, use Tizen Web API to get profile of the device.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Thu, 7 Apr 2016 10:42:29 +0000 (12:42 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Thu, 7 Apr 2016 11:24:13 +0000 (13:24 +0200)
Change-Id: I6c3c95a604fc4da5eb49439485b913b06d244a9f
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/dialog/cordova_dialog.gyp
src/dialog/cordova_dialog_api.js
src/dialog/cordova_dialog_extension.cc
src/dialog/cordova_dialog_extension.h
src/dialog/cordova_dialog_instance.cc [deleted file]
src/dialog/cordova_dialog_instance.h [deleted file]

index 9a0f0c7..8f13ec3 100644 (file)
@@ -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': [
         '../',
index f2ca43e..67fc46f 100755 (executable)
@@ -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) {
index 23c92ee..a375d3a 100755 (executable)
@@ -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
index 8d2653b..613653b 100755 (executable)
@@ -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 (file)
index 58a2b96..0000000
+++ /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 <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
diff --git a/src/dialog/cordova_dialog_instance.h b/src/dialog/cordova_dialog_instance.h
deleted file mode 100644 (file)
index 1d71a0f..0000000
+++ /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 <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_