summaryrefslogtreecommitdiffstats
path: root/dom/system/gonk/nsINetworkManager.idl
blob: 0da1237969d2bb5fbc4b9d446e23016d78117302 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface nsINetworkInfo;
interface nsINetworkInterface;

/**
 * Manage network interfaces.
 */
[scriptable, uuid(1ba9346b-53b5-4660-9dc6-58f0b258d0a6)]
interface nsINetworkManager : nsISupports
{
  /**
   * Register the given network interface with the network manager.
   *
   * Consumers will be notified with the 'network-interface-registered'
   * observer notification.
   *
   * Throws if there's already an interface registered with the same network id.
   *
   * @param network
   *        Network interface to register.
   */
  void registerNetworkInterface(in nsINetworkInterface network);

  /**
   * Update the routes and DNSes according the state of the given network.
   *
   * Consumers will be notified with the 'network-connection-state-changed'
   * observer notification.
   *
   * Throws an exception if the specified network interface object isn't
   * registered.
   *
   * @param network
   *        Network interface to update.
   */
  void updateNetworkInterface(in nsINetworkInterface network);

  /**
   * Unregister the given network interface from the network manager.
   *
   * Consumers will be notified with the 'network-interface-unregistered'
   * observer notification.
   *
   * Throws an exception if the specified network interface object isn't
   * registered.
   *
   * @param network
   *        Network interface to unregister.
   */
  void unregisterNetworkInterface(in nsINetworkInterface network);

  /**
   * Object containing all known network information, keyed by their
   * network id. Network id is composed of a sub-id + '-' + network
   * type. For mobile network types, sub-id is 'ril' + service id; for
   * non-mobile network types, sub-id is always 'device'.
   */
  readonly attribute jsval allNetworkInfo;

  /**
   * Priority list of network types. An array of
   * nsINetworkInterface::NETWORK_TYPE_* constants.
   *
   * The piror position of the type indicates the higher priority. The priority
   * is used to determine route when there are multiple connected networks.
   */
  attribute jsval networkTypePriorityList;

  /**
   * The preferred network type. One of the
   * nsINetworkInterface::NETWORK_TYPE_* constants.
   *
   * This attribute is used for setting default route to favor
   * interfaces with given type.  This can be overriden by calling
   * overrideDefaultRoute().
   */
  attribute long preferredNetworkType;

  /**
   * The network information of the network interface handling all network
   * traffic.
   *
   * When this changes, the 'network-active-changed' observer
   * notification is dispatched.
   */
  readonly attribute nsINetworkInfo activeNetworkInfo;

  /**
   * Override the default behaviour for preferredNetworkType and route
   * all network traffic through the the specified interface.
   *
   * Consumers can observe changes to the active network by subscribing to
   * the 'network-active-changed' observer notification.
   *
   * @param network
   *        Network to route all network traffic to. If this is null,
   *        a previous override is canceled.
   */
  long overrideActive(in nsINetworkInterface network);

  /**
   * Add host route to the specified network into routing table.
   *
   * @param network
   *        The network information for the host to be routed to.
   * @param host
   *        The host to be added.
   *        The host will be resolved in advance if it's not an ip-address.
   *
   * @return a Promise
   *         resolved if added; rejected, otherwise.
   */
  jsval addHostRoute(in nsINetworkInfo network,
                     in DOMString host);

  /**
   * Remove host route to the specified network from routing table.
   *
   * @param network
   *        The network information for the routing to be removed from.
   * @param host
   *        The host routed to the network.
   *        The host will be resolved in advance if it's not an ip-address.
   *
   * @return a Promise
   *         resolved if removed; rejected, otherwise.
   */
  jsval removeHostRoute(in nsINetworkInfo network,
                        in DOMString host);
};