summaryrefslogtreecommitdiff
path: root/gio/src/networkmonitor.hg
blob: 49965a9ab9eff809949ed4a179730b36dcd690d1 (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
/* Copyright (C) 2014 The giomm Development Team
 *
 * This library 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 2.1 of the License, or (at your option) any later version.
 *
 * This library 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 this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glibmm/interface.h>
#include <giomm/asyncresult.h>
#include <giomm/cancellable.h>
#include <giomm/socketconnectable.h>
#include <gio/gio.h>

_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/interface_p.h)
_PINCLUDE(gio/gio.h)

#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GNetworkMonitorInterface GNetworkMonitorInterface;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

namespace Gio
{

_WRAP_ENUM(NetworkConnectivity, GNetworkConnectivity, decl_prefix GIOMM_API)


/** Network status monitor.
 *
 * %NetworkMonitor 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.

 * @newin{2,44}
 */
class GIOMM_API NetworkMonitor : public Glib::Interface
{
  _CLASS_INTERFACE(NetworkMonitor, GNetworkMonitor, G_NETWORK_MONITOR, GNetworkMonitorInterface, , , GIOMM_API)

public:
  _WRAP_METHOD(static Glib::RefPtr<NetworkMonitor> get_default(), g_network_monitor_get_default, refreturn, newin "2,44")

  _WRAP_METHOD(bool get_network_available() const, g_network_monitor_get_network_available, newin "2,44")

  _WRAP_METHOD(bool get_network_metered() const, g_network_monitor_get_network_metered, newin "2,46")

  _WRAP_METHOD(NetworkConnectivity get_connectivity() const, g_network_monitor_get_connectivity)

  _WRAP_METHOD(bool can_reach(const Glib::RefPtr<SocketConnectable>& connectable, const Glib::RefPtr<Cancellable>& cancellable{?}), g_network_monitor_can_reach, errthrow, newin "2,44")

  //TODO:
  void can_reach_async(const Glib::RefPtr<SocketConnectable>& connectable, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable);
  _IGNORE(g_network_monitor_can_reach_async)

  _WRAP_METHOD(bool can_reach_finish(const Glib::RefPtr<AsyncResult>& result), g_network_monitor_can_reach_finish, errthrow, newin "2,44")

  _WRAP_SIGNAL(void network_changed(bool available), "network-changed", newin "2,44")

  //TODO: Wrap vfuncs?

  _WRAP_PROPERTY("network-available", bool, newin "2,44")
  _WRAP_PROPERTY("connectivity", NetworkConnectivity)
  _WRAP_PROPERTY("network-metered", bool, newin "2,46")
};

} // namespace Gio