summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2014-12-15 10:31:34 +0100
committerMurray Cumming <murrayc@murrayc.com>2014-12-15 10:34:27 +0100
commit9cb81b496abb992f23a0ed909f8e473f79de2d44 (patch)
tree0fa1709cee70f7a9d819d787e605604bb55532f7
parent6f720366013e1887374d5736e62030c55bc15df0 (diff)
downloadglibmm-9cb81b496abb992f23a0ed909f8e473f79de2d44.tar.gz
Gio: Added NetworkMonitor.
-rw-r--r--gio/src/filelist.am1
-rw-r--r--gio/src/networkmonitor.ccg38
-rw-r--r--gio/src/networkmonitor.hg69
-rw-r--r--tools/m4/convert_gio.m45
4 files changed, 113 insertions, 0 deletions
diff --git a/gio/src/filelist.am b/gio/src/filelist.am
index 8ce9dd5f..17737fb0 100644
--- a/gio/src/filelist.am
+++ b/gio/src/filelist.am
@@ -87,6 +87,7 @@ giomm_files_any_hg = \
mount.hg \
mountoperation.hg \
networkaddress.hg \
+ networkmonitor.hg \
networkservice.hg \
notification.hg \
outputstream.hg \
diff --git a/gio/src/networkmonitor.ccg b/gio/src/networkmonitor.ccg
new file mode 100644
index 00000000..aaa5ee13
--- /dev/null
+++ b/gio/src/networkmonitor.ccg
@@ -0,0 +1,38 @@
+/* Copyright (C) 2014 The gtkmm 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <glibmm/exceptionhandler.h>
+#include <gio/gio.h>
+#include "slot_async.h"
+
+namespace Gio {
+
+void NetworkMonitor::can_reach_async(const Glib::RefPtr<SocketConnectable>& connectable, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable)
+{
+ // Create a copy of the slot.
+ // A pointer to it will be passed through the callback's data parameter
+ // and deleted in the callback.
+ SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+ g_network_monitor_can_reach_async(gobj(),
+ Glib::unwrap(connectable),
+ Glib::unwrap(cancellable),
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
+} // namespace Gio
diff --git a/gio/src/networkmonitor.hg b/gio/src/networkmonitor.hg
new file mode 100644
index 00000000..4c6ee89d
--- /dev/null
+++ b/gio/src/networkmonitor.hg
@@ -0,0 +1,69 @@
+/* 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#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, NO_GTYPE)
+
+
+/** TODO
+ *
+ * @newin{2,42}
+ */
+class NetworkMonitor : public Glib::Interface
+{
+ _CLASS_INTERFACE(NetworkMonitor, GNetworkMonitor, G_NETWORK_MONITOR, GNetworkMonitorInterface)
+
+public:
+ _WRAP_METHOD(static Glib::RefPtr<NetworkMonitor> get_default(), g_network_monitor_get_default)
+
+ _WRAP_METHOD(bool get_network_available() const, g_network_monitor_get_network_available)
+
+ _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)
+
+ //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)
+
+ _WRAP_SIGNAL(void network_changed(bool available), "network-changed")
+
+ //TODO: Wrap vfuncs?
+
+ _WRAP_PROPERTY("network-available", bool)
+ _WRAP_PROPERTY("connectivity", NetworkConnectivity)
+};
+
+} // namespace Gio
diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4
index 3d170668..9444c32f 100644
--- a/tools/m4/convert_gio.m4
+++ b/tools/m4/convert_gio.m4
@@ -32,6 +32,7 @@ _CONV_ENUM(G,FileType)
_CONV_ENUM(G,MountMountFlags)
_CONV_ENUM(G,MountOperationResult)
_CONV_ENUM(G,MountUnmountFlags)
+_CONV_ENUM(G,NetworkConnectivity)
_CONV_ENUM(G,OutputStreamSpliceFlags)
_CONV_ENUM(G,PasswordSave)
_CONV_ENUM(G,ResolverRecordType)
@@ -240,6 +241,10 @@ _CONVERSION(`PasswordSave',`GPasswordSave',`($2)$3')
#MountOperation
#_CONVERSION(`GAskPasswordFlags',`AskPasswordFlags',`($2)$3')
+# NetworkMonitor
+_CONVERSION(`GNetworkMonitor*',`Glib::RefPtr<NetworkMonitor>',`Glib::wrap($3)')
+
+
# Notification
_CONVERSION(`GNotification*',`Glib::RefPtr<Notification>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<Notification>&',`GNotification*',__CONVERT_CONST_REFPTR_TO_P)