1 /* 2 * This is system cordova_plugin (TV specific API). 3 * Apache License (2004). See http://www.apache.org/licenses/LICENSE-2.0 4 * 5 * Copyright (c) 2014, LG Electronics, Inc. 6 */ 7 8 9 /** 10 * This represents the configuration API itself, and provides a global namespace for operating configuration service. 11 * @class 12 */ 13 cordova.define('cordova/plugin/configuration', function (require, exports, module) { // jshint ignore:line 14 15 function log(msg) { 16 // //console.log//will be removed // jshint ignore:line 17 } 18 19 var service; 20 if (window.PalmSystem) { // jshint ignore:line 21 log("Window.PalmSystem Available"); 22 service = require('cordova/plugin/webos/service'); 23 } else { 24 service = { 25 Request : function (uri, params) { 26 log(uri + " invoked. But I am a dummy because PalmSystem is not available"); 27 28 if (typeof params.onFailure === 'function') { 29 params.onFailure({ 30 returnValue:false, 31 errorText:"PalmSystem Not Available. Cordova is not installed?" 32 }); 33 } 34 }}; 35 } 36 37 /** 38 * configuration interface 39 */ 40 var Configuration = function () { 41 }; 42 43 function checkErrorCodeNText(result, errorCode, errorText) { 44 45 if (result.errorCode === undefined || result.errorCode === null ) { 46 result.errorCode = errorCode; 47 } 48 if (result.errorText === undefined || result.errorText === null) { 49 result.errorText = errorText; 50 } 51 } 52 53 /** 54 * @namespace Configuration.PictureMode 55 */ 56 Configuration.PictureMode = { 57 /** 58 * vivid 59 * @since 1.0 60 * @constant 61 */ 62 VIVID : "vivid", 63 /** 64 * standard 65 * @since 1.0 66 * @constant 67 */ 68 STANDARD : "normal", 69 /** 70 * APS (Auto Power Saving) 71 * @since 1.0 72 * @constant 73 */ 74 APS : "eco", 75 /** 76 * cinema 77 * @since 1.0 78 * @constant 79 */ 80 CINEMA : "cinema", 81 /** 82 * game 83 * @since 1.0 84 * @constant 85 */ 86 GAME : "game", 87 /** 88 * sports 89 * @since 1.0 90 * @constant 91 */ 92 SPORTS : "sports", 93 /** 94 * expert1 95 * @since 1.0 96 * @constant 97 */ 98 EXPERT1 : "expert1", 99 /** 100 * expert2 (calibration) 101 * @since 1.0 102 * @constant 103 */ 104 EXPERT2 : "expert2" 105 }; 106 107 108 /** 109 * @namespace Configuration.AppMode 110 */ 111 Configuration.AppMode = { 112 /** 113 * local 114 * @since 1.1 115 * @constant 116 */ 117 LOCAL : "local", 118 /** 119 * usb 120 * @since 1.1 121 * @constant 122 */ 123 USB : "usb", 124 /** 125 * remote 126 * @since 1.1 127 * @constant 128 */ 129 REMOTE : "remote" 130 }; 131 132 /** 133 * @namespace Configuration.AppType 134 */ 135 Configuration.AppType = { 136 /** 137 * IPK App 138 * @since 1.4.1 139 * @constant 140 */ 141 IPK : "ipk", 142 /** 143 * ZIP App 144 * @since 1.4.1 145 * @constant 146 */ 147 ZIP : "zip" 148 }; 149 150 Configuration.LocaleList = 151 [{ 152 'language': 'čeština', 153 'languageCode': 'cs', 154 'countries': [{ 155 'name': '', 156 'specifier': 'cs-CZ' 157 }] 158 }, { 159 'language': 'dansk', 160 'languageCode': 'da', 161 'countries': [{ 162 'name': '', 163 'specifier': 'da-DK' 164 }] 165 }, { 166 'language': 'Deutsch', 167 'languageCode': 'de', 168 'countries': [{ 169 'name': '', 170 'specifier': 'de-DE' 171 }] 172 }, { 173 'language': 'English', 174 'languageCode': 'en', 175 'countries': [{ 176 'name': '', 177 'specifier': 'en-US' 178 }] 179 }, { 180 'language': 'Español', 181 'languageCode': 'es', 182 'countries': [{ 183 'name': '', 184 'specifier': 'es-ES' 185 }] 186 }, { 187 'language': 'ελληνική γλώσσα', 188 'languageCode': 'el', 189 'countries': [{ 190 'name': '', 191 'specifier': 'el-GR' 192 }] 193 }, { 194 'language': 'Français', 195 'languageCode': 'fr', 196 'countries': [{ 197 'name': '', 198 'specifier': 'fr-FR' 199 }] 200 }, { 201 'language': 'italiano', 202 'languageCode': 'it', 203 'countries': [{ 204 'name': '', 205 'specifier': 'it-IT' 206 }] 207 }, { 208 'language': 'Nederlands', 209 'languageCode': 'nl', 210 'countries': [{ 211 'name': '', 212 'specifier': 'nl-NL' 213 }] 214 }, { 215 'language': 'norsk', 216 'languageCode': 'nb', 217 'countries': [{ 218 'name': '', 219 'specifier': 'nb-NO' 220 }] 221 }, { 222 'language': 'português', 223 'languageCode': 'pt', 224 'countries': [{ 225 'name': 'Portugal', 226 'specifier': 'pt-PT' 227 }, { 228 'name': 'Brasil', 229 'specifier': 'pt-BR' 230 }] 231 }, { 232 'language': 'русский', 233 'languageCode': 'ru', 234 'countries': [{ 235 'name': '', 236 'specifier': 'ru-RU' 237 }] 238 }, { 239 'language': 'suomi', 240 'languageCode': 'fi', 241 'countries': [{ 242 'name': '', 243 'specifier': 'fi-FI' 244 }] 245 }, { 246 'language': 'svenska', 247 'languageCode': 'sv', 248 'countries': [{ 249 'name': '', 250 'specifier': 'sv-SE' 251 }] 252 }, { 253 'language': '한국어', 254 'languageCode': 'ko', 255 'countries': [{ 256 'name': '', 257 'specifier': 'ko-KR' 258 }] 259 }, { 260 'language': '中文', 261 'languageCode': 'zh-Hans', 262 'countries': [{ 263 'name': '中国', 264 'specifier': 'zh-Hans-CN' 265 }] 266 }, { 267 'language': '日本語', 268 'languageCode': 'ja', 269 'countries': [{ 270 'name': '', 271 'specifier': 'ja-JP' 272 }] 273 }, { 274 'language': '中文', 275 'languageCode': 'zh', 276 'countries': [{ 277 'name': '香港', 278 'specifier': 'zh-Hant-HK' 279 }] 280 }]; 281 282 283 function isValidSpecifier(value) { 284 var arr = Configuration.LocaleList; 285 286 for (var i=0; i<arr.length; i++) { 287 var countries = arr[i].countries; 288 289 for(var j=0; j<countries.length; j++) 290 { 291 if (countries[j].specifier === value) { 292 return true; 293 } 294 } 295 } 296 297 return false; 298 } 299 300 function isValidLanguageCode(value) { 301 var arr = Configuration.LocaleList; 302 303 for (var i = 0; i < arr.length; i++) { 304 if (arr[i].languageCode === value) { 305 return true; 306 } 307 } 308 309 return false 310 } 311 312 var version = null; 313 function checkPlatformVersion(cb) { 314 315 if (version === null) { 316 317 service.Request('luna://com.webos.service.tv.systemproperty', { 318 method: 'getSystemInfo', 319 parameters: { 320 keys: ["sdkVersion"] 321 }, 322 onSuccess: function(result) { 323 log("getPlatformInfo: onSuccess"); 324 325 var temp = result.sdkVersion.split('.'); 326 if (temp.length >= 1 && temp[0] === '1') { 327 version = 1; 328 } else if (temp.length >= 1 && temp[0] === '2') { 329 version = 2; 330 } else if (temp.length >= 1 && temp[0] === '3') { 331 version = 3; 332 } else { 333 version = 0; 334 } 335 336 delete result.returnValue; 337 338 cb(version); 339 340 }, 341 onFailure: function(error) { 342 log("getPlatformInfo: onFailure"); 343 delete error.returnValue; 344 version = 0; 345 346 cb(version); 347 } 348 }); 349 350 } else { 351 cb(version); 352 } 353 } 354 355 /** 356 * Sets picture mode. Each <a href="Configuration.PictureMode.html#constructor">PictureMode</a> has a set of predefined picture properties. And each picture properties can be changed with setPictureProperty(). 357 * 358 * @class Configuration 359 * @param {Function} successCallback success callback function. 360 * @param {Function} errorCallback failure callback function. 361 * @param {Object} options 362 * <div align=left> 363 * <table class="hcap_spec" width=400> 364 * <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead> 365 * <tbody> 366 * <tr><th>mode</th><th>String</th><th><a href="Configuration.PictureMode.html#constructor">Configuration.PictureMode</a></th><th>required</th></tr> 367 * </tbody> 368 * </table> 369 * </div> 370 * @example 371 * // Javascript code 372 * function setPictureMode () { 373 * var options = { 374 * mode : Configuration.PictureMode.VIVID 375 * }; 376 * 377 * function successCb() { 378 * // Do something 379 * } 380 * 381 * function failureCb(cbObject) { 382 * var errorCode = cbObject.errorCode; 383 * var errorText = cbObject.errorText; 384 * console.log ("Error Code [" + errorCode + "]: " + errorText); 385 * } 386 * 387 * var configuration = new Configuration(); 388 * configuration.setPictureMode(successCb, failureCb, options); 389 * } 390 * @since 1.0 391 * @return <p>If the method is successfully executed, success callback function is called without a parameter.</br> 392 * If an error occurs, failure callback function is called with a failure callback object as a parameter.</p> 393 * @see 394 * <a href="Configuration%23getPictureMode.html">Configuration.getPictureMode()</a><br> 395 */ 396 Configuration.prototype.setPictureMode = function (successCallback, errorCallback, options) { 397 398 log("setPictureMode: " + JSON.stringify(options)); 399 400 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 401 method : "set", 402 parameters : { 403 category : "picture", 404 settings : { 405 "pictureMode" : options.mode 406 } 407 }, 408 onSuccess : function(result) { 409 log("setPictureMode: On Success"); 410 411 if (result.returnValue === true) { 412 if(typeof successCallback === 'function') { 413 successCallback(); 414 } 415 } 416 }, 417 onFailure : function(result) { 418 log("setPictureMode: On Failure"); 419 delete result.returnValue; 420 if (typeof errorCallback === 'function') { 421 checkErrorCodeNText(result, "CSPM", "Configuration.setPictureMode returns failure."); 422 errorCallback(result); 423 } 424 } 425 }); 426 427 log("Configuration.setPictureMode Done"); 428 }; 429 430 /** 431 * Gets picture mode. Each <a href="Configuration.PictureMode.html#constructor">PictureMode</a> has a set of predefined picture properties. 432 * 433 * @class Configuration 434 * @param {Function} successCallback success callback function. 435 * @param {Function} errorCallback failure callback function. 436 * @return {Object} 437 * <div align=left> 438 * <table class="hcap_spec" width=400> 439 * <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead> 440 * <tbody> 441 * <tr><th>mode</th><th>String</th><th><a href="Configuration.PictureMode.html#constructor">Configuration.PictureMode</a></th></tr> 442 * </tbody> 443 * </table> 444 * </div> 445 * 446 * @example 447 * // Javascript code 448 * function getPictureMode () { 449 * function successCb(cbObject) { 450 * console.log("cbObject : " + JSON.stringify(cbObject)); 451 * console.log("mode : " + cbObject.mode); 452 * 453 * // Do something 454 * ... 455 * } 456 * 457 * function failureCb(cbObject) { 458 * var errorCode = cbObject.errorCode; 459 * var errorText = cbObject.errorText; 460 * console.log ("Error Code [" + errorCode + "]: " + errorText); 461 * } 462 * 463 * var configuration = new Configuration(); 464 * configuration.getPictureMode(successCb, failureCb); 465 * } 466 * @since 1.0 467 * @see 468 * <a href="Configuration%23setPictureMode.html">Configuration.setPictureMode()</a><br> 469 */ 470 Configuration.prototype.getPictureMode = function (successCallback, errorCallback) { 471 472 log("getPictureMode: "); 473 474 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 475 method : "get", 476 parameters : { 477 category : "picture", 478 keys : ["pictureMode"] 479 }, 480 onSuccess : function(result) { 481 log("getPictureMode: On Success"); 482 483 if (result.returnValue === true) { 484 if (typeof successCallback === 'function') { 485 var cbObj = {}; 486 cbObj.mode = result.settings.pictureMode; 487 488 successCallback(cbObj); 489 } 490 } 491 }, 492 onFailure : function(result) { 493 log("getPictureMode: On Failure"); 494 delete result.returnValue; 495 if (typeof errorCallback === 'function') { 496 checkErrorCodeNText(result, "CGPM", "Configuration.getPictureMode returns failure."); 497 errorCallback(result); 498 } 499 } 500 }); 501 502 log("Configuration.getPictureMode Done"); 503 504 }; 505 506 /** 507 * Sets picture property. Each picture mode has a set of picture properties. 508 * If picture mode is changed, picture properties of that mode will be set accordingly. 509 * 510 * 511 * <div align=left> 512 * <table class="hcap_spec" width=400> 513 * <thead><tr><th>Property</th><th>VIVID</th><th>STANDARD</th><th>APS</th><th>CINEMA</th><th>SPORTS</th><th>GAME</th><th>EXPERTS1</th><th>EXPERTS2</th></tr></thead> 514 * <tbody> 515 * <tr><th>backlight</th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th></tr> 516 * <tr class="odd"><th>contrast</th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th></tr> 517 * <tr><th>brightness</th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th></tr> 518 * <tr class="odd"><th>sharpness</th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> X </th><th> X </th></tr> 519 * <tr><th>hSharpness</th><th> X </th><th> X </th><th> X </th><th> X </th><th> X </th><th> X </th><th> O </th><th> O </th></tr> 520 * <tr class="odd"><th>vSharpness</th><th> X </th><th> X </th><th> X </th><th> X </th><th> X </th><th> X </th><th> O </th><th> O </th></tr> 521 * <tr><th>color</th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th></tr> 522 * <tr class="odd"><th>tint</th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th></tr> 523 * <tr><th>colorTemperature</th><th> O </th><th> O </th><th> O </th><th> X </th><th> O </th><th> O </th><th> X </th><th> X </th></tr> 524 * <tr class="odd"><th>dynamicContrast</th><th> X </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th></tr> 525 * <tr><th>superResolution</th><th> X </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th></tr> 526 * <tr class="odd"><th>colorGamut</th><th> X </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th></tr> 527 * <tr><th>dynamicColor</th><th> X </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th></tr> 528 * <tr class="odd"><th>noiseReduction</th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th></tr> 529 * <tr><th>mpegNoiseReduction</th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th></tr> 530 * <tr class="odd"><th>blackLevel</th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th></tr> 531 * <tr><th>gamma</th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th><th> O </th></tr> 532 * </tbody> 533 * </table> 534 * </div> 535 * 536 * @class Configuration 537 * @param {Function} successCallback success callback function. 538 * @param {Function} errorCallback failure callback function. 539 * @param {Object} options 540 * <div align=left> 541 * <table class="hcap_spec" width=400> 542 * <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead> 543 * <tbody> 544 * <tr><th>backlight</th><th>Number</th><th>backlight of display (0~100) </th><th>optional</th></tr> 545 * <tr class="odd"><th>contrast</th><th>Number</th><th>contrast of display (0~100) </th><th>optional</th></tr> 546 * <tr><th>brightness</th><th>Number</th><th>brightness of display (0~100) </th><th>optional</th></tr> 547 * <tr class="odd"><th>sharpness</th><th>Number</th><th>sharpness of display (0~50) </th><th>optional</th></tr> 548 * <tr><th>hSharpness</th><th>Number</th><th>hSharpness of display (0~50)</th><th>optional</th></tr> 549 * <tr class="odd"><th>vSharpness</th><th>Number</th><th>vSharpness of display (0~50) </th><th>optional</th></tr> 550 * <tr><th>color</th><th>Number</th><th>color of display (0~100) </th><th>optional</th></tr> 551 * <tr class="odd"><th>tint</th><th>Number</th><th>tint of display (0~100) R:0, G:100</th><th>optional</th></tr> 552 * <tr><th>colorTemperature</th><th>Number</th><th>colorTemperature of display (0~100) W:0, C:100 </th><th>optional</th></tr> 553 * <tr class="odd"><th>dynamicContrast</th><th>String</th><th>dynamicContrast of display (off/low/medium/high) </th><th>optional</th></tr> 554 * <tr><th>superResolution</th><th>String</th><th>superResolution of display (off/low/medium/high) </th><th>optional</th></tr> 555 * <tr class="odd"><th>colorGamut</th><th>String</th><th>colorGamut of display (wide/standard) </th><th>optional</th></tr> 556 * <tr><th>dynamicColor</th><th>String</th><th>dynamicColor of display (off/low/medium/high) </th><th>optional</th></tr> 557 * <tr class="odd"><th>noiseReduction</th><th>String</th><th>noiseReduction of display (auto/off/low/medium/high) </th><th>optional</th></tr> 558 * <tr><th>mpegNoiseReduction</th><th>String</th><th>mpegNoiseReduction of display (auto/off/low/medium/high) </th><th>optional</th></tr> 559 * <tr class="odd"><th>blackLevel</th><th>String</th><th>blackLevel of display (low/high) </th><th>optional</th></tr> 560 * <tr><th>gamma</th><th>String</th><th>gamma of display (low/medium/high/high2) </th><th>optional</th></tr> 561 * </tbody> 562 * </table> 563 * </div> 564 * 565 * Note : 'high2' option is depends on platform. 566 * @example 567 * // Javascript code 568 * function setPictureProperty () { 569 * var options = { 570 * // For example, expert1 mode. 571 * backlight : 50, 572 * contrast : 50, 573 * brightness : 50, 574 * hSharpness : 50, 575 * vSharpness : 50, 576 * color : 50, 577 * tint : 50, 578 * colorTemperature : 50, 579 * dynamicContrast : "low", 580 * superResolution : "low", 581 * colorGamut : "wide", 582 * dynamicColor : "high", 583 * noiseReduction : "medium", 584 * mpegNoiseReduction : "low", 585 * blackLevel : "low", 586 * gamma : "medium" 587 * }; 588 * 589 * function successCb() { 590 * // Do something 591 * } 592 * 593 * function failureCb(cbObject) { 594 * var errorCode = cbObject.errorCode; 595 * var errorText = cbObject.errorText; 596 * console.log ("Error Code [" + errorCode + "]: " + errorText); 597 * } 598 * 599 * var configuration = new Configuration(); 600 * configuration.setPictureProperty(successCb, failureCb, options); 601 * } 602 * @since 1.0 603 * @return <p>If the method is successfully executed, success callback function is called without a parameter.</br> 604 * If an error occurs, failure callback function is called with a failure callback object as a parameter.</p> 605 * @see 606 * <a href="Configuration%23getPictureProperty.html">Configuration.getPictureProperty()</a><br> 607 */ 608 Configuration.prototype.setPictureProperty = function (successCallback, errorCallback, options) { 609 610 log("setPictureProperty: " + JSON.stringify(options)); 611 612 checkPlatformVersion(function(ver){ 613 614 var sets = {}; 615 616 for (var key in options) { 617 if (key !== undefined && key !== null) { 618 sets[key] = options[key]; 619 if (key === 'tint' || key === 'colorTemperature') { 620 sets[key] -=50; 621 } 622 else if (key === 'blackLevel') { 623 sets[key] = { 624 "unknown": options[key] 625 }; 626 if (options[key] !== "low" && options[key] !== "high" ) { 627 log("setPictureProperty: gamma value error " + JSON.stringify(options)); 628 var result = {}; 629 checkErrorCodeNText(result, "CSPP", "Configuration.setPictureProperty, There is No matched item : blackLevel."); 630 errorCallback(result); 631 return; 632 } 633 } else if (key === 'gamma' && (ver === 2 || ver === 3) && options[key] === "high") { 634 sets[key] = "high1"; 635 } 636 } 637 } 638 639 log(JSON.stringify(sets)); 640 641 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 642 method : "set", 643 parameters : { 644 category : "picture", 645 settings : sets 646 }, 647 onSuccess : function(result) { 648 log("setPictureProperty: On Success"); 649 650 if (result.returnValue === true) { 651 if (typeof successCallback === 'function') { 652 successCallback(); 653 } 654 } 655 }, 656 onFailure : function(result) { 657 log("setPictureProperty: On Failure"); 658 delete result.returnValue; 659 if (typeof errorCallback === 'function') { 660 checkErrorCodeNText(result, "CSPP", "Configuration.setPictureProperty returns failure."); 661 errorCallback(result); 662 } 663 } 664 }); 665 log("Configuration.setPictureProperty Done"); 666 }); 667 }; 668 669 /** 670 * Gets picture property. Each <a href="Configuration.PictureMode.html#constructor">PictureMode</a> has a set of predefined picture properties. 671 * 672 * @class Configuration 673 * @param {Function} successCallback success callback function. 674 * @param {Function} errorCallback failure callback function. 675 * @return {Object} 676 * <div align=left> 677 * <table class="hcap_spec" width=400> 678 * <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Available</th></tr></thead> 679 * <tbody> 680 * <tr><th>backlight</th><th>Number</th><th>backlight of display (0~100) </th><th>optional</th></tr> 681 * <tr class="odd"><th>contrast</th><th>Number</th><th>contrast of display (0~100) </th><th>optional</th></tr> 682 * <tr><th>brightness</th><th>Number</th><th>brightness of display (0~100) </th><th>optional</th></tr> 683 * <tr class="odd"><th>sharpness</th><th>Number</th><th>sharpness of display (0~50) </th><th>optional</th></tr> 684 * <tr><th>hSharpness</th><th>Number</th><th>hSharpness of display (0~50)</th><th>optional</th></tr> 685 * <tr class="odd"><th>vSharpness</th><th>Number</th><th>vSharpness of display (0~50) </th><th>optional</th></tr> 686 * <tr><th>color</th><th>Number</th><th>color of display (0~100) </th><th>optional</th></tr> 687 * <tr class="odd"><th>tint</th><th>Number</th><th>tint of display (0~100) R:0, G:100</th><th>optional</th></tr> 688 * <tr><th>colorTemperature</th><th>Number</th><th>colorTemperature of display (0~100) W:0, C:100 </th><th>optional</th></tr> 689 * <tr class="odd"><th>dynamicContrast</th><th>String</th><th>dynamicContrast of display (off/low/medium/high) </th><th>optional</th></tr> 690 * <tr><th>superResolution</th><th>String</th><th>superResolution of display (off/low/medium/high) </th><th>optional</th></tr> 691 * <tr class="odd"><th>colorGamut</th><th>String</th><th>colorGamut of display (wide/standard) </th><th>optional</th></tr> 692 * <tr><th>dynamicColor</th><th>String</th><th>dynamicColor of display (off/low/medium/high) </th><th>optional</th></tr> 693 * <tr class="odd"><th>noiseReduction</th><th>String</th><th>noiseReduction of display (auto/off/low/medium/high) </th><th>optional</th></tr> 694 * <tr><th>mpegNoiseReduction</th><th>String</th><th>mpegNoiseReduction of display (auto/off/low/medium/high) </th><th>optional</th></tr> 695 * <tr class="odd"><th>blackLevel</th><th>String</th><th>blackLevel of display (low/high) </th><th>optional</th></tr> 696 * <tr><th>gamma</th><th>String</th><th>gamma of display (low/medium/high) </th><th>optional</th></tr> 697 * </tbody> 698 * </table> 699 * </div> 700 * 701 * @example 702 * // Javascript code 703 * function getPictureProperty () { 704 * function successCb(cbObject) { 705 * console.log("cbObject : " + JSON.stringify(cbObject)); 706 * 707 * console.log("back light : " + cbObject.backlight); 708 * console.log("contrast : " + cbObject.contrast); 709 * console.log("brightness : " + cbObject.brightness); 710 * console.log("color : " + cbObject.color); 711 * console.log("tint : " + cbObject.tint); 712 * 713 * // Do something 714 * ... 715 * } 716 * 717 * function failureCb(cbObject) { 718 * var errorCode = cbObject.errorCode; 719 * var errorText = cbObject.errorText; 720 * console.log ("Error Code [" + errorCode + "]: " + errorText); 721 * } 722 * 723 * var configuration = new Configuration(); 724 * configuration.getPictureProperty(successCb, failureCb); 725 * } 726 * @since 1.0 727 * @see 728 * <a href="Configuration%23setPictureProperty.html">Configuration.setPictureProperty()</a><br> 729 */ 730 Configuration.prototype.getPictureProperty = function (successCallback, errorCallback) { 731 732 log("getPictureProperty: "); 733 734 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 735 method : "get", 736 parameters : { 737 category : "picture", 738 keys : ["brightness", "contrast", "color", "tint", "backlight", 739 "sharpness", "hSharpness", "vSharpness", "colorTemperature", 740 "dynamicContrast", "superResolution", "colorGamut", "dynamicColor", 741 "noiseReduction", "mpegNoiseReduction", "blackLevel", "gamma" ] 742 }, 743 onSuccess : function(result) { 744 log("getPictureProperty: On Success"); 745 746 if (result.returnValue === true) { 747 if (typeof successCallback === 'function') { 748 var cbObj = {}; 749 750 for (var key in result.settings) { 751 if (key !== undefined && key !== null) { 752 cbObj[key] = (isNaN(result.settings[key]) ? result.settings[key] : Number(result.settings[key]) ); 753 if (key === 'tint' || key === 'colorTemperature') { 754 cbObj[key] += 50; 755 } 756 else if (key === 'blackLevel') { 757 cbObj[key] = result.settings[key].unknown; 758 } 759 else if (key === 'gamma' && result.settings[key] === "high1") { 760 cbObj[key] = "high"; 761 } 762 } 763 } 764 765 successCallback(cbObj); 766 } 767 } 768 }, 769 onFailure : function(result) { 770 log("getPictureProperty: On Failure"); 771 delete result.returnValue; 772 if (typeof errorCallback === 'function') { 773 checkErrorCodeNText(result, "CGPP", "Configuration.getPictureProperty returns failure."); 774 errorCallback(result); 775 } 776 } 777 }); 778 779 log("Configuration.getPictureProperty Done"); 780 781 }; 782 783 var mapTable = { 784 "alias" : "signageName" 785 }; 786 787 /** 788 * Sets property. 789 * @class Configuration 790 * @param {Function} successCallback success callback function. 791 * @param {Function} errorCallback failure callback function. 792 * @param {Object} options string in JSON format. Refer to Configuration.getProperty for available keys of property(e.g. '{"alias":"display_1"}'). 793 * 794 * @example 795 * // Javascript code 796 * function setProperty () { 797 * var options = '{"alias":"display_1"}'; 798 * 799 * function successCb() { 800 * // Do something 801 * } 802 * 803 * function failureCb(cbObject) { 804 * var errorCode = cbObject.errorCode; 805 * var errorText = cbObject.errorText; 806 * console.log ("Error Code [" + errorCode + "]: " + errorText); 807 * } 808 * 809 * var configuration = new Configuration(); 810 * configuration.setProperty(successCb, failureCb, options); 811 * } 812 * 813 * @return 814 * <p>If the method is successfully executed, success callback function is called without a parameter.</br> 815 * If an error occurs, failure callback function is called with a failure callback object as a parameter.</p> 816 * @since 1.0 817 */ 818 Configuration.prototype.setProperty = function (successCallback, errorCallback, options) { 819 820 log("setProperty: " + JSON.stringify(options)); 821 822 var ret = JSON.parse(options); 823 var sets = {}; 824 var params = {}; 825 826 checkPlatformVersion(function(ver) { 827 if (ver === 3) { 828 mapTable.alias = "deviceName"; 829 params.category = "network"; 830 } 831 else 832 { 833 mapTable.alias = "signageName"; 834 params.category = "commercial"; 835 } 836 837 for (var key in ret) { 838 if (mapTable[key] !== undefined) { 839 sets[(mapTable[key])] = ret[key]; 840 } 841 } 842 843 params.settings = sets; 844 845 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 846 method: "set", 847 parameters: params, 848 onSuccess: function(result) { 849 log("setProperty: On Success"); 850 851 if (result.returnValue === true) { 852 if (typeof successCallback === 'function') { 853 successCallback(); 854 } 855 } 856 }, 857 onFailure: function(result) { 858 log("setProperty: On Failure"); 859 delete result.returnValue; 860 if (typeof errorCallback === 'function') { 861 checkErrorCodeNText(result, "CSP", "Configuration.setProperty returns failure."); 862 errorCallback(result); 863 } 864 } 865 }); 866 }); 867 868 log("Configuration.setProperty Done"); 869 }; 870 871 /** 872 * Gets the property of platform using key. This property can be either platform specific or user set value. 873 * @class Configuration 874 * @param {Function} successCallback success callback function. 875 * @param {Function} errorCallback failure callback function. 876 * @param {Object} options string in JSON. It should have "keys" string in JSON which has an array of keys for the value. For example, '{"keys":["alias","key2"]}' . 877 * <div align=left> 878 * <table class="hcap_spec" width=400> 879 * <thead><tr><th>Key</th><th>Description</th><th>Format</th><th>Read/Write</th><th>Example</th></tr></thead> 880 * <tbody> 881 * <tr><th>alias</th><th>Display alias name</th><th>String</th><th>read/write</th><th>display_1</th></tr> 882 * </tbody> 883 * </table> 884 * </div> 885 * 886 * @return {Object} String in JSON. For example, '{"alias":"display_1"}'. 887 * 888 * @example 889 * // Javascript code 890 * function getProperty () { 891 * var options = '{"keys":["alias"]}'; 892 * 893 * function successCb(cbObject) { 894 * console.log("cbObject : " + JSON.stringify(cbObject)); 895 * var parsedString = JSON.parse(cbObject); 896 * 897 * for(var key in parsedString) { 898 * var value = parsedString[key]; 899 * console.log(key + ": " + value); 900 * } 901 * } 902 * 903 * function failureCb(cbObject) { 904 * var errorCode = cbObject.errorCode; 905 * var errorText = cbObject.errorText; 906 * console.log ("Error Code [" + errorCode + "]: " + errorText); 907 * } 908 * 909 * var configuration = new Configuration(); 910 * configuration.getProperty(successCb, failureCb, options); 911 * } 912 * 913 * @since 1.0 914 */ 915 Configuration.prototype.getProperty = function (successCallback, errorCallback, options) { 916 917 log("getProperty: "); 918 919 var ret = JSON.parse(options); 920 var keys = ret.keys; 921 var params = {}; 922 var arrayKeys = []; 923 924 checkPlatformVersion(function(ver) { 925 926 if (ver === 3) { 927 mapTable.alias = "deviceName"; 928 params.category = "network"; 929 } 930 else 931 { 932 mapTable.alias = "signageName"; 933 params.category = "commercial"; 934 } 935 936 for (var key in keys) { 937 if (key !== null && key !== undefined) { 938 log("key" + keys[key]); 939 arrayKeys.push(mapTable[keys[key]]); 940 } 941 } 942 943 params.keys = arrayKeys; 944 945 log(arrayKeys); 946 947 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 948 method: "get", 949 parameters: params, 950 onSuccess: function(result) { 951 log("getProperty: On Success"); 952 953 if (result.returnValue === true) { 954 if (typeof successCallback === 'function') { 955 var cbObj = {}; 956 957 for (var key in keys) { 958 if (key !== null || key !== undefined) { 959 log("key" + keys[key]); 960 if (result.settings[mapTable[keys[key]]] !== undefined || result.settings[mapTable[keys[key]]] !== null) { 961 cbObj[keys[key]] = result.settings[mapTable[keys[key]]]; 962 } 963 } 964 } 965 successCallback(JSON.stringify(cbObj)); 966 967 } 968 } 969 }, 970 onFailure: function(result) { 971 log("getProperty: On Failure"); 972 delete result.returnValue; 973 if (typeof errorCallback === 'function') { 974 checkErrorCodeNText(result, "CGP", "Configuration.getProperty returns failure."); 975 errorCallback(result); 976 } 977 } 978 }); 979 }); 980 981 log("Configuration.getProperty Done"); 982 }; 983 984 /** 985 * Sets current time. 986 * @class Configuration 987 * @param {Function} successCallback success callback function. 988 * @param {Function} errorCallback failure callback function. 989 * @param {Object} options 990 * <div align=left> 991 * <table class="hcap_spec" width=400> 992 * <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead> 993 * <tbody> 994 * <tr><th>year</th><th>Number</th><th>year (2000~2037)</th><th>required</th></tr> 995 * <tr class="odd"><th>month</th><th>Number</th><th>month (1~12)</th><th>required</th></tr> 996 * <tr><th>day</th><th>Number</th><th>day (1~31)</th><th>required</th></tr> 997 * <tr class="odd"><th>hour</th><th>Number</th><th>hour (0~23)</th><th>required</th></tr> 998 * <tr><th>minute</th><th>Number</th><th>minute (0~59)</th><th>required</th></tr> 999 * <tr class="odd"><th>sec</th><th>Number</th><th>sec (0~59)</th><th>required</th></tr> 1000 * <tr><th>ntp</th><th>Boolean</th><th>NTP(Network Time Protocol) is enabled. If ntp is enabled, other setting values are ignored. true : enabled / false : disabled (default)</th><th>optional</th></tr> 1001 * </tbody> 1002 * </table> 1003 * </div> 1004 * 1005 * @example 1006 * // Javascript code 1007 * function setCurrentTime () { 1008 * var options = { 1009 * year : 2014, 1010 * month : 1, 1011 * day : 6, 1012 * hour : 14, 1013 * minute : 40, 1014 * sec : 50 1015 * }; 1016 * 1017 * function successCb() { 1018 * // Do something 1019 * } 1020 * 1021 * function failureCb(cbObject) { 1022 * var errorCode = cbObject.errorCode; 1023 * var errorText = cbObject.errorText; 1024 * console.log ("Error Code [" + errorCode + "]: " + errorText); 1025 * } 1026 * 1027 * var configuration = new Configuration(); 1028 * configuration.setCurrentTime(successCb, failureCb, options); 1029 * } 1030 * 1031 * @return <p>If the method is successfully executed, success callback function is called without a parameter.</br> 1032 * If an error occurs, failure callback function is called with a failure callback object as a parameter.</p> 1033 * @since 1.0 1034 * @since 1.3 options.ntp 1035 * @see 1036 * <a href="Configuration%23getCurrentTime.html">Configuration.getCurrentTime()</a><br> 1037 */ 1038 Configuration.prototype.setCurrentTime = function (successCallback, errorCallback, options) { 1039 1040 log("setCurrentTime: " + JSON.stringify(options)); 1041 var input = new Date(options.year, options.month-1, options.day, options.hour, options.minute, options.sec); 1042 1043 if (options.year < 2000 || options.year > 2037 || options.month < 1 || options.month > 12 || 1044 options.day < 1 || options.day > 31 || options.hour < 0 || options.hour > 23 || 1045 options.minute < 0 || options.minute > 59 || options.sec < 0 || options.sec > 59 || 1046 input.getFullYear() !== options.year || //for checking leap year (SCAP-221) 1047 input.getMonth() !== (options.month-1) || 1048 input.getDate() !== options.day || 1049 input.getHours() !== options.hour || 1050 input.getMinutes() !== options.minute || 1051 input.getSeconds() !== options.sec) 1052 { 1053 1054 if (typeof errorCallback === 'function') { 1055 log("setCurrentTime: out of range or invalid parameter type"); 1056 var result = {}; 1057 checkErrorCodeNText(result, "CSCT", "Configuration.setCurrentTime returns failure for out of range."); 1058 errorCallback(result); 1059 return; 1060 } 1061 } 1062 1063 log("setCurrentTime: " + JSON.stringify(options)); 1064 1065 //var utcSec = input.getTime()/1000; //removed timezone offset. it will calculate in storage service 1066 1067 var time = {}; 1068 time.year = options.year; 1069 time.month = options.month; 1070 time.day = options.day; 1071 time.hour = options.hour; 1072 time.minute = options.minute; 1073 time.sec = options.sec; 1074 1075 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 1076 method : "setSystemTime", 1077 parameters : { 1078 time : time, 1079 ntp : options.ntp 1080 }, 1081 onSuccess : function() { 1082 log("setCurrentTime: On Success"); 1083 if (typeof successCallback === 'function') { 1084 successCallback(); 1085 } 1086 }, 1087 onFailure : function(result) { 1088 log("setCurrentTime: On Failure"); 1089 1090 delete result.returnValue; 1091 if (typeof errorCallback === 'function') { 1092 checkErrorCodeNText(result, "CSCT", "Configuration.setCurrentTime returns failure."); 1093 errorCallback(result); 1094 } 1095 } 1096 }); 1097 1098 log("Configuration.setCurrentTime Done"); 1099 1100 }; 1101 1102 /** 1103 * Gets current time. 1104 * @class Configuration 1105 * @param {Function} successCallback success callback function. 1106 * @param {Function} errorCallback failure callback function. 1107 * @return {Object} 1108 * <div align=left> 1109 * <table class="hcap_spec" width=400> 1110 * <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead> 1111 * <tbody> 1112 * <tr><th>year</th><th>Number</th><th>year (2000~2037)</th><th>required</th></tr> 1113 * <tr class="odd"><th>month</th><th>Number</th><th>month (1~12)</th><th>required</th></tr> 1114 * <tr><th>day</th><th>Number</th><th>day (1~31)</th><th>required</th></tr> 1115 * <tr class="odd"><th>hour</th><th>Number</th><th>hour (0~23)</th><th>required</th></tr> 1116 * <tr><th>minute</th><th>Number</th><th>minute (0~59)</th><th>required</th></tr> 1117 * <tr class="odd"><th>sec</th><th>Number</th><th>sec (0~59)</th><th>required</th></tr> 1118 * <tr><th>ntp</th><th>Boolean</th><th>NTP(Network Time Protocol) is enabled. true : enabled / false : disabled (default)</th><th>optional</th></tr> 1119 * </tbody> 1120 * </table> 1121 * </div> 1122 * 1123 * @example 1124 * // Javascript code 1125 * function getCurrentTime () { 1126 * function successCb(cbObject) { 1127 * console.log("cbObject : " + JSON.stringify(cbObject)); 1128 * } 1129 * 1130 * function failureCb(cbObject) { 1131 * var errorCode = cbObject.errorCode; 1132 * var errorText = cbObject.errorText; 1133 * console.log ("Error Code [" + errorCode + "]: " + errorText); 1134 * } 1135 * 1136 * var configuration = new Configuration(); 1137 * configuration.getCurrentTime(successCb, failureCb); 1138 * } 1139 * 1140 * @since 1.0 1141 * @since 1.3 returns.ntp 1142 * @see 1143 * <a href="Configuration%23setCurrentTime.html">Configuration.setCurrentTime()</a><br> 1144 */ 1145 Configuration.prototype.getCurrentTime = function (successCallback, errorCallback) { 1146 1147 log("getCurrentTime: "); 1148 1149 service.Request("luna://com.palm.systemservice/time/", { 1150 method : "getEffectiveBroadcastTime", 1151 onSuccess : function(result) { 1152 log("getCurrentTime : On Success"); 1153 1154 if(result.returnValue === true) { 1155 var cbObj = {}; 1156 var d = new Date(result.adjustedUtc * 1000); 1157 cbObj.year = d.getFullYear(); 1158 cbObj.month = d.getMonth() + 1; 1159 cbObj.day = d.getDate(); 1160 cbObj.hour = d.getHours(); 1161 cbObj.minute = d.getMinutes(); 1162 cbObj.sec = d.getSeconds(); 1163 1164 service.Request("luna://com.palm.systemservice/", { 1165 method : "getPreferences", 1166 parameters : { 1167 keys : ["useNetworkTime"] 1168 }, 1169 onSuccess : function(res) { 1170 log("getPreferences : On Success"); 1171 1172 if(res.returnValue === true) { 1173 1174 cbObj.ntp = res.useNetworkTime; 1175 1176 if (typeof successCallback === 'function') { 1177 successCallback(cbObj); 1178 } 1179 1180 } else { 1181 1182 if (typeof errorCallback === 'function') { 1183 checkErrorCodeNText(result, "CGCT", "Configuration.getCurrentTime returns failure."); 1184 errorCallback(result); 1185 } 1186 } 1187 }, 1188 onFailure : function(result) { 1189 log("getCurrentTime: On Failure"); 1190 delete result.returnValue; 1191 if (typeof errorCallback === 'function') { 1192 checkErrorCodeNText(result, "CGCT", "Configuration.getCurrentTime returns failure."); 1193 errorCallback(result); 1194 } 1195 } 1196 }); 1197 } else { 1198 if (typeof errorCallback === 'function') { 1199 checkErrorCodeNText(result, "CGCT", "Configuration.getCurrentTime returns failure."); 1200 errorCallback(result); 1201 } 1202 } 1203 1204 }, 1205 onFailure : function(result) { 1206 log("getCurrentTime: On Failure"); 1207 delete result.returnValue; 1208 if (typeof errorCallback === 'function') { 1209 checkErrorCodeNText(result, "CGCT", "Configuration.getCurrentTime returns failure."); 1210 errorCallback(result); 1211 } 1212 } 1213 }); 1214 1215 log("Configuration.getCurrentTime Done"); 1216 1217 }; 1218 1219 /** 1220 * Restarts the application. 1221 * @class Configuration 1222 * @param {Function} successCallback success callback function. 1223 * @param {Function} errorCallback failure callback function. 1224 * 1225 * @example 1226 * // Javascript code 1227 * function restartApplication () { 1228 * function successCb() { 1229 * console.log("restart success : "); 1230 * } 1231 * 1232 * function failureCb(cbObject) { 1233 * var errorCode = cbObject.errorCode; 1234 * var errorText = cbObject.errorText; 1235 * console.log ("Error Code [" + errorCode + "]: " + errorText); 1236 * } 1237 * 1238 * var configuration = new Configuration(); 1239 * configuration.restartApplication(successCb, failureCb); 1240 * } 1241 * 1242 * @since 1.0 1243 */ 1244 Configuration.prototype.restartApplication = function (successCallback, errorCallback) { 1245 1246 log("restartApp: "); 1247 1248 service.Request("luna://com.webos.service.commercial.signage.storageservice/", { 1249 method : "restart_application", 1250 onSuccess : function(result) { 1251 log("restartApp: On Success"); 1252 1253 if (typeof successCallback === 'function') { 1254 successCallback(result); 1255 } 1256 }, 1257 onFailure : function(result) { 1258 log("restartApp: On Failure"); 1259 delete result.returnValue; 1260 if (typeof errorCallback === 'function') { 1261 checkErrorCodeNText(result, "CRA", "Configuration.restartApp returns failure."); 1262 errorCallback(result); 1263 } 1264 } 1265 }); 1266 1267 log("Configuration.restartApp Done"); 1268 1269 }; 1270 1271 1272 /** 1273 * Gets server property. Server property has information about application mode and server settings for application upgrade and launch. 1274 * 1275 * @class Configuration 1276 * @param {Function} successCallback success callback function. 1277 * @param {Function} errorCallback failure callback function. 1278 * @return {Object} 1279 * <div align=left> 1280 * <table class="hcap_spec" width=400> 1281 * <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead> 1282 * <tbody> 1283 * <tr><th>serverIp</th><th>String</th><th>IP address (local, usb : to upgrade / remote : to launch )</th></tr> 1284 * <tr class="odd"><th>serverPort</th><th>Number</th><th>Port number (local, usb : to upgrade / remote : to launch )</th></tr> 1285 * <tr><th>secureConnection</th><th>Boolean</th><th>true : https, false : http </th></tr> 1286 * <tr class="odd"><th>appLaunchMode</th><th>String</th><th>launch mode <a href="Configuration.AppMode.html#constructor">Configuration.AppMode</th></tr> 1287 * <tr><th>appType</th><th>String</th><th>app type <a href="Configuration.AppType.html#constructor">Configuration.AppType</th></tr> 1288 * <tr class="odd"><th>fqdnMode</th><th>Boolean</th><th>true : use fqdn settings for application upgrade or launch, <br>false : use serverIp and serverPort settings for application upgrade or launch</th></tr> 1289 * <tr><th>fqdnAddr</th><th>String</th><th>FQDN url. for example, http://lge.com/index.html or https://lge.com/index.html </th></tr> 1290 * </tbody> 1291 * </table> 1292 * </div> 1293 * 1294 * @example 1295 * // Javascript code 1296 * function getServerProperty () { 1297 * function successCb(cbObject) { 1298 * console.log("cbObject : " + JSON.stringify(cbObject)); 1299 * 1300 * console.log("server IP : " + cbObject.serverIp); 1301 * console.log("server Port : " + cbObject.serverPort); 1302 * console.log("secure Connection : " + cbObject.secureConnection); 1303 * console.log("applicationLaunchMode : " + cbObject.appLaunchMode); 1304 * console.log("application type : " + cbObject.appType); 1305 * console.log("fully Qualified Domain Name Mode : " + cbObject.fqdnMode); 1306 * console.log("fully Qualified Domain Name Address: " + cbObject.fqdnAddr); 1307 * 1308 * // Do something 1309 * } 1310 * 1311 * function failureCb(cbObject) { 1312 * var errorCode = cbObject.errorCode; 1313 * var errorText = cbObject.errorText; 1314 * console.log ("Error Code [" + errorCode + "]: " + errorText); 1315 * } 1316 * 1317 * var configuration = new Configuration(); 1318 * configuration.getServerProperty(successCb, failureCb); 1319 * } 1320 * @since 1.1 1321 * @see 1322 * <a href="Configuration%23setServerProperty.html">Configuration.setServerProperty()</a><br> 1323 */ 1324 Configuration.prototype.getServerProperty = function (successCallback, errorCallback) { 1325 1326 log("getServerProperty: "); 1327 1328 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 1329 method : "get", 1330 parameters : { 1331 category : "commercial", 1332 keys : ["serverIpPort", "siServerIp", "secureConnection", "appLaunchMode", "fqdnAddr", "fqdnMode", "appType"] 1333 }, 1334 1335 onSuccess : function(result) { 1336 log("getPictureProperty: On Success"); 1337 1338 if (result.returnValue === true) { 1339 if (typeof successCallback === 'function') { 1340 var cbObj = {}; 1341 cbObj.serverIp = result.settings.siServerIp; 1342 cbObj.serverPort = parseInt(result.settings.serverIpPort, 10); 1343 cbObj.secureConnection = (result.settings.secureConnection === "off" ? false : true ); 1344 cbObj.appLaunchMode = result.settings.appLaunchMode; 1345 cbObj.appType = result.settings.appType; 1346 cbObj.fqdnMode = (result.settings.fqdnMode === "off" ? false : true ); 1347 cbObj.fqdnAddr = result.settings.fqdnAddr; 1348 1349 successCallback(cbObj); 1350 } 1351 } 1352 }, 1353 onFailure : function(result) { 1354 log("getServerProperty: On Failure"); 1355 delete result.returnValue; 1356 if (typeof errorCallback === 'function') { 1357 checkErrorCodeNText(result, "CGSP", "Configuration.getServerProperty returns failure."); 1358 errorCallback(result); 1359 } 1360 } 1361 }); 1362 1363 log("Configuration.getServerProperty Done"); 1364 1365 }; 1366 1367 /** 1368 * Sets the server property. 1369 * <br> 1370 * <hr> 1371 * <b>scap_installation.json</b><br> 1372 * If scap_installation.json file exists under root directory of usb memory and 'Auto Set' is enabled in server settings menu, 1373 * server properties will be set as described in scap_installation.json and 'Auto Set' will be disabled automatically. 1374 * Factory default setting of 'Auto Set' is 'enabled'.</br> 1375 * scap_installation.json schema is as below. 1376 * 1377 * <div><pre class="code prettyprint"> 1378 { 1379 "$schema": "http://json-schema.org/draft-04/schema#", 1380 "id": "", 1381 "type": "object", 1382 "properties": { 1383 "serverIp": { 1384 "id": "serverIp", 1385 "type": "string" 1386 }, 1387 "serverPort": { 1388 "id": "serverPort", 1389 "type": "integer" 1390 }, 1391 "secureConnection": { 1392 "id": "secureConnection", 1393 "type": "boolean" 1394 }, 1395 "appLaunchMode": { 1396 "id": "appLaunchMode", 1397 "type": "string", 1398 "enum": [ 1399 "local", 1400 "usb", 1401 "remote" 1402 ] 1403 }, 1404 "fqdnMode": { 1405 "id": "fqdnMode", 1406 "type": "boolean" 1407 }, 1408 "fqdnAddr": { 1409 "id": "fqdnAddr", 1410 "type": "string" 1411 }, 1412 "required": [ 1413 "serverIp", 1414 "serverPort", 1415 "secureConnection", 1416 "appLaunchMode", 1417 "fqdnMode", 1418 "fqdnAddr" 1419 ] 1420 } 1421 } 1422 * </pre></div> 1423 * scap_installation.json example is as below. <br> 1424 * {<br> 1425 * "serverIp":"10.177.211.51", <br> 1426 * "serverPort":80, <br> 1427 * "secureConnection":false, <br> 1428 * "appLaunchMode":"local",<br> 1429 * "fqdnMode":true,<br> 1430 * "fqdnAddr":"http://192.168.0.1:2000/lgapp.zip"<br> 1431 * }<br> 1432 * <hr> 1433 * @class Configuration 1434 * @param {Function} successCallback success callback function. 1435 * @param {Function} errorCallback failure callback function. 1436 * @param {Object} options 1437 * <div align=left> 1438 * <table class="hcap_spec" width=400> 1439 * <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead> 1440 * <tbody> 1441 * <tr><th>serverIp</th><th>String</th><th>IP address (local, usb : to upgrade / remote : to launch )</th><th>required</th></tr> 1442 * <tr class="odd"><th>serverPort</th><th>Number</th><th>Port number (local, usb : to upgrade / remote : to launch )</th><th>required</th></tr> 1443 * <tr><th>secureConnection</th><th>Boolean</th><th>true : https, false : http </th><th>required</th></tr> 1444 * <tr class="odd"><th>appLaunchMode</th><th>String</th><th>launch mode <a href="Configuration.AppMode.html#constructor">Configuration.AppMode</th><th>required</th></tr> 1445 * <tr><th>appType</th><th>String</th><th>app type <a href="Configuration.AppType.html#constructor">Configuration.AppType</th><th>optional</th></tr> 1446 * <tr class="odd"><th>fqdnMode</th><th>Boolean</th><th>true : use fqdn settings when an application upgrades or launches, 1447 * <br>false : use serverIp and serverPort settings when an application upgrades or launches</th><th>required</th></tr> 1448 * <tr><th>fqdnAddr</th><th>String</th><th>FQDN url. for example, http://lge.com/index.html or https://lge.com/index.html </th><th>required</th></tr> 1449 * </tbody> 1450 * </table> 1451 * </div> 1452 * 1453 * @example 1454 * // Javascript code 1455 * function setServerProperty () { 1456 * var options = { 1457 * serverIp : "192.168.0.2", 1458 * serverPort : 80, 1459 * secureConnection : false, 1460 * appLaunchMode : Configuration.AppMode.REMOTE, 1461 * appType : Configuration.AppType.ZIP, 1462 * fqdnMode : false, 1463 * fqdnAddr : "http://signage.domain.com/index.html" 1464 * }; 1465 * 1466 * function successCb() { 1467 * // Do something 1468 * } 1469 * 1470 * function failureCb(cbObject) { 1471 * var errorCode = cbObject.errorCode; 1472 * var errorText = cbObject.errorText; 1473 * console.log ("Error Code [" + errorCode + "]: " + errorText); 1474 * } 1475 * 1476 * var configuration = new Configuration(); 1477 * configuration.setServerProperty(successCb, failureCb, options); 1478 * } 1479 * @since 1.1 1480 * @return <p>If the method is successfully executed, success callback function is called without a parameter.</br> 1481 * If an error occurs, failure callback function is called with a failure callback object as a parameter.</p> 1482 * @see 1483 * <a href="Configuration%23getServerProperty.html">Configuration.getServerProperty()</a><br> 1484 */ 1485 Configuration.prototype.setServerProperty = function (successCallback, errorCallback, options) { 1486 1487 log("setServerProperty: " + JSON.stringify(options)); 1488 1489 if(options === undefined || 1490 typeof options.serverIp !== 'string'|| /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(options.serverIp) === false || 1491 isNaN(options.serverPort) || options.serverPort < 0 || options.serverPort > 65535 || typeof options.serverPort !== 'number' || 1492 typeof options.secureConnection !== 'boolean' || typeof options.appLaunchMode !== 'string' || 1493 (options.appLaunchMode !== Configuration.AppMode.USB && options.appLaunchMode !== Configuration.AppMode.LOCAL && options.appLaunchMode !== Configuration.AppMode.REMOTE) || 1494 typeof options.fqdnMode !== 'boolean' || typeof options.fqdnAddr !== 'string') { 1495 1496 if (typeof errorCallback === 'function') { 1497 var result = {}; 1498 checkErrorCodeNText(result, "CSSP", "Configuration.setServerProperty, Invalid parameters."); 1499 log ("options.serverIp : " + typeof options.serverIp + " options.serverPort : " + typeof options.serverPort + " options.secureConnection : " + typeof options.secureConnection + 1500 " options.appLaunchMode : " + typeof options.appLaunchMode + " options.fqdnMode : " + typeof options.fqdnMode + " options.fqdnAddr : " + options.fqdnAddr); 1501 1502 errorCallback(result); 1503 return; 1504 } 1505 1506 } 1507 1508 var sets = {}; 1509 1510 sets.siServerIp = options.serverIp; 1511 sets.serverIpPort = options.serverPort + ''; 1512 sets.secureConnection = ( options.secureConnection === true ? "on" : "off"); 1513 sets.appLaunchMode = options.appLaunchMode; 1514 sets.fqdnMode = ( options.fqdnMode === true ? "on" : "off" ); 1515 sets.fqdnAddr = options.fqdnAddr; 1516 1517 if(typeof options.appType !== 'undefined') 1518 sets.appType = options.appType; 1519 1520 log(JSON.stringify(sets)); 1521 1522 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 1523 method : "set", 1524 parameters : { 1525 category : "commercial", 1526 settings : sets 1527 }, 1528 onSuccess : function(result) { 1529 log("setServerProperty: On Success"); 1530 1531 if (result.returnValue === true) { 1532 if (typeof successCallback === 'function') { 1533 successCallback(); 1534 } 1535 } 1536 }, 1537 onFailure : function(result) { 1538 log("setServerProperty: On Failure"); 1539 delete result.returnValue; 1540 if (typeof errorCallback === 'function') { 1541 checkErrorCodeNText(result, "CSSP", "Configuration.setServerProperty returns failure."); 1542 errorCallback(result); 1543 } 1544 } 1545 }); 1546 1547 log("Configuration.setServerProperty Done"); 1548 }; 1549 1550 /** 1551 * Clears the cache data on signage monitor. 1552 * @class Configuration 1553 * @param {Function} successCallback success callback function. 1554 * @param {Function} errorCallback failure callback function. 1555 * 1556 * @example 1557 * // Javascript code 1558 * function clearCache () { 1559 * function successCb() { 1560 * console.log("clearCache success : "); 1561 * } 1562 * 1563 * function failureCb(cbObject) { 1564 * var errorCode = cbObject.errorCode; 1565 * var errorText = cbObject.errorText; 1566 * console.log ("Error Code [" + errorCode + "]: " + errorText); 1567 * } 1568 * 1569 * var configuration = new Configuration(); 1570 * configuration.clearCache(successCb, failureCb); 1571 * } 1572 * 1573 * @since 1.3 1574 */ 1575 Configuration.prototype.clearCache = function (successCallback, errorCallback) { 1576 1577 log("clearCache: "); 1578 1579 service.Request("luna://com.webos.service.commercial.signage.storageservice/", { 1580 method : "clearCache", 1581 onSuccess : function(result) { 1582 log("clearCache: On Success"); 1583 1584 if (typeof successCallback === 'function') { 1585 successCallback(); 1586 } 1587 }, 1588 onFailure : function(result) { 1589 log("clearCache: On Failure"); 1590 delete result.returnValue; 1591 if (typeof errorCallback === 'function') { 1592 checkErrorCodeNText(result, "CCC", "Configuration.clearCache returns failure."); 1593 errorCallback(result); 1594 } 1595 } 1596 }); 1597 1598 log("Configuration.clearCache Done"); 1599 1600 }; 1601 1602 /** 1603 * Gets list of time zone supported on signage monitor. 1604 * 1605 * @class Configuration 1606 * @param {Function} successCallback success callback function. 1607 * @param {Function} errorCallback failure callback function. 1608 * @return {Object} 1609 * <div align=left> 1610 * <table class="hcap_spec" width=400> 1611 * <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead> 1612 * <tbody> 1613 * <tr><th>timeZone[]</th><th>Array</th><th> </th><th>required</th></tr> 1614 * <tr class="odd"><th>timeZone[].continent</th><th>String</th><th>continent</th><th>required</th></tr> 1615 * <tr><th>timeZone[].country</th><th>String</th><th>country</th><th>required</th></tr> 1616 * <tr class="odd"><th>timeZone[].city</th><th>String</th><th>city</th><th>required</th></tr> 1617 * </tbody> 1618 * </table> 1619 * </div> 1620 * 1621 * @example 1622 * // Javascript code 1623 * function getTimeZoneList () { 1624 * function successCb(cbObject) { 1625 * 1626 * for (var i = cbObject.timeZone.length-1; i>=0; i--) { 1627 * console.log("timeZone [" + i + "].continent : " + cbObject.timeZone[i].continent); 1628 * console.log("timeZone [" + i + "].country : " + cbObject.timeZone[i].country); 1629 * console.log("timeZone [" + i + "].city : " + cbObject.timeZone[i].city); 1630 * 1631 * } 1632 * 1633 * // Do something 1634 * 1635 * } 1636 * 1637 * function failureCb(cbObject) { 1638 * var errorCode = cbObject.errorCode; 1639 * var errorText = cbObject.errorText; 1640 * console.log ("Error Code [" + errorCode + "]: " + errorText); 1641 * } 1642 * 1643 * var configuration = new Configuration(); 1644 * configuration.getTimeZoneList(successCb, failureCb); 1645 * } 1646 * @since 1.3 1647 * @see 1648 * <a href="Configuration%23setTimeZone.html">Configuration.setTimeZone()</a><br> 1649 * <a href="Configuration%23getTimeZone.html">Configuration.getTimeZone()</a><br> 1650 */ 1651 Configuration.prototype.getTimeZoneList = function (successCallback, errorCallback) { 1652 1653 log("getTimeZoneList: "); 1654 1655 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 1656 method : "getTimeZoneList", 1657 onSuccess : function(result) { 1658 log("getTimeZoneList: On Success"); 1659 1660 if (result.returnValue === true) { 1661 if (typeof successCallback === 'function') { 1662 delete result.returnValue; 1663 successCallback(result); 1664 } 1665 } 1666 }, 1667 onFailure : function(result) { 1668 log("getTimeZoneList: On Failure"); 1669 delete result.returnValue; 1670 if (typeof errorCallback === 'function') { 1671 checkErrorCodeNText(result, "CGTL", "Configuration.getTimeZoneList returns failure."); 1672 errorCallback(result); 1673 } 1674 } 1675 }); 1676 1677 log("Configuration.getTimeZoneList Done"); 1678 1679 }; 1680 1681 /** 1682 * Gets time zone. 1683 * 1684 * @class Configuration 1685 * @param {Function} successCallback success callback function. 1686 * @param {Function} errorCallback failure callback function. 1687 * @return {Object} 1688 * <div align=left> 1689 * <table class="hcap_spec" width=400> 1690 * <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead> 1691 * <tbody> 1692 * <tr><th>timeZone</th><th>Object</th><th> </th><th>required</th></tr> 1693 * <tr class="odd"><th>timeZone.continent</th><th>String</th><th>continent</th><th>required</th></tr> 1694 * <tr><th>timeZone.country</th><th>String</th><th>country</th><th>required</th></tr> 1695 * <tr class="odd"><th>timeZone.city</th><th>String</th><th>city</th><th>required</th></tr> 1696 * </tbody> 1697 * </table> 1698 * </div> 1699 * 1700 * @example 1701 * // Javascript code 1702 * function getTimeZone () { 1703 * function successCb(cbObject) { 1704 * 1705 * console.log("timeZone.continent : " + cbObject.timeZone.continent); 1706 * console.log("timeZone.country : " + cbObject.timeZone.country); 1707 * console.log("timeZone.city : " + cbObject.timeZone.city); 1708 * 1709 * 1710 * // Do something 1711 * 1712 * } 1713 * 1714 * function failureCb(cbObject) { 1715 * var errorCode = cbObject.errorCode; 1716 * var errorText = cbObject.errorText; 1717 * console.log ("Error Code [" + errorCode + "]: " + errorText); 1718 * } 1719 * 1720 * var configuration = new Configuration(); 1721 * configuration.getTimeZone(successCb, failureCb); 1722 * } 1723 * @since 1.3 1724 * @see 1725 * <a href="Configuration%23setTimeZone.html">Configuration.setTimeZone()</a><br> 1726 * <a href="Configuration%23getTimeZoneList.html">Configuration.getTimeZoneList()</a><br> 1727 */ 1728 Configuration.prototype.getTimeZone = function (successCallback, errorCallback) { 1729 1730 log("getTimeZone: "); 1731 1732 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 1733 method : "getTimeZone", 1734 onSuccess : function(result) { 1735 log("getTimeZone: On Success"); 1736 1737 if (result.returnValue === true) { 1738 if (typeof successCallback === 'function') { 1739 delete result.returnValue; 1740 successCallback(result); 1741 } 1742 } 1743 }, 1744 onFailure : function(result) { 1745 log("getTimeZone: On Failure"); 1746 delete result.returnValue; 1747 if (typeof errorCallback === 'function') { 1748 checkErrorCodeNText(result, "CGTZ", "Configuration.getTimeZone returns failure."); 1749 errorCallback(result); 1750 } 1751 } 1752 }); 1753 1754 log("Configuration.getTimeZone Done"); 1755 1756 }; 1757 1758 1759 /** 1760 * Sets time zone which should be one of the list from getTimeZoneList. 1761 * 1762 * @class Configuration 1763 * @param {Function} successCallback success callback function. 1764 * @param {Function} errorCallback failure callback function. 1765 * @param {Object} options 1766 * <div align=left> 1767 * <table class="hcap_spec" width=400> 1768 * <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead> 1769 * <tbody> 1770 * <tr><th>timeZone</th><th>Object</th><th> </th><th>required</th></tr> 1771 * <tr class="odd"><th>timeZone.continent</th><th>String</th><th>continent</th><th>required</th></tr> 1772 * <tr><th>timeZone.country</th><th>String</th><th>country</th><th>required</th></tr> 1773 * <tr class="odd"><th>timeZone.city</th><th>String</th><th>city</th><th>required</th></tr> 1774 * </tbody> 1775 * </table> 1776 * </div> 1777 * 1778 * @example 1779 * // Javascript code 1780 * function setTimeZone () { 1781 * function successCb(cbObject) { 1782 * 1783 * // Do something 1784 * 1785 * } 1786 * 1787 * function failureCb(cbObject) { 1788 * var errorCode = cbObject.errorCode; 1789 * var errorText = cbObject.errorText; 1790 * console.log ("Error Code [" + errorCode + "]: " + errorText); 1791 * } 1792 * 1793 * var configuration = new Configuration(); 1794 * var timeZone = { 1795 * continent : "Asia", 1796 * country : "South Korea", 1797 * city : "Seoul" 1798 * }; 1799 * var options = { timeZone : timeZone }; 1800 * 1801 * configuration.setTimeZone(successCb, failureCb, options); 1802 * } 1803 * 1804 * @return <p>If the method is successfully executed, success callback function is called without a parameter.</br> 1805 * If an error occurs, failure callback function is called with a failure callback object as a parameter.</p> 1806 * 1807 * @since 1.3 1808 * @see 1809 * <a href="Configuration%23getTimeZone.html">Configuration.getTimeZone()</a><br> 1810 * <a href="Configuration%23getTimeZoneList.html">Configuration.getTimeZoneList()</a><br> 1811 */ 1812 Configuration.prototype.setTimeZone = function (successCallback, errorCallback, options) { 1813 1814 log("setTimeZone: "); 1815 1816 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 1817 method : "get", 1818 parameters : { 1819 category : "time", 1820 keys : ["autoClock"] 1821 }, 1822 onSuccess : function(result) { 1823 if (result.returnValue === true) { 1824 if (typeof successCallback === 'function') { 1825 if(result.settings.autoClock === "off") { 1826 delete result.returnValue; 1827 if (typeof errorCallback === 'function') { 1828 checkErrorCodeNText(result, "CSTZ", "Configuration.setTimeZone returns failure. autoClock is off"); 1829 errorCallback(result); 1830 } 1831 } else { 1832 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 1833 method: "setTimeZone", 1834 parameters: options, 1835 onSuccess: function(result) { 1836 log("setTimeZone: On Success"); 1837 if (result.returnValue === true) { 1838 if (typeof successCallback === 'function') { 1839 delete result.returnValue; 1840 successCallback(result); 1841 } 1842 } 1843 }, 1844 onFailure: function(result) { 1845 log("setTimeZone: On Failure"); 1846 delete result.returnValue; 1847 if (typeof errorCallback === 'function') { 1848 checkErrorCodeNText(result, "CSTZ", "Configuration.setTimeZone returns failure."); 1849 errorCallback(result); 1850 } 1851 } 1852 }); 1853 } 1854 } 1855 } 1856 }, 1857 onFailure : function(result) { 1858 log("setTimeZone: On Failure"); 1859 delete result.returnValue; 1860 if (typeof errorCallback === 'function') { 1861 checkErrorCodeNText(result, "CSTZ", "Configuration.setTimeZone returns failure."); 1862 errorCallback(result); 1863 } 1864 } 1865 }); 1866 1867 log("Configuration.setTimeZone Done"); 1868 1869 }; 1870 1871 // hidden for debug 1872 Configuration.prototype.debug = function (successCallback, errorCallback, options) { 1873 1874 // options.enabled = true / false; 1875 1876 log("debug: " + options.enabled); 1877 1878 service.Request("luna://com.webos.service.commercial.signage.storageservice/", { 1879 method : "debug", 1880 parameters : { 1881 enabled : options.enabled 1882 }, 1883 onSuccess : function(result) { 1884 log("debug: On Success"); 1885 1886 if (typeof successCallback === 'function') { 1887 successCallback(result); 1888 } 1889 }, 1890 onFailure : function(result) { 1891 log("debug: On Failure"); 1892 delete result.returnValue; 1893 if (typeof errorCallback === 'function') { 1894 checkErrorCodeNText(result, "CD", "Configuration.debug returns failure."); 1895 errorCallback(result); 1896 } 1897 } 1898 }); 1899 1900 log("Configuration.debug Done"); 1901 1902 }; 1903 1904 1905 /** 1906 * set USBLock enabled/disabled 1907 * @class Configuration 1908 * @param {Function} successCallback success callback function. 1909 * @param {Function} errorCallback failure callback function. 1910 * @param {Object} options 1911 * <div align=left> 1912 * <table class="hcap_spec" width=400> 1913 * <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead> 1914 * <tbody> 1915 * <tr><th>enabled</th><th>Boolean</th><th>true: usb is disable(lock on) / false: usb is enabled (lock off) </th><th>required</th></tr> 1916 * </tbody> 1917 * </table> 1918 * </div> 1919 * @return <p>If the method is successfully executed, call the success callback function without a parameter.</br> 1920 * If an error occurs, failure callback function is called with failure callback object as a parameter.</p> 1921 * @example 1922 * // Javascript code 1923 * 1924 * function setUSBLock () { 1925 * var options = { 1926 * enabled : true 1927 * }; 1928 * 1929 * function successCb() { 1930 * // Do something 1931 * } 1932 * 1933 * function failureCb(cbObject) { 1934 * var errorCode = cbObject.errorCode; 1935 * var errorText = cbObject.errorText; 1936 * console.log ("Error Code [" + errorCode + "]: " + errorText); 1937 * } 1938 * 1939 * var configuration = new Configuration(); 1940 * configuration.setUSBLock(successCb, failureCb, options); 1941 * } 1942 * @since 1.4 1943 * @see 1944 * <a href="Configuration%23getUSBLock.html">Configuration.getUSBLock()</a><br> 1945 */ 1946 1947 Configuration.prototype.setUSBLock = function (successCallback, errorCallback, options) { 1948 log("setUSBLock: " + options.enabled); 1949 1950 if (options.enabled === null && typeof errorCallback === 'function') { 1951 var result = {}; 1952 checkErrorCodeNText(result, "CSUL", "Configuration.setUSBLock returns failure. command was not defined."); 1953 errorCallback(result); 1954 log("Configuration.setUSBLock invalid "); 1955 return; 1956 } 1957 1958 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 1959 method : "set", 1960 parameters : { 1961 category : "commercial", 1962 settings : { 1963 "enableUsb" : (options.enabled === true ) ? "off" : "on" 1964 } 1965 }, 1966 onSuccess : function(result) { 1967 log("setUSBLock: On Success"); 1968 1969 if (result.returnValue === true) { 1970 if(typeof successCallback === 'function') { 1971 successCallback(); 1972 } 1973 } 1974 }, 1975 onFailure : function(result) { 1976 log("setUSBLock: On Failure"); 1977 delete result.returnValue; 1978 if (typeof errorCallback === 'function') { 1979 checkErrorCodeNText(result, "CSUL", "Configuration.setUSBLock returns failure."); 1980 errorCallback(result); 1981 } 1982 } 1983 }); 1984 1985 log("Configuration.setUSBLock Done"); 1986 }; 1987 /** 1988 * Gets USBLock enabled 1989 * @class Configuration 1990 * @param {Function} successCallback success callback function. 1991 * @param {Function} errorCallback failure callback function. 1992 * @return {Object} 1993 * <div align=left> 1994 * <table class="hcap_spec" width=400> 1995 * <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead> 1996 * <tbody> 1997 * <tr><th>enabled</th><th>Boolean</th><th>true: usb is disable(lock on) / false: usb is enabled (lock off) </th></tr> 1998 * </tbody> 1999 * </table> 2000 * </div> 2001 * 2002 * @example 2003 * // Javascript code 2004 * function getUSBLock () { 2005 * function successCb(cbObject) { 2006 * console.log("cbObject : " + JSON.stringify(cbObject)); 2007 * console.log("enabled : " + cbObject.enabled); 2008 * 2009 * // Do something 2010 * } 2011 * 2012 * function failureCb(cbObject) { 2013 * var errorCode = cbObject.errorCode; 2014 * var errorText = cbObject.errorText; 2015 * console.log ("Error Code [" + errorCode + "]: " + errorText); 2016 * } 2017 * 2018 * var configuration = new Configuration(); 2019 * configuration.getUSBLock(successCb, failureCb); 2020 * } 2021 * @since 1.4 2022 * @see 2023 * <a href="Configuration%23setUSBLock.html">Configuration.setUSBLock()</a><br> 2024 */ 2025 Configuration.prototype.getUSBLock = function (successCallback, errorCallback) { 2026 2027 log("getUSBLock: "); 2028 2029 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 2030 method: "get", 2031 parameters: { 2032 category: "commercial", 2033 keys: ["enableUsb"] 2034 }, 2035 onSuccess: function(result) { 2036 log("getUSBLock: On Success"); 2037 2038 if (result.returnValue === true) { 2039 var cbObj = {}; 2040 cbObj.enabled = (result.settings.enableUsb === "off") ? true : false; 2041 2042 if (typeof successCallback === 'function') { 2043 successCallback(cbObj); 2044 } 2045 } 2046 }, 2047 onFailure: function(result) { 2048 log("getUSBLock: On Failure"); 2049 delete result.returnValue; 2050 if (typeof errorCallback === 'function') { 2051 checkErrorCodeNText(result, "CGUL", "Configuration.getUSBLock returns failure."); 2052 errorCallback(result); 2053 } 2054 } 2055 }); 2056 2057 log("Configuration.getUSBLock Done"); 2058 }; 2059 2060 /** 2061 * set OSDLock enabled/disabled 2062 * @class Configuration 2063 * @param {Function} successCallback success callback function. 2064 * @param {Function} errorCallback failure callback function. 2065 * @param {Object} options 2066 * <div align=left> 2067 * <table class="hcap_spec" width=400> 2068 * <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead> 2069 * <tbody> 2070 * <tr><th>enabled</th><th>Boolean</th><th>true: osd is disable(lock on) / false: osd is enabled (lock off) </th><th>required</th></tr> 2071 * </tbody> 2072 * </table> 2073 * </div> 2074 * @return <p>If the method is successfully executed, call the success callback function without a parameter.</br> 2075 * If an error occurs, failure callback function is called with failure callback object as a parameter.</p> 2076 * @example 2077 * // Javascript code 2078 * 2079 * function setOSDLock () { 2080 * var options = { 2081 * enabled : true 2082 * }; 2083 * 2084 * function successCb() { 2085 * // Do something 2086 * } 2087 * 2088 * function failureCb(cbObject) { 2089 * var errorCode = cbObject.errorCode; 2090 * var errorText = cbObject.errorText; 2091 * console.log ("Error Code [" + errorCode + "]: " + errorText); 2092 * } 2093 * 2094 * var configuration = new Configuration(); 2095 * configuration.setOSDLock(successCb, failureCb, options); 2096 * } 2097 * @since 1.4 2098 * @see 2099 * <a href="Configuration%23getOSDLock.html">Configuration.getOSDLock()</a><br> 2100 */ 2101 2102 Configuration.prototype.setOSDLock = function (successCallback, errorCallback, options) { 2103 log("setOSDLock: " + options.enabled); 2104 2105 if (options.enabled === null && typeof errorCallback === 'function') { 2106 var result = {}; 2107 checkErrorCodeNText(result, "CSOL", "Configuration.setOSDLock returns failure. command was not defined."); 2108 errorCallback(result); 2109 log("Configuration.setOSDLock invalid "); 2110 return; 2111 } 2112 2113 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 2114 method : "set", 2115 parameters : { 2116 category : "hotelMode", 2117 notifySelf : false, 2118 settings : { 2119 "enableMrcu" : (options.enabled === true ) ? "off" : "on", 2120 "enableOsdVisibility" : (options.enabled === true ) ? "off" : "on" 2121 } 2122 }, 2123 onSuccess : function(result) { 2124 log("setOSDLock: On Success"); 2125 2126 if (result.returnValue === true) { 2127 if(typeof successCallback === 'function') { 2128 successCallback(); 2129 } 2130 } 2131 }, 2132 onFailure : function(result) { 2133 log("setOSDLock: On Failure"); 2134 delete result.returnValue; 2135 if (typeof errorCallback === 'function') { 2136 checkErrorCodeNText(result, "CSOL", "Configuration.setOSDLock returns failure."); 2137 errorCallback(result); 2138 } 2139 } 2140 }); 2141 2142 log("Configuration.setOSDLock Done"); 2143 }; 2144 /** 2145 * Gets OSDLock enabled 2146 * @class Configuration 2147 * @param {Function} successCallback success callback function. 2148 * @param {Function} errorCallback failure callback function. 2149 * @return {Object} 2150 * <div align=left> 2151 * <table class="hcap_spec" width=400> 2152 * <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead> 2153 * <tbody> 2154 * <tr><th>enabled</th><th>Boolean</th><th>true: osd is disable(lock on) / false: osd is enabled (lock off) </th></tr> 2155 * </tbody> 2156 * </table> 2157 * </div> 2158 * 2159 * @example 2160 * // Javascript code 2161 * function getOSDLock () { 2162 * function successCb(cbObject) { 2163 * console.log("cbObject : " + JSON.stringify(cbObject)); 2164 * console.log("enabled : " + cbObject.enabled); 2165 * 2166 * // Do something 2167 * } 2168 * 2169 * function failureCb(cbObject) { 2170 * var errorCode = cbObject.errorCode; 2171 * var errorText = cbObject.errorText; 2172 * console.log ("Error Code [" + errorCode + "]: " + errorText); 2173 * } 2174 * 2175 * var configuration = new Configuration(); 2176 * configuration.getOSDLock(successCb, failureCb); 2177 * } 2178 * @since 1.4 2179 * @see 2180 * <a href="Configuration%23setOSDLock.html">Configuration.setOSDLock()</a><br> 2181 */ 2182 Configuration.prototype.getOSDLock = function (successCallback, errorCallback) { 2183 2184 log("getOSDLock: "); 2185 2186 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 2187 method: "get", 2188 parameters: { 2189 category: "hotelMode", 2190 keys: ["enableMrcu", "enableOsdVisibility"] 2191 }, 2192 onSuccess: function(result) { 2193 log("getOSDLock: On Success"); 2194 2195 if (result.returnValue === true) { 2196 var cbObj = {}; 2197 cbObj.enabled = (result.settings.enableMrcu === "on" && result.settings.enableOsdVisibility === "on") ? false : true; 2198 2199 if (typeof successCallback === 'function') { 2200 successCallback(cbObj); 2201 } 2202 } 2203 }, 2204 onFailure: function(result) { 2205 log("getOSDLock: On Failure"); 2206 delete result.returnValue; 2207 if (typeof errorCallback === 'function') { 2208 checkErrorCodeNText(result, "CGOL", "Configuration.getOSDLock returns failure."); 2209 errorCallback(result); 2210 } 2211 } 2212 }); 2213 2214 log("Configuration.getOSDLock Done"); 2215 }; 2216 2217 2218 /** 2219 * Gets the supported locale item list with an item (specifier, language name, country name). 2220 * Locale specifier is composed of {language code}-{country code} and it is worked as the identifier when setting language. 2221 * @class Configuration 2222 * @param {Function} successCallback success callback function. 2223 * @param {Function} errorCallback failure callback function. 2224 * @return {Object} 2225 * <div align=left> 2226 * <table class="hcap_spec" width=400> 2227 * <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead> 2228 * <tbody> 2229 * <tr><th>localeList</th><th>Array</th><th>locale list</th></tr> 2230 * <tr class="odd"><th>localeList.language</th><th>String</th><th>language name</th></tr> 2231 * <tr><th>localeList.languageCode</th><th>String</th><th>language code</th></tr> 2232 * <tr class="odd"><th>localeList.countries</th><th>Array</th><th>country list</th></tr> 2233 * <tr><th>localeList.countries.name</th><th>String</th><th>country name</th></tr> 2234 * <tr class="odd"><th>localeList.countries.spercifier</th><th>String</th><th>locale specifier ({language code}-{country code} such as "en-GB" and "ko-KR")</th></tr> 2235 * </tbody> 2236 * </table> 2237 * </div> 2238 * 2239 * @example 2240 * // Javascript code 2241 * function getLocaleList () { 2242 * function successCb(cbObject) { 2243 * console.log("cbObject : " + JSON.stringify(cbObject)); 2244 * var localeList = cbObject.localeList; 2245 * console.log("localeList : " + JSON.stringify(localeList)); 2246 * 2247 * // Do something 2248 * } 2249 * 2250 * function failureCb(cbObject) { 2251 * var errorCode = cbObject.errorCode; 2252 * var errorText = cbObject.errorText; 2253 * console.log ("Error Code [" + errorCode + "]: " + errorText); 2254 * } 2255 * 2256 * var configuration = new Configuration(); 2257 * configuration.getLocaleList(successCb, failureCb); 2258 * } 2259 * @since 1.4 2260 * @see 2261 * <a href="Configuration%23getOSDLock.html">Configuration.setOSDLock()</a><br> 2262 */ 2263 Configuration.prototype.getLocaleList = function (successCallback, errorCallback) { 2264 2265 log("getLocaleList: "); 2266 2267 //it will get localelist from system after SCAP v1.5 2268 var cbObj = {}; 2269 cbObj.localeList = Configuration.LocaleList; 2270 2271 if (typeof successCallback === 'function') { 2272 successCallback(cbObj); 2273 } 2274 2275 log("Configuration.getLocaleList Done"); 2276 }; 2277 2278 2279 2280 /** 2281 * set OSDLanguage 2282 * @class Configuration 2283 * @param {Function} successCallback success callback function. 2284 * @param {Function} errorCallback failure callback function. 2285 * @param {Object} options 2286 * <div align=left> 2287 * <table class="hcap_spec" width=400> 2288 * <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead> 2289 * <tbody> 2290 * <tr><th>specifier</th><th>String</th><th>locale specifier</th><th>required</th></tr> 2291 * </tbody> 2292 * </table> 2293 * </div> 2294 * @return <p>If the method is successfully executed, call the success callback function without a parameter.</br> 2295 * If an error occurs, failure callback function is called with failure callback object as a parameter.</p> 2296 * @example 2297 * // Javascript code 2298 * function setOSDLanguage () { 2299 * var options = { 2300 * specifier : "ko-KR" 2301 * }; 2302 * 2303 * function successCb() { 2304 * // Do something 2305 * } 2306 * 2307 * function failureCb(cbObject) { 2308 * var errorCode = cbObject.errorCode; 2309 * var errorText = cbObject.errorText; 2310 * console.log ("Error Code [" + errorCode + "]: " + errorText); 2311 * } 2312 * 2313 * var configuration = new Configuration(); 2314 * configuration.setOSDLanguage(successCb, failureCb, options); 2315 * } 2316 * @since 1.4 2317 * @see 2318 * <a href="Configuration%23getOSDLanguage.html">Configuration.getOSDLanguage()</a><br> 2319 */ 2320 Configuration.prototype.setOSDLanguage = function (successCallback, errorCallback, options) { 2321 log("setOSDLanguage: " + options.specifier); 2322 2323 if ((options.specifier === null || typeof options.specifier !== 'string') && typeof errorCallback === 'function') { 2324 var result = {}; 2325 checkErrorCodeNText(result, "CSOL", "Configuration.setOSDLanguage returns failure. command was not defined."); 2326 errorCallback(result); 2327 log("Configuration.setOSDLanguage invalid "); 2328 return; 2329 } 2330 2331 if (isValidSpecifier(options.specifier) === true) { 2332 log("Specifier is valid"); 2333 2334 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 2335 method: "get", 2336 parameters: { 2337 keys: ["localeInfo"] 2338 }, 2339 onSuccess: function(result) { 2340 if (result.returnValue === true) { 2341 var localeInfo = {}; 2342 localeInfo = result.settings.localeInfo; 2343 localeInfo.locales.UI = options.specifier; 2344 localeInfo.locales.FMT = options.specifier; 2345 localeInfo.locales.TV = options.specifier; 2346 2347 log("localeInfo : " + JSON.stringify(localeInfo)); 2348 2349 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 2350 method: "set", 2351 parameters: { 2352 settings: { 2353 localeInfo: localeInfo 2354 } 2355 }, 2356 onSuccess: function(result) { 2357 log("setOSDLanguage: On Success"); 2358 2359 if (result.returnValue === true) { 2360 if (typeof successCallback === 'function') { 2361 successCallback(); 2362 } 2363 } 2364 }, 2365 onFailure: function(result) { 2366 log("setOSDLanguage: On Failure"); 2367 delete result.returnValue; 2368 if (typeof errorCallback === 'function') { 2369 checkErrorCodeNText(result, "CSOL", "Configuration.setOSDLanguage returns failure."); 2370 errorCallback(result); 2371 } 2372 } 2373 }); 2374 } 2375 }, 2376 onFailure: function(result) { 2377 delete result.returnValue; 2378 if (typeof errorCallback === 'function') { 2379 checkErrorCodeNText(result, "CSOL", "Configuration.setOSDLanguage returns failure."); 2380 errorCallback(result); 2381 } 2382 } 2383 }); 2384 }else { 2385 var result = {}; 2386 checkErrorCodeNText(result, "CSOL", "Configuration.setOSDLanguage returns failure. specifier is not valid."); 2387 errorCallback(result); 2388 log("Configuration.setOSDLanguage invalid "); 2389 return; 2390 } 2391 2392 log("Configuration.setOSDLanguage Done"); 2393 }; 2394 2395 2396 /** 2397 * Gets OSDLanguage 2398 * @class Configuration 2399 * @param {Function} successCallback success callback function. 2400 * @param {Function} errorCallback failure callback function. 2401 * @return {Object} 2402 * <div align=left> 2403 * <table class="hcap_spec" width=400> 2404 * <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead> 2405 * <tbody> 2406 * <tr><th>specifier</th><th>String</th><th>locale specifier</th></tr> 2407 * </tbody> 2408 * </table> 2409 * </div> 2410 * 2411 * @example 2412 * // Javascript code 2413 * function getOSDLanguage () { 2414 * function successCb(cbObject) { 2415 * console.log("cbObject : " + JSON.stringify(cbObject)); 2416 * 2417 * console.log("specifier : " + cbObject.specifier); 2418 * 2419 * // Do something 2420 * } 2421 * 2422 * function failureCb(cbObject) { 2423 * var errorCode = cbObject.errorCode; 2424 * var errorText = cbObject.errorText; 2425 * console.log ("Error Code [" + errorCode + "]: " + errorText); 2426 * } 2427 * 2428 * var configuration = new Configuration(); 2429 * configuration.getOSDLanguage(successCb, failureCb); 2430 * } 2431 * @since 1.4 2432 * @see 2433 * <a href="Configuration%23setOSDLanguage.html">Configuration.setOSDLanguage()</a><br> 2434 */ 2435 2436 Configuration.prototype.getOSDLanguage = function (successCallback, errorCallback) { 2437 2438 log("getOSDLanguage: "); 2439 2440 service.Request("luna://com.webos.service.commercial.signage.storageservice/settings/", { 2441 method: "get", 2442 parameters: { 2443 keys: ["localeInfo"] 2444 }, 2445 onSuccess: function(result) { 2446 log("getOSDLanguage: On Success"); 2447 2448 if (result.returnValue === true) { 2449 var cbObj = {}; 2450 log("localeInfo : " + JSON.stringify(result.settings.localeInfo)); 2451 cbObj.specifier = result.settings.localeInfo.locales.UI; 2452 2453 if (typeof successCallback === 'function') { 2454 successCallback(cbObj); 2455 } 2456 } 2457 }, 2458 onFailure: function(result) { 2459 log("getOSDLanguage: On Failure"); 2460 delete result.returnValue; 2461 if (typeof errorCallback === 'function') { 2462 checkErrorCodeNText(result, "CGOL", "Configuration.getOSDLanguage returns failure."); 2463 errorCallback(result); 2464 } 2465 } 2466 }); 2467 2468 log("Configuration.getOSDLanguage Done"); 2469 }; 2470 2471 2472 /** 2473 * set VirtualKeyboardLanguage 2474 * @class Configuration 2475 * @param {Function} successCallback success callback function. 2476 * @param {Function} errorCallback failure callback function. 2477 * @param {Object} options 2478 * <div align=left> 2479 * <table class="hcap_spec" width=400> 2480 * <thead><tr><th>Property</th><th>Type</th><th>Description</th><th>Required</th></tr></thead> 2481 * <tbody> 2482 * <tr><th>languageCodeList</th><th>Array</th><th>locale languageCodeList</th><th>required</th></tr> 2483 * </tbody> 2484 * </table> 2485 * </div> 2486 * @return <p>If the method is successfully executed, call the success callback function without a parameter.</br> 2487 * If an error occurs, failure callback function is called with failure callback object as a parameter.</p> 2488 * @example 2489 * // Javascript code 2490 * 2491 * function setVirtualKeyboardLanguage () { 2492 * var options = { 2493 * languageCodeList : ["fr", "es", "ko"] 2494 * }; 2495 * 2496 * function successCb() { 2497 * // Do something 2498 * } 2499 * 2500 * function failureCb(cbObject) { 2501 * var errorCode = cbObject.errorCode; 2502 * var errorText = cbObject.errorText; 2503 * console.log ("Error Code [" + errorCode + "]: " + errorText); 2504 * } 2505 * 2506 * var configuration = new Configuration(); 2507 * configuration.setVirtualKeyboardLanguage(successCb, failureCb, options); 2508 * } 2509 * @since 1.4 2510 * @see 2511 * <a href="Configuration%23getVirtualKeyboardLanguage.html">Configuration.getVirtualKeyboardLanguage()</a><br> 2512 */ 2513 2514 Configuration.prototype.setVirtualKeyboardLanguage = function (successCallback, errorCallback, options) { 2515 log("setVirtualKeyboardLanguage: " + options.languageCodeList); 2516 2517 if (options.languageCodeList === null && typeof errorCallback === 'function') { 2518 var result = {}; 2519 checkErrorCodeNText(result, "CSKL", "Configuration.setVirtualKeyboardLanguage returns failure. command was not defined."); 2520 errorCallback(result); 2521 log("Configuration.setVirtualKeyboardLanguage invalid "); 2522 return; 2523 } 2524 2525 for(var i=0; i<options.languageCodeList.length; i++){ 2526 if(isValidLanguageCode(options.languageCodeList[i]) === false) { 2527 var result = {}; 2528 checkErrorCodeNText(result, "CSKL", "Configuration.setVirtualKeyboardLanguage returns failure. language code is not valid."); 2529 errorCallback(result); 2530 log("Configuration.setVirtualKeyboardLanguage invalid "); 2531 return; 2532 } 2533 } 2534 2535 log("languageCodeList is valid"); 2536 2537 service.Request("luna://com.webos.service.commercial.signage.storageservice/configuration/", { 2538 method: "setVirtualKeyboardLanguage", 2539 parameters: { 2540 languageCodeList : options.languageCodeList 2541 }, 2542 onSuccess: function(result) { 2543 log("setVirtualKeyboardLanguage: On Success"); 2544 2545 if (result.returnValue === true) { 2546 if (typeof successCallback === 'function') { 2547 successCallback(); 2548 } 2549 } 2550 }, 2551 onFailure: function(result) { 2552 log("setVirtualKeyboardLanguage: On Failure"); 2553 delete result.returnValue; 2554 if (typeof errorCallback === 'function') { 2555 checkErrorCodeNText(result, "CSKL", "Configuration.setVirtualKeyboardLanguage returns failure."); 2556 errorCallback(result); 2557 } 2558 } 2559 }); 2560 2561 log("Configuration.setVirtualKeyboardLanguage Done"); 2562 }; 2563 2564 /** 2565 * Gets VirtualKeyboardLanguage list 2566 * @class Configuration 2567 * @param {Function} successCallback success callback function. 2568 * @param {Function} errorCallback failure callback function. 2569 * @return {Object} 2570 * <div align=left> 2571 * <table class="hcap_spec" width=400> 2572 * <thead><tr><th>Property</th><th>Type</th><th>Description</th></tr></thead> 2573 * <tbody> 2574 * <tr><th>languageCodeList</th><th>Array</th><th>language code list ex)["fr","es","ko"]</th></tr> 2575 * </tbody> 2576 * </table> 2577 * </div> 2578 * 2579 * @example 2580 * // Javascript code 2581 * function getVirtualKeyboardLanguage () { 2582 * function successCb(cbObject) { 2583 * console.log("cbObject : " + JSON.stringify(cbObject)); 2584 * 2585 * for(var i = cbObject.languageCodeList.length-1; i>=0; i--) { 2586 * console.log("languageCodeList [" + i + "] : " + cbObject.languageCodeList[i]); 2587 * } 2588 * // Do something 2589 * ... 2590 * } 2591 * 2592 * function failureCb(cbObject) { 2593 * var errorCode = cbObject.errorCode; 2594 * var errorText = cbObject.errorText; 2595 * console.log ("Error Code [" + errorCode + "]: " + errorText); 2596 * } 2597 * 2598 * var configuration = new Configuration(); 2599 * configuration.getVirtualKeyboardLanguage(successCb, failureCb); 2600 * } 2601 * @since 1.4 2602 * @see 2603 * <a href="Configuration%23setVirtualKeyboardLanguage.html">Configuration.setVirtualKeyboardLanguage()</a><br> 2604 */ 2605 2606 Configuration.prototype.getVirtualKeyboardLanguage = function (successCallback, errorCallback) { 2607 2608 log("getVirtualKeyboardLanguage: "); 2609 2610 service.Request("luna://com.webos.service.commercial.signage.storageservice/configuration/", { 2611 method: "getVirtualKeyboardLanguage", 2612 parameters: {}, 2613 onSuccess: function(result) { 2614 log("getVirtualKeyboardLanguage: On Success"); 2615 2616 if (result.returnValue === true) { 2617 var cbObj = {}; 2618 log("keyboards : " + JSON.stringify(result.languageCodeList)); 2619 cbObj.languageCodeList = result.languageCodeList; 2620 2621 if (typeof successCallback === 'function') { 2622 successCallback(cbObj); 2623 } 2624 } 2625 }, 2626 onFailure: function(result) { 2627 log("getVirtualKeyboardLanguage: On Failure"); 2628 delete result.returnValue; 2629 if (typeof errorCallback === 'function') { 2630 checkErrorCodeNText(result, "CGKL", "Configuration.getVirtualKeyboardLanguage returns failure."); 2631 errorCallback(result); 2632 } 2633 } 2634 }); 2635 2636 log("Configuration.getVirtualKeyboardLanguage Done"); 2637 }; 2638 2639 module.exports = Configuration; 2640 }); 2641 2642 Configuration = cordova.require('cordova/plugin/configuration'); // jshint ignore:line 2643 2644