From c400ecaa1c99b657a3371a1e82cacd9e64e3128b Mon Sep 17 00:00:00 2001 From: jomui Date: Thu, 10 Mar 2016 20:38:07 +0900 Subject: fix for permission deny of cynara Signed-off-by: jomui Change-Id: Ie56d07600da8189868fc4f242d0401ece25bbc4e --- geofence/include/geofence_client.h | 7 +++++-- geofence/src/geofence_client.c | 37 ++++++++++++++++++++++--------------- packaging/geofence-dbus.spec | 1 - server/src/geofence_dbus_server.c | 3 +-- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/geofence/include/geofence_client.h b/geofence/include/geofence_client.h index 2d73956..e2e384b 100644 --- a/geofence/include/geofence_client.h +++ b/geofence/include/geofence_client.h @@ -56,25 +56,28 @@ typedef void (*geofence_client_event_cb)(const char *sig, GVariant *param, void * @brief API to add the geofence. This will call the server API. * @param[in] geofence_client - Client dbus handle * @param[in] app_id - Caller's application ID +* @param[in] place_id - place id for add geofence * @param[in] latitude - latitude value if is a geopoint geofence * @param[in] longitude - longitude value if it is a geopint geofence * @param[in] radius - radius value if it is a geopoint geofence * @param[in] bssid - bssid value if it is a wifi/BT geofence +* @param[out] error_code - Error that has occured on the server side * @return int * @retval returns the fence-id of the geofence added * @see geo_client_delete_geofence */ -int geo_client_add_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint place_id, gint geofence_type, gdouble latitude, gdouble longitude, gint radius, const gchar *address, const gchar *bssid, const gchar *ssid); +int geo_client_add_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint place_id, gint geofence_type, gdouble latitude, gdouble longitude, gint radius, const gchar *address, const gchar *bssid, const gchar *ssid, gint *error_code); /** * @brief API to add the place. This will call the server API * @param[in] geofence_client - Client dbus handle * @param[in] app_id - Caller's application ID * @param[in] place_name - Name of the place +* @param[out] error_code - Error that has occured on the server side * retval returns the place_id of the place added * @see geo_client_delete_place */ -int geo_client_add_place(geofence_client_dbus_h geofence_client, gchar *appid, const gchar *place_name); +int geo_client_add_place(geofence_client_dbus_h geofence_client, gchar *app_id, const gchar *place_name, gint *error_code); /** * @brief API to update the place. This will call the server API diff --git a/geofence/src/geofence_client.c b/geofence/src/geofence_client.c index eca2942..319f75d 100644 --- a/geofence/src/geofence_client.c +++ b/geofence/src/geofence_client.c @@ -46,7 +46,7 @@ static void __geofence_signal_callback(GDBusConnection *conn, const gchar *name, handle->user_cb(sig, param, handle->user_data); } -EXPORT_API int geo_client_add_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint place_id, gint geofence_type, gdouble latitude, gdouble longitude, gint radius, const gchar *address, const gchar *bssid, const gchar *ssid) +EXPORT_API int geo_client_add_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint place_id, gint geofence_type, gdouble latitude, gdouble longitude, gint radius, const gchar *address, const gchar *bssid, const gchar *ssid, gint *error_code) { GEOFENCE_CLIENT_LOGD("ENTER >>>"); g_return_val_if_fail(geofence_client, GEOFENCE_CLIENT_ERROR_PARAMETER); @@ -71,6 +71,8 @@ EXPORT_API int geo_client_add_geofence(geofence_client_dbus_h geofence_client, g GEOFENCE_CLIENT_LOGE("Fail to add geofence Error[%s]", error->message); g_error_free(error); } + if (error_code != NULL) + *error_code = GEOFENCE_CLIENT_ACCESS_DENIED; } g_object_unref(proxy); } else { @@ -102,8 +104,8 @@ EXPORT_API int geo_client_delete_geofence(geofence_client_dbus_h geofence_client if (error) { GEOFENCE_CLIENT_LOGE("Fail to get proxy Error[%s]", error->message); g_error_free(error); - ret = GEOFENCE_CLIENT_ERROR_DBUS_CALL; } + ret = GEOFENCE_CLIENT_ACCESS_DENIED; } return ret; @@ -131,7 +133,8 @@ EXPORT_API int geo_client_get_geofences(geofence_client_dbus_h geofence_client, reg = g_dbus_proxy_call_sync(proxy, "GetGeofences", g_variant_new("(is)", place_id, app_id), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (reg) { g_variant_get(reg, "(iiaa{sv})", &new_fence_cnt, &new_error_code, &iterator); - *error_code = new_error_code; + if (error_code != NULL) + *error_code = new_error_code; *fence_cnt = new_fence_cnt; if (iterator == NULL) GEOFENCE_CLIENT_LOGE("Iterator is null"); @@ -141,8 +144,8 @@ EXPORT_API int geo_client_get_geofences(geofence_client_dbus_h geofence_client, if (error) { GEOFENCE_CLIENT_LOGE("Fail to get the list Error[%s]", error->message); g_error_free(error); - ret = GEOFENCE_CLIENT_ERROR_DBUS_CALL; } + ret = GEOFENCE_CLIENT_ACCESS_DENIED; } g_object_unref(proxy); } else { @@ -173,8 +176,8 @@ EXPORT_API int geo_client_enable_geofence(geofence_client_dbus_h geofence_client if (error) { GEOFENCE_CLIENT_LOGE("Fail to get proxy Error[%s]", error->message); g_error_free(error); - ret = GEOFENCE_CLIENT_ERROR_DBUS_CALL; } + ret = GEOFENCE_CLIENT_ACCESS_DENIED; } return ret; @@ -199,8 +202,8 @@ EXPORT_API int geo_client_start_geofence(geofence_client_dbus_h geofence_client, if (error) { GEOFENCE_CLIENT_LOGE("Fail to get proxy Error[%s]", error->message); g_error_free(error); - ret = GEOFENCE_CLIENT_ERROR_DBUS_CALL; } + ret = GEOFENCE_CLIENT_ACCESS_DENIED; } return ret; } @@ -224,14 +227,14 @@ EXPORT_API int geo_client_stop_geofence(geofence_client_dbus_h geofence_client, if (error) { GEOFENCE_CLIENT_LOGE("Fail to get proxy Error[%s]", error->message); g_error_free(error); - ret = GEOFENCE_CLIENT_ERROR_DBUS_CALL; } + ret = GEOFENCE_CLIENT_ACCESS_DENIED; } return ret; } -EXPORT_API int geo_client_add_place(geofence_client_dbus_h geofence_client, gchar *app_id, const gchar *place_name) +EXPORT_API int geo_client_add_place(geofence_client_dbus_h geofence_client, gchar *app_id, const gchar *place_name, gint *error_code) { /* add fence interface between App & geofence-server */ GEOFENCE_CLIENT_LOGD("ENTER >>>"); @@ -258,6 +261,8 @@ EXPORT_API int geo_client_add_place(geofence_client_dbus_h geofence_client, gcha GEOFENCE_CLIENT_LOGE("Fail to add place Error[%s]", error->message); g_error_free(error); } + if (error_code != NULL) + *error_code = GEOFENCE_CLIENT_ACCESS_DENIED; } g_object_unref(proxy); } else { @@ -289,8 +294,8 @@ EXPORT_API int geo_client_update_place(geofence_client_dbus_h geofence_client, g if (error) { GEOFENCE_CLIENT_LOGE("Fail to get proxy Error[%s]", error->message); g_error_free(error); - ret = GEOFENCE_CLIENT_ERROR_DBUS_CALL; } + ret = GEOFENCE_CLIENT_ACCESS_DENIED; } return ret; @@ -313,8 +318,8 @@ EXPORT_API int geo_client_delete_place(geofence_client_dbus_h geofence_client, g if (error) { GEOFENCE_CLIENT_LOGE("Fail to get proxy Error[%s]", error->message); g_error_free(error); - ret = GEOFENCE_CLIENT_ERROR_DBUS_CALL; } + ret = GEOFENCE_CLIENT_ACCESS_DENIED; } return ret; @@ -338,7 +343,8 @@ EXPORT_API int geo_client_get_place_name(geofence_client_dbus_h geofence_client, reg = g_dbus_proxy_call_sync(proxy, "GetPlaceName", g_variant_new("(is)", place_id, app_id), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (reg) { g_variant_get(reg, "(is)", &new_error_code, &new_place_name); - *error_code = new_error_code; + if (error_code != NULL) + *error_code = new_error_code; *place_name = g_strdup(new_place_name); g_free(new_place_name); g_variant_unref(reg); @@ -346,8 +352,8 @@ EXPORT_API int geo_client_get_place_name(geofence_client_dbus_h geofence_client, if (error) { GEOFENCE_CLIENT_LOGE("Fail to get the place name Error[%s]", error->message); g_error_free(error); - ret = GEOFENCE_CLIENT_ERROR_DBUS_CALL; } + ret = GEOFENCE_CLIENT_ACCESS_DENIED; } g_object_unref(proxy); } else { @@ -385,7 +391,8 @@ EXPORT_API int geo_client_get_places(geofence_client_dbus_h geofence_client, gch if (reg) { g_variant_get(reg, "(iiaa{sv})", &new_place_cnt, &new_error_code, &iterator); *place_cnt = new_place_cnt; - *error_code = new_error_code; + if (error_code != NULL) + *error_code = new_error_code; if (iterator == NULL) GEOFENCE_CLIENT_LOGE("Iterator is null"); *iter = iterator; @@ -394,16 +401,16 @@ EXPORT_API int geo_client_get_places(geofence_client_dbus_h geofence_client, gch if (error) { GEOFENCE_CLIENT_LOGE("Fail to get the place list Error[%s]", error->message); g_error_free(error); - ret = GEOFENCE_CLIENT_ERROR_DBUS_CALL; } + ret = GEOFENCE_CLIENT_ACCESS_DENIED; } g_object_unref(proxy); } else { if (error) { GEOFENCE_CLIENT_LOGE("Fail to get proxy Error[%s]", error->message); g_error_free(error); - ret = GEOFENCE_CLIENT_ERROR_DBUS_CALL; } + ret = GEOFENCE_CLIENT_ERROR_DBUS_CALL; } return ret; diff --git a/packaging/geofence-dbus.spec b/packaging/geofence-dbus.spec index 54880b9..fd1df4b 100644 --- a/packaging/geofence-dbus.spec +++ b/packaging/geofence-dbus.spec @@ -18,7 +18,6 @@ BuildRequires: pkgconfig(gobject-2.0) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(gio-unix-2.0) -BuildRequires: pkgconfig(capi-base-common) %description Geofence dbus interface diff --git a/server/src/geofence_dbus_server.c b/server/src/geofence_dbus_server.c index 5740139..a56b112 100644 --- a/server/src/geofence_dbus_server.c +++ b/server/src/geofence_dbus_server.c @@ -501,8 +501,6 @@ EXPORT_API int geofence_dbus_server_create(geofence_dbus_server_h *geofence_dbus geofence_dbus_server_s *server = g_new0(geofence_dbus_server_s, 1); g_return_val_if_fail(server, GEOFENCE_DBUS_SERVER_ERROR_MEMORY); - /* g_log_set_default_handler(__glib_log, server); */ - server->service_name = g_strdup(GEOFENCE_SERVICE_NAME); server->service_path = g_strdup(GEOFENCE_SERVICE_PATH); server->manager = g_dbus_object_manager_server_new(server->service_path); @@ -525,6 +523,7 @@ EXPORT_API int geofence_dbus_server_destroy(geofence_dbus_server_h geofence_dbus geofence_dbus_server_s *server = (geofence_dbus_server_s *)geofence_dbus_server; int ret = GEOFENCE_DBUS_SERVER_ERROR_NONE; + g_bus_unown_name(server->owner_id); if (server->prev_owner) { g_free(server->prev_owner); -- cgit v1.2.3