Commit 74e20786 authored by Jussi Kukkonen's avatar Jussi Kukkonen

add async function to Address + layout fixes to Position

parent dc9d1b80
/*
* Geoclue
* position-example.c - Example using the Position client API
* asynchronous method call
* (asynchronous method call)
*
* Author: Jussi Kukkonen <jku@openedhand.com>
* Copyright 2008 by Garmin Ltd. or its subsidiaries
*/
/* NOTE: provider options are not used in this example */
#include <glib.h>
#include <geoclue/geoclue-common.h>
#include <geoclue/geoclue-position.h>
......@@ -29,17 +31,13 @@ position_callback (GeocluePosition *pos,
} else {
if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
GeoclueAccuracyLevel level;
double horiz_acc;
geoclue_accuracy_get_details (accuracy, &level, &horiz_acc, NULL);
g_print ("Current position:\n");
geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
g_print ("Current position (accuracy %d):\n", level);
g_print ("\t%f, %f\n", latitude, longitude);
g_print ("\tAccuracy level %d (%.0f meters)\n", level, horiz_acc);
} else {
g_print ("Latitude and longitude not available.\n");
g_print ("Current position not available.\n");
}
}
g_main_loop_quit ((GMainLoop *)userdata);
......
......@@ -177,3 +177,46 @@ geoclue_address_get_address (GeoclueAddress *address,
return TRUE;
}
typedef struct _GeoclueAddressAsyncData {
GeoclueAddress *address;
GCallback callback;
gpointer userdata;
} GeoclueAddressAsyncData;
static void
get_address_async_callback (DBusGProxy *proxy,
int timestamp,
GHashTable *details,
GeoclueAccuracy *accuracy,
GError *error,
GeoclueAddressAsyncData *data)
{
(*(GeoclueAddressCallback)data->callback) (data->address,
timestamp,
details,
accuracy,
error,
data->userdata);
g_free (data);
}
void
geoclue_address_get_address_async (GeoclueAddress *address,
GeoclueAddressCallback callback,
gpointer userdata)
{
GeoclueProvider *provider = GEOCLUE_PROVIDER (address);
GeoclueAddressAsyncData *data;
data = g_new (GeoclueAddressAsyncData, 1);
data->address = address;
data->callback = G_CALLBACK (callback);
data->userdata = userdata;
org_freedesktop_Geoclue_Address_get_address_async
(provider->proxy,
(org_freedesktop_Geoclue_Address_get_address_reply) get_address_async_callback,
data);
}
......@@ -45,6 +45,18 @@ gboolean geoclue_address_get_address (GeoclueAddress *address,
GHashTable **details,
GeoclueAccuracy **accuracy,
GError **error);
typedef void (*GeoclueAddressCallback) (GeoclueAddress *address,
int timestamp,
GHashTable *details,
GeoclueAccuracy *accuracy,
GError *error,
gpointer userdata);
void geoclue_address_get_address_async (GeoclueAddress *address,
GeoclueAddressCallback callback,
gpointer userdata);
G_END_DECLS
#endif
......@@ -232,9 +232,9 @@ get_position_async_callback (DBusGProxy *proxy,
}
void
geoclue_position_get_position_async (GeocluePosition *position,
GeocluePositionCallback callback,
gpointer userdata)
geoclue_position_get_position_async (GeocluePosition *position,
GeocluePositionCallback callback,
gpointer userdata)
{
GeoclueProvider *provider = GEOCLUE_PROVIDER (position);
GeocluePositionAsyncData *data;
......@@ -248,5 +248,4 @@ geoclue_position_get_position_async (GeocluePosition *position,
(provider->proxy,
(org_freedesktop_Geoclue_Position_get_position_reply)get_position_async_callback,
data);
/*do we need "call" ?*/
}
......@@ -60,9 +60,9 @@ typedef void (*GeocluePositionCallback) (GeocluePosition *position,
GError *error,
gpointer userdata);
void geoclue_position_get_position_async (GeocluePosition *position,
GeocluePositionCallback callback,
gpointer userdata);
void geoclue_position_get_position_async (GeocluePosition *position,
GeocluePositionCallback callback,
gpointer userdata);
G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment