~ubuntu-branches/debian/sid/glib2.0/sid

« back to all changes in this revision

Viewing changes to gio/gnetworkmonitor.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-05-08 06:25:57 UTC
  • mfrom: (1.27.14) (3.1.181 experimental)
  • Revision ID: package-import@ubuntu.com-20130508062557-i7gbku66mls70gi2
Tags: 2.36.1-2
Merge experimental branch, upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "ginitable.h"
29
29
#include "gioenumtypes.h"
30
30
#include "giomodule-priv.h"
31
 
#include "gsimpleasyncresult.h"
 
31
#include "gtask.h"
32
32
 
33
33
/**
34
34
 * SECTION:gnetworkmonitor
38
38
 *
39
39
 * #GNetworkMonitor provides an easy-to-use cross-platform API
40
40
 * for monitoring network connectivity. On Linux, the implementation
41
 
 * is based on the kernels netlink interface.
 
41
 * is based on the kernel's netlink interface.
42
42
 */
43
43
 
44
44
/**
148
148
                                        GAsyncReadyCallback  callback,
149
149
                                        gpointer             user_data)
150
150
{
151
 
  GSimpleAsyncResult *simple;
 
151
  GTask *task;
152
152
  GError *error = NULL;
153
153
 
154
 
  simple = g_simple_async_result_new (G_OBJECT (monitor),
155
 
                                      callback, user_data,
156
 
                                      g_network_monitor_real_can_reach_async);
 
154
  task = g_task_new (monitor, cancellable, callback, user_data);
157
155
  if (g_network_monitor_can_reach (monitor, connectable, cancellable, &error))
158
 
    g_simple_async_result_set_op_res_gboolean (simple, TRUE);
 
156
    g_task_return_boolean (task, TRUE);
159
157
  else
160
 
    g_simple_async_result_take_error (simple, error);
161
 
  g_simple_async_result_complete_in_idle (simple);
162
 
  g_object_unref (simple);
 
158
    g_task_return_error (task, error);
 
159
  g_object_unref (task);
163
160
}
164
161
 
165
162
/**
199
196
                                         GAsyncResult     *result,
200
197
                                         GError          **error)
201
198
{
202
 
  GSimpleAsyncResult *simple;
203
 
 
204
 
  g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (monitor), g_network_monitor_real_can_reach_async), FALSE);
205
 
 
206
 
  simple = G_SIMPLE_ASYNC_RESULT (result);
207
 
  if (g_simple_async_result_propagate_error (simple, error))
208
 
    return FALSE;
209
 
  else
210
 
    return g_simple_async_result_get_op_res_gboolean (simple);
 
199
  g_return_val_if_fail (g_task_is_valid (result, monitor), FALSE);
 
200
 
 
201
  return g_task_propagate_boolean (G_TASK (result), error);
211
202
}
212
203
 
213
204
/**