From: Pawel Sikorski Date: Wed, 22 Jul 2015 08:20:06 +0000 (+0200) Subject: TV related code removal X-Git-Tag: submit/tizen_tv/20150803.021740^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9bf426b77e467319e2b31780bbb3edf1121d79dd;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git TV related code removal tizen_3.0 branch should not include TV related code Task: http://168.219.209.56/jira/browse/XWALK-587 Change-Id: Ic1dbfac08fcd1371a85fba5d4d72be84f9f9f341 Signed-off-by: Pawel Sikorski --- diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 5b37f23a..e4f0d500 100755 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -111,12 +111,7 @@ Source0: %{name}-%{version}.tar.gz # I586 %define tizen_feature_wi_fi_support 0 %endif -%define tizen_feature_tvaudio_support 0 -%define tizen_feature_tvchannel_support 0 -%define tizen_feature_tv_display_support 0 -%define tizen_feature_tvinputdevice_support 0 %define tizen_feature_inputdevice_support 1 -%define tizen_feature_tvwindow_support 0 %if 0%{?tizen_feature_telephony_support} %define tizen_feature_callhistory_support 1 @@ -208,12 +203,7 @@ Source0: %{name}-%{version}.tar.gz %define tizen_feature_time_support 1 %define tizen_feature_web_setting_support 0 %define tizen_feature_wi_fi_support 1 -%define tizen_feature_tvaudio_support 0 -%define tizen_feature_tvchannel_support 0 -%define tizen_feature_tv_display_support 0 -%define tizen_feature_tvinputdevice_support 0 %define tizen_feature_inputdevice_support 1 -%define tizen_feature_tvwindow_support 0 #- telephony related APIs # CallHistory API is optional in Tizen Wearable Profile. @@ -275,15 +265,7 @@ Source0: %{name}-%{version}.tar.gz %define tizen_feature_time_support 1 %define tizen_feature_web_setting_support 1 %define tizen_feature_wi_fi_support 1 -#off for tizen 3.0 (no libavoc) -%define tizen_feature_tvaudio_support 0 -#off for tizen 3.0 (no tvs-api) -%define tizen_feature_tvchannel_support 0 -#off for tizen 3.0 (no systeminfo definitions) -%define tizen_feature_tv_display_support 0 -%define tizen_feature_tvinputdevice_support 1 %define tizen_feature_inputdevice_support 1 -%define tizen_feature_tvwindow_support 0 %endif # tizen_profile_tv @@ -412,16 +394,6 @@ BuildRequires: pkgconfig(contacts-service2) BuildRequires: pkgconfig(contacts-service2) %endif -%if 0%{?tizen_feature_tvchannel_support} -BuildRequires: pkgconfig(tvs-api) -%endif - -%if 0%{?tizen_feature_tvwindow_support} -#TODO Currently, TVWindow does not have implementation yet. -#Hence, below dependency can be disabled (there is no tvs-api on tizen 3.0 yet) -#BuildRequires: pkgconfig(tvs-api) -%endif - %if 0%{?tizen_feature_exif_support} BuildRequires: pkgconfig(libexif) %endif @@ -434,11 +406,6 @@ BuildRequires: pkgconfig(capi-network-nfc) BuildRequires: pkgconfig(capi-media-radio) %endif -%if 0%{?tizen_feature_tvaudio_support} -BuildRequires: pkgconfig(libavoc) -BuildRequires: pkgconfig(capi-media-audio-io) -%endif - %if 0%{?tizen_feature_se_support} BuildRequires: pkgconfig(smartcard-service) BuildRequires: pkgconfig(smartcard-service-common) @@ -526,12 +493,7 @@ GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_system_info_support=%{?tizen_feature_s GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_system_setting_support=%{?tizen_feature_system_setting_support}" GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_telephony_support=%{?tizen_feature_telephony_support}" GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_time_support=%{tizen_feature_time_support}" -GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_tvaudio_support=%{?tizen_feature_tvaudio_support}" -GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_tvchannel_support=%{?tizen_feature_tvchannel_support}" -GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_tv_display_support=%{?tizen_feature_tv_display_support}" -GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_tvinputdevice_support=%{?tizen_feature_tvinputdevice_support}" GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_inputdevice_support=%{?tizen_feature_inputdevice_support}" -GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_tvwindow_support=%{?tizen_feature_tvwindow_support}" GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_web_setting_support=%{?tizen_feature_web_setting_support}" GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_wi_fi_support=%{?tizen_feature_wi_fi_support}" @@ -562,13 +524,6 @@ install -p -m 644 tools/js_minimize.py %{buildroot}%{_includedir}/%{name}/tools cp -a tools/gyp %{buildroot}%{_includedir}/%{name}/tools/gyp cp -a tools/slimit %{buildroot}%{_includedir}/%{name}/tools/slimit -%if 0%{?tizen_feature_tvaudio_support} -# tv audio beep files: -%define ringtones_directory /opt/usr/share/settings/Ringtones/ -mkdir -p %{buildroot}%{ringtones_directory} -cp res/tvsounds/*.pcm %{buildroot}%{ringtones_directory} -%endif - # execute desc_gentool LD_LIBRARY_PATH=$LD_LIBRARY_PATH:%{buildroot}%{_libdir}/%{crosswalk_extensions} out/Default/desc_gentool %{buildroot}%{_libdir}/%{crosswalk_extensions} > plugins.json @@ -582,11 +537,6 @@ install -p -m 644 plugins.json %{buildroot}%{_libdir}/%{crosswalk_extensions}/pl %{_datadir}/license/%{name} %manifest webapi-plugins.manifest -%if 0%{?tizen_feature_tvaudio_support} -# tv audio beep files: -%{ringtones_directory}/*.pcm -%endif - %files devel %{_includedir}/* %{_libdir}/pkgconfig/* diff --git a/src/tizen-wrt.gyp b/src/tizen-wrt.gyp index 7b0e7ef6..82fe5fb9 100755 --- a/src/tizen-wrt.gyp +++ b/src/tizen-wrt.gyp @@ -266,27 +266,6 @@ ], }, ], - [ - 'tizen_feature_tv_display_support==1', { - 'dependencies': [ - 'tvdisplay/tvdisplay.gyp:*', - ], - }, - ], - [ - 'tizen_feature_tvaudio_support==1', { - 'dependencies': [ - 'tvaudio/tvaudio.gyp:*', - ], - }, - ], - [ - 'tizen_feature_tvinputdevice_support==1', { - 'dependencies': [ - 'tvinputdevice/tvinputdevice.gyp:*' - ], - }, - ], [ 'tizen_feature_inputdevice_support==1', { 'dependencies': [ @@ -294,20 +273,6 @@ ], }, ], - [ - 'tizen_feature_tvchannel_support==1', { - 'dependencies': [ - 'tvchannel/tvchannel.gyp:*', - ], - }, - ], - [ - 'tizen_feature_tvwindow_support==1', { - 'dependencies': [ - 'tvwindow/tvwindow.gyp:*', - ], - }, - ], [ 'tizen_feature_web_setting_support==1', { 'dependencies': [ diff --git a/src/tvaudio/tvaudio.gyp b/src/tvaudio/tvaudio.gyp deleted file mode 100644 index 2bbebfa8..00000000 --- a/src/tvaudio/tvaudio.gyp +++ /dev/null @@ -1,38 +0,0 @@ -{ - 'includes':[ - '../common/common.gypi', - ], - 'targets': [ - { - 'target_name': 'tizen_tvaudio', - 'type': 'loadable_module', - 'dependencies': [ - '../common/common.gyp:tizen_common', - ], - 'sources': [ - 'tvaudio_api.js', - 'tvaudio_extension.cc', - 'tvaudio_extension.h', - 'tvaudio_instance.cc', - 'tvaudio_instance.h', - 'tvaudio_manager.cc', - 'tvaudio_manager.h' - ], - 'includes': [ - '../common/pkg-config.gypi', - ], - 'conditions': [ - ['tizen == 1', { - 'variables': { - 'packages': [ - 'glib-2.0', - 'libavoc', - 'capi-media-audio-io', - 'capi-media-sound-manager', - ] - }, - }], - ], - }, - ], -} diff --git a/src/tvaudio/tvaudio_api.js b/src/tvaudio/tvaudio_api.js deleted file mode 100644 index 42c76f24..00000000 --- a/src/tvaudio/tvaudio_api.js +++ /dev/null @@ -1,244 +0,0 @@ -/* - * 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. - */ - -var native = new xwalk.utils.NativeManager(extension); -var validator = xwalk.utils.validator; -var types = validator.Types; - - -/** - * @type {string} - * @const - */ -var VOLUME_CHANGE_LISTENER = 'VolumeChangeCallback'; - - - -/** - * This class provides access to the API functionalities through - * the tizen.tvaudiocontrol interface. - * @constructor - */ -function AudioControlManager() { - if (!(this instanceof AudioControlManager)) { - throw new TypeError; - } -} - - - -/** - * Turns on or off the silent mode. - * @param {!boolean} mute The mute state - * (true = turn on the silent mode, false = turn off the silent mode) - */ - -AudioControlManager.prototype.setMute = function(mute) { - var args = validator.validateArgs(arguments, [ - {name: 'mute', type: types.BOOLEAN} - ]); - - var ret = native.callSync('AudioControlManager_setMute', { - mute: args.mute - }); - - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } -}; - - -/** - * Gets the mute state. - * @return {boolean} 'true' if sound is muted else 'false' - */ -AudioControlManager.prototype.isMute = function() { - var ret = native.callSync('AudioControlManager_isMute'); - - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } - - return native.getResultObject(ret); -}; - - -/** - * Changes the volume level. - * @param {!number} volume The value of volume - * (the available volume range is 0 ~ 100) - */ -AudioControlManager.prototype.setVolume = function(volume) { - - var args = validator.validateArgs(arguments, [ - {name: 'volume', type: types.UNSIGNED_LONG} - ]); - - if (args.volume < 0 || args.volume > 100) { - throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, - 'Volume is out of range: ' + args.volume, 'InvalidValuesError'); - } - - if (arguments.length < 1) { - throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, - 'no volume argument: ' + arguments.length, 'InvalidValuesError'); - } - - var ret = native.callSync('AudioControlManager_setVolume', { - volume: args.volume - }); - - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } -}; - - -/** - * Increases the volume by 1 level. - */ -AudioControlManager.prototype.setVolumeUp = function() { - var ret = native.callSync('AudioControlManager_setVolumeUp'); - - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } -}; - - -/** - * Decreases the volume by 1 level. - */ -AudioControlManager.prototype.setVolumeDown = function() { - var ret = native.callSync('AudioControlManager_setVolumeDown'); - - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } -}; - - -/** - * Gets the current volume level. - * @return {number} The current volume (the volume range is 0 ~ 100) - */ -AudioControlManager.prototype.getVolume = function() { - var ret = native.callSync('AudioControlManager_getVolume'); - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } - return native.getResultObject(ret); -}; - - -/** - * Registers a volume change callback for getting notified - * when TV volume has been changed. - * - * @param {!function} listener The method to invoke - * when the volume has been changed. - */ -AudioControlManager.prototype.setVolumeChangeListener = function(listener) { - var args = validator.validateArgs(arguments, [ - {name: 'listener', type: types.FUNCTION} - ]); - - native.removeListener(VOLUME_CHANGE_LISTENER); - - var ret = native.callSync('AudioControlManager_setVolumeChangeListener'); - - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } - - native.addListener(VOLUME_CHANGE_LISTENER, function(msg) { - args.listener(msg.volume); - }); -}; - - -/** - * Unregisters the volume change callback for detecting the volume changes. - */ -AudioControlManager.prototype.unsetVolumeChangeListener = function() { - var ret = native.callSync('AudioControlManager_unsetVolumeChangeListener'); - - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } - - native.removeListener(VOLUME_CHANGE_LISTENER); -}; - - -/** - * Gets the current audio output mode. - * @return {AudioOutputMode} The current audio output mode - */ -AudioControlManager.prototype.getOutputMode = function() { - var ret = native.callSync('AudioControlManager_getOutputMode'); - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } - return native.getResultObject(ret); -}; - - -/** - * Allowed types of sound - * They should correspond to values in native layer and .pcm files - */ -var AudioBeepType = [ - 'MOVE', // indented use the same sound - 'UP', - 'DOWN', - 'LEFT', - 'RIGHT', - 'PAGE_LEFT', - 'PAGE_RIGHT', - 'BACK', - 'SELECT', - 'CANCEL', - 'WARNING', - 'KEYPAD', - 'KEYPAD_ENTER', - 'KEYPAD_DEL', - 'PREPARING' -]; -Object.freeze(AudioBeepType); - - -/** - * Plays one of specific sounds. - * @param {!AudioBeepType} beep The Sound to play. - */ -AudioControlManager.prototype.playSound = function(beep) { - var args = validator.validateArgs(arguments, [{ - name: 'type', - type: validator.Types.ENUM, - values: AudioBeepType // AudioBeepType - }]); - - var ret = native.callSync('AudioControlManager_playSound', - {type: args.type}); - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } - return; -}; - -// Exports -exports = new AudioControlManager(); diff --git a/src/tvaudio/tvaudio_extension.cc b/src/tvaudio/tvaudio_extension.cc deleted file mode 100644 index 1cf303bd..00000000 --- a/src/tvaudio/tvaudio_extension.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 "tvaudio/tvaudio_extension.h" -#include "tvaudio/tvaudio_instance.h" - -// This will be generated from tvaudio_api.js -extern const char kSource_tvaudio_api[]; - -namespace extension { -namespace tvaudio { - -TVAudioExtension::TVAudioExtension() { - SetExtensionName("tizen.tvaudiocontrol"); - SetJavaScriptAPI(kSource_tvaudio_api); -} - -TVAudioExtension::~TVAudioExtension() {} - -AudioControlManager& TVAudioExtension::manager() { - // Initialize API on first request - return AudioControlManager::getInstance(); -} - -common::Instance* TVAudioExtension::CreateInstance() { - return new TVAudioInstance; -} - -} // namespace tvaudio -} // namespace extension - -common::Extension* CreateExtension() { - return new extension::tvaudio::TVAudioExtension; -} diff --git a/src/tvaudio/tvaudio_extension.h b/src/tvaudio/tvaudio_extension.h deleted file mode 100644 index a53e2dc7..00000000 --- a/src/tvaudio/tvaudio_extension.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 SRC_TVAUDIO_TVAUDIO_EXTENSION_H_ -#define SRC_TVAUDIO_TVAUDIO_EXTENSION_H_ - -#include "common/extension.h" -#include "tvaudio/tvaudio_manager.h" - -namespace extension { -namespace tvaudio { - -class TVAudioExtension : public common::Extension { - public: - TVAudioExtension(); - virtual ~TVAudioExtension(); - - AudioControlManager& manager(); - - private: - virtual common::Instance* CreateInstance(); -}; - -} // namespace tvaudio -} // namespace extension - -#endif // SRC_TVAUDIO_TVAUDIO_EXTENSION_H_ - diff --git a/src/tvaudio/tvaudio_instance.cc b/src/tvaudio/tvaudio_instance.cc deleted file mode 100644 index bcf1b061..00000000 --- a/src/tvaudio/tvaudio_instance.cc +++ /dev/null @@ -1,210 +0,0 @@ -/* - * 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 -#include -#include - -#include "common/picojson.h" -#include "common/logger.h" -#include "common/platform_exception.h" - -#include "tvaudio/tvaudio_instance.h" -#include "tvaudio/tvaudio_manager.h" - -namespace extension { -namespace tvaudio { - -namespace { -const std::map AudioOutputModeMap = { - {PCM, "PCM"}, - {DOLBY, "DOLBY"}, - {DTS, "DTS"}, - {AAC, "AAC"} -}; -} // namespace - -TVAudioInstance::TVAudioInstance() { - LoggerD("Enter"); - using std::placeholders::_1; - using std::placeholders::_2; - #define REGISTER_SYNC(c, x) \ - RegisterSyncHandler(c, std::bind(&TVAudioInstance::x, this, _1, _2)); - REGISTER_SYNC("AudioControlManager_setMute", setMute); - REGISTER_SYNC("AudioControlManager_isMute", isMute); - REGISTER_SYNC("AudioControlManager_setVolume", setVolume); - REGISTER_SYNC("AudioControlManager_setVolumeUp", setVolumeUp); - REGISTER_SYNC("AudioControlManager_setVolumeDown", setVolumeDown); - REGISTER_SYNC("AudioControlManager_getVolume", getVolume); - REGISTER_SYNC("AudioControlManager_getOutputMode", getOutputMode); - REGISTER_SYNC("AudioControlManager_setVolumeChangeListener", setVolumeChangeListener); - REGISTER_SYNC("AudioControlManager_unsetVolumeChangeListener", unsetVolumeChangeListener); - REGISTER_SYNC("AudioControlManager_playSound", playSound); - #undef REGISTER_SYNC -} - -TVAudioInstance::~TVAudioInstance() { - LoggerD("Enter"); -} - -void TVAudioInstance::setMute(const picojson::value& args, - picojson::object& out) { - LoggerD("Enter"); - bool mute = args.get("mute").get(); - common::PlatformResult result = - AudioControlManager::getInstance().setMute(mute); - if (result.IsError()) { - LoggerD("Error occured"); - ReportError(result, &out); - } else { - picojson::value result; - ReportSuccess(result, out); - } -} - -void TVAudioInstance::isMute(const picojson::value& args, - picojson::object& out) { - LoggerD("Enter"); - bool mute; - common::PlatformResult result = - AudioControlManager::getInstance().isMute(mute); - if (result.IsError()) { - LoggerD("Error occured"); - ReportError(result, &out); - } else - ReportSuccess(picojson::value(mute), out); -} - -void TVAudioInstance::setVolume(const picojson::value& args, - picojson::object& out) { - LoggerD("Enter"); - double volume = args.get("volume").get(); - common::PlatformResult result = - AudioControlManager::getInstance().setVolume(volume); - if (result.IsError()) { - LoggerD("Error occured"); - ReportError(result, &out); - } else { - picojson::value result; - ReportSuccess(result, out); - } -} - -void TVAudioInstance::setVolumeUp(const picojson::value& args, - picojson::object& out) { - LoggerD("Enter"); - common::PlatformResult result = - AudioControlManager::getInstance().setVolumeUp(); - if (result.IsError()) { - LoggerD("Error occured"); - ReportError(result, &out); - } else { - picojson::value result; - ReportSuccess(result, out); - } -} - -void TVAudioInstance::setVolumeDown(const picojson::value& args, - picojson::object& out) { - LoggerD("Enter"); - common::PlatformResult result = - AudioControlManager::getInstance().setVolumeDown(); - if (result.IsError()) { - LoggerD("Error occured"); - ReportError(result, &out); - } else { - picojson::value result; - ReportSuccess(result, out); - } -} - -void TVAudioInstance::getVolume(const picojson::value& args, - picojson::object& out) { - LoggerD("Enter"); - u_int16_t volume; - common::PlatformResult result = - AudioControlManager::getInstance().getVolume(volume); - if (result.IsError()) { - LoggerD("Error occured"); - ReportError(result, &out); - } else { - picojson::value result = picojson::value(static_cast(volume)); - ReportSuccess(result, out); - } -} - -void TVAudioInstance::getOutputMode(const picojson::value& args, - picojson::object& out) { - LoggerD("Enter"); - AudioOutputMode mode; - common::PlatformResult result = - AudioControlManager::getInstance().getOutputMode(mode); - if (result.IsError()) { - LoggerD("Error occured"); - ReportError(result, &out); - } else if (AudioOutputModeMap.find(mode) == AudioOutputModeMap.end()) { - LoggerE("Unknown mode type: %d", mode); - ReportError(common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, - "Uknown audio output mode"), &out); - } else { - ReportSuccess(picojson::value(AudioOutputModeMap.at(mode)), out); - } -} - -void TVAudioInstance::setVolumeChangeListener(const picojson::value& args, - picojson::object& out) { - common::PlatformResult result = - AudioControlManager::getInstance().registerVolumeChangeListener(this); - if (result.IsError()) { - LoggerD("Error occured"); - ReportError(result, &out); - } else { - picojson::value result; - ReportSuccess(result, out); - } -} - -void TVAudioInstance::unsetVolumeChangeListener(const picojson::value& args, - picojson::object& out) { - AudioControlManager::getInstance().unregisterVolumeChangeListener(); - ReportSuccess(out); -} - -void TVAudioInstance::onVolumeChangeCallback(u_int16_t volume) { - LoggerD("Enter"); - picojson::value event = picojson::value(picojson::object()); - picojson::object& obj = event.get(); - obj["listenerId"] = picojson::value("VolumeChangeCallback"); - obj["volume"] = picojson::value(static_cast(volume)); - PostMessage(event.serialize().c_str()); -} - -void TVAudioInstance::playSound(const picojson::value& args, - picojson::object& out) { - const std::string& type = args.get("type").to_str(); - common::PlatformResult result = - AudioControlManager::getInstance().playSound(type); - if (result.IsError()) { - LoggerD("Error occured"); - ReportError(result, &out); - } else { - picojson::value result; - ReportSuccess(result, out); - } -} - -} // namespace tvaudio -} // namespace extension diff --git a/src/tvaudio/tvaudio_instance.h b/src/tvaudio/tvaudio_instance.h deleted file mode 100644 index cf27c0dd..00000000 --- a/src/tvaudio/tvaudio_instance.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 SRC_TVAUDIO_TVAUDIO_INSTANCE_H_ -#define SRC_TVAUDIO_TVAUDIO_INSTANCE_H_ - -#include "common/extension.h" - -#include "tvaudio/tvaudio_manager.h" - -namespace extension { -namespace tvaudio { - -class TVAudioInstance : - public common::ParsedInstance, - public VolumeChangeListener { - public: - TVAudioInstance(); - virtual ~TVAudioInstance(); - - private: - void setMute(const picojson::value& args, picojson::object& out); - void isMute(const picojson::value& args, picojson::object& out); - void setVolume(const picojson::value& args, picojson::object& out); - void setVolumeUp(const picojson::value& args, picojson::object& out); - void setVolumeDown(const picojson::value& args, picojson::object& out); - void getVolume(const picojson::value& args, picojson::object& out); - void getOutputMode(const picojson::value& args, picojson::object& out); - void setVolumeChangeListener(const picojson::value& args, picojson::object& out); - void unsetVolumeChangeListener(const picojson::value& args, picojson::object& out); - virtual void onVolumeChangeCallback(u_int16_t volume); - void playSound(const picojson::value& args, picojson::object& out); -}; - -} // namespace tvaudio -} // namespace extension - -#endif // SRC_TVAUDIO_TVAUDIO_INSTANCE_H_ diff --git a/src/tvaudio/tvaudio_manager.cc b/src/tvaudio/tvaudio_manager.cc deleted file mode 100755 index 048f8599..00000000 --- a/src/tvaudio/tvaudio_manager.cc +++ /dev/null @@ -1,379 +0,0 @@ -/* - * 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 "tvaudio/tvaudio_manager.h" - -#include -#include -#include -#include -#include - -#include // NOLINT (readability/streams) -// this flag is no longer enforced in the newest cpplint.py - -#include -#include - -#include "common/logger.h" -#include "common/platform_exception.h" - - -namespace extension { -namespace tvaudio { - -using common::UnknownException; -using common::InvalidValuesException; -using common::ErrorCode; - -namespace { -const int AVOC_SUCCESS = 0; -const u_int16_t VOLUME_STEP = 1; -} - -VolumeChangeListener::~VolumeChangeListener() { - LoggerD("Enter"); -} - -AudioControlManager::AudioControlManager() : - m_volume_step(VOLUME_STEP), - m_volume_change_listener(NULL), - m_playThreadIdInit(false) { - LoggerD("Enter"); - m_playData.stopSound = false; -} - -AudioControlManager::~AudioControlManager() { - LoggerD("Enter"); -} - -AudioControlManager& AudioControlManager::getInstance() { - static AudioControlManager instance; - return instance; -} - -common::PlatformResult AudioControlManager::setMute(bool mute) { - LoggerD("Enter"); - int ret = sound_manager_set_master_mute(mute); - if (SOUND_MANAGER_ERROR_NONE != ret) { - LoggerE("Failed to change mute state: %d", ret); - return common::PlatformResult(ErrorCode::UNKNOWN_ERR, - "Unknown error. Failed to change mute state"); - } - return common::PlatformResult(ErrorCode::NO_ERROR); -} - -common::PlatformResult AudioControlManager::isMute(bool &isMute) { - LoggerD("Enter"); - int ret = sound_manager_get_master_mute(&isMute); - if (SOUND_MANAGER_ERROR_NONE != ret) { - LoggerE("Failed to get mute state: %d", ret); - return common::PlatformResult(ErrorCode::UNKNOWN_ERR, - "Unknown error. Failed to get mute state"); - } - LoggerD("Mute state: %d", isMute); - return common::PlatformResult(ErrorCode::NO_ERROR); -} - -common::PlatformResult AudioControlManager::setVolume(u_int16_t volume) { - LoggerD("Enter. Volume: %d", volume); - if (volume > 100) { - LoggerE("Invalid volume number"); - return common::PlatformResult(ErrorCode::INVALID_VALUES_ERR, - "Invalid volume number"); - } - int ret = sound_manager_set_master_volume(volume); - if (SOUND_MANAGER_ERROR_NONE != ret) { - LoggerE("Failed to set volume: %d", ret); - return common::PlatformResult(ErrorCode::UNKNOWN_ERR, - "Unknown error. Failed to set volume"); - } - return common::PlatformResult(ErrorCode::NO_ERROR); -} - -common::PlatformResult AudioControlManager::setVolumeUp() { - LoggerD("Enter"); - common::PlatformResult ret(ErrorCode::NO_ERROR); - u_int16_t currentVolume; - ret = getVolume(currentVolume); - if (ret.IsError()) - return ret; - if (currentVolume < 100) { - ret = setVolume(currentVolume + m_volume_step <= 100 ? - currentVolume + m_volume_step : 100); - if (ret.IsError()) - return ret; - } - bool muteState; - ret = isMute(muteState); - if (ret.IsError()) - return ret; - if (muteState) { - return setMute(false); - } - return common::PlatformResult(ErrorCode::NO_ERROR); -} - -common::PlatformResult AudioControlManager::setVolumeDown() { - LoggerD("Enter"); - common::PlatformResult ret(ErrorCode::NO_ERROR); - u_int16_t currentVolume; - ret = getVolume(currentVolume); - if (ret.IsError()) - return ret; - if (currentVolume > 0) { - ret = setVolume(currentVolume >= m_volume_step ? - currentVolume - m_volume_step : 0); - if (ret.IsError()) - return ret; - } - bool muteState; - ret = isMute(muteState); - if (ret.IsError()) - return ret; - if (muteState) { - return setMute(false); - } - return common::PlatformResult(ErrorCode::NO_ERROR); -} - -common::PlatformResult AudioControlManager::getVolume(u_int16_t &volume) { - LoggerD("Enter"); - int tempVolume; - int ret = sound_manager_get_master_volume(&tempVolume); - if (SOUND_MANAGER_ERROR_NONE != ret) { - LoggerE("Failed to get volume: %d", ret); - return common::PlatformResult(ErrorCode::UNKNOWN_ERR, - "Unknown error. Failed to get volume"); - } - LoggerD("Volume: %d", volume); - volume = tempVolume; - return common::PlatformResult(ErrorCode::NO_ERROR); -} - -common::PlatformResult AudioControlManager::getOutputMode(AudioOutputMode &mode) { - LoggerD("Enter"); - avoc_audio_format_e type; - int ret = avoc_get_audio_format(&type); - if (AVOC_SUCCESS != ret) { - LoggerE("Failed to get audio output type: %d", ret); - return common::PlatformResult(ErrorCode::UNKNOWN_ERR, - "Unknown error. Failed to get audio output type"); - } - switch (type) { - case AVOC_AUDIO_FORMAT_PCM: - mode = AudioOutputMode::PCM; - break; - case AVOC_AUDIO_FORMAT_ES_DOLBY_DIGITAL: - mode = AudioOutputMode::DOLBY; - break; - case AVOC_AUDIO_FORMAT_ES_DTS: - case AVOC_AUDIO_FORMAT_NEO_ES_DTS: - mode = AudioOutputMode::DTS; - break; - case AVOC_AUDIO_FORMAT_ES_AAC: - mode = AudioOutputMode::AAC; - break; - default: - LoggerE("Unexpected audio output type: %d", type); - return common::PlatformResult(ErrorCode::UNKNOWN_ERR, - "Unexecpted audio output type"); - } - return common::PlatformResult(ErrorCode::NO_ERROR); -} - -common::PlatformResult AudioControlManager::registerVolumeChangeListener( - VolumeChangeListener* listener) { - LoggerD("Enter"); - unregisterVolumeChangeListener(); - int r = sound_manager_set_master_volume_changed_cb( - volumeChangeCallback, NULL); - if (SOUND_MANAGER_ERROR_NONE != r) { - LoggerE("Failed to add listener: %d", r); - return common::PlatformResult(ErrorCode::UNKNOWN_ERR, - "Failed to add listener"); - } - m_volume_change_listener = listener; - LoggerD("Added listener"); - return common::PlatformResult(ErrorCode::NO_ERROR); -} - -common::PlatformResult AudioControlManager::unregisterVolumeChangeListener() { - LoggerD("Enter"); - int r = sound_manager_unset_master_volume_changed_cb(); - if (SOUND_MANAGER_ERROR_NONE != r) { - LoggerW("Failed to remove listener: %d", r); - return common::PlatformResult(ErrorCode::UNKNOWN_ERR, - "Failed to remove listener"); - } - m_volume_change_listener = NULL; - return common::PlatformResult(ErrorCode::NO_ERROR); -} - -void AudioControlManager::volumeChangeCallback( - unsigned int /*volume*/, - void* /*user_data*/) { - LoggerD("Enter"); - if (!g_idle_add(onVolumeChange, NULL)) { - LoggerW("Failed to add to g_idle"); - } -} - -gboolean AudioControlManager::onVolumeChange(gpointer /*user_data*/) { - LoggerD("Enter"); - if (!getInstance().m_volume_change_listener) { - LoggerD("Listener is null. Ignoring"); - return G_SOURCE_REMOVE; - } - u_int16_t val; - common::PlatformResult ret = getInstance().getVolume(val); - if (ret.IsError()) { - LoggerE("Failed to retrieve volume level"); - } - getInstance().m_volume_change_listener->onVolumeChangeCallback(val); - return G_SOURCE_REMOVE; -} - -/** - * Play one of predefined sounds - * - * If sound is already played it is replaced by the new sound - */ -common::PlatformResult AudioControlManager::playSound(const std::string &type) { - LoggerD("Enter"); - const auto beep = SoundMap.find(type); - if (beep == SoundMap.end()) { - return common::PlatformResult(ErrorCode::UNKNOWN_ERR, - "Unknown error. Unknown beep type: " + type); - } - - if (m_playThreadIdInit) { - m_playData.stopSound = true; - pthread_join(m_playThreadId, NULL); - m_playData.stopSound = false; - } - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - - m_playData.beep_type = beep->first; - m_playData.filename = beep->second; - - if (0 == pthread_create(&m_playThreadId, &attr, play, &m_playData )) { - m_playThreadIdInit = true; - } else { - LoggerE("Failed to create pthread"); - return common::PlatformResult(ErrorCode::UNKNOWN_ERR, - "Failed to create pthread to play sound"); - } - return common::PlatformResult(ErrorCode::NO_ERROR); -} - -void* AudioControlManager::play(void* play_data) { - LoggerD("Enter"); - PlayData* pData = static_cast(play_data); - - LoggerD("Beep type: %s", pData->beep_type.c_str()); - - const std::string& filename = pData->filename; - std::unique_ptr > pBuffer = - AudioControlManager::loadFile(filename); - - audio_out_h handle; - int error = audio_out_create(SAMPLING_FREQ, - AUDIO_CHANNEL_STEREO, - AUDIO_SAMPLE_TYPE_S16_LE, - SOUND_TYPE_NOTIFICATION, - &handle); - if (AUDIO_IO_ERROR_NONE != error) { - LoggerE("Failed to open audio output: %d", error); - return NULL; - } - - error = audio_out_prepare(handle); - if (AUDIO_IO_ERROR_NONE != error) { - LoggerE("Failed to open audio output: %d", error); - audio_out_destroy(handle); - return NULL; - } - - int counter = 0; - int dataLeftSize = pBuffer->size(); - while ((!pData->stopSound) && (dataLeftSize > 0)) { - if ((dataLeftSize - AudioControlManager::CHUNK) < 0) { - dataLeftSize = dataLeftSize; - error = audio_out_write(handle, - &(*pBuffer)[counter], - dataLeftSize); - if (dataLeftSize != error) { - LoggerE("Failed to write to audio output: %d", error); - audio_out_destroy(handle); - return NULL; - } - break; - } else { - dataLeftSize = dataLeftSize - AudioControlManager::CHUNK; - error = audio_out_write(handle, - &(*pBuffer)[counter], - AudioControlManager::CHUNK); - if (AudioControlManager::CHUNK != error) { - LoggerE("Failed to write to audio output: %d", error); - audio_out_destroy(handle); - return NULL; - } - } - counter += AudioControlManager::CHUNK; - } // while - audio_out_destroy(handle); - return NULL; -} - -std::unique_ptr > -AudioControlManager::loadFile(const std::string& filename) { - LoggerD("Enter"); - std::unique_ptr> pBuffer(new std::vector()); - std::ifstream file(filename.c_str(), - (std::ios::binary | std::ios::in | std::ios::ate)); - if (!file.is_open()) { - LoggerE("Could not open file %s", filename.c_str()); - return std::unique_ptr< std::vector>(); - } - - std::ifstream::pos_type size = file.tellg(); - if (size < 0) { - file.close(); - LoggerE("Failed to open file %s - incorrect size", filename.c_str()); - return std::unique_ptr>(); - } - - LoggerD("resizing"); - pBuffer->resize(size); - LoggerD("resized"); - file.seekg(0, std::ios::beg); - if (!file.read(&(*pBuffer)[0], size)) { - file.close(); - LoggerE("Failed to read audio file %s", filename.c_str()); - return std::unique_ptr >(); - } - file.close(); - - LoggerD("Got buffer"); - return pBuffer; -} - -} // namespace tvaudio -} // namespace extension - diff --git a/src/tvaudio/tvaudio_manager.h b/src/tvaudio/tvaudio_manager.h deleted file mode 100755 index 3683e463..00000000 --- a/src/tvaudio/tvaudio_manager.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include - -#ifndef SRC_TVAUDIO_TVAUDIO_MANAGER_H_ -#define SRC_TVAUDIO_TVAUDIO_MANAGER_H_ - - -#include -#include "common/platform_result.h" - -namespace extension { -namespace tvaudio { - -enum AudioOutputMode { - PCM = 0, - DOLBY, - DTS, - AAC -}; - -class VolumeChangeListener { - public: - virtual void onVolumeChangeCallback(u_int16_t volume) = 0; - virtual ~VolumeChangeListener(); -}; - -class AudioControlManager { - public: - common::PlatformResult setMute(bool mute); - common::PlatformResult isMute(bool &isMute); - common::PlatformResult setVolume(u_int16_t volume); - common::PlatformResult setVolumeUp(); - common::PlatformResult setVolumeDown(); - common::PlatformResult playSound(const std::string &type); - common::PlatformResult getVolume(u_int16_t &volume); - common::PlatformResult getOutputMode(AudioOutputMode &mode); - common::PlatformResult registerVolumeChangeListener(VolumeChangeListener* listener); - common::PlatformResult unregisterVolumeChangeListener(); - static void volumeChangeCallback(unsigned int volume, void* user_data); - static gboolean onVolumeChange(gpointer user_data); - - // Non-copyable, -assignable, -movable - AudioControlManager(const AudioControlManager &) = delete; - AudioControlManager(AudioControlManager &&) = delete; - AudioControlManager& operator=(const AudioControlManager &) & = delete; - AudioControlManager& operator=(AudioControlManager &&) & = delete; - - static AudioControlManager& getInstance(); - - virtual ~AudioControlManager(); - - private: - u_int16_t m_volume_step; - VolumeChangeListener* m_volume_change_listener; - AudioControlManager(); - - static const int CHUNK = 768; - static const int SAMPLING_FREQ = 44100; - - static void* play(void* _args); - - bool m_playThreadIdInit; - pthread_t m_playThreadId; - - static std::unique_ptr> - loadFile(const std::string& filename); - - // key : sound file path - const std::map SoundMap = { - {"MOVE", "/opt/usr/share/settings/Ringtones/move.pcm"}, - {"UP", "/opt/usr/share/settings/Ringtones/move.pcm"}, - {"DOWN", "/opt/usr/share/settings/Ringtones/move.pcm"}, - {"LEFT", "/opt/usr/share/settings/Ringtones/move.pcm"}, - {"RIGHT", "/opt/usr/share/settings/Ringtones/move.pcm"}, - {"PAGE_LEFT", "/opt/usr/share/settings/Ringtones/move.pcm"}, - {"PAGE_RIGHT", "/opt/usr/share/settings/Ringtones/move.pcm"}, - - {"BACK", "/opt/usr/share/settings/Ringtones/back.pcm"}, - {"SELECT", "/opt/usr/share/settings/Ringtones/select.pcm"}, - {"CANCEL", "/opt/usr/share/settings/Ringtones/cancel.pcm"}, - {"WARNING", "/opt/usr/share/settings/Ringtones/enter.pcm"}, - {"KEYPAD", "/opt/usr/share/settings/Ringtones/keypad.pcm"}, - {"KEYPAD_ENTER", "/opt/usr/share/settings/Ringtones/enter.pcm"}, - {"KEYPAD_DEL", "/opt/usr/share/settings/Ringtones/del.pcm"}, - {"PREPARING", "/opt/usr/share/settings/Ringtones/preparing.pcm"}, - }; - struct PlayData { - std::atomic stopSound; - std::string beep_type; - std::string filename; - }; - PlayData m_playData; -}; - -} // namespace tvaudio -} // namespace extension - -#endif // SRC_TVAUDIO_TVAUDIO_MANAGER_H_ - diff --git a/src/tvchannel/channel_info.cc b/src/tvchannel/channel_info.cc deleted file mode 100644 index 0e526a5c..00000000 --- a/src/tvchannel/channel_info.cc +++ /dev/null @@ -1,161 +0,0 @@ -/* - * 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 "tvchannel/channel_info.h" -#include -#include -#include "tvchannel/tvchannel_manager.h" -#include "common/logger.h" - -namespace extension { -namespace tvchannel { - -ChannelInfo::ChannelInfo() : - m_major(0), m_minor(0), m_channelName(""), m_programNumber(0), m_ptc(0), - m_lcn(0), m_sourceID(0), m_transportStreamID(0), m_originalNetworkID(0), - m_serviceName(""), m_serviceID(0) { -} - -ChannelInfo::~ChannelInfo() { -} - -void ChannelInfo::fromApiData(const TCServiceData &channelData) { - LoggerD("Enter"); - m_ptc = channelData.Get(CHANNEL_NUMBER); - m_major = channelData.Get(MAJOR); - m_minor = channelData.Get(MINOR); - m_lcn = channelData.Get(LCN); - m_sourceID = channelData.Get(SOURCE_ID); - m_programNumber = channelData.Get(PROGRAM_NUMBER); - m_transportStreamID = channelData.Get(TRANSPORT_STREAM_ID); - m_originalNetworkID = channelData.Get(ORIGINAL_NETWORK_ID); - m_serviceID = channelData.Get < TCServiceId > (SERVICE_ID); - - setChannelName(channelData); - setServiceName(channelData); -} - -int64_t ChannelInfo::getMajor() const { - return m_major; -} - -void ChannelInfo::setMajor(int64_t major) { - m_major = major; -} - -int64_t ChannelInfo::getMinor() const { - return m_minor; -} - -void ChannelInfo::setMinor(int64_t minor) { - m_minor = minor; -} - -std::string ChannelInfo::getChannelName() const { - return m_channelName; -} - -void ChannelInfo::setChannelName(std::string channelName) { - m_channelName = channelName; -} - -void ChannelInfo::setChannelName(const TCServiceData &channelData) { - LoggerD("Enter"); - size_t len = channelData.GetLength(SERVICE_NAME); - if (len) { - LoggerD("ServiceName length %d", len); - size_t c_len = len * sizeof(t_wchar_t) / sizeof(char); - t_wchar_t svc_name[len + 1]; - channelData.Get(SERVICE_NAME, svc_name); - char name[CHANNEL_NAME_MAX_SIZE]; - TVChannelManager::ucs2utf8(name, sizeof(name), - reinterpret_cast(svc_name), c_len); - m_channelName = name; - } else { - m_channelName = ""; - } -} - -int64_t ChannelInfo::getProgramNumber() const { - return m_programNumber; -} - -void ChannelInfo::setProgramNumber(int64_t programNumber) { - m_programNumber = programNumber; -} - -int64_t ChannelInfo::getPtc() const { - return m_ptc; -} - -void ChannelInfo::setPtc(int64_t ptc) { - m_ptc = ptc; -} - -int64_t ChannelInfo::getLcn() const { - return m_lcn; -} - -void ChannelInfo::setLcn(int64_t lcn) { - m_lcn = lcn; -} - -int64_t ChannelInfo::getSourceID() const { - return m_sourceID; -} - -void ChannelInfo::setSourceID(int64_t sourceID) { - m_sourceID = sourceID; -} - -int64_t ChannelInfo::getTransportStreamID() const { - return m_transportStreamID; -} - -void ChannelInfo::setTransportStreamID(int64_t transportStreamID) { - m_transportStreamID = transportStreamID; -} - -int64_t ChannelInfo::getOriginalNetworkID() const { - return m_originalNetworkID; -} - -void ChannelInfo::setOriginalNetworkID(int64_t originalNetworkID) { - m_originalNetworkID = originalNetworkID; -} - -std::string ChannelInfo::getServiceName() const { - return getChannelName(); -} - -void ChannelInfo::setServiceName(std::string serviceName) { - setChannelName(serviceName); -} - -void ChannelInfo::setServiceName(const TCServiceData &data) { - setChannelName(data); -} - -TCServiceId ChannelInfo::getServiceID() const { - return m_serviceID; -} - -void ChannelInfo::setServiceID(TCServiceId serviceID) { - m_serviceID = serviceID; -} - -} // namespace tvchannel -} // namespace extension diff --git a/src/tvchannel/channel_info.h b/src/tvchannel/channel_info.h deleted file mode 100644 index b8eecc2e..00000000 --- a/src/tvchannel/channel_info.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 SRC_TVCHANNEL_CHANNEL_INFO_H_ -#define SRC_TVCHANNEL_CHANNEL_INFO_H_ - -#include -#include -#include "tvchannel/types.h" - -namespace extension { -namespace tvchannel { - -class ChannelInfo { - public: - ChannelInfo(); - virtual ~ChannelInfo(); - - void fromApiData(const TCServiceData &channelData); - - int64_t getMajor() const; - void setMajor(int64_t major); - - int64_t getMinor() const; - void setMinor(int64_t minor); - - std::string getChannelName() const; - void setChannelName(std::string channelName); - void setChannelName(const TCServiceData &channelData); - - int64_t getProgramNumber() const; - void setProgramNumber(int64_t programNumber); - - int64_t getPtc() const; - void setPtc(int64_t ptc); - - int64_t getLcn() const; - void setLcn(int64_t lcn); - - int64_t getSourceID() const; - void setSourceID(int64_t sourceID); - - int64_t getTransportStreamID() const; - void setTransportStreamID(int64_t transportStreamID); - - int64_t getOriginalNetworkID() const; - void setOriginalNetworkID(int64_t originalNetworkID); - - std::string getServiceName() const; - void setServiceName(std::string serviceName); - void setServiceName(const TCServiceData &channelData); - - TCServiceId getServiceID() const; - void setServiceID(TCServiceId serviceID); - - private: - int64_t m_major; - int64_t m_minor; - std::string m_channelName; - int64_t m_programNumber; - int64_t m_ptc; - int64_t m_lcn; - int64_t m_sourceID; - int64_t m_transportStreamID; - int64_t m_originalNetworkID; - std::string m_serviceName; - TCServiceId m_serviceID; - - static const int CHANNEL_NAME_MAX_SIZE = 128; -}; - -} // namespace tvchannel -} // namespace extension - -#endif // SRC_TVCHANNEL_CHANNEL_INFO_H_ diff --git a/src/tvchannel/criteria_filter.cc b/src/tvchannel/criteria_filter.cc deleted file mode 100644 index 942d7734..00000000 --- a/src/tvchannel/criteria_filter.cc +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 "tvchannel/criteria_filter.h" -#include - -namespace extension { -namespace tvchannel { - -CriteriaFilter::CriteriaFilter(EServiceMode _mode) : - m_mode(_mode) { -} - -void CriteriaFilter::filterWhere(int32_t columnName, - const int32_t columnValue) { - if (m_mode == SERVICE_MODE_ATSC && columnName == ORIGINAL_NETWORK_ID) { - LoggerD("ORIGINAL_NETWORK_ID not supported"); - return; - } - if ((m_mode == SERVICE_MODE_DVB || m_mode == SERVICE_MODE_DVBNT) - && (columnName == MINOR || columnName == SOURCE_ID)) { - LoggerD("%d not supported", columnName); - return; - } - if (m_mode == SERVICE_MODE_ISDB && columnName == SOURCE_ID) { - LoggerD("SOURCE_ID not supported"); - return; - } - - columnMap[columnName] = columnValue; -} - -void CriteriaFilter::getFilteredCriteria(std::unique_ptr < TCCriteriaHelper > & _pCriteria) { - for (auto it = columnMap.begin(); it != columnMap.end(); ++it) { - _pCriteria->Where(it->first, it->second); - } -} - -void CriteriaFilter::resetFilter() { - columnMap.clear(); -} - -} // namespace tvchannel -} // namespace extension diff --git a/src/tvchannel/criteria_filter.h b/src/tvchannel/criteria_filter.h deleted file mode 100644 index 7be9ab63..00000000 --- a/src/tvchannel/criteria_filter.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 SRC_TVCHANNEL_CRITERIA_FILTER_H_ -#define SRC_TVCHANNEL_CRITERIA_FILTER_H_ - -#include -#include -#include -#include -#include - -namespace extension { -namespace tvchannel { - -class CriteriaFilter { - public: - explicit CriteriaFilter(EServiceMode mode); - void filterWhere(int32_t columnName, const int32_t columnValue); - void getFilteredCriteria(std::unique_ptr < TCCriteriaHelper > & _pCriteria); - void resetFilter(); - private: - EServiceMode m_mode; - std::map columnMap; -}; - -} // namespace tvchannel -} // namespace extension - -#endif // SRC_TVCHANNEL_CRITERIA_FILTER_H_ diff --git a/src/tvchannel/program_info.cc b/src/tvchannel/program_info.cc deleted file mode 100644 index 2b7b740c..00000000 --- a/src/tvchannel/program_info.cc +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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 "tvchannel/program_info.h" -#include "tvchannel/tvchannel_manager.h" -#include "common/logger.h" - -namespace extension { -namespace tvchannel { - -ProgramInfo::ProgramInfo() : -m_title(""), -m_startTime(0), -m_duration(0), -m_detailedDescription(""), -m_language(""), -m_rating("") { -} - -ProgramInfo::~ProgramInfo() { -} - -void ProgramInfo::fromApiData(const TCProgramData &data) { - LoggerD("Enter"); - setTitle(data); - m_startTime = data.StartTime(); - m_duration = data.EndTime() - m_startTime; - setDetailedDescription(data); - setLanguage(data); -} - -std::string ProgramInfo::getTitle() const { - return m_title; -} - -void ProgramInfo::setTitle(const TCProgramData &data) { - LoggerD("Enter"); - try { - unsigned int len; - size_t c_len; - t_wchar_t *title; - - len = data.TitleLength(); - if (len) { - LoggerD("Title length %d", len); - title = new t_wchar_t[len + 1]; - TCProgramData copy = data; - copy.Title(title, &len); - c_len = len * sizeof (t_wchar_t) / sizeof (char); - char name[128]; - TVChannelManager::ucs2utf8(name, (size_t)sizeof (name), - reinterpret_cast(title), c_len); - delete [] title; - m_title = name; - } else { - m_title = ""; - } - } catch (...) { - LoggerD("There is some problem on text encoding."); - m_title = ""; - } -} - -void ProgramInfo::setTitle(std::string title) { - m_title = title; -} - -int64_t ProgramInfo::getStartTime() const { - return m_startTime; -} - -double ProgramInfo::getStartTimeMs() const { - return static_cast (m_startTime * 1000.0); -} - -void ProgramInfo::setStartTime(int64_t startTime) { - m_startTime = startTime; -} - -int64_t ProgramInfo::getDuration() const { - return m_duration; -} - -void ProgramInfo::setDuration(int64_t duration) { - m_duration = duration; -} - -std::string ProgramInfo::getDetailedDescription() const { - return m_detailedDescription; -} - -void ProgramInfo::setDetailedDescription(std::string detailedDescription) { - m_detailedDescription = detailedDescription; -} - -void ProgramInfo::setDetailedDescription(const TCProgramData &data) { - LoggerD("Enter"); - try { - unsigned int len; - size_t c_len; - t_wchar_t *description; - - len = data.ExtendedTextLength(); - LoggerD("Description length %d", len); - if (len) { - description = new t_wchar_t[len + 1]; - TCProgramData copy = data; - copy.ExtendedText(description, &len); - - c_len = len * sizeof (t_wchar_t) / sizeof (char); - char name[TCProgramData::EExtendChannelTextLength - ::EXTEND_CHANNEL_TEXT_LENGTH]; - TVChannelManager::ucs2utf8(name, (size_t)sizeof (name), - reinterpret_cast(description), c_len); - delete [] description; - m_detailedDescription = name; - } else { - m_detailedDescription = ""; - } - } catch (...) { - LoggerD("There is some problem on text encoding."); - m_detailedDescription = ""; - } -} - -std::string ProgramInfo::getLanguage() const { - return m_language; -} - -void ProgramInfo::setLanguage(std::string language) { - m_language = language; -} - -void ProgramInfo::setLanguage(const TCProgramData &data) { - // todo: convert language number to code? - m_language = std::to_string(data.Language()); -} - -std::string ProgramInfo::getRating() const { - return m_rating; -} - -void ProgramInfo::setRating(std::string rating) { - m_rating = rating; -} - - -} // namespace tvchannel -} // namespace extension diff --git a/src/tvchannel/program_info.h b/src/tvchannel/program_info.h deleted file mode 100644 index 41aa1d8b..00000000 --- a/src/tvchannel/program_info.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 SRC_TVCHANNEL_PROGRAM_INFO_H_ -#define SRC_TVCHANNEL_PROGRAM_INFO_H_ - -#include -#include - -#include "tvchannel/types.h" - -namespace extension { -namespace tvchannel { - -class ProgramInfo { - public: - ProgramInfo(); - virtual ~ProgramInfo(); - void fromApiData(const TCProgramData &data); - - std::string getTitle() const; - void setTitle(std::string title); - void setTitle(const TCProgramData &data); - - int64_t getStartTime() const; - double getStartTimeMs() const; - void setStartTime(int64_t startTime); - - int64_t getDuration() const; - void setDuration(int64_t duration); - - std::string getDetailedDescription() const; - void setDetailedDescription(std::string detailedDescription); - void setDetailedDescription(const TCProgramData &data); - - std::string getLanguage() const; - void setLanguage(std::string language); - void setLanguage(const TCProgramData &data); - - std::string getRating() const; - void setRating(std::string rating); - - private: - std::string m_title; - int64_t m_startTime; - int64_t m_duration; - std::string m_detailedDescription; - std::string m_language; - std::string m_rating; -}; - -} // namespace tvchannel -} // namespace extension - -#endif // SRC_TVCHANNEL_PROGRAM_INFO_H_ diff --git a/src/tvchannel/tune_option.cc b/src/tvchannel/tune_option.cc deleted file mode 100644 index fb3fb621..00000000 --- a/src/tvchannel/tune_option.cc +++ /dev/null @@ -1,170 +0,0 @@ -/* - * 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 "tvchannel/tune_option.h" -#include -#include - -namespace extension { -namespace tvchannel { - -TuneOption::TuneOption() { - initialize(); -} - -void TuneOption::initialize() { - m_ptc = 0; - m_major = 0; - m_minor = 0; - m_sourceID = 0; - m_programNumber = 0; - m_transportStreamID = 0; - m_originalNetworkID = 0; - m_ptc_is_set = false; - m_major_is_set = false; - m_minor_is_set = false; - m_sourceID_is_set = false; - m_programNumber_is_set = false; - m_transportStreamID_is_set = false; - m_originalNetworkID_is_set = false; -} - -TuneOption::~TuneOption() { -} - -TuneOption::TuneOption(picojson::object const& _tuneDict) { - LoggerD("Enter"); - initialize(); - picojson::object tuneDict = _tuneDict; - if (tuneDict.find("major") != tuneDict.end()) { - setMajor(static_cast(tuneDict["major"].get())); - } - if (tuneDict.find("minor") != tuneDict.end()) { - setMinor(static_cast(tuneDict["minor"].get())); - } - if (tuneDict.find("sourceID") != tuneDict.end()) { - setSourceID(static_cast(tuneDict["sourceID"].get())); - } - if (tuneDict.find("programNumber") != tuneDict.end()) { - setProgramNumber( - static_cast(tuneDict["programNumber"].get())); - } - if (tuneDict.find("transportStreamID") != tuneDict.end()) { - setTransportStreamID( - static_cast(tuneDict["transportStreamID"].get())); - } - if (tuneDict.find("ptc") != tuneDict.end()) { - setPtc(static_cast(tuneDict["ptc"].get())); - } - if (tuneDict.find("originalNetworkID") != tuneDict.end()) { - setOriginalNetworkID( - static_cast(tuneDict["originalNetworkID"].get())); - } -} - -int64_t TuneOption::getPtc() const { - return m_ptc; -} - -bool TuneOption::isPtcSet() const { - return m_ptc_is_set; -} - -void TuneOption::setPtc(int64_t ptc) { - m_ptc = ptc; - m_ptc_is_set = true; -} - -int64_t TuneOption::getMajor() const { - return m_major; -} - -bool TuneOption::isMajorSet() const { - return m_major_is_set; -} - -void TuneOption::setMajor(int64_t major) { - m_major = major; - m_major_is_set = true; -} - -int64_t TuneOption::getMinor() const { - return m_minor; -} - -bool TuneOption::isMinorSet() const { - return m_minor_is_set; -} - -void TuneOption::setMinor(int64_t minor) { - m_minor = minor; - m_minor_is_set = true; -} - -int64_t TuneOption::getSourceID() const { - return m_sourceID; -} - -bool TuneOption::isSourceIDSet() const { - return m_sourceID_is_set; -} - -void TuneOption::setSourceID(int64_t sourceID) { - m_sourceID = sourceID; - m_sourceID_is_set = true; -} - -int64_t TuneOption::getProgramNumber() const { - return m_programNumber; -} - -bool TuneOption::isProgramNumberSet() const { - return m_programNumber_is_set; -} - -void TuneOption::setProgramNumber(int64_t programNumber) { - m_programNumber = programNumber; - m_programNumber_is_set = true; -} - -int64_t TuneOption::getTransportStreamID() const { - return m_transportStreamID; -} - -bool TuneOption::isTransportStreamIDSet() const { - return m_transportStreamID_is_set; -} - -void TuneOption::setTransportStreamID(int64_t transportStreamID) { - m_transportStreamID = transportStreamID; - m_transportStreamID_is_set = true; -} - -int64_t TuneOption::getOriginalNetworkID() const { - return m_originalNetworkID; -} - -bool TuneOption::isOriginalNetworkIDSet() const { - return m_originalNetworkID_is_set; -} - -void TuneOption::setOriginalNetworkID(int64_t originalNetworkID) { - m_originalNetworkID = originalNetworkID; - m_originalNetworkID_is_set = true; -} - -} // namespace tvchannel -} // namespace extension diff --git a/src/tvchannel/tune_option.h b/src/tvchannel/tune_option.h deleted file mode 100644 index 3241ddd5..00000000 --- a/src/tvchannel/tune_option.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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 SRC_TVCHANNEL_TUNE_OPTION_H_ -#define SRC_TVCHANNEL_TUNE_OPTION_H_ - -#include -#include "common/picojson.h" -#include "tvchannel/types.h" - -namespace extension { -namespace tvchannel { - -class TuneOption { - public: - TuneOption(); - virtual ~TuneOption(); - - explicit TuneOption(picojson::object const& _tuneDict); - - int64_t getPtc() const; - bool isPtcSet() const; - void setPtc(int64_t ptc); - - int64_t getMajor() const; - bool isMajorSet() const; - void setMajor(int64_t major); - - int64_t getMinor() const; - bool isMinorSet() const; - void setMinor(int64_t minor); - - int64_t getSourceID() const; - bool isSourceIDSet() const; - void setSourceID(int64_t sourceID); - - int64_t getProgramNumber() const; - bool isProgramNumberSet() const; - void setProgramNumber(int64_t programNumber); - - int64_t getTransportStreamID() const; - bool isTransportStreamIDSet() const; - void setTransportStreamID(int64_t transportStreamID); - - int64_t getOriginalNetworkID() const; - bool isOriginalNetworkIDSet() const; - void setOriginalNetworkID(int64_t originalNetworkID); - - private: - int64_t m_ptc; - int64_t m_major; - int64_t m_minor; - int64_t m_sourceID; - int64_t m_programNumber; - int64_t m_transportStreamID; - int64_t m_originalNetworkID; - bool m_ptc_is_set; - bool m_major_is_set; - bool m_minor_is_set; - bool m_sourceID_is_set; - bool m_programNumber_is_set; - bool m_transportStreamID_is_set; - bool m_originalNetworkID_is_set; - void initialize(); -}; - -typedef std::shared_ptr TuneOptionPtr; - -} // namespace tvchannel -} // namespace extension - -#endif // SRC_TVCHANNEL_TUNE_OPTION_H_ diff --git a/src/tvchannel/tvchannel.gyp b/src/tvchannel/tvchannel.gyp deleted file mode 100644 index 233578d8..00000000 --- a/src/tvchannel/tvchannel.gyp +++ /dev/null @@ -1,53 +0,0 @@ -{ - 'includes':[ - '../common/common.gypi', - ], - 'targets': [ - { - 'target_name': 'tizen_tvchannel', - 'type': 'loadable_module', - 'variables': { - 'packages': [ - 'tvs-api', - ], - }, - 'dependencies': [ - '../common/common.gyp:tizen_common', - '../tizen/tizen.gyp:tizen', - ], - 'includes': [ - '../common/pkg-config.gypi', - ], - 'conditions': [ - ['tizen == 1', { - 'variables': { - 'packages': [ - 'tvs-api' - ], - }, - }, - ], - ], - 'sources': [ - 'tvchannel_api.js', - 'tvchannel_error.h', - 'tvchannel_extension.cc', - 'tvchannel_extension.h', - 'tvchannel_instance.cc', - 'tvchannel_instance.h', - 'channel_info.cc', - 'channel_info.h', - 'program_info.cc', - 'program_info.h', - 'tvchannel_manager.h', - 'tvchannel_manager.cc', - 'types.h', - 'types.cc', - 'tune_option.h', - 'tune_option.cc', - 'criteria_filter.h', - 'criteria_filter.cc' - ], - }, - ], -} diff --git a/src/tvchannel/tvchannel_api.js b/src/tvchannel/tvchannel_api.js deleted file mode 100644 index c6fd14ec..00000000 --- a/src/tvchannel/tvchannel_api.js +++ /dev/null @@ -1,471 +0,0 @@ -/* - * 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. - */ - -var native = new xwalk.utils.NativeManager(extension); -var validator = xwalk.utils.validator; -var validatorType = xwalk.utils.type; - - -/** - * An enumerator that defines window types. - * @enum {string} - */ -var WindowType = { - MAIN: 'MAIN' -}; - - -/** - * An enumerator to indicate the tune mode. - * @enum {string} - */ -var TuneMode = { - ALL: 'ALL', - DIGITAL: 'DIGITAL', - ANALOG: 'ANALOG', - FAVORITE: 'FAVORITE' -}; - -function ChannelInfo(dict) { - for (var key in dict) { - if (dict.hasOwnProperty(key)) { - Object.defineProperty(this, key, { - value: dict[key], - enumerable: true - }); - } - } -} - -function dictListToChannelList(list) { - var result = [], - i = 0, - il = list.length; - for (; i < il; ++i) { - result.push(new ChannelInfo(list[i])); - } - return result; -} - -function ProgramInfo(dict) { - for (var key in dict) { - if (dict.hasOwnProperty(key)) { - Object.defineProperty(this, key, { - value: key === 'startTime' ? new tizen.TZDate(new Date(dict[key])) : dict[key], - enumerable: true - }); - } - } -} - -function dictListToProgramList(list) { - var result = [], - i = 0, - il = list.length; - for (; i < il; ++i) { - result.push(new ProgramInfo(list[i])); - } - return result; -} - -function ListenerManager(native, listenerName) { - this.listeners = {}; - this.nextId = 1; - native.addListener(listenerName, this.onListenerCalled.bind(this)); -} - -ListenerManager.prototype.onListenerCalled = function(msg) { - var channel = new ChannelInfo(msg.channel); - for (var key in this.listeners) { - if (this.listeners.hasOwnProperty(key)) { - this.listeners[key](channel, msg.windowType); - } - } -}; - -ListenerManager.prototype.addListener = function(callback) { - var id = this.nextId; - this.listeners[id] = callback; - ++this.nextId; - return id; -}; - -ListenerManager.prototype.removeListener = function(watchId) { - if (this.listeners.hasOwnProperty(watchId)) { - delete this.listeners[watchId]; - } -}; - - -/** - * @const - * @type {string} - */ -var CHANNEL_CHANGE_LISTENER = 'ChannelChanged'; - -var channelListener = new ListenerManager(native, CHANNEL_CHANGE_LISTENER); - - -/** - * @const - * @type {string} - */ -var PROGRAMINFO_LISTENER = 'ProgramInfoReceived'; - -//TVChannelManager interface -function TVChannelManager() { - if (!(this instanceof TVChannelManager)) { - throw new TypeError; - } -} - - -TVChannelManager.prototype.tune = function(tuneOption, successCallback, errorCallback, windowType) { - var data = validator.validateArgs(arguments, [ - { - name: 'tuneOption', - type: validator.Types.DICTIONARY - }, - { - name: 'callback', - type: validator.Types.LISTENER, - values: ['onsuccess', 'onnosignal', 'onprograminforeceived'] - }, - { - name: 'errorCallback', - type: validator.Types.FUNCTION, - optional: true, - nullable: true - }, - { - name: 'windowType', - optional: true, - nullable: true, - type: validator.Types.ENUM, - values: validatorType.getValues(WindowType) - } - ]); - native.addListener(PROGRAMINFO_LISTENER, function(msg) { - if (validatorType.isFunction(data.callback.onprograminforeceived)) { - data.callback.onprograminforeceived(new ProgramInfo(msg.program), msg.windowType); - } - }); - native.call('TVChannelManager_tune', { - tuneOption: data.tuneOption, - windowType: data.windowType - }, function(msg) { - if (msg.error) { - if (validatorType.isFunction(data.errorCallback)) { - data.errorCallback(native.getErrorObject(msg)); - } - } else if (msg.nosignal) { - if (validatorType.isFunction(data.callback.onnosignal)) { - data.callback.onnosignal(); - } - } else if (msg.success) { - if (validatorType.isFunction(data.callback.onsuccess)) { - data.callback.onsuccess(new ChannelInfo(msg.channel), msg.windowType); - } - } - }); -}; - -function tuneUpDown(args, methodName) { - var data = validator.validateArgs(args, [ - { - name: 'callback', - type: validator.Types.LISTENER, - values: ['onsuccess', 'onnosignal', 'onprograminforeceived'] - }, - { - name: 'errorCallback', - type: validator.Types.FUNCTION, - optional: true, - nullable: true - }, - { - name: 'tuneMode', - optional: true, - nullable: true, - type: validator.Types.ENUM, - values: validatorType.getValues(TuneMode) - }, - { - name: 'windowType', - optional: true, - nullable: true, - type: validator.Types.ENUM, - values: validatorType.getValues(WindowType) - } - ]); - native.addListener(PROGRAMINFO_LISTENER, function(msg) { - if (validatorType.isFunction(data.callback.onprograminforeceived)) { - data.callback.onprograminforeceived(new ProgramInfo(msg.program), msg.windowType); - } - }); - native.call(methodName, { - tuneMode: data.tuneMode, - windowType: data.windowType - }, function(msg) { - if (msg.error) { - if (validatorType.isFunction(data.errorCallback)) { - data.errorCallback(native.getErrorObject(msg)); - } - } else if (msg.nosignal) { - if (validatorType.isFunction(data.callback.onnosignal)) { - data.callback.onnosignal(); - } - } else if (msg.success) { - if (validatorType.isFunction(data.callback.onsuccess)) { - data.callback.onsuccess(new ChannelInfo(msg.channel), msg.windowType); - } - } - }); -} - -TVChannelManager.prototype.tuneUp = function(callback, errorCallback, tuneMode, windowType) { - tuneUpDown(arguments, 'TVChannelManager_tuneUp'); -}; - -TVChannelManager.prototype.tuneDown = function(successCallback, - errorCallback, tuneMode, windowType) { - tuneUpDown(arguments, 'TVChannelManager_tuneDown'); -}; - -TVChannelManager.prototype.findChannel = function(major, minor, successCallback, errorCallback) { - var args = validator.validateArgs(arguments, [ - { - name: 'major', - optional: false, - nullable: false, - type: validator.Types.LONG - }, - { - name: 'minor', - optional: false, - nullable: false, - type: validator.Types.LONG - }, - { - name: 'successCallback', - type: validator.Types.FUNCTION, - optional: false, - nullable: false - }, - { - name: 'errorCallback', - type: validator.Types.FUNCTION, - optional: true, - nullable: true - } - ]); - native.call('TVChannelManager_findChannel', { - major: args.major, - minor: args.minor - }, function(msg) { - if (msg.error) { - if (validatorType.isFunction(args.errorCallback)) { - args.errorCallback(native.getErrorObject(msg)); - } - } else { - args.successCallback(dictListToChannelList(msg.channelInfos)); - } - }); -}; - -TVChannelManager.prototype.getChannelList = function(successCallback, - errorCallback, tuneMode, start, number) { - var args = validator.validateArgs(arguments, [ - { - name: 'successCallback', - type: validator.Types.FUNCTION, - optional: false, - nullable: false - }, - { - name: 'errorCallback', - type: validator.Types.FUNCTION, - optional: true, - nullable: true - }, - { - name: 'tuneMode', - optional: true, - nullable: true, - type: validator.Types.ENUM, - values: validatorType.getValues(TuneMode) - }, - { - name: 'nStart', - optional: true, - nullable: true, - type: validator.Types.LONG - }, - { - name: 'number', - optional: true, - nullable: true, - type: validator.Types.LONG - } - ]); - if (args.nStart < 0) { - throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, - "nStart is lower than 0"); - } - if (args.number < 0) { - throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, - "number is lower than 0"); - } - native.call('TVChannelManager_getChannelList', { - tuneMode: args.tuneMode, - nStart: args.nStart, - number: args.number - }, function(msg) { - if (msg.error) { - if (validatorType.isFunction(args.errorCallback)) { - args.errorCallback(native.getErrorObject(msg)); - } - } else { - args.successCallback(dictListToChannelList(msg.channelInfos)); - } - }); -}; - -TVChannelManager.prototype.getCurrentChannel = function(windowType) { - var args = validator.validateArgs(arguments, [ - { - name: 'windowType', - optional: true, - nullable: true, - type: validator.Types.ENUM, - values: validatorType.getValues(WindowType) - } - ]); - var ret = native.callSync('TVChannelManager_getCurrentChannel', { - windowType: args.windowType ? args.windowType : WindowType.MAIN - }); - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } - return new ChannelInfo(native.getResultObject(ret)); -}; - -TVChannelManager.prototype.getProgramList = function(channelInfo, - startTime, successCallback, errorCallback, duration) { - var args = validator.validateArgs(arguments, [ - { - name: 'channelInfo', - type: validator.Types.PLATFORM_OBJECT, - values: ChannelInfo - }, - { - name: 'startTime', - type: validator.Types.PLATFORM_OBJECT, - values: tizen.TZDate - }, - { - name: 'successCallback', - type: validator.Types.FUNCTION, - optional: false, - nullable: false - }, - { - name: 'errorCallback', - type: validator.Types.FUNCTION, - optional: true, - nullable: true - }, - { - name: 'duration', - optional: true, - nullable: true, - type: validator.Types.LONG - } - ]); - native.call('TVChannelManager_getProgramList', { - channelId: args.channelInfo._serviceId, - startTime: args.startTime.getTime(), - duration: args.duration - }, function(msg) { - if (msg.error) { - if (validatorType.isFunction(args.errorCallback)) { - args.errorCallback(native.getErrorObject(msg)); - } - } else { - args.successCallback(dictListToProgramList(msg.programInfos)); - } - }); -}; - -TVChannelManager.prototype.getCurrentProgram = function(windowType) { - var args = validator.validateArgs(arguments, [ - { - name: 'windowType', - optional: true, - nullable: true, - type: validator.Types.ENUM, - values: validatorType.getValues(WindowType) - } - ]); - var ret = native.callSync('TVChannelManager_getCurrentProgram', { - windowType: args.windowType ? args.windowType : WindowType.MAIN - }); - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } - return new ProgramInfo(native.getResultObject(ret)); -}; - -TVChannelManager.prototype.addChannelChangeListener = function(callback, windowType) { - var args = validator.validateArgs(arguments, [ - { - name: 'callback', - type: validator.Types.FUNCTION - }, - { - name: 'windowType', - optional: true, - nullable: true, - type: validator.Types.ENUM, - values: validatorType.getValues(WindowType) - } - ]); - - return channelListener.addListener(args.callback); -}; - -TVChannelManager.prototype.removeChannelChangeListener = function(listenerId) { - channelListener.removeListener(listenerId); -}; - -TVChannelManager.prototype.addProgramChangeListener = function(successCallback, windowType) { - return undefined; -}; - -TVChannelManager.prototype.removeProgramChangeListener = function(listenerId) { - return undefined; -}; - -TVChannelManager.prototype.getNumOfAvailableTuner = function() - { - var ret = native.callSync('TVChannelManager_getNumOfAvailableTuner'); - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } - return native.getResultObject(ret); -}; - -exports = new TVChannelManager(); diff --git a/src/tvchannel/tvchannel_extension.cc b/src/tvchannel/tvchannel_extension.cc deleted file mode 100644 index 56e4da97..00000000 --- a/src/tvchannel/tvchannel_extension.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 "tvchannel/tvchannel_extension.h" -#include "tvchannel/tvchannel_instance.h" - -// This will be generated from datasync_api.js. -extern const char kSource_tvchannel_api[]; - -TVChannelExtension::TVChannelExtension() { - SetExtensionName("tizen.tvchannel"); - SetJavaScriptAPI(kSource_tvchannel_api); -} - -TVChannelExtension::~TVChannelExtension() { -} - -common::Instance* TVChannelExtension::CreateInstance() { - return new extension::tvchannel::TVChannelInstance(); -} - -// entry point -common::Extension* CreateExtension() { - return new TVChannelExtension(); -} - diff --git a/src/tvchannel/tvchannel_extension.h b/src/tvchannel/tvchannel_extension.h deleted file mode 100644 index fc336a8b..00000000 --- a/src/tvchannel/tvchannel_extension.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 SRC_TVCHANNEL_TVCHANNEL_EXTENSION_H_ -#define SRC_TVCHANNEL_TVCHANNEL_EXTENSION_H_ - -#include "common/extension.h" - -class TVChannelExtension: public common::Extension { - public: - TVChannelExtension(); - virtual ~TVChannelExtension(); - private: - virtual common::Instance* CreateInstance(); -}; - -#endif // SRC_TVCHANNEL_TVCHANNEL_EXTENSION_H_ diff --git a/src/tvchannel/tvchannel_instance.cc b/src/tvchannel/tvchannel_instance.cc deleted file mode 100644 index 6649c690..00000000 --- a/src/tvchannel/tvchannel_instance.cc +++ /dev/null @@ -1,518 +0,0 @@ -/* - * 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 "tvchannel/tvchannel_instance.h" -#include -#include "common/logger.h" -#include "tizen/tizen.h" -#include "common/picojson.h" -#include "tvchannel/channel_info.h" -#include "tvchannel/program_info.h" -#include "tvchannel/types.h" -#include "common/task-queue.h" - -namespace extension { -namespace tvchannel { - -using common::TaskQueue; - -TVChannelInstance::TVChannelInstance() { - using std::placeholders::_1; - using std::placeholders::_2; - - #define REGISTER_ASYNC(c, func) \ - RegisterSyncHandler(c, func); - #define REGISTER_SYNC(c, func) \ - RegisterSyncHandler(c, func); - - REGISTER_SYNC("TVChannelManager_getCurrentChannel", - std::bind(&TVChannelInstance::getCurrentChannel, this, _1, _2)); - REGISTER_SYNC("TVChannelManager_getCurrentProgram", - std::bind(&TVChannelInstance::getCurrentProgram, this, _1, _2)); - REGISTER_ASYNC("TVChannelManager_findChannel", - std::bind(&TVChannelInstance::findChannel, this, _1, _2)); - REGISTER_ASYNC("TVChannelManager_getChannelList", - std::bind(&TVChannelInstance::getChannelList, this, _1, _2)); - REGISTER_ASYNC("TVChannelManager_getProgramList", - std::bind(&TVChannelInstance::getProgramList, this, _1, _2)); - REGISTER_ASYNC("TVChannelManager_tune", - std::bind(&TVChannelInstance::tune, this, _1, _2)); - REGISTER_ASYNC("TVChannelManager_tuneUp", - std::bind(&TVChannelInstance::tuneUp, this, _1, _2)); - REGISTER_ASYNC("TVChannelManager_tuneDown", - std::bind(&TVChannelInstance::tuneDown, this, _1, _2)); - - #undef REGISTER_ASYNC - #undef REGISTER_SYNC - - m_pSubscriber = TVChannelManager::getInstance()->createSubscriber(this); - TVChannelManager::getInstance()->registerListener(m_pSubscriber); -} - -TVChannelInstance::~TVChannelInstance() { - LoggerD("Entered"); -} - -void TVChannelInstance::tune(picojson::value const& args, - picojson::object& out) { - LoggerD("Enter"); - picojson::object tuneOption = - args.get("tuneOption").get(); - double callbackId = args.get("callbackId").get(); - std::string windowType; - if (args.contains("windowType")) { - windowType = args.get("windowType").get(); - } else { - windowType = "MAIN"; - } - - LoggerD("CallbackID %f", callbackId); - std::shared_ptr pTuneData( - new TVChannelManager::TuneData(TuneOption(tuneOption), - stringToWindowType(windowType), callbackId)); - - std::function const&)> task = std::bind( - &TVChannelInstance::tuneTask, this, std::placeholders::_1); - std::function const&)> taskAfter = std::bind( - &TVChannelInstance::tuneTaskAfter, this, std::placeholders::_1); - - common::TaskQueue::GetInstance().Queue(task, - taskAfter, pTuneData); - - picojson::value v; - ReportSuccess(v, out); -} - -void TVChannelInstance::tuneTaskAfter( - std::shared_ptr const& _tuneData) { - LoggerD("Enter"); - if (_tuneData->pError) { - picojson::value event = picojson::value(picojson::object()); - picojson::object& obj = event.get(); - obj.insert(std::make_pair("callbackId", picojson::value( - _tuneData->callbackId))); - obj.insert(std::make_pair("error", _tuneData->pError->ToJSON())); - PostMessage(event.serialize().c_str()); - } -} - -void TVChannelInstance::tuneTask( - std::shared_ptr const& _tuneData) { - LoggerD("Enter"); - TVChannelManager::getInstance()->tune(_tuneData); -} - -void TVChannelInstance::tuneUp(picojson::value const& args, - picojson::object& out) { - LoggerD("Enter"); - - NavigatorMode navMode; - if (args.contains("tuneMode")) { - navMode = stringToNavigatorMode( - args.get("tuneMode").get()); - } else { - navMode = NavigatorMode::ALL; - } - - double callbackId = args.get("callbackId").get(); - std::string windowType; - if (args.contains("windowType")) { - windowType = args.get("windowType").get(); - } else { - windowType = "MAIN"; - } - - LoggerD("CallbackID %f", callbackId); - std::shared_ptr pTuneData( - new TVChannelManager::TuneData(navMode, - stringToWindowType(windowType), callbackId)); - - std::function const&)> task = std::bind( - &TVChannelInstance::tuneUpTask, this, std::placeholders::_1); - std::function const&)> taskAfter = std::bind( - &TVChannelInstance::tuneTaskAfter, this, std::placeholders::_1); - - common::TaskQueue::GetInstance().Queue(task, - taskAfter, pTuneData); - - picojson::value v; - ReportSuccess(v, out); -} - -void TVChannelInstance::tuneUpTask( - std::shared_ptr const& _tuneData) { - TVChannelManager::getInstance()->tuneUp(_tuneData); -} - -void TVChannelInstance::tuneDown(picojson::value const& args, - picojson::object& out) { - LoggerD("Enter"); - - NavigatorMode navMode; - if (args.contains("tuneMode")) { - navMode = stringToNavigatorMode( - args.get("tuneMode").get()); - } else { - navMode = NavigatorMode::ALL; - } - - double callbackId = args.get("callbackId").get(); - std::string windowType; - if (args.contains("windowType")) { - windowType = args.get("windowType").get(); - } else { - windowType = "MAIN"; - } - - LoggerD("CallbackID %f", callbackId); - std::shared_ptr pTuneData( - new TVChannelManager::TuneData(navMode, - stringToWindowType(windowType), callbackId)); - - std::function const&)> task = std::bind( - &TVChannelInstance::tuneUpTask, this, std::placeholders::_1); - std::function const&)> taskAfter = std::bind( - &TVChannelInstance::tuneTaskAfter, this, std::placeholders::_1); - - common::TaskQueue::GetInstance().Queue(task, - taskAfter, pTuneData); - - picojson::value v; - ReportSuccess(v, out); -} - -void TVChannelInstance::tuneDownTask( - std::shared_ptr const& _tuneData) { - TVChannelManager::getInstance()->tuneDown(_tuneData); -} - -void TVChannelInstance::getCurrentChannel(picojson::value const& args, - picojson::object& out) { - - std::unique_ptr pChannel = - TVChannelManager::getInstance()->getCurrentChannel( - stringToWindowType(args.get("windowType").get())); - - picojson::value v = channelInfoToJson(pChannel); - ReportSuccess(v, out); -} - -picojson::value TVChannelInstance::channelInfoToJson( - const std::unique_ptr &pChannel) { - picojson::value::object channel; - channel.insert( - std::make_pair("major", - picojson::value(static_cast(pChannel->getMajor())))); - channel.insert( - std::make_pair("minor", - picojson::value(static_cast(pChannel->getMinor())))); - channel.insert( - std::make_pair("channelName", - picojson::value(pChannel->getChannelName()))); - channel.insert( - std::make_pair("programNumber", - picojson::value( - static_cast(pChannel->getProgramNumber())))); - channel.insert( - std::make_pair("ptc", - picojson::value(static_cast(pChannel->getPtc())))); - channel.insert( - std::make_pair("lcn", - picojson::value(static_cast(pChannel->getLcn())))); - channel.insert( - std::make_pair("sourceID", - picojson::value(static_cast(pChannel->getSourceID())))); - channel.insert( - std::make_pair("transportStreamID", - picojson::value( - static_cast(pChannel->getTransportStreamID())))); - channel.insert( - std::make_pair("originalNetworkID", - picojson::value( - static_cast(pChannel->getOriginalNetworkID())))); - channel.insert( - std::make_pair("serviceName", - picojson::value(pChannel->getServiceName()))); - // internal property - channel.insert( - std::make_pair("_serviceId", - picojson::value( - static_cast(pChannel->getServiceID())))); - return picojson::value(channel); -} - -picojson::value TVChannelInstance::programInfoToJson( - const std::unique_ptr& pInfo) { - picojson::value::object program; - program.insert(std::make_pair("title", picojson::value(pInfo->getTitle()))); - program.insert( - std::make_pair("startTime", - picojson::value(static_cast(pInfo->getStartTimeMs())))); - program.insert( - std::make_pair("duration", - picojson::value(static_cast(pInfo->getDuration())))); - program.insert( - std::make_pair("detailedDescription", - picojson::value(pInfo->getDetailedDescription()))); - program.insert( - std::make_pair("language", picojson::value(pInfo->getLanguage()))); - program.insert( - std::make_pair("rating", picojson::value(pInfo->getRating()))); - - picojson::value result(program); - return result; -} - -void TVChannelInstance::getCurrentProgram(const picojson::value& args, - picojson::object& out) { - std::unique_ptr pInfo( - TVChannelManager::getInstance()->getCurrentProgram( - stringToWindowType(args.get("windowType").get()))); - ReportSuccess(programInfoToJson(pInfo), out); -} - -void TVChannelInstance::onChannelChange(double callbackId) { - LoggerD("Enter"); - try { - WindowType windowType = stringToWindowType("MAIN"); - - picojson::value::object dict; - std::unique_ptr pChannel = - TVChannelManager::getInstance()->getCurrentChannel(windowType); - dict["listenerId"] = picojson::value("ChannelChanged"); - dict["channel"] = channelInfoToJson(pChannel); - dict["windowType"] = picojson::value("MAIN"); - dict["success"] = picojson::value(true); - picojson::value resultListener(dict); - PostMessage(resultListener.serialize().c_str()); - if (callbackId !=- 1) { - dict.erase("listenerId"); - dict["callbackId"] = picojson::value(callbackId); - picojson::value resultCallback(dict); - PostMessage(resultCallback.serialize().c_str()); - } - } catch (common::PlatformException& e) { - LoggerW("Failed to post message: %s", e.message().c_str()); - } catch (...) { - LoggerW("Failed to post message, unknown error"); - } -} - -void TVChannelInstance::onEPGReceived(double callbackId) { - try { - picojson::value::object dict; - dict["listenerId"] = picojson::value("ProgramInfoReceived"); - dict["windowType"] = picojson::value("MAIN"); - std::unique_ptr pInfo( - TVChannelManager::getInstance()->getCurrentProgram(MAIN)); - dict["program"] = programInfoToJson(pInfo); - picojson::value result(dict); - PostMessage(result.serialize().c_str()); - } catch (common::PlatformException& e) { - LoggerW("Failed to post message: %s", e.message().c_str()); - } catch (...) { - LoggerW("Failed to post message, unknown error"); - } -} -void TVChannelInstance::onNoSignal(double callbackId) { - try { - picojson::value::object dict; - dict["windowType"] = picojson::value("MAIN"); - dict["callbackId"] = picojson::value(callbackId); - dict["nosignal"] = picojson::value(true); - picojson::value result(dict); - PostMessage(result.serialize().c_str()); - } catch (common::PlatformException& e) { - LoggerW("Failed to post message: %s", e.message().c_str()); - } catch (...) { - LoggerW("Failed to post message, unknown error"); - } -} - -void TVChannelInstance::findChannel(const picojson::value& args, - picojson::object& out) { - LoggerD("Enter"); - std::function)> - asyncWork = std::bind( - &TVChannelManager::findChannel, - TVChannelManager::getInstance(), - std::placeholders::_1); - std::function)> - afterWork = std::bind( - &TVChannelInstance::findChannelResult, - this, - std::placeholders::_1); - std::shared_ptr data( - new TVChannelManager::FindChannelData()); - data->major = static_cast(args.get("major").get()); - data->minor = static_cast(args.get("minor").get()); - data->callbackId = args.get("callbackId").get(); - TaskQueue::GetInstance().Queue( - asyncWork, - afterWork, - data); - picojson::value result; - ReportSuccess(result, out); -} - -void TVChannelInstance::findChannelResult( - const std::shared_ptr& data) { - LoggerD("Enter"); - picojson::value::object dict; - dict["callbackId"] = picojson::value(data->callbackId); - if (data->error) { - dict["error"] = data->error->ToJSON(); - } else { - picojson::value::array channels; - auto it = data->channels.begin(); - for (; it != data->channels.end(); ++it) { - channels.push_back(channelInfoToJson( - std::unique_ptr(*it))); - } - data->channels.clear(); - dict["channelInfos"] = picojson::value(channels); - } - picojson::value result(dict); - PostMessage(result.serialize().c_str()); -} - -void TVChannelInstance::getChannelList(const picojson::value& args, - picojson::object& out) { - LoggerD("Enter"); - std::function)> - asyncWork = std::bind( - &TVChannelManager::getChannelList, - TVChannelManager::getInstance(), - std::placeholders::_1); - std::function)> - afterWork = std::bind( - &TVChannelInstance::getChannelListResult, - this, - std::placeholders::_1); - std::shared_ptr data( - new TVChannelManager::GetChannelListData()); - if (args.contains("tuneMode")) { - data->tuneMode = stringToNavigatorMode( - args.get("tuneMode").get()); - } - if (args.contains("nStart")) { - data->nStart = static_cast(args.get("nStart").get()); - data->nStartSet = true; - } - if (args.contains("number")) { - data->number = static_cast(args.get("number").get()); - data->numberSet = true; - } - data->callbackId = args.get("callbackId").get(); - TaskQueue::GetInstance().Queue( - asyncWork, - afterWork, - data); - picojson::value result; - ReportSuccess(result, out); -} - -void TVChannelInstance::getChannelListResult( - const std::shared_ptr& data) { - picojson::value::object dict; - dict["callbackId"] = picojson::value(data->callbackId); - if (data->error) { - dict["error"] = data->error->ToJSON(); - } else { - picojson::value::array channels; - int32_t start = data->nStartSet ? data->nStart : 0; - int32_t number = data->numberSet ? data->number : data->channels.size(); - int32_t i = 0; - auto it = data->channels.begin(); - for (; it != data->channels.end(); ++it) { - // add only limited rows by start and number - if (i >= start && i < start + number) { - channels.push_back(channelInfoToJson( - std::unique_ptr(*it))); - } else { - delete *it; - } - ++i; - } - data->channels.clear(); - dict["channelInfos"] = picojson::value(channels); - } - picojson::value result(dict); - PostMessage(result.serialize().c_str()); -} - -void TVChannelInstance::getProgramList( - const picojson::value& args, picojson::object& out) { - LoggerD("Enter"); - std::function)> - asyncWork = std::bind( - &TVChannelManager::getProgramList, - TVChannelManager::getInstance(), - std::placeholders::_1); - std::function)> - afterWork = std::bind( - &TVChannelInstance::getProgramListResult, - this, - std::placeholders::_1); - std::shared_ptr data( - new TVChannelManager::GetProgramListData()); - data->channelId = static_cast( - args.get("channelId").get()); - data->startTime = static_cast( - args.get("startTime").get()); - if (args.contains("duration")) { - data->duration = - static_cast(args.get("duration").get()); - } else { - data->duration = UINT32_MAX; - } - data->callbackId = args.get("callbackId").get(); - TaskQueue::GetInstance().Queue( - asyncWork, - afterWork, - data); - picojson::value result; - ReportSuccess(result, out); -} - -void TVChannelInstance::getProgramListResult( - const std::shared_ptr& data) { - picojson::value::object dict; - dict["callbackId"] = picojson::value(data->callbackId); - if (data->error) { - dict["error"] = data->error->ToJSON(); - } else { - picojson::value::array programs; - auto it = data->programs.begin(); - for (; it != data->programs.end(); ++it) { - programs.push_back(programInfoToJson( - std::unique_ptr(*it))); - } - data->programs.clear(); - dict["programInfos"] = picojson::value(programs); - } - picojson::value result(dict); - PostMessage(result.serialize().c_str()); -} - -} // namespace tvchannel -} // namespace extension diff --git a/src/tvchannel/tvchannel_instance.h b/src/tvchannel/tvchannel_instance.h deleted file mode 100644 index b400acbc..00000000 --- a/src/tvchannel/tvchannel_instance.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 SRC_TVCHANNEL_TVCHANNEL_INSTANCE_H_ -#define SRC_TVCHANNEL_TVCHANNEL_INSTANCE_H_ - -#include -#include - -#include "common/extension.h" -#include "common/picojson.h" -#include "tvchannel/tvchannel_extension.h" -#include "tvchannel/tvchannel_manager.h" - -namespace extension { -namespace tvchannel { - -class TVChannelInstance: - public common::ParsedInstance, - public EventListener { - public: - TVChannelInstance(); - virtual ~TVChannelInstance(); - - private: - void getCurrentChannel(const picojson::value& args, picojson::object& out); - void getCurrentProgram(const picojson::value& args, picojson::object& out); - virtual void onChannelChange(double callbackId); - virtual void onEPGReceived(double callbackId); - virtual void onNoSignal(double callbackId); - void findChannel(const picojson::value& args, picojson::object& out); - void findChannelResult( - const std::shared_ptr& data); - void getChannelList(const picojson::value& args, picojson::object& out); - void getChannelListResult( - const std::shared_ptr& data); - picojson::value channelInfoToJson( - const std::unique_ptr &pChannel); - picojson::value programInfoToJson( - const std::unique_ptr &pProgram); - void getProgramList(const picojson::value& args, picojson::object& out); - void getProgramListResult( - const std::shared_ptr& data); - void tune(picojson::value const& args, - picojson::object& out); - void tuneUp(picojson::value const& args, - picojson::object& out); - void tuneDown(picojson::value const& args, - picojson::object& out); - void tuneTask(std::shared_ptr< - TVChannelManager::TuneData> const& _tuneData); - void tuneTaskAfter( - std::shared_ptr const& _pTuneData); - void tuneUpTask(std::shared_ptr< - TVChannelManager::TuneData> const& _tuneData); - void tuneDownTask( - std::shared_ptr const& _tuneData); - - ISignalSubscriber* m_pSubscriber; -}; - -} // namespace tvchannel -} // namespace extension - -#endif // SRC_TVCHANNEL_TVCHANNEL_INSTANCE_H_ diff --git a/src/tvchannel/tvchannel_manager.cc b/src/tvchannel/tvchannel_manager.cc deleted file mode 100644 index 58fc3059..00000000 --- a/src/tvchannel/tvchannel_manager.cc +++ /dev/null @@ -1,623 +0,0 @@ -/* - * 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 "tvchannel/tvchannel_manager.h" -#include -#include -#include -#include -#include "tvchannel/channel_info.h" -#include "tvchannel/program_info.h" -#include "common/logger.h" -#include "common/task-queue.h" -#include -#include "tvchannel/criteria_filter.h" - -namespace extension { -namespace tvchannel { - -TVChannelManager* TVChannelManager::getInstance() { - static TVChannelManager manager; - return &manager; -} - -TVChannelManager::TVChannelManager() : - m_listener(NULL) { - LoggerD("Enter"); - int ret = TVServiceAPI::CreateService(&m_pService); - if (TV_SERVICE_API_SUCCESS != ret) { - LoggerE("Failed to create tvs-api service: %d", ret); - throw common::UnknownException("Failed to create tvs-api service"); - } -} - -IService* TVChannelManager::getService() { - return m_pService; -} - -void TVChannelManager::tune(std::shared_ptr const& _pTuneData) { - LoggerD("Enter"); - try { - std::unique_lock lock(tuneMutex); - - WindowType windowType = _pTuneData->windowType; - TuneOption tuneOption = _pTuneData->tuneOption; - - TCServiceId currentServiceId = - getCurrentChannel(windowType)->getServiceID(); - - TSTvMode tvMode = getTvMode( - getNavigation(getProfile(windowType), SCREENID)); - - ENavigationMode naviMode = NAVIGATION_MODE_ALL; - std::unique_ptr < TCCriteriaHelper > pCriteria = getBasicCriteria( - tvMode, naviMode); - pCriteria->Fetch(SERVICE_ID); - pCriteria->Fetch(CHANNEL_TYPE); - pCriteria->Fetch(CHANNEL_NUMBER); - - CriteriaFilter filter = CriteriaFilter(tvMode.serviceMode); - - if (tuneOption.isMajorSet()) { - LoggerD("MAJOR: %d", tuneOption.getMajor()); - filter.filterWhere(MAJOR, static_cast(tuneOption.getMajor())); - } - if (tuneOption.isMinorSet()) { - LoggerD("MINOR: %d", tuneOption.getMinor()); - filter.filterWhere(MINOR, static_cast(tuneOption.getMinor())); - } - if (tuneOption.isPtcSet()) { - LoggerD("PTC: %d", tuneOption.getPtc()); - filter.filterWhere(CHANNEL_NUMBER, - static_cast(tuneOption.getPtc())); - } - if (tuneOption.isOriginalNetworkIDSet()) { - LoggerD("ORIGINAL_NETWORK_ID: %d", tuneOption.getOriginalNetworkID()); - filter.filterWhere(ORIGINAL_NETWORK_ID, - static_cast(tuneOption.getOriginalNetworkID())); - } - if (tuneOption.isProgramNumberSet()) { - LoggerD("PROGRAM_NUMBER: %d", tuneOption.getProgramNumber()); - filter.filterWhere(PROGRAM_NUMBER, - static_cast(tuneOption.getProgramNumber())); - } - if (tuneOption.isSourceIDSet()) { - LoggerD("SOURCE_ID: %d", tuneOption.getSourceID()); - filter.filterWhere(SOURCE_ID, - static_cast(tuneOption.getSourceID())); - } - if (tuneOption.isTransportStreamIDSet()) { - LoggerD("TRANSPORT_STREAM_ID: %d", tuneOption.getTransportStreamID()); - filter.filterWhere(TRANSPORT_STREAM_ID, - static_cast(tuneOption.getTransportStreamID())); - } - - filter.getFilteredCriteria(pCriteria); - - TCServiceData foundService; - int ret = getService()->FindService(*pCriteria, foundService); - if (TV_SERVICE_API_METHOD_SUCCESS != ret) { - LoggerE("Failed to find channel: %d", ret); - throw common::NotFoundException("Failed to find channel"); - } - - TCServiceId serviceId = foundService.Get < TCServiceId > (SERVICE_ID); - u_int16_t channelNumber = foundService.Get < u_int16_t - > (CHANNEL_NUMBER); - EChannelType channelType = foundService.Get < EChannelType - > (CHANNEL_TYPE); - - ret = getNavigation(getProfile(windowType), 0)->SetService(serviceId); - if (TV_SERVICE_API_METHOD_SUCCESS != ret) { - LoggerE("Failed to set selected channel: %d", ret); - throw common::UnknownException( - "Failed to set selected channel"); - } - _pTuneData->serviceId = serviceId; - m_callbackTuneMap[serviceId] = _pTuneData->callbackId; - } catch (common::PlatformException const& _error) { - _pTuneData->pError.reset( - new common::PlatformException(_error.name(), _error.message())); - LoggerE("Some exception caught"); - } -} - -ENavigationMode navigatorModeToENavigationMode(NavigatorMode mode) { - switch (mode) { - case DIGITAL: - return NAVIGATION_MODE_DIGITAL; - case ANALOG: - return NAVIGATION_MODE_ANALOG; - case FAVORITE: - return NAVIGATION_MODE_FAVORITES; - default: - return NAVIGATION_MODE_ALL; - } -} - -void TVChannelManager::tuneUp(std::shared_ptr const& _pTuneData) { - LoggerD("Enter"); - try { - std::unique_lock lock(tuneMutex); - - WindowType windowType = _pTuneData->windowType; - - TCServiceId currentServiceId = - getCurrentChannel(windowType)->getServiceID(); - - TSTvMode tvMode = getTvMode( - getNavigation(getProfile(windowType), SCREENID)); - - ENavigationMode naviMode = navigatorModeToENavigationMode( - _pTuneData->navMode); - std::unique_ptr < TCCriteriaHelper > pCriteria = getBasicCriteria( - tvMode, naviMode); - pCriteria->Fetch(SERVICE_ID); - pCriteria->Fetch(SERVICE_NAME); - pCriteria->Fetch(CHANNEL_TYPE); - pCriteria->Fetch(CHANNEL_NUMBER); - TCServiceData previousService; - int ret = getNavigation( - getProfile(windowType), SCREENID)->GetPreviousService(*pCriteria, - currentServiceId, - previousService); - if (TV_SERVICE_API_METHOD_SUCCESS != ret) { - LoggerE("Failed to find previous channel: %d", ret); - throw common::NotFoundException("Failed to find previous channel"); - } - TCServiceId serviceId = previousService.Get(SERVICE_ID); - - // if GetNextService's result is same with current service id, - // it means failure to find previous channel. - if (currentServiceId == serviceId) { - LoggerE("Failed to find previous channel: %d", ret); - throw common::NotFoundException("Failed to find next channel"); - } - ret = getNavigation(getProfile(windowType), 0)->SetService(serviceId); - if (TV_SERVICE_API_METHOD_SUCCESS != ret) { - LoggerE("Failed to set selected channel: %d", ret); - throw common::UnknownException( - "Failed to set selected channel"); - } - m_callbackTuneMap[serviceId] = _pTuneData->callbackId; - } catch (common::PlatformException const& _error) { - _pTuneData->pError.reset( - new common::PlatformException(_error.name(), _error.message())); - LoggerE("Some exception caught"); - } -} - -void TVChannelManager::tuneDown(std::shared_ptr const& _pTuneData) { - LoggerD("Enter"); - try { - std::unique_lock lock(tuneMutex); - - WindowType windowType = _pTuneData->windowType; - - TCServiceId currentServiceId = - getCurrentChannel(windowType)->getServiceID(); - - TSTvMode tvMode = getTvMode( - getNavigation(getProfile(windowType), SCREENID)); - - ENavigationMode naviMode = navigatorModeToENavigationMode( - _pTuneData->navMode); - std::unique_ptr < TCCriteriaHelper > pCriteria = getBasicCriteria( - tvMode, naviMode); - pCriteria->Fetch(SERVICE_ID); - pCriteria->Fetch(SERVICE_NAME); - pCriteria->Fetch(CHANNEL_TYPE); - pCriteria->Fetch(CHANNEL_NUMBER); - TCServiceData nextService; - int ret = getNavigation( - getProfile(windowType), SCREENID)->GetNextService(*pCriteria, - currentServiceId, - nextService); - if (TV_SERVICE_API_METHOD_SUCCESS != ret) { - LoggerE("Failed to find previous channel: %d", ret); - throw common::NotFoundException("Failed to find previous channel"); - } - TCServiceId serviceId = nextService.Get(SERVICE_ID); - - // if GetNextService's result is same with current service id, - // it means failure to find previous channel. - if (currentServiceId == serviceId) { - LoggerE("Failed to find previous channel: %d", ret); - throw common::NotFoundException("Failed to find previous channel"); - } - ret = getNavigation(getProfile(windowType), 0)->SetService(serviceId); - if (TV_SERVICE_API_METHOD_SUCCESS != ret) { - LoggerE("Failed to set selected channel: %d", ret); - throw common::UnknownException( - "Failed to set selected channel"); - } - m_callbackTuneMap[serviceId] = _pTuneData->callbackId; - } catch (common::PlatformException const& _error) { - _pTuneData->pError.reset( - new common::PlatformException(_error.name(), _error.message())); - LoggerE("Some exception caught"); - } -} - -IServiceNavigation* TVChannelManager::getNavigation(EProfile profileId, - u_int16_t screenId) { - LoggerD("Enter"); - IServiceNavigation* navigation; - int ret = TVServiceAPI::CreateServiceNavigation(profileId, screenId, - &navigation); - if (TV_SERVICE_API_SUCCESS != ret) { - LoggerE("Failed to create service navigation: %d", ret); - throw common::UnknownException("Failed to create service navigation"); - } - return navigation; -} - -TSTvMode TVChannelManager::getTvMode(IServiceNavigation* pNavigation) { - LoggerD("Enter"); - TSTvMode tvMode; - int ret = pNavigation->GetTvMode(tvMode); - if (TV_SERVICE_API_METHOD_SUCCESS != ret) { - LoggerE("Failed to get current tv mode: %d", ret); - throw common::UnknownException("Failed to get current tv mode"); - } - LoggerD("tvMode : antenna - %d, service - %d", tvMode.antennaMode, - tvMode.serviceMode); - return tvMode; -} - -std::unique_ptr TVChannelManager::getBasicCriteria( - TSTvMode tvMode, ENavigationMode naviMode) { - LoggerD("Enter"); - std::unique_ptr < TCCriteriaHelper > pCriteria(new TCCriteriaHelper()); - bool found = TCNavigationModeHelper::GetNavigationCriteria(tvMode, naviMode, - *pCriteria); - if (!found) { - LoggerE("Failed to create navigation criteria"); - throw common::UnknownException("Failed to create navigation criteria"); - } - return pCriteria; -} - -TCServiceData TVChannelManager::getCurrentServiceInfo( - IServiceNavigation* _pNavigation, TSTvMode _mode, - std::unique_ptr const& _pCriteria) { - LoggerD("Enter"); - TCServiceData serviceData; - int ret = _pNavigation->GetCurrentServiceInfo(_mode, *_pCriteria, - serviceData); - if (TV_SERVICE_API_METHOD_SUCCESS != ret) { - LoggerE("Failed to get current service info: %d", ret); - throw common::UnknownException("Failed to get current service info"); - } - return serviceData; -} - -std::unique_ptr TVChannelManager::getCurrentChannel( - WindowType _windowType) { - LoggerD("Entered %d", _windowType); - - std::unique_ptr < TCCriteriaHelper > pCriteria(new TCCriteriaHelper()); - pCriteria->Fetch(SERVICE_ID); - pCriteria->Fetch(MAJOR); - pCriteria->Fetch(MINOR); - pCriteria->Fetch(PROGRAM_NUMBER); - pCriteria->Fetch(CHANNEL_NUMBER); - pCriteria->Fetch(CHANNEL_TYPE); - pCriteria->Fetch(SERVICE_NAME); - pCriteria->Fetch(SOURCE_ID); - pCriteria->Fetch(TRANSPORT_STREAM_ID); - pCriteria->Fetch(ORIGINAL_NETWORK_ID); - pCriteria->Fetch(LCN); - - // Navigation - IServiceNavigation* navigation = getNavigation(getProfile(_windowType), - SCREENID); - - TSTvMode tvMode = getTvMode(navigation); - - TCServiceData serviceData = getCurrentServiceInfo(navigation, tvMode, - pCriteria); - LoggerD("Current channel id: %llu", - serviceData.Get < TCServiceId > (SERVICE_ID)); - std::unique_ptr pChannel(new ChannelInfo()); - pChannel->fromApiData(serviceData); - return pChannel; -} - -EProfile TVChannelManager::getProfile(WindowType windowType) { - LoggerD("Enter"); - switch (windowType) { - case MAIN: - return PROFILE_TYPE_MAIN; -// PIP is not supported - j.h.lim -// case PIP: -// return PROFILE_TYPE_PIP; - default: - LoggerE("Unsupported window type: %d", windowType); - } -} - -TCServiceId TVChannelManager::getCurrentChannelId(WindowType _windowType) { - LoggerD("Enter"); - // Navigation - IServiceNavigation* navigation = getNavigation(getProfile(_windowType), - SCREENID); - TSTvMode tvMode = getTvMode(navigation); - std::unique_ptr < TCCriteriaHelper > pCriteria(new TCCriteriaHelper()); - pCriteria->Fetch(SERVICE_ID); - TCServiceData serviceData = getCurrentServiceInfo(navigation, tvMode, - pCriteria); - return serviceData.Get < TCServiceId > (SERVICE_ID); -} - -ProgramInfo* TVChannelManager::getCurrentProgram(WindowType _windowType) { - LoggerD("Enter"); - IServiceGuide* guide; - int ret = TVServiceAPI::CreateServiceGuide(&guide); - if (TV_SERVICE_API_SUCCESS != ret) { - LoggerE("Failed to create service guide: %d", ret); - throw common::UnknownException("Failed to create service guide"); - } - - TCProgramData programData; - ret = guide->GetPresentProgram(getCurrentChannelId(_windowType), - programData); - if (TV_SERVICE_API_METHOD_SUCCESS != ret) { - LoggerE("Failed to get current program: %d", ret); - throw common::UnknownException("Failed to get current program"); - } - ProgramInfo* program = new ProgramInfo(); - program->fromApiData(programData); - return program; -} - -ISignalSubscriber* TVChannelManager::createSubscriber( - EventListener* pListener) { - LoggerD("Enter"); - m_listener = pListener; - ISignalSubscriber* pSubscriber; - int ret = TVServiceAPI::CreateSignalSubscriber(signalListener, - &pSubscriber); - if (TV_SERVICE_API_SUCCESS != ret) { - LoggerW("Failed to create tvs-api SignalSubscriber"); - } - return pSubscriber; -} - -void TVChannelManager::registerListener(ISignalSubscriber* pSubscriber) { - LoggerD("Enter"); - pSubscriber->Unsubscribe(SIGNAL_TUNE_SUCCESS); - int ret = pSubscriber->Subscribe(SIGNAL_TUNE_SUCCESS); - if (TV_SERVICE_API_METHOD_SUCCESS != ret) { - LoggerW("Failed to add listener: SIGNAL_TUNE_SUCCESS"); - } - pSubscriber->Unsubscribe(SIGNAL_TUNER_LOCK_FAIL); - ret = pSubscriber->Subscribe(SIGNAL_TUNER_LOCK_FAIL); - if (TV_SERVICE_API_METHOD_SUCCESS != ret) { - LoggerW("Failed to add listener: SIGNAL_TUNER_LOCK_FAIL"); - } - pSubscriber->Unsubscribe(SIGNAL_EPG_COMPLETED); - ret = pSubscriber->Subscribe(SIGNAL_EPG_COMPLETED); - if (TV_SERVICE_API_METHOD_SUCCESS != ret) { - LoggerW("Failed to add listener: SIGNAL_EPG_COMPLETED"); - } -} - -int TVChannelManager::signalListener(ESignalType type, EProfile _profile, - u_int16_t _screenID, TSSignalData data, void*) { - LoggerD("Enter: %d", type); - if (!getInstance()->m_listener) { - LoggerE("Listener is empty, ignoring message"); - return 0; - } - - TCServiceId pChannelId = - getInstance()->getCurrentChannelId(stringToWindowType("MAIN")); - double callbackID = -1; - auto it = getInstance()->m_callbackTuneMap.find(pChannelId); - if (it != getInstance()->m_callbackTuneMap.end()) { - callbackID = it->second; - } - LoggerD("CallbackID %f", callbackID); - - switch (type) { - case SIGNAL_TUNE_SUCCESS: - getInstance()->m_listener->onChannelChange(callbackID); - break; - case SIGNAL_TUNER_LOCK_FAIL: - getInstance()->m_listener->onNoSignal(callbackID); - break; - case SIGNAL_EPG_COMPLETED: - getInstance()->m_listener->onEPGReceived(callbackID); - break; - default: - LoggerW("Unrecognized event type"); - } - return 0; -} - -void TVChannelManager::ucs2utf8(char *out, size_t out_len, char *in, - size_t in_len) { - iconv_t cd; - size_t r; - - cd = iconv_open("UTF-8", "UCS-2BE"); - if (cd == (iconv_t) - 1) { - LoggerE("Failed to open iconv"); - } - - r = iconv(cd, &in, &in_len, &out, &out_len); - if (r == (size_t) - 1) { - LoggerE("Failed convert string to utf8"); - } - - iconv_close(cd); -} - -void TVChannelManager::findChannel( - const std::shared_ptr& data) { - LoggerD("Enter"); - try { - IServiceNavigation* navigation = - getNavigation(getProfile(WindowType::MAIN), 0); - - std::unique_ptr criteria = getBasicCriteria( - getTvMode(navigation), NAVIGATION_MODE_ALL); - criteria->Fetch(SERVICE_ID); - criteria->Fetch(MAJOR); - criteria->Fetch(MINOR); - criteria->Fetch(PROGRAM_NUMBER); - criteria->Fetch(CHANNEL_NUMBER); - criteria->Fetch(CHANNEL_TYPE); - criteria->Fetch(SERVICE_NAME); - criteria->Fetch(SOURCE_ID); - criteria->Fetch(TRANSPORT_STREAM_ID); - criteria->Fetch(ORIGINAL_NETWORK_ID); - criteria->Fetch(LCN); - - CriteriaFilter filter = CriteriaFilter( - getTvMode(navigation).serviceMode); - filter.filterWhere(MAJOR, static_cast(data->major)); - filter.filterWhere(MINOR, static_cast(data->minor)); - filter.getFilteredCriteria(criteria); - - std::list resultServices; - int ret = m_pService->FindServiceList(*criteria, resultServices); - if (TV_SERVICE_API_METHOD_FAILURE == ret) { - LoggerE("Failed to find channel: %d", ret); - throw common::NotFoundException("Failed to find channel"); - } - LoggerD("Found channels: %d", resultServices.size()); - auto it = resultServices.begin(); - for (; it != resultServices.end(); ++it) { - ChannelInfo *channelInfo = new ChannelInfo(); - channelInfo->fromApiData(*(*it)); - data->channels.push_back(channelInfo); - delete (*it); - } - resultServices.clear(); - } catch (common::PlatformException& e) { - data->error.reset(new common::PlatformException(e.name(), e.message())); - } catch (...) { - data->error.reset( - new common::UnknownException("Couldn't find channels")); - } -} - -void TVChannelManager::getChannelList( - const std::shared_ptr& data) { - LoggerD("Enter"); - try { - IServiceNavigation* navigation = - getNavigation(getProfile(WindowType::MAIN), 0); - - ENavigationMode naviMode = NAVIGATION_MODE_ALL; - switch (data->tuneMode) { - case DIGITAL: - naviMode = NAVIGATION_MODE_DIGITAL; - break; - case ANALOG: - naviMode = NAVIGATION_MODE_ANALOG; - break; - case FAVORITE: - naviMode = NAVIGATION_MODE_FAVORITES; - break; - default: - naviMode = NAVIGATION_MODE_ALL; - } - std::unique_ptr criteria = getBasicCriteria( - getTvMode(navigation), naviMode); - criteria->Fetch(SERVICE_ID); - criteria->Fetch(MAJOR); - criteria->Fetch(MINOR); - criteria->Fetch(PROGRAM_NUMBER); - criteria->Fetch(CHANNEL_NUMBER); - criteria->Fetch(CHANNEL_TYPE); - criteria->Fetch(SERVICE_NAME); - criteria->Fetch(SOURCE_ID); - criteria->Fetch(TRANSPORT_STREAM_ID); - criteria->Fetch(ORIGINAL_NETWORK_ID); - criteria->Fetch(LCN); - if (NAVIGATION_MODE_FAVORITES == naviMode) { - criteria->WhereNot(FAVORITE_ID, 0); - } - - std::list resultServices; - int ret = m_pService->FindServiceList(*criteria, resultServices); - if (TV_SERVICE_API_METHOD_FAILURE == ret) { - LoggerE("Failed to find channels: %d", ret); - throw common::NotFoundException("Failed to find channels"); - } - LoggerD("Found channels: %d", resultServices.size()); - auto it = resultServices.begin(); - for (; it != resultServices.end(); ++it) { - ChannelInfo *channelInfo = new ChannelInfo(); - channelInfo->fromApiData(*(*it)); - data->channels.push_back(channelInfo); - delete (*it); - } - resultServices.clear(); - } catch (common::PlatformException& e) { - data->error.reset(new common::PlatformException(e.name(), e.message())); - } catch (...) { - data->error.reset( - new common::UnknownException("Couldn't find channels")); - } -} - -void TVChannelManager::getProgramList( - const std::shared_ptr& data) { - LoggerD("Enter"); - try { - IServiceGuide* guide; - int ret = TVServiceAPI::CreateServiceGuide(&guide); - if (TV_SERVICE_API_SUCCESS != ret) { - LoggerE("Failed to create service guide: %d", ret); - throw common::UnknownException("Failed to create service guide"); - } - - std::map programList; - ret = guide->GetProgramList(data->channelId, - data->startTime, data->duration, programList); - if (TV_SERVICE_API_METHOD_FAILURE == ret) { - LoggerE("Failed to get program list."); - throw common::NotFoundException("Failed to get program list."); - } - LoggerD("Found programs: %d", programList.size()); - - auto it = programList.begin(); - for (; it != programList.end(); ++it) { - ProgramInfo *programInfo = new ProgramInfo(); - programInfo->fromApiData(*(it->second)); - data->programs.push_back(programInfo); - delete it->second; - } - programList.clear(); - } catch (common::PlatformException& e) { - data->error.reset(new common::PlatformException(e.name(), e.message())); - } catch (...) { - data->error.reset( - new common::UnknownException("Couldn't find channels")); - } -} - -TVChannelManager::~TVChannelManager() { - TVServiceAPI::Destroy(); -} - - -} // namespace tvchannel -} // namespace extension diff --git a/src/tvchannel/tvchannel_manager.h b/src/tvchannel/tvchannel_manager.h deleted file mode 100644 index 09d996f2..00000000 --- a/src/tvchannel/tvchannel_manager.h +++ /dev/null @@ -1,166 +0,0 @@ -/* - * 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 SRC_TVCHANNEL_TVCHANNEL_MANAGER_H_ -#define SRC_TVCHANNEL_TVCHANNEL_MANAGER_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "tvchannel/types.h" -#include "tvchannel/tune_option.h" -#include "common/platform_exception.h" -#include "tvchannel/program_info.h" - -namespace common { -class PlatformException; -} - -namespace extension { -namespace tvchannel { - -class ChannelInfo; -class ProgramInfo; -// TVServiceAPI static methods returns 0 on success -static const int TV_SERVICE_API_SUCCESS = 0; -// TVServiceAPI object methods return 1 on success -static const int TV_SERVICE_API_METHOD_SUCCESS = 1; -// TVServiceAPI object methods return -1 on failure -static const int TV_SERVICE_API_METHOD_FAILURE = -1; -// You need to check error return in function/method docs and use correct -// constant - -class EventListener { - public: - virtual void onChannelChange(double callbackId) = 0; - virtual void onEPGReceived(double callbackId) = 0; - virtual void onNoSignal(double callbackId) = 0; - virtual ~EventListener() { - } -}; - -class TVChannelManager { - public: - struct TuneData { - TuneData(TuneOption _tuneOption, WindowType _windowType, - double _callbackId) : - tuneOption(_tuneOption), windowType(_windowType), - callbackId(_callbackId) { - } - TuneData(NavigatorMode _navMode, WindowType _windowType, - double _callbackId) : - navMode(_navMode), windowType(_windowType), - callbackId(_callbackId) { - } - NavigatorMode navMode; - TuneOption tuneOption; - WindowType windowType; - double callbackId; - u_int64_t serviceId; - std::shared_ptr pError; - }; - - static TVChannelManager* getInstance(); - static void ucs2utf8(char *out, size_t out_len, char *in, size_t in_len); - void registerListener(ISignalSubscriber* pSubscriber); - ISignalSubscriber* createSubscriber(EventListener* pListener); - std::unique_ptr getCurrentChannel(WindowType _windowType); - ProgramInfo* getCurrentProgram(WindowType _windowType); - - void tune(std::shared_ptr const& _pTuneData); - void tuneUp(std::shared_ptr const& _pTuneData); - void tuneDown(std::shared_ptr const& _pTuneData); - - EProfile getProfile(WindowType windowType); - IServiceNavigation* getNavigation(EProfile profileId, u_int16_t screenId); - TSTvMode getTvMode(IServiceNavigation* _pNavigation); - std::unique_ptr getBasicCriteria(TSTvMode tvMode, - ENavigationMode naviMode); - TCServiceData getCurrentServiceInfo(IServiceNavigation* _pNavigation, - TSTvMode _mode, std::unique_ptr const& _pCriteria); - - IService* getService(); - - struct FindChannelData { - std::shared_ptr error; - int32_t major; - int32_t minor; - double callbackId; - std::list channels; - }; - - void findChannel(const std::shared_ptr& data); - - struct GetChannelListData { - NavigatorMode tuneMode; - bool nStartSet; - bool numberSet; - std::shared_ptr error; - int32_t nStart; - int32_t number; - double callbackId; - std::list channels; - - GetChannelListData() : - tuneMode(NOT_DEFINED), - nStartSet(false), - numberSet(false) { - } - }; - - void getChannelList(const std::shared_ptr& data); - - struct GetProgramListData { - TCServiceId channelId; - u_int32_t startTime; - u_int32_t duration; - std::shared_ptr error; - double callbackId; - std::list programs; - }; - - void getProgramList(const std::shared_ptr& data); - - ~TVChannelManager(); - - private: - EventListener* m_listener; - // Not copyable, assignable, movable - TVChannelManager(); - TVChannelManager(TVChannelManager const&) = delete; - void operator=(TVChannelManager const&) = delete; - TVChannelManager(TVChannelManager &&) = delete; - - TCServiceId getCurrentChannelId(WindowType _windowType); - static int signalListener(ESignalType type, EProfile _profile, - u_int16_t _screenID, TSSignalData data, void*); - IService* m_pService; - - static const int SCREENID = 0; - - std::mutex tuneMutex; - std::map m_callbackTuneMap; -}; - -} // namespace tvchannel -} // namespace extension - -#endif // SRC_TVCHANNEL_TVCHANNEL_MANAGER_H_ diff --git a/src/tvchannel/types.cc b/src/tvchannel/types.cc deleted file mode 100644 index 7dd7096e..00000000 --- a/src/tvchannel/types.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 "tvchannel/types.h" -#include "common/logger.h" -#include "common/platform_exception.h" - -namespace extension { -namespace tvchannel { - -const char* NAVIGATOR_MODE_ALL = "ALL"; -const char* NAVIGATOR_MODE_DIGITAL = "DIGITAL"; -const char* NAVIGATOR_MODE_ANALOG = "ANALOG"; -const char* NAVIGATOR_MODE_FAVORITE = "FAVORITE"; - -NavigatorMode stringToNavigatorMode(const std::string &mode) { - if (mode == NAVIGATOR_MODE_ALL) { - return NavigatorMode::ALL; - } - if (mode == NAVIGATOR_MODE_DIGITAL) { - return NavigatorMode::DIGITAL; - } - if (mode == NAVIGATOR_MODE_ANALOG) { - return NavigatorMode::ANALOG; - } - if (mode == NAVIGATOR_MODE_FAVORITE) { - return NavigatorMode::FAVORITE; - } - LoggerE("Unrecognized mode"); - throw common::UnknownException("Unrecognized mode"); -} - -const char* TIZEN_TV_WINDOW_TYPE_MAIN = "MAIN"; -// PIP is not supported - j.h.lim -// const char* TIZEN_TV_WINDOW_TYPE_PIP = "PIP"; - -std::string windowTypeToString(WindowType type) { - switch (type) { - case MAIN: - return TIZEN_TV_WINDOW_TYPE_MAIN; - break; -// PIP is not supported - j.h.lim -// case PIP: -// return TIZEN_TV_WINDOW_TYPE_PIP; -// break; - default: - LoggerE("Unrecognized window type: %d", type); - throw common::UnknownException("Unrecognized window type"); - } -} - -WindowType stringToWindowType(std::string type) { - if (type == TIZEN_TV_WINDOW_TYPE_MAIN) { - return MAIN; -// PIP is not supported - j.h.lim -// } else if (type == TIZEN_TV_WINDOW_TYPE_PIP) { -// return PIP; - } else { - LoggerE("Unrecognized window type: %s", type.c_str()); - throw common::UnknownException("Unrecognized window type"); - } -} - -} // namespace tvchannel -} // namespace extension - diff --git a/src/tvchannel/types.h b/src/tvchannel/types.h deleted file mode 100644 index 315d4e19..00000000 --- a/src/tvchannel/types.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 SRC_TVCHANNEL_TYPES_H_ -#define SRC_TVCHANNEL_TYPES_H_ - -#include - -namespace extension { -namespace tvchannel { - -enum NavigatorMode { - NOT_DEFINED, - ALL, - DIGITAL, - ANALOG, - FAVORITE -}; - -enum WindowType { - MAIN = 0, -// PIP is not supported - j.h.lim -// PIP -}; - -extern const char* TIZEN_TV_WINDOW_TYPE_MAIN; - -enum class SourceType { - TV, - AV, - SVIDEO, - COMP, - PC, - HDMI, - SCART, - DVI, - MEDIA, - IPTV, - UNKNOWN -}; - -extern const char* NAVIGATOR_MODE_ALL; -extern const char* NAVIGATOR_MODE_DIGITAL; -extern const char* NAVIGATOR_MODE_ANALOG; -extern const char* NAVIGATOR_MODE_FAVORITE; - -NavigatorMode stringToNavigatorMode(std::string const& mode); -std::string windowTypeToString(WindowType type); -WindowType stringToWindowType(std::string type); - -} // namespace tvchannel -} // namespace extension - -#endif // SRC_TVCHANNEL_TYPES_H_ diff --git a/src/tvdisplay/tvdisplay.gyp b/src/tvdisplay/tvdisplay.gyp deleted file mode 100644 index d56c01ab..00000000 --- a/src/tvdisplay/tvdisplay.gyp +++ /dev/null @@ -1,37 +0,0 @@ -{ - 'includes':[ - '../common/common.gypi', - ], - 'targets': [ - { - 'target_name': 'tizen_tvdisplay', - 'type': 'loadable_module', - 'dependencies': [ - '../common/common.gyp:tizen_common', - ], - 'includes': [ - '../common/pkg-config.gypi', - ], - 'sources': [ - 'tvdisplay_api.js', - 'tvdisplay_extension.cc', - 'tvdisplay_extension.h', - 'tvdisplay_instance.cc', - 'tvdisplay_instance.h', - ], - 'conditions': [ - [ - 'tizen == 1', - { - 'variables': { - 'packages': [ - 'capi-system-info', - 'vconf', - ] - }, - }, - ], - ], - }, - ], -} diff --git a/src/tvdisplay/tvdisplay_api.js b/src/tvdisplay/tvdisplay_api.js deleted file mode 100644 index 5d160a18..00000000 --- a/src/tvdisplay/tvdisplay_api.js +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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. - */ - -/** - * @author m.wasowski2@samsung.com (Marcin Wasowski) - */ - -function TVDisplay() {} - -var native = new xwalk.utils.NativeManager(extension); -var validator = xwalk.utils.validator; -var validatorTypes = xwalk.utils.validator.Types; - -var UNKNOWN_ERROR = 'UnknownError'; - - -/** - * Allowed values for is3DModeEnabled return value - * @type {Display3DModeState} - */ -var Display3DModeState = { - NOT_CONNECTED: 'NOT_CONNECTED', - NOT_SUPPORTED: 'NOT_SUPPORTED', - READY: 'READY' -}; -Object.freeze(Display3DModeState); - - -/** - * Check if 3D mode is enabled - * @return {Display3DModeState} mode String informing if 3D content - * is supported and ready - */ -TVDisplay.prototype.is3DModeEnabled = function() { - var ret = native.callSync('TVDisplay_is3DModeEnabled', {}); - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } - return native.getResultObject(ret); -}; - - -/** - * Allowed values for 3D effect modes mapped to return values from C API - * - * OFF - identifier for 3DEffect mode off - * TOP_BOTTOM - Top-bottom: Left at top, right at bottom - * SIDE_BY_SIDE - Top-bottom: Left at left side, right at right side - * LINE_BY_LINE - Line-by-line: Left and right image interlaced by row - * VERTICAL_STRIP - Vertical-strip: Left and right image - * interlaced by column - * FRAME_SEQUENCE - Left and right image interlaced by frame - * CHECKER_BD - Checkerboard (only for PC or game console sources) - * FROM_2D_TO_3D - Left and right image computed from - * No-stereoscopic image -*/ -var Display3DEffectMode = [ - 'OFF', - 'TOP_BOTTOM', - 'SIDE_BY_SIDE', - 'LINE_BY_LINE', - 'VERTICAL_STRIPE', - 'FRAME_SEQUENCE', - 'CHECKER_BD', - 'FROM_2D_TO_3D' -]; -Object.freeze(Display3DEffectMode); - - -/** - * Get current 3D effect mode or 'OFF' if no 3D enabled - * @return {string} current mode name - */ -TVDisplay.prototype.get3DEffectMode = function() { - var ret = native.callSync('TVDisplay_get3DEffectMode', {}); - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } - var mode = Display3DEffectMode[native.getResultObject(ret)]; - if (!mode) { - var error_msg = 'Unknown 3D effect mode (' + reply.result + ')'; - throw new WebAPIException(0, error_msg, UNKNOWN_ERROR); - } - return mode; -}; - - -/** - * Get list of supported 3D effects - * - * @param {!Mode3DEffectListSupportCallback} successCallback - * @param {?ErrorCallback} errorCallback - */ -TVDisplay.prototype.getSupported3DEffectModeList = function( - successCallback, - errorCallback) { - - var successCallback = { - name: 'successCallback', - type: validatorTypes.FUNCTION, - optional: false, - nullable: false - }; - var errorCallback = { - name: 'errorCallback', - type: validatorTypes.FUNCTION, - optional: true, - nullable: true - }; - - var args = validator.validateArgs( - arguments, - [successCallback, errorCallback]); - - native.call( - 'TVDisplay_getSupported3DEffectModeList', - {}, - function(msg) { - if (msg && !msg.error) { - args.successCallback(msg.result); - } else if (msg && validatorTypes.isFunction(args.errorCallback)) { - args.errorCallback(native.getErrorObject(msg.error)); - } else { - return; - } - } - ); - -}; - - -exports = new TVDisplay(); diff --git a/src/tvdisplay/tvdisplay_extension.cc b/src/tvdisplay/tvdisplay_extension.cc deleted file mode 100644 index e23e7420..00000000 --- a/src/tvdisplay/tvdisplay_extension.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 "tvdisplay/tvdisplay_extension.h" -#include "tvdisplay/tvdisplay_instance.h" - -// This will be generated from tvdisplay_api.js. -extern const char kSource_tvdisplay_api[]; - - -namespace extension { -namespace tvdisplay { - -TVDisplayExtension::TVDisplayExtension() { - SetExtensionName("tizen.tvdisplaycontrol"); - SetJavaScriptAPI(kSource_tvdisplay_api); -} - -TVDisplayExtension::~TVDisplayExtension() {} - -common::Instance* TVDisplayExtension::CreateInstance() { - return new extension::tvdisplay::TVDisplayInstance(); -} - -} // namespace tvdisplay -} // namespace extension - -// entry point -common::Extension* CreateExtension() { - return new extension::tvdisplay::TVDisplayExtension(); -} - diff --git a/src/tvdisplay/tvdisplay_extension.h b/src/tvdisplay/tvdisplay_extension.h deleted file mode 100644 index bd2792cf..00000000 --- a/src/tvdisplay/tvdisplay_extension.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 SRC_TVDISPLAY_TVDISPLAY_EXTENSION_H_ -#define SRC_TVDISPLAY_TVDISPLAY_EXTENSION_H_ - -#include "common/extension.h" - -namespace extension { -namespace tvdisplay { - -class TVDisplayExtension : public common::Extension { - public: - TVDisplayExtension(); - virtual ~TVDisplayExtension(); - - private: - virtual common::Instance* CreateInstance(); -}; - -} // namespace tvdisplay -} // namespace extension - -#endif // SRC_TVDISPLAY_TVDISPLAY_EXTENSION_H_ diff --git a/src/tvdisplay/tvdisplay_instance.cc b/src/tvdisplay/tvdisplay_instance.cc deleted file mode 100644 index 3c86e740..00000000 --- a/src/tvdisplay/tvdisplay_instance.cc +++ /dev/null @@ -1,234 +0,0 @@ -/* - * 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 "tvdisplay/tvdisplay_instance.h" - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - - -namespace { - const char* kCmd = "cmd"; - const char* kArg = "arg"; - const char* kError = "error"; - const char* kValue = "value"; - const char* kResult = "result"; - const char* kSuccess = "success"; - const char* kNotImplemented = "Not implemented"; - const char *kID = "callbackId"; - - const int kVCONF_SUCCESS = 0; - const char* kVCONF_3D_MODE_KEY = "db/menu/picture/3d/3dmode"; - - const std::map supported_3D_modes { - {SYSTEM_INFO_3D_MODE_OFF, "OFF"}, - {SYSTEM_INFO_3D_MODE_TOP_BOTTOM, "TOP_BOTTOM"}, - {SYSTEM_INFO_3D_MODE_SIDE_BY_SIDE, "SIDE_BY_SIDE"}, - {SYSTEM_INFO_3D_MODE_CHECKER_BOARD, "CHECKER_BD"}, - {SYSTEM_INFO_3D_MODE_LINE_BY_LINE, "LINE_BY_LINE"}, - {SYSTEM_INFO_3D_MODE_VERTICAL_STRIPE, "VERTICAL_STRIPE"}, - {SYSTEM_INFO_3D_MODE_FRAME_SEQUENTIAL, "FRAME_SEQUENCE"}, - {SYSTEM_INFO_3D_MODE_2D_3D_CONVERSION, "FROM_2D_TO_3D"} - }; - - common::PlatformResult is_3D_enabled(bool &is_3D_supported) { - LOGD("Enter"); - int is_supported = -1; - int ret = system_info_get_value_int( - SYSTEM_INFO_KEY_3D_SUPPORT, - &is_supported); - - if (SYSTEM_INFO_ERROR_NONE != ret) { - std::string message = "'system_info' error while " - "getting 3d mode details: " + std::to_string(ret); - LOGE("%s", message.c_str()); - return common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, - "Unknown error. " + message); - } - - is_3D_supported = (is_supported == 1); - return common::PlatformResult(common::ErrorCode::NO_ERROR); - } -} // namespace - -namespace extension { -namespace tvdisplay { - -TVDisplayInstance::TVDisplayInstance() { - using std::placeholders::_1; - using std::placeholders::_2; - - #define REGISTER_ASYNC(c, func) \ - RegisterSyncHandler(c, func); - #define REGISTER_SYNC(c, func) \ - RegisterSyncHandler(c, func); - - REGISTER_SYNC("TVDisplay_is3DModeEnabled", - std::bind(&TVDisplayInstance::Is3DModeEnabled, this, _1, _2)); - REGISTER_SYNC("TVDisplay_get3DEffectMode", - std::bind(&TVDisplayInstance::Get3DEffectMode,this, _1, _2)); - REGISTER_ASYNC("TVDisplay_getSupported3DEffectModeList", - std::bind(&TVDisplayInstance::GetSupported3DEffectModeList, - this, _1, _2)); - - #undef REGISTER_ASYNC - #undef REGISTER_SYNC -} - -TVDisplayInstance::~TVDisplayInstance() {} - - -void TVDisplayInstance::Is3DModeEnabled( - const picojson::value& value, - picojson::object& out) { - LOGD("Enter"); - picojson::value::object o; - std::string mode = "NOT_SUPPORTED"; - bool is_3D_supported = false; - common::PlatformResult result = is_3D_enabled(is_3D_supported); - if (result.IsError()) { - LOGD("Error occured"); - ReportError(result, &out); - } else { - if (is_3D_supported) { - mode = "READY"; - } - LOGD("3D Mode is: %s", mode.c_str()); - picojson::value result(mode); - ReportSuccess(result, out); - } -} - -void TVDisplayInstance::Get3DEffectMode( - const picojson::value& value, - picojson::object& out) { - LOGD("Enter"); - - int mode = 0; - int ret = vconf_get_int(kVCONF_3D_MODE_KEY, &mode); - - if (kVCONF_SUCCESS != ret) { - std::string err - = "Platform error while getting 3d mode details: " - + std::to_string(ret); - LOGE("%s", err.c_str()); - ReportError(common::UnknownException(err), out); - } - ReportSuccess(picojson::value(mode * 1.0), out); -} - -void TVDisplayInstance::GetSupported3DEffectModeList( - const picojson::value& value, - picojson::object& out) { - LOGD("Enter"); - - std::shared_ptr reply - = std::shared_ptr ( - new picojson::value::object()); - - (*reply)[kID] = value.get(kID); - - std::function const&)> task = - std::bind( - &TVDisplayInstance::GetSupported3DEffectModeListTask, - this, - std::placeholders::_1); - std::function const&) > taskAfter = - std::bind( - &TVDisplayInstance::GetSupported3DEffectModeListTaskAfter, - this, - std::placeholders::_1); - common::TaskQueue::GetInstance() - .Queue ( - task, - taskAfter, - reply); - ReportSuccess(out); -} - -void TVDisplayInstance::GetSupported3DEffectModeListTask( - std::shared_ptr const& data) { - LOGD("Enter"); - - picojson::object & reply = (*data); - std::vector modes; - bool is_3D_supported = false; - common::PlatformResult res = is_3D_enabled(is_3D_supported); - if (res.IsError()) { - LOGD("Error occured"); - reply[kError] = res.ToJSON(); - return; - } - if (!is_3D_supported) { - LOGD("3D is disabled"); - reply[kResult] = picojson::value(modes); - reply[kSuccess] = picojson::value(true); - return; - } - int flags = -1; - int result = system_info_get_value_int( - SYSTEM_INFO_KEY_3D_EFFECT_MODE, - &flags); - if (SYSTEM_INFO_ERROR_NONE != result) { - const char * kMessage = - "Fetching SYSTEM_INFO_KEY_3D_EFFECT_MODE failed"; - LOGE("%s: %d", kMessage, result); - LOGD("Error occured"); - res = common::PlatformResult(common::ErrorCode::UNKNOWN_ERR, - "Unknown error. " + std::string(kMessage)); - reply[kError] = res.ToJSON(); - return; - } - - auto it = supported_3D_modes.begin(); - for (it; it != supported_3D_modes.end(); ++it) { - if (it->first & flags) { - modes.push_back(picojson::value(it->second)); - } - } - - if (flags & SYSTEM_INFO_3D_MODE_FRAME_PACKING) { - LOGD("There is no FRAME_PACKING mode in TIZEN"); - } - if (flags & SYSTEM_INFO_3D_MODE_FRAME_DUAL) { - LOGD("There is no FRAME_DUAL mode in TIZEN"); - } - - reply[kResult] = picojson::value(modes); - reply[kSuccess] = picojson::value(true); -} - -void TVDisplayInstance::GetSupported3DEffectModeListTaskAfter( - std::shared_ptr const& data) { - LOGD("Enter"); - picojson::value out(*data); - std::string serialized(out.serialize()); - PostMessage(serialized.c_str()); -} - -} // namespace tvdisplay -} // namespace extension diff --git a/src/tvdisplay/tvdisplay_instance.h b/src/tvdisplay/tvdisplay_instance.h deleted file mode 100644 index e8ea11ac..00000000 --- a/src/tvdisplay/tvdisplay_instance.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 SRC_TVDISPLAY_TVDISPLAY_INSTANCE_H_ -#define SRC_TVDISPLAY_TVDISPLAY_INSTANCE_H_ - -#include -#include -#include - -#include "common/extension.h" -#include "common/picojson.h" -#include "common/platform_result.h" - -namespace extension { -namespace tvdisplay { - -class TVDisplayInstance : public common::ParsedInstance { - public: - TVDisplayInstance(); - virtual ~TVDisplayInstance(); - - private: - void Is3DModeEnabled( - const picojson::value& value, - picojson::object& out); - - void Get3DEffectMode( - const picojson::value& value, - picojson::object& out); - - void GetSupported3DEffectModeList( - const picojson::value& value, - picojson::object& out); - - void GetSupported3DEffectModeListTask( - std::shared_ptr const& data); - - void GetSupported3DEffectModeListTaskAfter( - std::shared_ptr const& data); - - public: - static TVDisplayInstance* getInstance(); -}; - -} // namespace tvdisplay -} // namespace extension - -#endif // SRC_TVDISPLAY_TVDISPLAY_INSTANCE_H_ diff --git a/src/tvinputdevice/tvinputdevice.gyp b/src/tvinputdevice/tvinputdevice.gyp deleted file mode 100644 index 9bd3ab0c..00000000 --- a/src/tvinputdevice/tvinputdevice.gyp +++ /dev/null @@ -1,32 +0,0 @@ -{ - 'includes':[ - '../common/common.gypi', - ], - 'targets': [ - { - 'target_name': 'tizen_tvinputdevice', - 'type': 'loadable_module', - 'dependencies': [ - '../common/common.gyp:tizen_common', - ], - 'sources': [ - 'tvinputdevice_api.js', - 'tvinputdevice_extension.cc', - 'tvinputdevice_extension.h', - 'tvinputdevice_instance.cc', - 'tvinputdevice_instance.h' - ], - 'includes': [ - '../common/pkg-config.gypi', - ], - 'conditions': [ - ['tizen == 1', { - 'variables': { - 'packages': [ - ] - }, - }], - ], - }, - ], -} diff --git a/src/tvinputdevice/tvinputdevice_api.js b/src/tvinputdevice/tvinputdevice_api.js deleted file mode 100644 index 0c58d8f4..00000000 --- a/src/tvinputdevice/tvinputdevice_api.js +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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. - */ - -var native = new xwalk.utils.NativeManager(extension); -var validator = xwalk.utils.validator; -var types = validator.Types; -var map = { - "VolumeUp": { - keyName: "XF86AudioRaiseVolume", - keyCode: 447 - }, - "VolumeDown": { - keyName: "XF86AudioLowerVolume", - keyCode: 448 - }, -}; - - -function TVInputDeviceKey(dict) { - for (var key in dict) { - if (dict.hasOwnProperty(key)) { - Object.defineProperty(this, key, { - value: dict[key], - enumerable: true - }); - } - } - Object.freeze(this); -} - - -/** - * This class provides access to the API functionalities through the tizen.tvinputdevice interface. - * @constructor - */ -function TVInputDeviceManager() { - if (!(this instanceof TVInputDeviceManager)) { - throw new TypeError; - } -} - -/** - * Retrieves the list of keys can be registered with the registerKey() method. - * @return {array} Array of keys - */ -TVInputDeviceManager.prototype.getSupportedKeys = function() { - - var re = []; - for (var key in map) { - if (map.hasOwnProperty(key)) { - re.push(new TVInputDeviceKey({name: key, code: map[key].keyCode})); - } - } - - return re; -}; - - -/** - * Returns information about the key which has the given name. - * @param {!string} keyName The key name - * @return {object} Key object - */ -TVInputDeviceManager.prototype.getKey = function(keyName) { - var args = validator.validateArgs(arguments, [ - {name: 'keyName', type: types.STRING} - ]); - - if (!map[args.keyName]) { - throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, - 'Parameter "keyName" is invalid.'); - } - - return new TVInputDeviceKey( { name: args.keyName, code: map[args.keyName].keyCode } ); - -}; - - -/** - * Registers an input device key to receive DOM keyboard event when it is pressed or released. - * @param {!string} keyName The key name - */ -TVInputDeviceManager.prototype.registerKey = function(keyName) { - var args = validator.validateArgs(arguments, [ - {name: 'keyName', type: types.STRING} - ]); - if (!map[args.keyName]) { - throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, - 'Parameter "keyName" is invalid.'); - } - - var ret = native.sendRuntimeSyncMessage('tizen://api/inputdevice/registerKey',map[args.keyName].keyName); - - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } -}; - - -/** - * Unregisters an input device key. - * @param {!string} keyName The key name - */ -TVInputDeviceManager.prototype.unregisterKey = function(keyName) { - var args = validator.validateArgs(arguments, [ - {name: 'keyName', type: types.STRING} - ]); - - if (!map[args.keyName]) { - throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, - 'Parameter "keyName" is invalid.'); - } - - var ret = native.sendRuntimeSyncMessage('tizen://api/inputdevice/unregisterKey',map[args.keyName].keyName); - - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } -}; - - -// Exports -exports = new TVInputDeviceManager(); diff --git a/src/tvinputdevice/tvinputdevice_extension.cc b/src/tvinputdevice/tvinputdevice_extension.cc deleted file mode 100644 index e007872f..00000000 --- a/src/tvinputdevice/tvinputdevice_extension.cc +++ /dev/null @@ -1,30 +0,0 @@ -// 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 "../tvinputdevice/tvinputdevice_extension.h" -#include "../tvinputdevice/tvinputdevice_instance.h" - -// This will be generated from tvinputdevice_api.js -extern const char kSource_tvinputdevice_api[]; - -namespace extension { -namespace tvinputdevice { - -TVInputDeviceExtension::TVInputDeviceExtension() { - SetExtensionName("tizen.tvinputdevice"); - SetJavaScriptAPI(kSource_tvinputdevice_api); -} - -TVInputDeviceExtension::~TVInputDeviceExtension() {} - -common::Instance* TVInputDeviceExtension::CreateInstance() { - return new TVInputDeviceInstance; -} - -} // namespace tvinputdevice -} // namespace extension - -common::Extension* CreateExtension() { - return new extension::tvinputdevice::TVInputDeviceExtension; -} diff --git a/src/tvinputdevice/tvinputdevice_extension.h b/src/tvinputdevice/tvinputdevice_extension.h deleted file mode 100644 index 8a633f15..00000000 --- a/src/tvinputdevice/tvinputdevice_extension.h +++ /dev/null @@ -1,26 +0,0 @@ -// 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 SRC_TVINPUTDEVICE_TVINPUTDEVICE_EXTENSION_H_ -#define SRC_TVINPUTDEVICE_TVINPUTDEVICE_EXTENSION_H_ - -#include "common/extension.h" - -namespace extension { -namespace tvinputdevice { - -class TVInputDeviceExtension : public common::Extension { - public: - TVInputDeviceExtension(); - virtual ~TVInputDeviceExtension(); - - private: - virtual common::Instance* CreateInstance(); -}; - -} // namespace tvinputdevice -} // namespace extension - -#endif // SRC_TVINPUTDEVICE_TVINPUTDEVICE_EXTENSION_H_ - diff --git a/src/tvinputdevice/tvinputdevice_instance.cc b/src/tvinputdevice/tvinputdevice_instance.cc deleted file mode 100644 index fe926ca4..00000000 --- a/src/tvinputdevice/tvinputdevice_instance.cc +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 "../tvinputdevice/tvinputdevice_instance.h" -#include "common/logger.h" - - -namespace extension { -namespace tvinputdevice { - -TVInputDeviceInstance::TVInputDeviceInstance() { - LOGD("Enter"); -} - -TVInputDeviceInstance::~TVInputDeviceInstance() { - LOGD("Enter"); -} - -} // namespace tvinputdevice -} // namespace extension diff --git a/src/tvinputdevice/tvinputdevice_instance.h b/src/tvinputdevice/tvinputdevice_instance.h deleted file mode 100644 index d48248e1..00000000 --- a/src/tvinputdevice/tvinputdevice_instance.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 SRC_TVINPUTDEVICE_TVINPUTDEVICE_INSTANCE_H_ -#define SRC_TVINPUTDEVICE_TVINPUTDEVICE_INSTANCE_H_ - -#include "common/picojson.h" -#include "common/extension.h" - - -namespace extension { -namespace tvinputdevice { - -class TVInputDeviceInstance : public common::ParsedInstance { - public: - TVInputDeviceInstance(); - virtual ~TVInputDeviceInstance(); - - private: -}; - -} // namespace tvinputdevice -} // namespace extension - -#endif // SRC_TVINPUTDEVICE_TVINPUTDEVICE_INSTANCE_H_ diff --git a/src/tvwindow/tvwindow.gyp b/src/tvwindow/tvwindow.gyp deleted file mode 100644 index 00d93e37..00000000 --- a/src/tvwindow/tvwindow.gyp +++ /dev/null @@ -1,33 +0,0 @@ -{ - 'includes':[ - '../common/common.gypi', - ], - 'targets': [ - { - 'target_name': 'tizen_tvwindow', - 'type': 'loadable_module', - 'variables': { - 'packages': [ - 'capi-system-info', - #'tvs-api',# off for tizen 3.0. additionally, not use currently - ], - }, - 'dependencies': [ - '../common/common.gyp:tizen_common', - '../tizen/tizen.gyp:tizen', - ], - 'includes': [ - '../common/pkg-config.gypi', - ], - 'sources': [ - 'tvwindow_api.js', - 'tvwindow_extension.cc', - 'tvwindow_extension.h', - 'tvwindow_manager.cc', - 'tvwindow_manager.h', - 'tvwindow_instance.cc', - 'tvwindow_instance.h', - ], - }, - ], -} diff --git a/src/tvwindow/tvwindow_api.js b/src/tvwindow/tvwindow_api.js deleted file mode 100644 index f42de8d2..00000000 --- a/src/tvwindow/tvwindow_api.js +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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. - */ - -var native = new xwalk.utils.NativeManager(extension); -var validator = xwalk.utils.validator; -var WindowType = { - MAIN: 'MAIN' -}; - -//TVWindowManager interface -function TVWindowManager() { - if (!(this instanceof TVWindowManager)) { - throw new TypeError; - } - var ret = native.callSync('TVWindow_GetScreenDimension', {}); - if (native.isFailure(ret)) { - throw native.getErrorObject(ret); - } - var result = native.getResultObject(ret); - this.max_width = result.width; - this.max_height = result.height; -} - - -TVWindowManager.prototype.getAvailableWindows = function(successCallback, errorCallback) { - return undefined; -}; - -TVWindowManager.prototype.setSource = function(videosource, successCallback, errorCallback, type) { - return undefined; -}; - -TVWindowManager.prototype.getSource = function(type) { - return undefined; -}; - -TVWindowManager.prototype.show = function(successCallback, errorCallback, rectangle, type) { - // todo privilege check -// xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.TV_WINDOW); - var args = validator.validateArgs(arguments, [ - { - name: 'successCallback', - type: validator.Types.FUNCTION - }, - { - name: 'errorCallback', - type: validator.Types.FUNCTION, - optional: true, - nullable: true - }//, - //todo rectangle -// { -// name: 'type', -// optional: true, -// nullable: true, -// type: validator.Types.ENUM, -// values: Object.keys(WindowType) -// } - ]); - - native.sendRuntimeAsyncMessage('tizen://tvwindow/show', null, function(result) { - if (native.isFailure(result)) { - native.callIfPossible(args.errorCallback, native.getErrorObject(result)); - } else { - native.sendRuntimeAsyncMessage('tizen://tvwindow/reposition', '400,400,120,80', function(result) { - if (native.isFailure(result)) { - native.callIfPossible(args.errorCallback, native.getErrorObject(result)); - } else { - //todo wait for tv-window ready - setTimeout(function() { - args.successCallback([400,400,120,80], "MAIN"); - }, 1000); - } - }); - } - }); -}; - -TVWindowManager.prototype.hide = function(successCallback, errorCallback, type) { - // todo privilege check -// xwalk.utils.checkPrivilegeAccess(xwalk.utils.privilege.TV_WINDOW); - var args = validator.validateArgs(arguments, [ - { - name: 'successCallback', - type: validator.Types.FUNCTION - }, - { - name: 'errorCallback', - type: validator.Types.FUNCTION, - optional: true, - nullable: true - }, - { - name: 'type', - optional: true, - nullable: true, - type: validator.Types.ENUM, - values: Object.keys(WindowType) - } - ]); - - native.sendRuntimeAsyncMessage('tizen://tvwindow/hide', null, function(result) { - if (native.isFailure(result)) { - native.callIfPossible(args.errorCallback, native.getErrorObject(result)); - } else { - native.callIfPossible(args.successCallback); - } - }); -}; - -TVWindowManager.prototype.getRect = function(successCallback, errorCallback, unit, type) { - return undefined; -}; - -exports = new TVWindowManager(); diff --git a/src/tvwindow/tvwindow_extension.cc b/src/tvwindow/tvwindow_extension.cc deleted file mode 100644 index 1b662f1a..00000000 --- a/src/tvwindow/tvwindow_extension.cc +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 "tvwindow/tvwindow_extension.h" -#include "tvwindow/tvwindow_instance.h" - -// This will be generated from datasync_api.js. -extern const char kSource_tvwindow_api[]; - -namespace extension { -namespace tvwindow { - -TVWindowExtension::TVWindowExtension() { - SetExtensionName("tizen.tvwindow"); - SetJavaScriptAPI(kSource_tvwindow_api); -} - -TVWindowExtension::~TVWindowExtension() {} - -TVWindowManager& TVWindowExtension::manager() { - // Initialize API on first request - return TVWindowManager::getInstance(); -} - -common::Instance* TVWindowExtension::CreateInstance() { - return new TVWindowInstance(*this); -} - -} // namespace tvwindow -} // namespace extension - -// entry point -common::Extension* CreateExtension() { - return new extension::tvwindow::TVWindowExtension; -} diff --git a/src/tvwindow/tvwindow_extension.h b/src/tvwindow/tvwindow_extension.h deleted file mode 100644 index 398d46a7..00000000 --- a/src/tvwindow/tvwindow_extension.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 SRC_TVWINDOW_TVWINDOW_EXTENSION_H_ -#define SRC_TVWINDOW_TVWINDOW_EXTENSION_H_ - -#include "common/extension.h" -#include "tvwindow/tvwindow_manager.h" - -namespace extension { -namespace tvwindow { - -class TVWindowExtension : public common::Extension { - public: - TVWindowExtension(); - virtual ~TVWindowExtension(); - - TVWindowManager& manager(); - - private: - // common::Extension implementation. - virtual common::Instance* CreateInstance(); -}; - -} // namespace tvwindow -} // namespace extension - -#endif // SRC_TVWINDOW_TVWINDOW_EXTENSION_H_ diff --git a/src/tvwindow/tvwindow_instance.cc b/src/tvwindow/tvwindow_instance.cc deleted file mode 100644 index a8cbfe78..00000000 --- a/src/tvwindow/tvwindow_instance.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 "tvwindow/tvwindow_instance.h" -#include "common/logger.h" -#include "tizen/tizen.h" -#include "common/picojson.h" -#include "common/platform_result.h" -#include - -namespace extension { -namespace tvwindow { - -TVWindowInstance::TVWindowInstance(TVWindowExtension const& extension) { - LoggerD("Entered"); - using std::placeholders::_1; - using std::placeholders::_2; - - RegisterSyncHandler("TVWindow_GetScreenDimension", - std::bind(&TVWindowInstance::GetScreenDimension, this, _1, _2)); -} - -TVWindowInstance::~TVWindowInstance() { - LoggerD("Entered"); -} - -void TVWindowInstance::GetScreenDimension(const picojson::value& args, - picojson::object& out) { - LoggerD("Entered"); - - int max_width = 0; - if (system_info_get_value_int(SYSTEM_INFO_KEY_OSD_RESOLUTION_WIDTH, - &max_width) != SYSTEM_INFO_ERROR_NONE) { - common::PlatformResult res(common::ErrorCode::UNKNOWN_ERR, - "Failed to retrieve screen max width"); - ReportError(res, &out); - return; - } - int max_height = 0; - if (system_info_get_value_int(SYSTEM_INFO_KEY_OSD_RESOLUTION_HEIGHT, - &max_height) != SYSTEM_INFO_ERROR_NONE) { - common::PlatformResult res(common::ErrorCode::UNKNOWN_ERR, - "Failed to retrieve screen max height"); - ReportError(res, &out); - return; - } - picojson::value::object dict; - dict["width"] = picojson::value(static_cast(max_width)); - dict["height"] = picojson::value(static_cast(max_height)); - picojson::value result(dict); - ReportSuccess(result, out); -} - -} // namespace tvwindow -} // namespace extension diff --git a/src/tvwindow/tvwindow_instance.h b/src/tvwindow/tvwindow_instance.h deleted file mode 100644 index f6af0314..00000000 --- a/src/tvwindow/tvwindow_instance.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 SRC_TVWINDOW_TVWINDOW_INSTANCE_H_ -#define SRC_TVWINDOW_TVWINDOW_INSTANCE_H_ - -#include - -#include "common/extension.h" -#include "common/picojson.h" - -#include "tvwindow/tvwindow_extension.h" - -namespace extension { -namespace tvwindow { - -class TVWindowInstance : public common::ParsedInstance { - public: - explicit TVWindowInstance(TVWindowExtension const& extension); - virtual ~TVWindowInstance(); - - private: - void GetScreenDimension(const picojson::value& args, picojson::object& out); -}; - -} // namespace tvwindow -} // namespace extension - -#endif // SRC_TVWINDOW_TVWINDOW_INSTANCE_H_ diff --git a/src/tvwindow/tvwindow_manager.cc b/src/tvwindow/tvwindow_manager.cc deleted file mode 100644 index 696e31e4..00000000 --- a/src/tvwindow/tvwindow_manager.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 "tvwindow/tvwindow_manager.h" - -namespace extension { -namespace tvwindow { - -TVWindowManager::TVWindowManager() { - LoggerD("Enter"); -} - -TVWindowManager& TVWindowManager::getInstance() { - static TVWindowManager manager; - return manager; -} -} // namespace tvwindow -} // namespace extension diff --git a/src/tvwindow/tvwindow_manager.h b/src/tvwindow/tvwindow_manager.h deleted file mode 100644 index 3c951b64..00000000 --- a/src/tvwindow/tvwindow_manager.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 SRC_TVWINDOW_TVWINDOW_MANAGER_H_ -#define SRC_TVWINDOW_TVWINDOW_MANAGER_H_ - -#include "common/logger.h" - -namespace extension { -namespace tvwindow { - -class TVWindowManager { - public: - static TVWindowManager& getInstance(); - - private: - TVWindowManager(); - // Not copyable, assignable, movable - TVWindowManager(TVWindowManager const&); - void operator=(TVWindowManager const&); - TVWindowManager(TVWindowManager &&); -}; - -} // namespace tvwindow -} // namespace extension - -#endif // SRC_TVWINDOW_TVWINDOW_MANAGER_H_ diff --git a/src/utils/utils_api.js b/src/utils/utils_api.js index 6020012c..45d4551d 100755 --- a/src/utils/utils_api.js +++ b/src/utils/utils_api.js @@ -115,7 +115,6 @@ function Utils() { SYSTEM: 'http://tizen.org/privilege/system', SYSTEMMANAGER: 'http://tizen.org/privilege/systemmanager', TELEPHONY: 'http://tizen.org/privilege/telephony', - TV_WINDOW: 'http://tizen.org/privilege/tv.window ', VOLUME_SET: 'http://tizen.org/privilege/volume.set' }; Object.freeze(privilege);