summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjell.ahlstedt@bredband.net>2014-05-15 13:18:23 +0200
committerKjell Ahlstedt <kjell.ahlstedt@bredband.net>2014-05-15 13:18:23 +0200
commit517785fddc76b10d0087f7c3de510a29844ca3e8 (patch)
treeb338571716c2cc7b08b0e0736b851dbb61b4f253
parent1e626a1885e99f7fb120505ee2b9427f1fc6c1d1 (diff)
downloadglibmm-517785fddc76b10d0087f7c3de510a29844ca3e8.tar.gz
examples/network: Use SocketSource and SignalSocket.
* examples/network/socket-client.cc: Use Gio::Socket::create_source(). * examples/network/socket-server.cc: Use Gio::signal_socket().connect(). Bug #725281.
-rw-r--r--examples/network/socket-client.cc17
-rw-r--r--examples/network/socket-server.cc15
2 files changed, 8 insertions, 24 deletions
diff --git a/examples/network/socket-client.cc b/examples/network/socket-client.cc
index 29122573..1276e37a 100644
--- a/examples/network/socket-client.cc
+++ b/examples/network/socket-client.cc
@@ -44,8 +44,7 @@ socket_address_to_string (const Glib::RefPtr<Gio::SocketAddress>& address)
}
static bool
-source_ready (gpointer /*data*/,
- GIOCondition /*condition*/)
+source_ready(Glib::IOCondition /*condition*/)
{
loop->quit ();
return false;
@@ -57,21 +56,15 @@ ensure_condition (const Glib::RefPtr<Gio::Socket>& socket,
const Glib::RefPtr<Gio::Cancellable>& cancellable,
Glib::IOCondition condition)
{
- GSource *source;
-
if (!non_blocking)
return;
if (use_source)
{
- source = g_socket_create_source (socket->gobj (),
- (GIOCondition) condition,
- cancellable->gobj ());
- g_source_set_callback (source,
- (GSourceFunc) source_ready,
- NULL, NULL);
- g_source_attach (source, NULL);
- loop->run ();
+ Glib::RefPtr<Gio::SocketSource> source = socket->create_source(condition, cancellable);
+ source->connect(sigc::ptr_fun(&source_ready));
+ source->attach();
+ loop->run();
}
else
{
diff --git a/examples/network/socket-server.cc b/examples/network/socket-server.cc
index d5078596..2bf9d2b9 100644
--- a/examples/network/socket-server.cc
+++ b/examples/network/socket-server.cc
@@ -49,8 +49,7 @@ socket_address_to_string (const Glib::RefPtr<Gio::SocketAddress>& address)
}
static bool
-source_ready (gpointer /*data*/,
- GIOCondition /*condition*/)
+source_ready(Glib::IOCondition /*condition*/)
{
loop->quit ();
return false;
@@ -62,21 +61,13 @@ ensure_condition (const Glib::RefPtr<Gio::Socket>& socket,
const Glib::RefPtr<Gio::Cancellable>& cancellable,
Glib::IOCondition condition)
{
- GSource *source;
-
if (!non_blocking)
return;
if (use_source)
{
- source = g_socket_create_source (socket->gobj (),
- (GIOCondition) condition,
- cancellable->gobj ());
- g_source_set_callback (source,
- (GSourceFunc) source_ready,
- NULL, NULL);
- g_source_attach (source, NULL);
- loop->run ();
+ Gio::signal_socket().connect(sigc::ptr_fun(&source_ready), socket, condition);
+ loop->run();
}
else
{