Commit 58609b12 authored by Jussi Kukkonen's avatar Jussi Kukkonen

add missing async-functions to Master and MasterClient

parent 2b56c40c
......@@ -26,11 +26,7 @@
* ...
*
* master = geoclue_master_get_default ();
*
* client = geoclue_master_create_client (master, NULL, NULL);
* if (!client) {
* / * handle error * /
* }
*
* if (!geoclue_master_client_set_requirements (client,
* GEOCLUE_ACCURACY_LEVEL_NONE,
......@@ -80,12 +76,21 @@ enum {
LAST_SIGNAL
};
static guint32 signals[LAST_SIGNAL] = {0, };
#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GEOCLUE_TYPE_MASTER_CLIENT, GeoclueMasterClientPrivate))
G_DEFINE_TYPE_WITH_CODE (GeoclueMasterClient, geoclue_master_client, G_TYPE_OBJECT, geoclue_types_init (););
typedef struct _GeoclueMasterClientAsyncData {
GeoclueMasterClient *client;
GCallback callback;
gpointer userdata;
} GeoclueMasterClientAsyncData;
static void
finalize (GObject *object)
{
......@@ -301,6 +306,65 @@ geoclue_master_client_set_requirements (GeoclueMasterClient *client,
return TRUE;
}
static void
set_requirements_callback (DBusGProxy *proxy,
GError *error,
GeoclueMasterClientAsyncData *data)
{
(*(GeoclueSetRequirementsCallback)data->callback) (data->client,
error,
data->userdata);
g_free (data);
}
/**
* GeoclueSetRequirementsCallback:
* @client: A #GeoclueMasterClient object
* @error: Error as #Gerror (may be %NULL)
* @userdata: User data pointer set in geoclue_master_client_set_requirements_async()
*
* Callback function for geoclue_master_client_set_requirements_async().
*/
/**
* geoclue_master_client_set_requirements_async:
* @client: A #GeoclueMasterClient
* @min_accuracy: The required minimum accuracy as a #GeoclueAccuracyLevel.
* @min_time: The minimum time between update signals (currently not implemented)
* @require_updates: Whether the updates (signals) are required. Only applies to interfaces with signals
* @allowed_resources: The resources that are allowed to be used as a #GeoclueResourceFlags
* @callback: #GeoclueSetRequirementsCallback function to call when requirements have been set
* @userdata: User data pointer
*
* Asynchronous version of geoclue_master_client_set_requirements().
*/
void
geoclue_master_client_set_requirements_async (GeoclueMasterClient *client,
GeoclueAccuracyLevel min_accuracy,
int min_time,
gboolean require_updates,
GeoclueResourceFlags allowed_resources,
GeoclueSetRequirementsCallback callback,
gpointer userdata)
{
GeoclueMasterClientPrivate *priv = GET_PRIVATE (client);
GeoclueMasterClientAsyncData *data;
data = g_new (GeoclueMasterClientAsyncData, 1);
data->client = client;
data->callback = G_CALLBACK (callback);
data->userdata = userdata;
org_freedesktop_Geoclue_MasterClient_set_requirements_async
(priv->proxy,
min_accuracy,
min_time,
require_updates,
allowed_resources,
(org_freedesktop_Geoclue_MasterClient_set_requirements_reply)set_requirements_callback,
data);
}
/**
* geoclue_master_client_create_address:
* @client: A #GeoclueMasterClient
......@@ -326,12 +390,6 @@ geoclue_master_client_create_address (GeoclueMasterClient *client,
return geoclue_address_new (GEOCLUE_MASTER_DBUS_SERVICE, priv->object_path);
}
typedef struct _GeoclueMasterClientAsyncData {
GeoclueMasterClient *client;
GCallback callback;
gpointer userdata;
} GeoclueMasterClientAsyncData;
static void
address_start_async_callback (DBusGProxy *proxy,
GError *error,
......@@ -352,7 +410,7 @@ address_start_async_callback (DBusGProxy *proxy,
}
/**
* GreateAddressCallback:
* CreateAddressCallback:
* @client: A #GeoclueMasterClient object
* @address: returned #GeoclueAddress
* @error: Error as #Gerror (may be %NULL)
......@@ -435,7 +493,7 @@ position_start_async_callback (DBusGProxy *proxy,
}
/**
* GreatePositionCallback:
* CreatePositionCallback:
* @client: A #GeoclueMasterClient object
* @position: returned #GeocluePosition
* @error: Error as #Gerror (may be %NULL)
......@@ -504,6 +562,54 @@ gboolean geoclue_master_client_get_address_provider (GeoclueMasterClient *clien
return TRUE;
}
static void
get_provider_callback (DBusGProxy *proxy,
char * name,
char * description,
char * service,
char * path,
GError *error,
GeoclueMasterClientAsyncData *data)
{
(*(GeoclueGetProviderCallback)data->callback) (data->client,
name,
description,
service,
path,
error,
data->userdata);
g_free (data);
}
/**
* geoclue_master_client_get_address_provider_async:
* @client: A #GeoclueMasterClient
* @callback: A #GeoclueGetProviderCallback function that will be called when return values are available
* @userdata: pointer for user specified data
*
* Gets name and other information for the currently used address provider asynchronously.
*/
void
geoclue_master_client_get_address_provider_async (GeoclueMasterClient *client,
GeoclueGetProviderCallback callback,
gpointer userdata)
{
GeoclueMasterClientPrivate *priv = GET_PRIVATE (client);
GeoclueMasterClientAsyncData *data;
data = g_new (GeoclueMasterClientAsyncData, 1);
data->client = client;
data->callback = G_CALLBACK (callback);
data->userdata = userdata;
org_freedesktop_Geoclue_MasterClient_get_address_provider_async
(priv->proxy,
(org_freedesktop_Geoclue_MasterClient_get_address_provider_reply)get_provider_callback,
data);
}
/**
* geoclue_master_client_get_position_provider:
* @client: A #GeoclueMasterClient
......@@ -535,3 +641,29 @@ gboolean geoclue_master_client_get_position_provider (GeoclueMasterClient *clie
return TRUE;
}
/**
* geoclue_master_client_get_position_provider_async:
* @client: A #GeoclueMasterClient
* @callback: A #GeoclueGetProviderCallback function that will be called when return values are available
* @userdata: pointer for user specified data
*
* Gets name and other information for the currently used position provider asynchronously.
*/
void
geoclue_master_client_get_position_provider_async (GeoclueMasterClient *client,
GeoclueGetProviderCallback callback,
gpointer userdata)
{
GeoclueMasterClientPrivate *priv = GET_PRIVATE (client);
GeoclueMasterClientAsyncData *data;
data = g_new (GeoclueMasterClientAsyncData, 1);
data->client = client;
data->callback = G_CALLBACK (callback);
data->userdata = userdata;
org_freedesktop_Geoclue_MasterClient_get_position_provider_async
(priv->proxy,
(org_freedesktop_Geoclue_MasterClient_get_position_provider_reply)get_provider_callback,
data);
}
......@@ -49,6 +49,16 @@ gboolean geoclue_master_client_set_requirements (GeoclueMasterClient *client,
gboolean require_updates,
GeoclueResourceFlags allowed_resources,
GError **error);
typedef void (*GeoclueSetRequirementsCallback) (GeoclueMasterClient *client,
GError *error,
gpointer userdata);
void geoclue_master_client_set_requirements_async (GeoclueMasterClient *client,
GeoclueAccuracyLevel min_accuracy,
int min_time,
gboolean require_updates,
GeoclueResourceFlags allowed_resources,
GeoclueSetRequirementsCallback callback,
gpointer userdata);
GeoclueAddress *geoclue_master_client_create_address (GeoclueMasterClient *client, GError **error);
typedef void (*CreateAddressCallback) (GeoclueMasterClient *client,
......@@ -75,12 +85,26 @@ gboolean geoclue_master_client_get_address_provider (GeoclueMasterClient *clien
char **service,
char **path,
GError **error);
typedef void (*GeoclueGetProviderCallback) (GeoclueMasterClient *client,
char *name,
char *description,
char *service,
char *path,
GError *error,
gpointer userdata);
void geoclue_master_client_get_address_provider_async (GeoclueMasterClient *client,
GeoclueGetProviderCallback callback,
gpointer userdata);
gboolean geoclue_master_client_get_position_provider (GeoclueMasterClient *client,
char **name,
char **description,
char **service,
char **path,
GError **error);
void geoclue_master_client_get_position_provider_async (GeoclueMasterClient *client,
GeoclueGetProviderCallback callback,
gpointer userdata);
G_END_DECLS
......
......@@ -36,6 +36,14 @@ typedef struct _GeoclueMasterPrivate {
G_DEFINE_TYPE (GeoclueMaster, geoclue_master, G_TYPE_OBJECT);
typedef struct _GeoclueMasterAsyncData {
GeoclueMaster *master;
GCallback callback;
gpointer userdata;
} GeoclueMasterAsyncData;
static void
finalize (GObject *object)
{
......@@ -147,3 +155,50 @@ geoclue_master_create_client (GeoclueMaster *master,
return client;
}
static void
create_client_callback (DBusGProxy *proxy,
char *path,
GError *error,
GeoclueMasterAsyncData *data)
{
GeoclueMasterClient *client;
client = NULL;
if (!error) {
client = g_object_new (GEOCLUE_TYPE_MASTER_CLIENT,
"object-path", path,
NULL);
}
(*(GeoclueCreateClientCallback)data->callback) (data->master,
client,
path,
error,
data->userdata);
g_free (data);
}
void
geoclue_master_create_client_async (GeoclueMaster *master,
GeoclueCreateClientCallback callback,
gpointer userdata)
{
GeoclueMasterPrivate *priv;
GeoclueMasterAsyncData *data;
g_return_if_fail (GEOCLUE_IS_MASTER (master));
priv = GET_PRIVATE (master);
data = g_new (GeoclueMasterAsyncData, 1);
data->master = master;
data->callback = G_CALLBACK (callback);
data->userdata = userdata;
org_freedesktop_Geoclue_Master_create_async
(priv->proxy,
(org_freedesktop_Geoclue_Master_create_reply)create_client_callback,
data);
}
......@@ -33,9 +33,18 @@ typedef struct _GeoclueMasterClass {
GType geoclue_master_get_type (void);
GeoclueMaster *geoclue_master_get_default (void);
GeoclueMasterClient *geoclue_master_create_client (GeoclueMaster *master,
char **object_path,
GError **error);
typedef void (*GeoclueCreateClientCallback) (GeoclueMaster *master,
GeoclueMasterClient *client,
char *object_path,
GError *error,
gpointer userdata);
void geoclue_master_create_client_async (GeoclueMaster *master,
GeoclueCreateClientCallback 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