1/* GIO - GLib Input, Output and Streaming Library
2 *
3 * Copyright 2011 Red Hat, Inc.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef __G_NETWORK_MONITOR_H__
22#define __G_NETWORK_MONITOR_H__
23
24#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
25#error "Only <gio/gio.h> can be included directly."
26#endif
27
28#include <gio/giotypes.h>
29
30G_BEGIN_DECLS
31
32/**
33 * G_NETWORK_MONITOR_EXTENSION_POINT_NAME:
34 *
35 * Extension point for network status monitoring functionality.
36 * See [Extending GIO][extending-gio].
37 *
38 * Since: 2.30
39 */
40#define G_NETWORK_MONITOR_EXTENSION_POINT_NAME "gio-network-monitor"
41
42#define G_TYPE_NETWORK_MONITOR (g_network_monitor_get_type ())
43#define G_NETWORK_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_NETWORK_MONITOR, GNetworkMonitor))
44#define G_IS_NETWORK_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_NETWORK_MONITOR))
45#define G_NETWORK_MONITOR_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), G_TYPE_NETWORK_MONITOR, GNetworkMonitorInterface))
46
47typedef struct _GNetworkMonitorInterface GNetworkMonitorInterface;
48
49struct _GNetworkMonitorInterface {
50 GTypeInterface g_iface;
51
52 void (*network_changed) (GNetworkMonitor *monitor,
53 gboolean network_available);
54
55 gboolean (*can_reach) (GNetworkMonitor *monitor,
56 GSocketConnectable *connectable,
57 GCancellable *cancellable,
58 GError **error);
59 void (*can_reach_async) (GNetworkMonitor *monitor,
60 GSocketConnectable *connectable,
61 GCancellable *cancellable,
62 GAsyncReadyCallback callback,
63 gpointer user_data);
64 gboolean (*can_reach_finish) (GNetworkMonitor *monitor,
65 GAsyncResult *result,
66 GError **error);
67};
68
69GIO_AVAILABLE_IN_2_32
70GType g_network_monitor_get_type (void) G_GNUC_CONST;
71GIO_AVAILABLE_IN_2_32
72GNetworkMonitor *g_network_monitor_get_default (void);
73
74GIO_AVAILABLE_IN_2_32
75gboolean g_network_monitor_get_network_available (GNetworkMonitor *monitor);
76
77GIO_AVAILABLE_IN_2_46
78gboolean g_network_monitor_get_network_metered (GNetworkMonitor *monitor);
79
80GIO_AVAILABLE_IN_2_44
81GNetworkConnectivity g_network_monitor_get_connectivity (GNetworkMonitor *monitor);
82
83GIO_AVAILABLE_IN_2_32
84gboolean g_network_monitor_can_reach (GNetworkMonitor *monitor,
85 GSocketConnectable *connectable,
86 GCancellable *cancellable,
87 GError **error);
88GIO_AVAILABLE_IN_2_32
89void g_network_monitor_can_reach_async (GNetworkMonitor *monitor,
90 GSocketConnectable *connectable,
91 GCancellable *cancellable,
92 GAsyncReadyCallback callback,
93 gpointer user_data);
94GIO_AVAILABLE_IN_2_32
95gboolean g_network_monitor_can_reach_finish (GNetworkMonitor *monitor,
96 GAsyncResult *result,
97 GError **error);
98
99G_END_DECLS
100
101#endif /* __G_NETWORK_MONITOR_H__ */
102