top

WidgetData API

To use Samsung Product API, 

<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>

Should be loaded in index.html

The module defines the functionalities of storing data in the application's secure storage that are provides as the Samsung TV for Tizen Platform Product API.

Since : 1.0

Table of Contents

  1. 1. Interfaces
    1. 1.1. WidgetDataManagerObject
    2. 1.2. WidgetDataManager
    3. 1.3. WidgetDataStringSuccessCallback
  2. 2. Full WebIDL

Summary of Interfaces and Methods

Interface Method
WidgetDataManagerObject  
WidgetDataManager DOMString getVersion ()
void readWidgetData (DOMString password, long dataLength, DOMString widgetId,WidgetDataStringSuccessCallback onsuccess, optional ErrorCallback ? onerror)
void removeWidgetData (DOMString widgetId, optional SuccessCallback ? onsuccess, optional ErrorCallback ? onerror)
void writeWidgetData (DOMString password, long dataLength, DOMString widgetId, optional SuccessCallback ? onsuccess, optional ErrorCallback ? onerror)
WidgetDataStringSuccessCallback  

1. Interfaces

1.1. WidgetDataManagerObject

The interface defines what is instantiated by the WebApi object of Samsung TV for Tizen Platform Product API.
There will be a webapis.widgetdata object that allows access to the functionality of the WidgetData API

  [NoInterfaceObject]interface WidgetDataManagerObject {
      readonly attribute WidgetDataManager widgetdata;
  };

  WebApi implements WidgetDataManagerObject;

Since : 1.0

Attributes

1.2. WidgetDataManager

This interface provides methods to use the WidgetData functionalities.

  [NoInterfaceObject]interface WidgetDataManager {
      DOMString getVersion();
      void readWidgetData(DOMString password, long dataLength, DOMString widgetId, WidgetDataStringSuccessCallback onsuccess, optional ErrorCallback ? onerror);
      void removeWidgetData(DOMString widgetId, optional SuccessCallback ? onsuccess, optional ErrorCallback ? onerror);
      void writeWidgetData(DOMString password, DOMString data, long dataLength, DOMString widgetId, optional SuccessCallback ? onsuccess, optional ErrorCallback ? onerror);
  };

Since : 1.0

Methods

getVersion
This method get the plugin's version number.

  DOMString getVersion();

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/widgetdata

Return value:

DOMString return value of plugin's version

Code example:


  try {    
      var value = webapis.widgetdata.getVersion();    
      console.log(" version value = " + value); 
  } catch (error) {    
      console.log(" error code = " + error.code);  
  }
readWidgetData
This method read the encrypted data.

  void readWidgetData(DOMString password, long dataLength, DOMString widgetId, WidgetDataStringSuccessCallback onsuccess, optional ErrorCallback ?  onerror);

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/widgetdata

Parameters:

  • password: Value of password
  • dataLength: Value of dataLength
  • widgetId: Id of widget
  • onsuccess: WidgetDataStringSuccessCallback
  • onerror [optional]: ErrorCallback

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if invalid DOMString type passed for 'password' parameter

    • with error type TypeMismatchError, if invalid long type passed for 'dataLength' parameter

    • with error type TypeMismatchError, if invalid DOMString type passed for 'widgetId' parameter

    • with error type TypeMismatchError, if invalid WidgetDataStringSuccessCallback type passed for 'onsuccess' parameter

    • with error type TypeMismatchError, if invalid ErrorCallback type passed for 'onerror' parameter

Code example:


  function onsuccess(data)  {   
      console.log("readWidgetData data = " + data); 
  } 
  function onerror(error)  {   
      console.log("error code : " + error.code); 
  }
  try {    
      webapis.widgetdata.readWidgetData(password, dataLength, widgetId, onsuccess, onerror);  
  } catch (error) {    
      console.log(" error code = " + error.code);  
  }
removeWidgetData
This method remove the encrypted data.

  void removeWidgetData(DOMString widgetId, optional SuccessCallback ?  onsuccess, optional ErrorCallback ?  onerror);

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/widgetdata

Parameters:

  • widgetId: Id of widget
  • onsuccess [optional]: SuccessCallback
  • onerror [optional]: ErrorCallback

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if invalid DOMString type passed for 'widgetId' parameter

    • with error type TypeMismatchError, if invalid SuccessCallback type passed for 'onsuccess' parameter

    • with error type TypeMismatchError, if invalid ErrorCallback type passed for 'onerror' parameter

Code example:


  function onsuccess(data)  {   
      console.log("removeWidgetData data = " + data); 
  } 
  function onerror(error)  {   
      console.log("error code : " + error.code); 
  } 
  try {    
      webapis.widgetdata.removeWidgetData(widgetId, onsuccess, onerror);  
  } catch (error) {    
      console.log(" error code = " + error.code);  
  }
writeWidgetData
This method write the encrypted data.

  void writeWidgetData(DOMString password, DOMString data, long dataLength, DOMString widgetId, optional SuccessCallback ?  onsuccess, optional ErrorCallback ?  onerror);

Since : 1.0

Privilege level: public

Privilege: http://developer.samsung.com/privilege/widgetdata

Parameters:

  • password: Value of password
  • data: Value of data
  • dataLength: Value of dataLength
  • widgetId: Id of widget
  • onsuccess [optional]: SuccessCallback
  • onerror [optional]: ErrorCallback

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if invalid DOMString type passed for 'password' parameter

    • with error type TypeMismatchError, if invalid DOMString type passed for 'data' parameter

    • with error type TypeMismatchError, if invalid long type passed for 'dataLength' parameter

    • with error type TypeMismatchError, if invalid DOMString type passed for 'widgetId' parameter

    • with error type TypeMismatchError, if invalid WidgetDataStringSuccessCallback type passed for 'onsuccess' parameter

    • with error type TypeMismatchError, if invalid ErrorCallback type passed for 'onerror' parameter

Code example:


  function onsuccess(data)  {   
      console.log("writeWidgetData data = " + data); 
  } 
  function onerror(error)  {   
      console.log("error code : " + error.code); 
  }
  try {    
      webapis.widgetdata.writeWidgetData(password, data, dataLength, widgetId, onsuccess, onerror);  
  } catch (error) {    
      console.log(" error code = " + error.code);  
  }

1.3. WidgetDataStringSuccessCallback

This callback interface is used in methods that do not require any return value in the success callback.

  [Callback = FunctionOnly, NoInterfaceObject]interface WidgetDataStringSuccessCallback {
      void onsuccess(DOMString data);
  };

Since : 1.0

 

2. Full WebIDL


  module WidgetData {
      [NoInterfaceObject]interface WidgetDataManagerObject {
          readonly attribute WidgetDataManager widgetdata;
      };
      WebApi implements WidgetDataManagerObject;

      [NoInterfaceObject]interface WidgetDataManager {
          DOMString getVersion();
          void readWidgetData(DOMString password, long dataLength, DOMString widgetId, WidgetDataStringSuccessCallback onsuccess, optional ErrorCallback ? onerror);
          void removeWidgetData(DOMString widgetId, optional SuccessCallback ? onsuccess, optional ErrorCallback ? onerror);
          void writeWidgetData(DOMString password, DOMString data, long dataLength, DOMString widgetId, optional SuccessCallback ? onsuccess, optional ErrorCallback ? onerror);
      };
      [Callback = FunctionOnly, NoInterfaceObject]interface WidgetDataStringSuccessCallback {
          void onsuccess(DOMString data);
      };
  };