NetworkBearerSelection API
This API provides interfaces and methods for users to set network bearer selection.
Since Tizen 2.3, the "http://tizen.org/privilege/internet" privilege is additionally required.
If not declared in config.xml of wgt file, UnknownError occurs.
Since: 2.1
Table of Contents
- 1. Type Definitions
- 1.1. NetworkType
- 2. Interfaces
- 3. Related Feature
- 4. Full WebIDL
Summary of Interfaces and Methods
Interface | Method |
---|---|
NetworkBearerSelectionObject | |
NetworkBearerSelection |
void requestRouteToHost (NetworkType networkType, DOMString domainName, NetworkSuccessCallback successCallback, optional ErrorCallback? errorCallback)
void releaseRouteToHost (NetworkType networkType, DOMString domainName, SuccessCallback successCallback, optional ErrorCallback? errorCallback)
|
NetworkSuccessCallback |
void onsuccess ()
void ondisconnected ()
|
1. Type Definitions
2. Interfaces
2.1. NetworkBearerSelectionObject
[NoInterfaceObject] interface NetworkBearerSelectionObject { readonly attribute NetworkBearerSelection networkbearerselection; };
Tizen implements NetworkBearerSelectionObject;
Since: 2.1
There is a tizen.networkbearerselection object that allows accessing the functionality of the Network Bearer Selection API.
Attributes
-
readonly
NetworkBearerSelection networkbearerselectionObject representing a network bearer selection.
Since: 2.1
2.2. NetworkBearerSelection
[NoInterfaceObject] interface NetworkBearerSelection { void requestRouteToHost(NetworkType networkType, DOMString domainName, NetworkSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void releaseRouteToHost(NetworkType networkType, DOMString domainName, SuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 2.1
This API offers methods for network bearer selection.
Methods
-
requestRouteToHost
-
Requests a specific network connection.
void requestRouteToHost(NetworkType networkType, DOMString domainName, NetworkSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.1
The function must asynchronously acquire success or fail.
When called, it starts a request process defined with these set of steps:
- 1. Open "networkType" network connection.
- 2. Resolve "domainName" to IP.
- 3. Change the routing path bound to domainName's IP to use the specific network type.
-
4. If previous steps have been successfully accomplished, call the onsuccess() callback function.
If previous steps have failed, call the ondisconnected() callback function.
If network is disconnected, the routing path will be deleted and ondisconnected() is called.
The ErrorCallback method is launched with these error types:
- UnknownError : If the "http://tizen.org/privilege/internet" privilege is not declared in config.xml or any other platform error occurs.
Privilege level: partner
Privilege: http://tizen.org/privilege/networkbearerselection
Privilege level: public
Privilege: http://tizen.org/privilege/internet
Remark: The "http://tizen.org/privilege/internet" privilege is required since Tizen 2.3.
Parameters:
- networkType: The network type.
- domainName: The domain name.
- successCallback: Callback function that is called when data network connection is connected.
- errorCallback [optional] [nullable]: Callback function that is called when the request is failed.
Exceptions:
- WebAPIException
with error type NotSupportedError, if this feature is not supported.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
Code example:
var statuscb = { onsuccess: function() { console.log("onsuccess func is called"); }, ondisconnected: function() { console.log("ondisconnected func is called"); } }; function ecb(e) { console.log("error callback is called: " + e.message + ": " + e.code); } tizen.networkbearerselection.requestRouteToHost("CELLULAR", "www.tizen.org", statuscb, ecb);
-
releaseRouteToHost
-
Releases a specific network connection.
void releaseRouteToHost(NetworkType networkType, DOMString domainName, SuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.1
The function must asynchronously acquire success or fail.
When called, it closes a network connection.
The ErrorCallback method is launched with these error types:
- UnknownError : If the "http://tizen.org/privilege/internet" privilege is not declared in config.xml or any other platform error occurs.
Privilege level: partner
Privilege: http://tizen.org/privilege/networkbearerselection
Privilege level: public
Privilege: http://tizen.org/privilege/internet
Remark: The "http://tizen.org/privilege/internet" privilege is required since Tizen 2.3.
Parameters:
- networkType: Network type.
- domainName: Domain name.
- successCallback: Callback function that is called when data network connection is released.
- errorCallback [optional] [nullable]: Callback function that is called when the releasing fails.
Exceptions:
- WebAPIException
with error type NotSupportedError, if this feature is not supported.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
Code example:
function scb() { console.log("success callback is called"); } function ecb(e) { console.log("error callback is called: " + e.message + ": " + e.code); } var statuscb = { onsuccess: function() { console.log("onsuccess func is called"); tizen.networkbearerselection.releaseRouteToHost("CELLULAR", "www.google.com", scb, ecb); }, ondisconnected: function() { console.log("ondisconnected func is called"); } }; tizen.networkbearerselection.requestRouteToHost("CELLULAR", "www.google.com", statuscb, ecb);
2.3. NetworkSuccessCallback
[Callback, NoInterfaceObject] interface NetworkSuccessCallback { void onsuccess(); void ondisconnected(); };
Since: 2.1
It is used in asynchronous operations with requestRouteToHost().
3. Related Feature
To guarantee that the NBS application runs on a device with telephony feature, declare the following feature requirements in the config file:
4. Full WebIDL
module NetworkBearerSelection { enum NetworkType { "CELLULAR", "UNKNOWN" }; Tizen implements NetworkBearerSelectionObject; [NoInterfaceObject] interface NetworkBearerSelectionObject { readonly attribute NetworkBearerSelection networkbearerselection; }; [NoInterfaceObject] interface NetworkBearerSelection { void requestRouteToHost(NetworkType networkType, DOMString domainName, NetworkSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void releaseRouteToHost(NetworkType networkType, DOMString domainName, SuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [Callback, NoInterfaceObject] interface NetworkSuccessCallback { void onsuccess(); void ondisconnected(); }; };