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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
|
/*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* gtkD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
module gio.NetworkMonitorT;
public import gio.AsyncResultIF;
public import gio.Cancellable;
public import gio.NetworkMonitorIF;
public import gio.SocketConnectableIF;
public import gio.c.functions;
public import gio.c.types;
public import glib.ErrorG;
public import glib.GException;
public import gobject.ObjectG;
public import gobject.Signals;
public import gtkc.giotypes;
public import std.algorithm;
/**
* #GNetworkMonitor provides an easy-to-use cross-platform API
* for monitoring network connectivity. On Linux, the available
* implementations are based on the kernel's netlink interface and
* on NetworkManager.
*
* There is also an implementation for use inside Flatpak sandboxes.
*
* Since: 2.32
*/
public template NetworkMonitorT(TStruct)
{
/** Get the main Gtk struct */
public GNetworkMonitor* getNetworkMonitorStruct(bool transferOwnership = false)
{
if (transferOwnership)
ownedRef = false;
return cast(GNetworkMonitor*)getStruct();
}
/**
* Attempts to determine whether or not the host pointed to by
* @connectable can be reached, without actually trying to connect to
* it.
*
* This may return %TRUE even when #GNetworkMonitor:network-available
* is %FALSE, if, for example, @monitor can determine that
* @connectable refers to a host on a local network.
*
* If @monitor believes that an attempt to connect to @connectable
* will succeed, it will return %TRUE. Otherwise, it will return
* %FALSE and set @error to an appropriate error (such as
* %G_IO_ERROR_HOST_UNREACHABLE).
*
* Note that although this does not attempt to connect to
* @connectable, it may still block for a brief period of time (eg,
* trying to do multicast DNS on the local network), so if you do not
* want to block, you should use g_network_monitor_can_reach_async().
*
* Params:
* connectable = a #GSocketConnectable
* cancellable = a #GCancellable, or %NULL
*
* Returns: %TRUE if @connectable is reachable, %FALSE if not.
*
* Since: 2.32
*
* Throws: GException on failure.
*/
public bool canReach(SocketConnectableIF connectable, Cancellable cancellable)
{
GError* err = null;
auto __p = g_network_monitor_can_reach(getNetworkMonitorStruct(), (connectable is null) ? null : connectable.getSocketConnectableStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
return __p;
}
/**
* Asynchronously attempts to determine whether or not the host
* pointed to by @connectable can be reached, without actually
* trying to connect to it.
*
* For more details, see g_network_monitor_can_reach().
*
* When the operation is finished, @callback will be called.
* You can then call g_network_monitor_can_reach_finish()
* to get the result of the operation.
*
* Params:
* connectable = a #GSocketConnectable
* cancellable = a #GCancellable, or %NULL
* callback = a #GAsyncReadyCallback to call when the
* request is satisfied
* userData = the data to pass to callback function
*/
public void canReachAsync(SocketConnectableIF connectable, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
{
g_network_monitor_can_reach_async(getNetworkMonitorStruct(), (connectable is null) ? null : connectable.getSocketConnectableStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
}
/**
* Finishes an async network connectivity test.
* See g_network_monitor_can_reach_async().
*
* Params:
* result = a #GAsyncResult
*
* Returns: %TRUE if network is reachable, %FALSE if not.
*
* Throws: GException on failure.
*/
public bool canReachFinish(AsyncResultIF result)
{
GError* err = null;
auto __p = g_network_monitor_can_reach_finish(getNetworkMonitorStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
return __p;
}
/**
* Gets a more detailed networking state than
* g_network_monitor_get_network_available().
*
* If #GNetworkMonitor:network-available is %FALSE, then the
* connectivity state will be %G_NETWORK_CONNECTIVITY_LOCAL.
*
* If #GNetworkMonitor:network-available is %TRUE, then the
* connectivity state will be %G_NETWORK_CONNECTIVITY_FULL (if there
* is full Internet connectivity), %G_NETWORK_CONNECTIVITY_LIMITED (if
* the host has a default route, but appears to be unable to actually
* reach the full Internet), or %G_NETWORK_CONNECTIVITY_PORTAL (if the
* host is trapped behind a "captive portal" that requires some sort
* of login or acknowledgement before allowing full Internet access).
*
* Note that in the case of %G_NETWORK_CONNECTIVITY_LIMITED and
* %G_NETWORK_CONNECTIVITY_PORTAL, it is possible that some sites are
* reachable but others are not. In this case, applications can
* attempt to connect to remote servers, but should gracefully fall
* back to their "offline" behavior if the connection attempt fails.
*
* Returns: the network connectivity state
*
* Since: 2.44
*/
public GNetworkConnectivity getConnectivity()
{
return g_network_monitor_get_connectivity(getNetworkMonitorStruct());
}
/**
* Checks if the network is available. "Available" here means that the
* system has a default route available for at least one of IPv4 or
* IPv6. It does not necessarily imply that the public Internet is
* reachable. See #GNetworkMonitor:network-available for more details.
*
* Returns: whether the network is available
*
* Since: 2.32
*/
public bool getNetworkAvailable()
{
return g_network_monitor_get_network_available(getNetworkMonitorStruct()) != 0;
}
/**
* Checks if the network is metered.
* See #GNetworkMonitor:network-metered for more details.
*
* Returns: whether the connection is metered
*
* Since: 2.46
*/
public bool getNetworkMetered()
{
return g_network_monitor_get_network_metered(getNetworkMonitorStruct()) != 0;
}
/**
* Emitted when the network configuration changes.
*
* Params:
* networkAvailable = the current value of #GNetworkMonitor:network-available
*
* Since: 2.32
*/
gulong addOnNetworkChanged(void delegate(bool, NetworkMonitorIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
return Signals.connect(this, "network-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
}
}
|