/* 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
