[FMRadio][feature] interface draft
authorDominik Rekawek <d.rekawek@samsung.com>
Fri, 12 Dec 2014 18:17:39 +0000 (19:17 +0100)
committerDominik Rekawek <d.rekawek@samsung.com>
Sat, 20 Dec 2014 14:48:03 +0000 (15:48 +0100)
JS: Attributes and functions defined
Cpp: Functions in instance defined

Verify:
> tizen.fmradio
{ frequency: 'TEST',
  frequencyUpperBound: 'TEST',
  frequencyLowerBound: 'TEST',
  signalStrength: 'TEST',
  state: 'TEST',
  isAntennaConnected: 'TEST',
  mute: 'TEST' }

Change-Id: I60f31a81ff6ba3d1a2f13da5eb8f8346649eb535
Signed-off-by: Dominik Rekawek <d.rekawek@samsung.com>
packaging/webapi-plugins.spec
src/radio/radio.gyp [new file with mode: 0644]
src/radio/radio_api.js [new file with mode: 0644]
src/radio/radio_extension.cc [new file with mode: 0644]
src/radio/radio_extension.h [new file with mode: 0644]
src/radio/radio_instance.cc [new file with mode: 0644]
src/radio/radio_instance.h [new file with mode: 0644]
src/tizen-wrt.gyp

index 862fa160eaf2f9668203f2ea8d5e36a6a04fb3df..fa12a9a58986824104ae8d6665bdd8f8f1d690f8 100644 (file)
@@ -33,7 +33,7 @@ Source0:    %{name}-%{version}.tar.gz
 %define tizen_feature_datasync_support            1
 %define tizen_feature_download_support            0
 %define tizen_feature_exif_support                0
-%define tizen_feature_fm_radio_support            0
+%define tizen_feature_fm_radio_support            1
 %define tizen_feature_gamepad_support             0
 %define tizen_feature_ham_support                 0
 %define tizen_feature_messaging_email_support     1
@@ -214,6 +214,10 @@ BuildRequires:  pkgconfig(libexif)
 BuildRequires:  pkgconfig(capi-network-nfc)
 %endif
 
+%if 0%{?tizen_feature_fm_radio_support}
+BuildRequires: pkgconfig(capi-media-radio)
+%endif
+
 %description
 Tizen Web APIs implemented.
 
diff --git a/src/radio/radio.gyp b/src/radio/radio.gyp
new file mode 100644 (file)
index 0000000..d4abb6c
--- /dev/null
@@ -0,0 +1,28 @@
+{
+  'includes':[
+    '../common/common.gypi',
+  ],
+  'targets': [
+    {
+      'target_name': 'tizen_fmradio',
+      'type': 'loadable_module',
+      'sources': [
+        'radio_api.js',
+        'radio_extension.cc',
+        'radio_extension.h',
+        'radio_instance.cc',
+        'radio_instance.h'
+      ],
+      'conditions': [
+        ['tizen == 1', {
+          'variables': {
+            'packages': [
+                'vconf',
+                'capi-media-radio',
+            ]
+          },
+        }],
+      ],
+    },
+  ],
+}
diff --git a/src/radio/radio_api.js b/src/radio/radio_api.js
new file mode 100644 (file)
index 0000000..790f071
--- /dev/null
@@ -0,0 +1,70 @@
+/* global xwalk, extension, tizen */
+
+// Copyright 2014 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var validator_ = xwalk.utils.validator;
+var types_ = validator_.Types;
+var native_ = new xwalk.utils.NativeManager(extension);
+
+var RadioState = {
+        PLAYING : 'PLAYING',
+        SCANNING : 'SCANNING',
+        READY : 'READY'
+};
+
+function FMRadioManager() {
+     Object.defineProperties(this, {
+            'frequency': { value: 'TEST', writable: false,enumerable: true },
+            'frequencyUpperBound': { value: 'TEST',writable: false,enumerable: true },
+            'frequencyLowerBound': { value: 'TEST',writable: false,enumerable: true },
+            'signalStrength': {  value: 'TEST',writable: false,enumerable: true },
+            'state': { value: 'TEST',writable: false,enumerable: true },
+            'isAntennaConnected': {  value: 'TEST',writable: false,enumerable: true },
+            'mute': {value: 'TEST', writable: false,enumerable: true }
+          });
+}
+
+FMRadioManager.prototype.seekUp = function() {
+    var ret = native_.call('FMRadio_SeekUp');
+    return 'SeekUp';
+};
+
+FMRadioManager.prototype.seekDown = function() {
+    var ret = native_.call('FMRadio_SeekDown');
+    return 'SeekDown'
+};
+
+FMRadioManager.prototype.scanStart = function() {
+    var ret = native_.call('FMRadio_ScanStart');
+    return 'scanStart'
+};
+
+FMRadioManager.prototype.scanStop = function() {
+    var ret = native_.call('FMRadio_ScanStop');
+    return 'scanStop'
+};
+
+FMRadioManager.prototype.setFMRadioInterruptedListener = function() {
+    var ret = native_.callSync('FMRadio_SetFMRadioInterruptedListener');
+    return 'setFMRadioInterruptedListener'
+};
+
+FMRadioManager.prototype.unsetFMRadioInterruptedListener = function() {
+    var ret = native_.callSync('FMRadio_UnsetFMRadioInterruptedListener');
+    return 'unsetFMRadioInterruptedListener'
+};
+
+FMRadioManager.prototype.setAntennaChangeListener = function() {
+    var ret = native_.callSync('FMRadio_SetAntennaChangeListener');
+    return 'setAntennaChangeListener'
+};
+
+FMRadioManager.prototype.unsetAntennaChangeListener = function() {
+    var ret = native_.callSync('FMRadio_UnsetAntennaChangeListener');
+    return 'unsetAntennaChangeListener'
+};
+
+exports = new FMRadioManager();
+
diff --git a/src/radio/radio_extension.cc b/src/radio/radio_extension.cc
new file mode 100644 (file)
index 0000000..0ca6d1c
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright 2014 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "radio/radio_extension.h"
+#include "radio/radio_instance.h"
+
+#include <common/logger.h>
+
+// This will be generated from radio_api.js
+extern const char kSource_radio_api[];
+
+common::Extension* CreateExtension() {
+  return new RadioExtension;
+}
+
+RadioExtension::RadioExtension() {
+  SetExtensionName("tizen.fmradio");
+  SetJavaScriptAPI(kSource_radio_api);
+  LoggerD("RadioExtension()");
+}
+
+RadioExtension::~RadioExtension() {}
+
+common::Instance* RadioExtension::CreateInstance() {
+  return new extension::radio::RadioInstance;
+}
diff --git a/src/radio/radio_extension.h b/src/radio/radio_extension.h
new file mode 100644 (file)
index 0000000..b93d493
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2014 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef RADIO_RADIO_EXTENSION_H_
+#define RADIO_RADIO_EXTENSION_H_
+
+#include "common/extension.h"
+
+class RadioExtension : public common::Extension {
+ public:
+  RadioExtension();
+  virtual ~RadioExtension();
+
+ private:
+  virtual common::Instance* CreateInstance();
+};
+
+#endif
+
diff --git a/src/radio/radio_instance.cc b/src/radio/radio_instance.cc
new file mode 100644 (file)
index 0000000..70a9d80
--- /dev/null
@@ -0,0 +1,90 @@
+// Copyright 2014 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "radio/radio_instance.h"
+
+#include <functional>
+
+#include "common/picojson.h"
+#include "common/logger.h"
+#include "common/platform_exception.h"
+
+#include <radio.h>
+
+namespace extension {
+namespace radio {
+
+    using namespace common;
+    using namespace extension::radio;
+
+    RadioInstance::RadioInstance() {
+        using namespace std::placeholders;
+        #define REGISTER_SYNC(c,x) \
+            RegisterSyncHandler(c, std::bind(&RadioInstance::x, this, _1, _2));
+            REGISTER_SYNC("FMRadio_Start", Start);
+            REGISTER_SYNC("FMRadio_Stop", Stop);
+            REGISTER_SYNC("FMRadio_SetFMRadioInterruptedListener", SetFMRadioInterruptedListener);
+            REGISTER_SYNC("FMRadio_UnsetFMRadioInterruptedListener", UnsetFMRadioInterruptedListener);
+            REGISTER_SYNC("FMRadio_SetAntennaChangeListener", SetAntennaChangeListener);
+            REGISTER_SYNC("FMRadio_UnsetAntennaChangeListener", UnsetAntennaChangeListener);
+        #undef REGISTER_SYNC
+        #define REGISTER_ASYNC(c,x) \
+            RegisterHandler(c, std::bind(&RadioInstance::x, this, _1, _2));
+            REGISTER_ASYNC("FMRadio_SeekUp", SeekUp);
+            REGISTER_ASYNC("FMRadio_SeekDown", SeekDown);
+            REGISTER_ASYNC("FMRadio_ScanStart", ScanStart);
+            REGISTER_ASYNC("FMRadio_ScanStop", ScanStop);
+        #undef REGISTER_ASYNC
+
+        LoggerD("RadioInstance()");
+    }
+
+    RadioInstance::~RadioInstance() {
+    }
+
+    void RadioInstance::Start(const picojson::value& args,
+            picojson::object& out){
+        LoggerD(".cc Start()");
+    }
+
+    void RadioInstance::Stop(const picojson::value& args,
+            picojson::object& out){
+        LoggerD(".cc Stop()");
+    }
+
+    void RadioInstance::SeekUp(const picojson::value& args,
+            picojson::object& out) {
+        LoggerD(".cc SeekUp()");
+    }
+    void RadioInstance::SeekDown(const picojson::value& args,
+            picojson::object& out) {
+        LoggerD(".cc SeekDown()");
+    }
+    void RadioInstance::ScanStart(const picojson::value& args,
+            picojson::object& out) {
+        LoggerD(".cc ScanStart()");
+    }
+    void RadioInstance::ScanStop(const picojson::value& args,
+            picojson::object& out) {
+        LoggerD(".cc ScanStop()");
+    }
+    void RadioInstance::SetFMRadioInterruptedListener(const picojson::value& args,
+            picojson::object& out) {
+        LoggerD(".cc SetFMRadioInterruptedListener()");
+    }
+    void RadioInstance::UnsetFMRadioInterruptedListener(const picojson::value& args,
+            picojson::object& out) {
+        LoggerD(".cc UnsetFMRadioInterruptedListener()");
+    }
+    void RadioInstance::SetAntennaChangeListener(const picojson::value& args,
+            picojson::object& out) {
+        LoggerD(".cc SetAntennaChangeListener()");
+    }
+    void RadioInstance::UnsetAntennaChangeListener(const picojson::value& args,
+            picojson::object& out) {
+        LoggerD(".cc UnsetAntennaChangeListener()");
+    }
+
+}
+}
diff --git a/src/radio/radio_instance.h b/src/radio/radio_instance.h
new file mode 100644 (file)
index 0000000..8eb1779
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright 2014 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef RADIO_RADIO_INSTANCE_H_
+#define RADIO_RADIO_INSTANCE_H_
+
+#include "common/extension.h"
+
+
+namespace extension {
+namespace radio {
+
+class RadioInstance
+    : public common::ParsedInstance
+      {
+ public:
+  RadioInstance();
+  virtual ~RadioInstance();
+
+
+
+ private:
+  void Start(const picojson::value& args, picojson::object& out);
+  void Stop(const picojson::value& args, picojson::object& out);
+  void SeekUp(const picojson::value& args, picojson::object& out);
+  void SeekDown(const picojson::value& args, picojson::object& out);
+  void ScanStart(const picojson::value& args, picojson::object& out);
+  void ScanStop(const picojson::value& args, picojson::object& out);
+  void SetFMRadioInterruptedListener(const picojson::value& args, picojson::object& out);
+  void UnsetFMRadioInterruptedListener(const picojson::value& args, picojson::object& out);
+  void SetAntennaChangeListener(const picojson::value& args, picojson::object& out);
+  void UnsetAntennaChangeListener(const picojson::value& args, picojson::object& out);
+};
+
+}
+}
+
+#endif
index c313651bdee6ac790ae2d7cceb039e8283cde722..76449442937aada0184f9342d02264b5c53670c7 100644 (file)
@@ -28,6 +28,7 @@
               'power/power.gyp:*',
               'bookmark/bookmark.gyp:*',
               'systeminfo/systeminfo.gyp:*',
+              'radio/radio.gyp:*',
             ],
           },
         ], # end mobile