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 /** 75 * Attempts to determine whether or not the host pointed to by 76 * @connectable can be reached, without actually trying to connect to 77 * it. 78 * 79 * This may return %TRUE even when #GNetworkMonitor:network-available 80 * is %FALSE, if, for example, @monitor can determine that 81 * @connectable refers to a host on a local network. 82 * 83 * If @monitor believes that an attempt to connect to @connectable 84 * will succeed, it will return %TRUE. Otherwise, it will return 85 * %FALSE and set @error to an appropriate error (such as 86 * %G_IO_ERROR_HOST_UNREACHABLE). 87 * 88 * Note that although this does not attempt to connect to 89 * @connectable, it may still block for a brief period of time (eg, 90 * trying to do multicast DNS on the local network), so if you do not 91 * want to block, you should use g_network_monitor_can_reach_async(). 92 * 93 * Params: 94 * connectable = a #GSocketConnectable 95 * cancellable = a #GCancellable, or %NULL 96 * 97 * Returns: %TRUE if @connectable is reachable, %FALSE if not. 98 * 99 * Since: 2.32 100 * 101 * Throws: GException on failure. 102 */ 103 public bool canReach(SocketConnectableIF connectable, Cancellable cancellable); 104 105 /** 106 * Asynchronously attempts to determine whether or not the host 107 * pointed to by @connectable can be reached, without actually 108 * trying to connect to it. 109 * 110 * For more details, see g_network_monitor_can_reach(). 111 * 112 * When the operation is finished, @callback will be called. 113 * You can then call g_network_monitor_can_reach_finish() 114 * to get the result of the operation. 115 * 116 * Params: 117 * connectable = a #GSocketConnectable 118 * cancellable = a #GCancellable, or %NULL 119 * callback = a #GAsyncReadyCallback to call when the 120 * request is satisfied 121 * userData = the data to pass to callback function 122 */ 123 public void canReachAsync(SocketConnectableIF connectable, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 124 125 /** 126 * Finishes an async network connectivity test. 127 * See g_network_monitor_can_reach_async(). 128 * 129 * Params: 130 * result = a #GAsyncResult 131 * 132 * Returns: %TRUE if network is reachable, %FALSE if not. 133 * 134 * Throws: GException on failure. 135 */ 136 public bool canReachFinish(AsyncResultIF result); 137 138 /** 139 * Gets a more detailed networking state than 140 * g_network_monitor_get_network_available(). 141 * 142 * If #GNetworkMonitor:network-available is %FALSE, then the 143 * connectivity state will be %G_NETWORK_CONNECTIVITY_LOCAL. 144 * 145 * If #GNetworkMonitor:network-available is %TRUE, then the 146 * connectivity state will be %G_NETWORK_CONNECTIVITY_FULL (if there 147 * is full Internet connectivity), %G_NETWORK_CONNECTIVITY_LIMITED (if 148 * the host has a default route, but appears to be unable to actually 149 * reach the full Internet), or %G_NETWORK_CONNECTIVITY_PORTAL (if the 150 * host is trapped behind a "captive portal" that requires some sort 151 * of login or acknowledgement before allowing full Internet access). 152 * 153 * Note that in the case of %G_NETWORK_CONNECTIVITY_LIMITED and 154 * %G_NETWORK_CONNECTIVITY_PORTAL, it is possible that some sites are 155 * reachable but others are not. In this case, applications can 156 * attempt to connect to remote servers, but should gracefully fall 157 * back to their "offline" behavior if the connection attempt fails. 158 * 159 * Returns: the network connectivity state 160 * 161 * Since: 2.44 162 */ 163 public GNetworkConnectivity getConnectivity(); 164 165 /** 166 * Checks if the network is available. "Available" here means that the 167 * system has a default route available for at least one of IPv4 or 168 * IPv6. It does not necessarily imply that the public Internet is 169 * reachable. See #GNetworkMonitor:network-available for more details. 170 * 171 * Returns: whether the network is available 172 * 173 * Since: 2.32 174 */ 175 public bool getNetworkAvailable(); 176 177 /** 178 * Checks if the network is metered. 179 * See #GNetworkMonitor:network-metered for more details. 180 * 181 * Returns: whether the connection is metered 182 * 183 * Since: 2.46 184 */ 185 public bool getNetworkMetered(); 186 187 /** 188 * Emitted when the network configuration changes. If @available is 189 * %TRUE, then some hosts may be reachable that were not reachable 190 * before, while others that were reachable before may no longer be 191 * reachable. If @available is %FALSE, then no remote hosts are 192 * reachable. 193 * 194 * Params: 195 * available = the current value of #GNetworkMonitor:network-available 196 * 197 * Since: 2.32 198 */ 199 gulong addOnNetworkChanged(void delegate(bool, NetworkMonitorIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 200 }