1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.NetworkMonitorIF;
26 
27 private import gio.AsyncResultIF;
28 private import gio.Cancellable;
29 private import gio.NetworkMonitorIF;
30 private import gio.SocketConnectableIF;
31 private import gio.c.functions;
32 public  import gio.c.types;
33 private import glib.ErrorG;
34 private import glib.GException;
35 private import gobject.ObjectG;
36 private import gobject.Signals;
37 public  import gtkc.giotypes;
38 private import std.algorithm;
39 
40 
41 /**
42  * #GNetworkMonitor provides an easy-to-use cross-platform API
43  * for monitoring network connectivity. On Linux, the available
44  * implementations are based on the kernel's netlink interface and
45  * on NetworkManager.
46  * 
47  * There is also an implementation for use inside Flatpak sandboxes.
48  *
49  * Since: 2.32
50  */
51 public interface NetworkMonitorIF{
52 	/** Get the main Gtk struct */
53 	public GNetworkMonitor* getNetworkMonitorStruct(bool transferOwnership = false);
54 
55 	/** the main Gtk struct as a void* */
56 	protected void* getStruct();
57 
58 
59 	/** */
60 	public static GType getType()
61 	{
62 		return g_network_monitor_get_type();
63 	}
64 
65 	/**
66 	 * Gets the default #GNetworkMonitor for the system.
67 	 *
68 	 * Returns: a #GNetworkMonitor
69 	 *
70 	 * Since: 2.32
71 	 */
72 	public static NetworkMonitorIF getDefault()
73 	{
74 		auto p = g_network_monitor_get_default();
75 
76 		if(p is null)
77 		{
78 			return null;
79 		}
80 
81 		return ObjectG.getDObject!(NetworkMonitorIF)(cast(GNetworkMonitor*) p);
82 	}
83 
84 	/**
85 	 * Attempts to determine whether or not the host pointed to by
86 	 * @connectable can be reached, without actually trying to connect to
87 	 * it.
88 	 *
89 	 * This may return %TRUE even when #GNetworkMonitor:network-available
90 	 * is %FALSE, if, for example, @monitor can determine that
91 	 * @connectable refers to a host on a local network.
92 	 *
93 	 * If @monitor believes that an attempt to connect to @connectable
94 	 * will succeed, it will return %TRUE. Otherwise, it will return
95 	 * %FALSE and set @error to an appropriate error (such as
96 	 * %G_IO_ERROR_HOST_UNREACHABLE).
97 	 *
98 	 * Note that although this does not attempt to connect to
99 	 * @connectable, it may still block for a brief period of time (eg,
100 	 * trying to do multicast DNS on the local network), so if you do not
101 	 * want to block, you should use g_network_monitor_can_reach_async().
102 	 *
103 	 * Params:
104 	 *     connectable = a #GSocketConnectable
105 	 *     cancellable = a #GCancellable, or %NULL
106 	 *
107 	 * Returns: %TRUE if @connectable is reachable, %FALSE if not.
108 	 *
109 	 * Since: 2.32
110 	 *
111 	 * Throws: GException on failure.
112 	 */
113 	public bool canReach(SocketConnectableIF connectable, Cancellable cancellable);
114 
115 	/**
116 	 * Asynchronously attempts to determine whether or not the host
117 	 * pointed to by @connectable can be reached, without actually
118 	 * trying to connect to it.
119 	 *
120 	 * For more details, see g_network_monitor_can_reach().
121 	 *
122 	 * When the operation is finished, @callback will be called.
123 	 * You can then call g_network_monitor_can_reach_finish()
124 	 * to get the result of the operation.
125 	 *
126 	 * Params:
127 	 *     connectable = a #GSocketConnectable
128 	 *     cancellable = a #GCancellable, or %NULL
129 	 *     callback = a #GAsyncReadyCallback to call when the
130 	 *         request is satisfied
131 	 *     userData = the data to pass to callback function
132 	 */
133 	public void canReachAsync(SocketConnectableIF connectable, Cancellable cancellable, GAsyncReadyCallback callback, void* userData);
134 
135 	/**
136 	 * Finishes an async network connectivity test.
137 	 * See g_network_monitor_can_reach_async().
138 	 *
139 	 * Params:
140 	 *     result = a #GAsyncResult
141 	 *
142 	 * Returns: %TRUE if network is reachable, %FALSE if not.
143 	 *
144 	 * Throws: GException on failure.
145 	 */
146 	public bool canReachFinish(AsyncResultIF result);
147 
148 	/**
149 	 * Gets a more detailed networking state than
150 	 * g_network_monitor_get_network_available().
151 	 *
152 	 * If #GNetworkMonitor:network-available is %FALSE, then the
153 	 * connectivity state will be %G_NETWORK_CONNECTIVITY_LOCAL.
154 	 *
155 	 * If #GNetworkMonitor:network-available is %TRUE, then the
156 	 * connectivity state will be %G_NETWORK_CONNECTIVITY_FULL (if there
157 	 * is full Internet connectivity), %G_NETWORK_CONNECTIVITY_LIMITED (if
158 	 * the host has a default route, but appears to be unable to actually
159 	 * reach the full Internet), or %G_NETWORK_CONNECTIVITY_PORTAL (if the
160 	 * host is trapped behind a "captive portal" that requires some sort
161 	 * of login or acknowledgement before allowing full Internet access).
162 	 *
163 	 * Note that in the case of %G_NETWORK_CONNECTIVITY_LIMITED and
164 	 * %G_NETWORK_CONNECTIVITY_PORTAL, it is possible that some sites are
165 	 * reachable but others are not. In this case, applications can
166 	 * attempt to connect to remote servers, but should gracefully fall
167 	 * back to their "offline" behavior if the connection attempt fails.
168 	 *
169 	 * Returns: the network connectivity state
170 	 *
171 	 * Since: 2.44
172 	 */
173 	public GNetworkConnectivity getConnectivity();
174 
175 	/**
176 	 * Checks if the network is available. "Available" here means that the
177 	 * system has a default route available for at least one of IPv4 or
178 	 * IPv6. It does not necessarily imply that the public Internet is
179 	 * reachable. See #GNetworkMonitor:network-available for more details.
180 	 *
181 	 * Returns: whether the network is available
182 	 *
183 	 * Since: 2.32
184 	 */
185 	public bool getNetworkAvailable();
186 
187 	/**
188 	 * Checks if the network is metered.
189 	 * See #GNetworkMonitor:network-metered for more details.
190 	 *
191 	 * Returns: whether the connection is metered
192 	 *
193 	 * Since: 2.46
194 	 */
195 	public bool getNetworkMetered();
196 
197 	/**
198 	 * Emitted when the network configuration changes. If @available is
199 	 * %TRUE, then some hosts may be reachable that were not reachable
200 	 * before, while others that were reachable before may no longer be
201 	 * reachable. If @available is %FALSE, then no remote hosts are
202 	 * reachable.
203 	 *
204 	 * Params:
205 	 *     available = the current value of #GNetworkMonitor:network-available
206 	 *
207 	 * Since: 2.32
208 	 */
209 	gulong addOnNetworkChanged(void delegate(bool, NetworkMonitorIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0);
210 }