Commit 48c01b09 authored by Zeeshan Ali's avatar Zeeshan Ali

service-client,manager: Make use of proxy code

Make use of generated code to talk to agent.
parent 02079da4
......@@ -35,6 +35,7 @@ AM_CPPFLAGS = $(GEOCLUE_CFLAGS) \
-DG_LOG_DOMAIN=\""Geoclue"\" \
-DABS_TOP_SRCDIR=\""$(abs_top_srcdir)"\" \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
-I$(srcdir)/agent \
-I$(srcdir)/public-api
libgeoclue_la_SOURCES = \
......@@ -87,10 +88,11 @@ libgeoclue_la_LIBADD = \
geoclue_SOURCES = \
gclue-main.c \
$(NULL)
geoclue_LDADD = $(GEOCLUE_LIBS) \
$(LIBS) \
$(builddir)/libgeoclue.la \
$(builddir)/geocode-glib/libgeocode-glib.la \
geoclue_LDADD = $(GEOCLUE_LIBS) \
$(LIBS) \
$(builddir)/libgeoclue.la \
$(builddir)/agent/libgeoclue-agent.la \
$(builddir)/geocode-glib/libgeocode-glib.la \
$(builddir)/public-api/libgeoclue-public-api.la
CLEANFILES = $(BUILT_SOURCES)
......
......@@ -48,7 +48,7 @@ struct _GClueServiceClientPrivate
GClueClientInfo *client_info;
const char *path;
GDBusConnection *connection;
GDBusProxy *agent_proxy;
GClueAgent *agent_proxy;
GClueServiceLocation *location;
GClueServiceLocation *prev_location;
......@@ -233,21 +233,17 @@ on_authorize_app_ready (GObject *source_object,
{
StartData *data = (StartData *) user_data;
GError *error = NULL;
GVariant *results = NULL;
gboolean authorized = FALSE;
GClueAccuracyLevel accuracy_level;
results = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object),
res,
&error);
if (results == NULL)
goto error_out;
g_variant_get_child (results, 0, "b", &authorized);
accuracy_level = gclue_client_get_requested_accuracy_level
(GCLUE_CLIENT (data->client));
g_variant_get_child (results, 1, "u", &accuracy_level);
g_variant_unref (results);
if (!gclue_agent_call_authorize_app_finish (GCLUE_AGENT (source_object),
&authorized,
&accuracy_level,
res,
&error))
goto error_out;
if (!authorized) {
g_set_error_literal (&error,
......@@ -306,14 +302,12 @@ gclue_service_client_handle_start (GClueClient *client,
return TRUE;
}
g_dbus_proxy_call (priv->agent_proxy,
"AuthorizeApp",
g_variant_new ("(su)", desktop_id, accuracy_level),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
on_authorize_app_ready,
data);
gclue_agent_call_authorize_app (priv->agent_proxy,
desktop_id,
accuracy_level,
NULL,
on_authorize_app_ready,
data);
return TRUE;
}
......@@ -578,7 +572,7 @@ gclue_service_client_class_init (GClueServiceClientClass *klass)
gParamSpecs[PROP_AGENT_PROXY] = g_param_spec_object ("agent-proxy",
"AgentProxy",
"Proxy to app authorization agent",
G_TYPE_DBUS_PROXY,
GCLUE_TYPE_AGENT_PROXY,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT);
g_object_class_install_property (object_class,
......@@ -628,7 +622,7 @@ GClueServiceClient *
gclue_service_client_new (GClueClientInfo *info,
const char *path,
GDBusConnection *connection,
GDBusProxy *agent_proxy,
GClueAgent *agent_proxy,
GError **error)
{
return g_initable_new (GCLUE_TYPE_SERVICE_CLIENT,
......
......@@ -25,6 +25,7 @@
#include <glib-object.h>
#include "geoclue-interface.h"
#include "geoclue-agent-interface.h"
#include "gclue-client-info.h"
G_BEGIN_DECLS
......@@ -59,7 +60,7 @@ GType gclue_service_client_get_type (void) G_GNUC_CONST;
GClueServiceClient * gclue_service_client_new (GClueClientInfo *info,
const char *path,
GDBusConnection *connection,
GDBusProxy *agent_proxy,
GClueAgent *agent_proxy,
GError **error);
const char * gclue_service_client_get_path (GClueServiceClient *client);
GClueClientInfo * gclue_service_client_get_client_info (GClueServiceClient *client);
......
......@@ -26,6 +26,7 @@
#include "gclue-service-manager.h"
#include "gclue-service-client.h"
#include "gclue-client-info.h"
#include "geoclue-agent-interface.h"
#include "gclue-config.h"
#define AGENT_WAIT_TIMEOUT 100 /* milliseconds */
......@@ -90,7 +91,7 @@ complete_get_client (OnClientInfoNewReadyData *data)
GClueServiceManagerPrivate *priv = GCLUE_SERVICE_MANAGER (data->manager)->priv;
GClueServiceClient *client;
GClueClientInfo *info = data->client_info;
GDBusProxy *agent_proxy = NULL;
GClueAgent *agent_proxy = NULL;
GError *error = NULL;
char *path;
guint32 user_id;
......@@ -146,7 +147,7 @@ on_client_info_new_ready (GObject *source_object,
OnClientInfoNewReadyData *data = (OnClientInfoNewReadyData *) user_data;
GClueServiceManagerPrivate *priv = GCLUE_SERVICE_MANAGER (data->manager)->priv;
GClueClientInfo *info = NULL;
GDBusProxy *agent_proxy;
GClueAgent *agent_proxy;
GError *error = NULL;
guint32 user_id;
gint64 now;
......@@ -253,10 +254,10 @@ on_agent_proxy_ready (GObject *source_object,
AddAgentData *data = (AddAgentData *) user_data;
GClueServiceManagerPrivate *priv = GCLUE_SERVICE_MANAGER (data->manager)->priv;
guint32 user_id;
GDBusProxy *agent;
GClueAgent *agent;
GError *error = NULL;
agent = g_dbus_proxy_new_for_bus_finish (res, &error);
agent = gclue_agent_proxy_new_for_bus_finish (res, &error);
if (agent == NULL)
goto error_out;
......@@ -322,15 +323,13 @@ on_agent_info_new_ready (GObject *source_object,
path = g_strdup_printf (AGENT_PATH,
gclue_client_info_get_user_id (data->info));
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
gclue_client_info_get_bus_name (data->info),
path,
"org.freedesktop.GeoClue2.Agent",
NULL,
on_agent_proxy_ready,
user_data);
gclue_agent_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
gclue_client_info_get_bus_name (data->info),
path,
NULL,
on_agent_proxy_ready,
user_data);
g_free (path);
}
......
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