WidgetData API

To use Samsung Product API,

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

Should be loaded in index.html

This module defines the application secure storage functionalities provided by the Tizen Samsung Product API.

Since : 2.3

Product : TV, AV, B2B

Privilege Level : Public

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

Summary of Interfaces and Methods

Interface Method
WidgetDataManagerObject

WidgetDataManager

DOMString getVersion();
void read(SuccessCallback onsuccess, optional ErrorCallback? onerror);
void write(DOMString data, optional SuccessCallback? onsuccess, optional ErrorCallback? onerror);
void remove(optional SuccessCallback? onsuccess, optional ErrorCallback? onerror);

1. Interfaces

1.1 WidgetDataManagerObject

Defines a WebApi object instance of the Tizen Samsung Product API.
The webapis.widgetdata object enables access to WidgetData API functionality.

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

Attributes

1.2 WidgetDataManager

Provides methods for WidgetData functionalities.

[NoInterfaceObject] interface WidgetDataManager {
  DOMString getVersion();
  void read(SuccessCallback onsuccess, optional ErrorCallback? onerror);
  void write(DOMString data, optional SuccessCallback? onsuccess, optional ErrorCallback? onerror);
  void remove(optional SuccessCallback? onsuccess, optional ErrorCallback? onerror);
};

Methods

getVersion

Retrieves the plugin version number.

DOMString getVersion();

Product : TV, AV, B2B

Privilege Level : Public

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

Return Value :

  • DOMString : DOMString Plugin version

Exceptions :

  • WebAPIException
    • with error type SecurityError, if the application does not have the privilege to call this method.

Since : 2.3

Code Example :

try {
  var value = webapis.widgetdata.getVersion();
  console.log(" version value = " + value);
} catch (error) {
  console.log(" error code = " + error.code);
}

read

Reads encrypted data.

void read(SuccessCallback onsuccess, optional ErrorCallback? onerror);

Product : TV, AV, B2B

Privilege Level : Public

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

Parameters :

  • onsuccess : Callback method to invoke when the data is successfully read
  • onerror [optional][nullable] : Callback method to invoke if an error occurs
    NotFoundError, if no file was found in the local path.
    SecurityError, if the application does not have the privilege to call this method.
    UnknownError, if any other error occurs.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.

Since : 4.0

Code Example :

function onsuccess(data)  {
  console.log("success read :" + data);
}
function onerror(error)  {
  console.log("error code : " + error.code);
}
try {
  webapis.widgetdata.read(onsuccess, onerror);
} catch (error) {
  console.log(" error code = " + error.code);
}

write

Writes encrypted data.

void write(DOMString data, optional SuccessCallback? onsuccess, optional ErrorCallback? onerror);

Product : TV, AV, B2B

Privilege Level : Public

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

Parameters :

  • data : Data, up to 20000 characters
  • onsuccess [optional][nullable] : Callback method to invoke when the data is successfully written
  • onerror [optional][nullable] : Callback method to invoke if an error occurs
    DOMStringSizeError, if any of the input parameters exceeds the limited size.
    SecurityError, if the application does not have the privilege to call this method.
    UnknownError, if any other error occurs.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.

Since : 4.0

Code Example :

function onsuccess()  {
  console.log("success write");
}
function onerror(error)  {
  console.log("error code : " + error.code);
}
try {
  var data = "STRING DATA";
  webapis.widgetdata.write(data, onsuccess, onerror);
} catch (error) {
  console.log(" error code = " + error.code);
}

remove

Removes encrypted data.

void remove(optional SuccessCallback? onsuccess, optional ErrorCallback? onerror);

Product : TV, AV, B2B

Privilege Level : Public

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

Parameters :

  • onsuccess [optional][nullable] : Callback method to invoke when the data is successfully removed
  • onerror [optional][nullable] : Callback method to invoke if an error occurs
    NotFoundError, if no file was found in the local path.
    SecurityError, if the application does not have the privilege to call this method.
    UnknownError, if any other error occurs.

Exceptions :

  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.

Since : 4.0

Code Example :

function onsuccess()  {
  console.log("success remove");
}
function onerror(error)  {
  console.log("error code : " + error.code);
}
try {
  webapis.widgetdata.remove(onsuccess, onerror);
} catch (error) {
  console.log(" error code = " + error.code);
}

2. Full WebIDL

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

  WebApi implements WidgetDataManagerObject;

  [NoInterfaceObject] interface WidgetDataManager {
    DOMString getVersion();
    void read(SuccessCallback onsuccess, optional ErrorCallback? onerror);
    void write(DOMString data, optional SuccessCallback? onsuccess, optional ErrorCallback? onerror);
    void remove(optional SuccessCallback? onsuccess, optional ErrorCallback? onerror);
  };

};