From 0365efb3c1fddc23dee77a597785de3ab3a214f4 Mon Sep 17 00:00:00 2001 From: Paul Kim Date: Mon, 11 Mar 2024 17:48:10 +0900 Subject: [PATCH] issue #11 Add IDCAP API. Support mirroring PIN NUM option feature. --- procentric/application/app_hoteltv_full.html | 1 + procentric/application/index.html | 5 +- procentric/application/lib/hoteltv.hcap.js | 156 +++++++++++++++---- procentric/application/lib/idcap.js | 21 +++ procentric/application/wellcome.html | 1 + 5 files changed, 150 insertions(+), 34 deletions(-) create mode 100755 procentric/application/lib/idcap.js diff --git a/procentric/application/app_hoteltv_full.html b/procentric/application/app_hoteltv_full.html index 1e5525d..cdb85e1 100755 --- a/procentric/application/app_hoteltv_full.html +++ b/procentric/application/app_hoteltv_full.html @@ -422,6 +422,7 @@ + diff --git a/procentric/application/index.html b/procentric/application/index.html index b84637d..fa065f0 100755 --- a/procentric/application/index.html +++ b/procentric/application/index.html @@ -3,8 +3,8 @@ - - + + CENTIRM LG-PROCENTRIC HOTEL SERVICE @@ -59,6 +59,7 @@ + diff --git a/procentric/application/lib/hoteltv.hcap.js b/procentric/application/lib/hoteltv.hcap.js index d6ae53f..15ae9a6 100755 --- a/procentric/application/lib/hoteltv.hcap.js +++ b/procentric/application/lib/hoteltv.hcap.js @@ -40,8 +40,12 @@ HotelTV.hcap = (function() { 'network_info', 'tv_channel_ui', "mute_on_tv_input", 'soft_ap_ui', "soft_ap", "soft_ap_password", + 'picture', 'end_of_item' ]; + + + const g_media = { 'hndl': null, 'status': 'stop', @@ -49,7 +53,7 @@ HotelTV.hcap = (function() { 'tm_lststat': null, }; - const g_hcap_info = { + const g_nativApps_info = { 'preapp': null, }; @@ -62,8 +66,6 @@ HotelTV.hcap = (function() { //// 비공개 매써드 /** * HCAP Wrapper Function::> Get ProCentric Server Info(Realted HCAP API:hcap.power.reboot) - * @param {string} sz_key property key name. - * @param {callback} callback is callback object */ function __hcapfxn_Reboot() { hcap.power.reboot({ @@ -78,8 +80,7 @@ HotelTV.hcap = (function() { /** * HCAP Wrapper Function::> Get ProCentric Server Info(Realted HCAP API:hcap.system.setBrowserDebugMode) - * @param {string} sz_key property key name. - * @param {callback} callback is callback object + * @param {Boolean} enable enable/disable flag. */ function __hcapfxn_setBrowserDebugMode(enable) { hcap.system.setBrowserDebugMode({ @@ -96,7 +97,6 @@ HotelTV.hcap = (function() { /** * HCAP Wrapper Function::> Get Device Properties(Realted HCAP API:hcap.property.getProperty) * @param {string} sz_key property key name. - * @param {callback} callback is callback object */ function __hcapfxn_get_property(sz_key) { return new Promise((resolve, reject) => { @@ -113,7 +113,7 @@ HotelTV.hcap = (function() { /** * HCAP Wrapper Function::> Get Device Properties(Realted HCAP API:hcap.property.setProperty) * @param {string} sz_key property key name. - * @param {callback} callback is callback object + * @param {object} value is object to setting property */ function __hcapfxn_set_property(sz_key, value) { return new Promise((resolve, reject) => { @@ -128,8 +128,63 @@ HotelTV.hcap = (function() { }; /** - * HCAP Wrapper Function::> Get Device Networn Information(Realted HCAP API:hcap.network.getNetworkInformation) + * IDCAP Wrapper Function::> Get Device Configuration(Properties)(Realted IDCAP API:idcap://configuration/property/get) * @param {string} sz_key property key name. + */ + function __idcapfxn_get_property(sz_key) { + return new Promise((resolve, reject) => { + idcap.request( "idcap://configuration/property/get" , { + "parameters": { + "key" : sz_key + }, + "onSuccess": function (s) { + console.log("onSuccess cbObject = " + JSON.stringify(s)); + resolve({ "key": sz_key, "value": s.value }) + }, + "onFailure": function (err) { + console.log("onFailure : errorMessage = " + err.errorMessage); + resolve({ "key": sz_key, "value": "unknown" }) + } + }); + }); + }; + + /** + * IDCAP Wrapper Function::> Get Device Configuration(Properties)(Realted IDCAP API:idcap://configuration/property/set) + * @param {string} sz_key property key name. + * @param {object} value is object to setting property + */ + function __idcapfxn_set_property(sz_key, value) { + return new Promise((resolve, reject) => { + // let param = { + // "key": sz_key, + // "value": value.toString(), + // "onSuccess": function(s) { resolve({ "key": sz_key, "value": value }) }, + // "onFailure": function(f) { resolve({ "key": sz_key, "value": "unknown" }) } + // }; + // hcap.property.setProperty(param); + + idcap.request( "idcap://configuration/property/set" , { + "parameters": { + "key" : sz_key, + "value" : value.toString() + }, + "onSuccess": function () { + resolve({ "key": sz_key, "value": value }); + }, + "onFailure": function (err) { + resolve({ "key": sz_key, "value": "unknown" }) + console.log("onFailure : errorMessage = " + err.errorMessage); + } + }); + }); + }; + + + + /** + * HCAP Wrapper Function::> Get Device Networn Information(Realted HCAP API:hcap.network.getNetworkInformation) + * @param {string} sz_key network property key name. * @param {callback} callback is callback object */ function __hcapfxn_get_netinfo(sz_key, callback) { @@ -184,9 +239,26 @@ HotelTV.hcap = (function() { }); }; + /** + * HCAP Wrapper Function::> Get Device Picture Property Information(Realted HCAP API:hcap.property.getPictureProperty) + * @param {string} sz_key picture property key name. + */ + function __hcapfxn_get_picproperty(sz_key, callback) { + return new Promise((resolve, reject) => { + let param = { + "key": sz_key, + "onSuccess": function(s) { resolve({ "key": sz_key, "value": s.value }) }, + //"onFailure": function(f) { reject({ "key": sz_key, "value": "unknown" }) } + "onFailure": function(f) { resolve({ "key": sz_key, "value": "unknown" }) } + }; + hcap.property.getProperty(param); + }); + }; + + /** * HCAP Wrapper Function::> Get Device Locale List - * @param {string} sz_key property key name. + * @param {string} sz_key locale key name. * @param {callback} callback is callback object */ function __hcapfxn_get_dev_locale_info(sz_key, callback) { @@ -201,7 +273,7 @@ HotelTV.hcap = (function() { /** * HCAP Wrapper Function::> Get ProCentric Server Info(Realted HCAP API:hcap.system.getProcentricServer) - * @param {string} sz_key property key name. + * @param {string} sz_key procentric server property key name. * @param {callback} callback is callback object */ function __hcapfxn_get_pctrsvrinfo(sz_key, callback) { @@ -216,7 +288,6 @@ HotelTV.hcap = (function() { /** * HCAP Wrapper Function::> Get ProCentric Server Info(Realted HCAP API:hcap.system.getHotelMode) - * @param {string} sz_key property key name. * @param {callback} callback is callback object */ function __hcapfxn_get_pctrhotelmodeinfo(callback) { @@ -516,9 +587,7 @@ HotelTV.hcap = (function() { Init: function() { hcap.channel.stopCurrentChannel({ "onSuccess": null, - "onFailure": function(f) { - console.log("onFailure : errorMessage = " + f.errorMessage); - } + "onFailure": null }); }, @@ -561,6 +630,11 @@ HotelTV.hcap = (function() { if (hcap_property_key[i] != 'end_of_item') { if (hcap_property_key[i] == 'network_info') { _pmFxnArProperty.push(__hcapfxn_get_netinfo(hcap_property_key[i])); + } else if (hcap_property_key[i] == 'picture') { + + } else if (hcap_property_key[i] == "wifi_screen_share"){ + // HCAP대신 IDCAP API호출 + _pmFxnArProperty.push(__idcapfxn_get_property(hcap_property_key[i])); } else { _pmFxnArProperty.push(__hcapfxn_get_property(hcap_property_key[i])); } @@ -935,15 +1009,27 @@ HotelTV.hcap = (function() { } else if (_cfg == 'audio') { // TV Default Volume - hcap.volume.setVolumeLevel({ - "level": Number(_devconfig[_cfg].defaultVolume.display), - "onSuccess": function() { - console.log("onSuccess Set to TV default volume set as " + _devconfig[_cfg].defaultVolume.display); + // 현재 오디오 볼륨과 같은 값으로 설정 시도시 에러: Kknow issue + hcap.volume.getVolumeLevel({ + "onSuccess" : function(s) { + if ( Number(_devconfig[_cfg].defaultVolume.display)!=Number(s.level) ){ + hcap.volume.setVolumeLevel({ + "level": Number(_devconfig[_cfg].defaultVolume.display), + "onSuccess": function() { + console.log("onSuccess Set to TV default volume set as " + _devconfig[_cfg].defaultVolume.display); + }, + "onFailure": function(__err) { + console.log("onFailure : errorMessage = " + __err.errorMessage); + } + }); + } else { + console.log("onSuccess : no need default volume changing"); + } }, - "onFailure": function(f) { - console.log("onFailure : errorMessage = " + f.errorMessage); + "onFailure" : function(__err) { + console.log("onFailure : errorMessage = " + __err.errorMessage); } - }); + }); } } @@ -984,8 +1070,13 @@ HotelTV.hcap = (function() { // WIFI SCREEN SHARE if (_devinfo["wifi_screen_share"] !== undefined) { - if (_devinfo["wifi_screen_share"] != 1) { - _pmFxnArProperty.push(__hcapfxn_set_property('wifi_screen_share', 1)); + // if (_devinfo["wifi_screen_share"] != 1) { + // _pmFxnArProperty.push(__hcapfxn_set_property('wifi_screen_share', 1)); + // } + // PIN 번호를 이용한 screen share는 IDCAP API에서만 지원 + // 일부 모바일 폰에서 연동 안되는 문제 있음. + if (_devinfo["wifi_screen_share"] != 2) { + _pmFxnArProperty.push(__idcapfxn_set_property('wifi_screen_share', 2)); } } @@ -1081,6 +1172,7 @@ HotelTV.hcap = (function() { .then(_ret => { for (let i = 0; i < _ret.length; i++) { let _set_item = _ret[i]; + //리부팅을 하지 않아도 되는 항목들 no_need_reboot_param을 필터링 let no_need_reboot_param = ["wifi_screen_share", "soft_ap", "soft_ap_ui", "osd_layer_id"]; if (no_need_reboot_param.indexOf(_set_item.key) == -1) { //Needed reboot the system @@ -1278,7 +1370,7 @@ HotelTV.hcap = (function() { }, PreAppGetInfo: function(_en_show_msg) { - // if (g_hcap_info.preapp == null) { + // if (g_nativApps_info.preapp == null) { // hcap.preloadedApplication.getPreloadedApplicationList({ // "onSuccess": function(s) { // if (_en_show_msg == true) { @@ -1292,7 +1384,7 @@ HotelTV.hcap = (function() { // } // } // if (s.result == true) { - // g_hcap_info.preapp = s.list; + // g_nativApps_info.preapp = s.list; // } // }, // "onFailure": function(f) { @@ -1315,8 +1407,8 @@ HotelTV.hcap = (function() { } } if (s.result == true) { - g_hcap_info.preapp = s.list; - resolve({ "error": 0, "applist": g_hcap_info.preapp }); + g_nativApps_info.preapp = s.list; + resolve({ "error": 0, "applist": g_nativApps_info.preapp }); } }, "onFailure": function(f) { @@ -1328,9 +1420,9 @@ HotelTV.hcap = (function() { }, LaunchPreApp: function(_name, _param) { - if (g_hcap_info.preapp != null) { + if (g_nativApps_info.preapp != null) { if (_name == "youtube") { - for (const [key, item] of Object.entries(g_hcap_info.preapp)) { + for (const [key, item] of Object.entries(g_nativApps_info.preapp)) { if (item.title == 'YouTube') { hcap.preloadedApplication.launchPreloadedApplication({ "id": item.id, // YOUTUBE @@ -1344,7 +1436,7 @@ HotelTV.hcap = (function() { } } } else if (_name == "netflix") { - for (const [key, item] of Object.entries(g_hcap_info.preapp)) { + for (const [key, item] of Object.entries(g_nativApps_info.preapp)) { if (item.title == 'Netflix') { hcap.preloadedApplication.launchPreloadedApplication({ "id": item.id, // NETFLIX @@ -1359,7 +1451,7 @@ HotelTV.hcap = (function() { } } } else if (_name == "screenmirroring") { - for (const [key, item] of Object.entries(g_hcap_info.preapp)) { + for (const [key, item] of Object.entries(g_nativApps_info.preapp)) { if (item.id == '144115188075855880') { hcap.preloadedApplication.launchPreloadedApplication({ "id": item.id, // SCREEN SHARE @@ -1373,7 +1465,7 @@ HotelTV.hcap = (function() { } } } else if (_name == "BLUETOOTHAUDIO") { - for (const [key, item] of Object.entries(g_hcap_info.preapp)) { + for (const [key, item] of Object.entries(g_nativApps_info.preapp)) { if (item.id == '244115188075859015') { hcap.preloadedApplication.launchPreloadedApplication({ "id": item.id, // SCREEN SHARE diff --git a/procentric/application/lib/idcap.js b/procentric/application/lib/idcap.js new file mode 100755 index 0000000..8abd04a --- /dev/null +++ b/procentric/application/lib/idcap.js @@ -0,0 +1,21 @@ +/* + ============================================================================ + Web Solution Project, ID SW Development Department, LG ELECTRONICS INC., SEOUL, KOREA + Copyright(c) 2021 by LG Electronics Inc. + idcap version : 5 + ============================================================================ +*/ +var extIDCAPSecure,extRegisterIDCAPCloseHandler,extDisableIdcapConsoleLog,extWebWorker,isSubscribeParam,retry_count,idcap; +if(void 0===idcap)if("object"===typeof window)(function(){function c(a){1==idcap.isLogEnabled&&(a=1024 +