src/here_utils.cpp
src/here_view.cpp
src/here_view_objects.cpp
+ src/heremaps-check-uc.cpp
# UC-DBus
src/heremaps-uc-dbus.c
#ENDIF("${BINTYPE}" STREQUAL "eng")
ADD_SUBDIRECTORY(heremaps-uc)
-ADD_SUBDIRECTORY(heremaps-uc-launcher)
\ No newline at end of file
+ADD_SUBDIRECTORY(heremaps-uc-launcher)
GMainLoop *loop = NULL;
-static void on_bus_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data)
+static void on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
{
LS_LOGD("HereMapsUCLauncher: Acquired the bus <%s>", name);
-
- g_main_loop_quit(loop);
- LS_LOGD("HereMapsUCLauncher: g_main_loop_quit");
}
static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
{
LS_LOGD("HereMapsUCLauncher: Acquired the name <%s> on the system bus", name);
+
+ g_main_loop_quit(loop);
+ LS_LOGD("HereMapsUCLauncher: g_main_loop_quit");
}
static void on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data)
app_control_send_launch_request(app_control, NULL, NULL);
app_control_destroy(app_control);
+#if !GLIB_CHECK_VERSION(2, 35, 0)
+ g_type_init();
+#endif
+
gchar *service_name = g_strdup(UC_RECEIVER_NAME);
+
guint owner_id = g_bus_own_name(G_BUS_TYPE_SESSION, service_name, G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
LS_LOGD("g_bus_own_name id=[%d]", owner_id);
loop = g_main_loop_new(NULL, TRUE);
- LS_LOGD("HereMapsUCLauncher: g_main_loop_quit");
+ LS_LOGD("HereMapsUCLauncher: g_main_loop_run");
g_main_loop_run(loop);
g_main_loop_unref(loop);
elm_exit();
}
-static void read_vconf(heremaps_uc_app_data *ad)
-{
- LS_FUNC_ENTER
- app_control_h reply;
- int enabled = 0;
- int ret = 0;
-
- ret = vconf_get_bool(VCONFKEY_LOCATION_HEREMAPS_CONSENT, &enabled);
- if (ret != 0)
- LS_LOGE("Fail to get vconf value");
-
- app_control_create(&reply);
- if (enabled == 0)
- app_control_add_extra_data(reply, "result", "No");
- else
- app_control_add_extra_data(reply, "result", "Yes");
- ret = app_control_reply_to_launch_request(reply, ad->app_control, APP_CONTROL_RESULT_SUCCEEDED);
- if (ret != APP_CONTROL_ERROR_NONE)
- LS_LOGE("app_control_reply_to_launch_request fail. err=%d", ret);
- app_control_destroy(reply);
-}
-
static void save_vconf(int value, heremaps_uc_app_data *ad)
{
- app_control_h reply;
int enabled = 0;
int ret = 0;
- ret = vconf_get_bool(VCONFKEY_LOCATION_HEREMAPS_CONSENT, &enabled);
+ ret = vconf_get_int(VCONFKEY_LOCATION_HEREMAPS_CONSENT, &enabled);
if (ret != 0)
LS_LOGE("Fail to get vconf value");
else if (enabled != value) {
- ret = vconf_set_bool(VCONFKEY_LOCATION_HEREMAPS_CONSENT, value);
+ ret = vconf_set_int(VCONFKEY_LOCATION_HEREMAPS_CONSENT, value);
if (ret != 0)
LS_LOGE("Fail to set vconf value");
}
-
- app_control_create(&reply);
- if (ret != 0)
- app_control_add_extra_data(reply, "result", "No");
- else {
- if (value == 1) {
- LS_LOGE("Vconf value of HereMaps is true");
- app_control_add_extra_data(reply, "result", "Yes");
- } else {
- LS_LOGE("Vconf value of HereMaps is false");
- app_control_add_extra_data(reply, "result", "No");
- }
- }
-
- ret = app_control_reply_to_launch_request(reply, ad->app_control, APP_CONTROL_RESULT_SUCCEEDED);
- if (ret != APP_CONTROL_ERROR_NONE)
- LS_LOGE("app_control_reply_to_launch_request fail. err=%d", ret);
- app_control_destroy(reply);
}
static void disagree_btn_cb(void *data, Evas_Object * obj, void *event)
LS_FUNC_ENTER
heremaps_uc_app_data *ad = (heremaps_uc_app_data *) data;
- read_vconf(ad);
+ save_vconf(0, ad);
elm_exit();
}
{
LS_FUNC_ENTER
- gboolean ret = FALSE;
heremaps_uc_app_data *ad = (heremaps_uc_app_data *) user_data;
- char *action = NULL;
- char *data = NULL;
LS_RETURN_IF_FAILED(ad);
- ret = app_control_clone(&(ad->app_control), app_control);
- if (ret == FALSE)
- LS_LOGE("app_control_clone. err=%d", ret);
-
- app_control_get_extra_data(app_control, "action", &action);
- if (action != NULL) {
- if (strcmp(action, "Get") == 0) {
- read_vconf(ad);
- elm_exit();
- } else if (strcmp(action, "Set") == 0) {
- app_control_get_extra_data(app_control, "value", &data);
- LS_LOGE("DATA = %s", data);
-
- if (data != NULL) {
- if (strcmp(data, "Yes") == 0)
- save_vconf(1, ad);
- else
- save_vconf(0, ad);
- elm_exit();
- }
- }
- }
-
if (ad->win_main) {
evas_object_del(ad->win_main);
ad->win_main = NULL;
bindtextdomain(HEREMAPS_UC_PKG, LOCALE_DIR);
+ save_vconf(-1, ad);
+
ad->win_main = create_win(HEREMAPS_UC_PKG);
ad->conformant = create_conformant(ad->win_main);
ad->layout_main = create_layout(ad->conformant);
event_callback.pause = _app_pause_cb;
event_callback.resume = _app_resume_cb;
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, NULL);
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, NULL);
- ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, NULL);
ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _app_language_changed_cb, NULL);
- ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, NULL);
ret = APP_ERROR_NONE;
ret = ui_app_main(argc, argv, &event_callback, &ad);
int HerePluginCaptureSnapshot(maps_view_h hView, void **data, int *w, int *h, maps_view_colorspace_type_e *cs);
+int HerePluginCheckUC(const char *provider, maps_service_request_user_consent_cb pCbFunc, void *user_data);
+
#endif //_LOCATION_HERE_API_H_
\ No newline at end of file
HERE_ERROR_UNKNOWN, /**< Unknown error */
HERE_ERROR_SERVICE_NOT_AVAILABLE, /**< Service unavailabe*/
HERE_ERROR_NOT_FOUND, /**< Result not found */
+ HERE_ERROR_USER_NOT_CONSENTED, /**< Result not consented */
} here_error_e;
#endif //_LOCATION_HERE_TYPES_H_
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _LOCATION_HEREMAPS_CHECK_UC_H_
+#define _LOCATION_HEREMAPS_CHECK_UC_H_
+
+//plug-in header
+#include "here_utils.h"
+#include <common/BaseReply.h>
+
+typedef struct _data
+{
+ const char *provider;
+ maps_service_request_user_consent_cb pCbFunc;
+ void *user_data;
+} heremaps_uc_cb_data;
+
+bool heremaps_check_agreement();
+
+#endif //_LOCATION_HEREMAPS_CHECK_UC_H_
+
#include "here_place.h"
#include "here_route.h"
#include "here_view.h"
+#include "heremaps-uc-dbus.h"
+#include "heremaps-check-uc.h"
+
#include <common/HereConfig.h>
+#include <app.h>
+#include <vconf.h>
+#include <vconf-internal-location-keys.h>
using namespace HERE_PLUGIN_NAMESPACE_PREFIX;
error = vh->captureSnapshot(view, data, w, h, cs);
return error;
}
+
+static void _heremaps_consent_changed_cb(keynode_t *node EINA_UNUSED, void *user_data)
+{
+ MAPS_FUNC_ENTER
+
+ heremaps_uc_cb_data *uc_data = (heremaps_uc_cb_data *)user_data;
+ int enabled = 0;
+
+ if (!uc_data) {
+ MAPS_LOGD("uc_data is NULL");
+ return;
+ }
+ if (!uc_data->pCbFunc) {
+ MAPS_LOGD("pCbFunc is NULL");
+ g_free(uc_data);
+ return;
+ }
+
+ vconf_get_int(VCONFKEY_LOCATION_HEREMAPS_CONSENT, &enabled);
+ if (enabled != 0 && enabled != 1)
+ return;
+ vconf_ignore_key_changed(VCONFKEY_LOCATION_HEREMAPS_CONSENT, _heremaps_consent_changed_cb);
+
+ MAPS_LOGD("Vconf value of HereMaps is %d", enabled);
+ if (enabled == 0)
+ uc_data->pCbFunc(FALSE, uc_data->provider, uc_data->user_data);
+ else
+ uc_data->pCbFunc(TRUE, uc_data->provider, uc_data->user_data);
+ g_free(uc_data);
+
+ MAPS_FUNC_EXIT
+}
+
+int HerePluginCheckUC(const char *provider, maps_service_request_user_consent_cb pCbFunc, void *user_data)
+{
+ heremaps_uc_cb_data *uc_data = (heremaps_uc_cb_data *)g_malloc0(sizeof(heremaps_uc_cb_data));
+ uc_data->provider = provider;
+ uc_data->pCbFunc = pCbFunc;
+ uc_data->user_data = user_data;
+
+ int ret = HEREMAPS_UC_DBUS_ERROR_NONE;
+ bool agreed = heremaps_check_agreement();
+
+ if (agreed != TRUE) {
+ if (vconf_notify_key_changed(VCONFKEY_LOCATION_HEREMAPS_CONSENT, _heremaps_consent_changed_cb, uc_data) < 0) {
+ MAPS_LOGD("Unable to register a vconf changed cb to VCONFKEY_LOCATION_HEREMAPS_CONSENT");
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+ } else
+ MAPS_LOGD("Registered a vconf changed cb to VCONFKEY_LOCATION_HEREMAPS_CONSENT");
+ MAPS_LOGD("heremaps_uc_dbus_launch_receiver is called");
+ ret = heremaps_uc_dbus_launch_receiver();
+ if (ret != HEREMAPS_UC_DBUS_ERROR_NONE)
+ MAPS_LOGD("heremaps_uc_dbus_launch_receiver fail");
+ return HERE_ERROR_USER_NOT_CONSENTED;
+ } else {
+ MAPS_LOGD("Vconf value of HereMaps is true");
+ pCbFunc(TRUE, provider, user_data);
+ }
+
+ return HERE_ERROR_NONE;
+}
+
#include "here_utils.h"
#include "here_view.h"
#include "heremaps-uc-dbus.h"
+#include "heremaps-check-uc.h"
#include <common/HereConfig.h>
-#include <app.h>
#include <iostream>
#include <fstream>
#include <string>
-#include <vconf.h>
-#include <vconf-internal-location-keys.h>
using namespace HERE_PLUGIN_NAMESPACE_PREFIX;
using namespace TIZEN_MAPS_NAMESPACE_PREFIX;
here_error_e HereManager::CheckAgreement()
{
- const char UTC_TPK_APP[] = "org.tizen.capi-maps-service-native-utc";
- const char ITC_TPK_APP[] = "org.tizen.capi-maps-service-native-itc";
- const char UTC_APP[] = "core.capi-maps-service-tests";
- const char ITC_APP[] = "native.capi-maps-service-itc";
-
- int enabled = 0;
- int ret = 0;
- char *strAppId = NULL;
here_error_e error = HERE_ERROR_NONE;
- ret = vconf_get_bool(VCONFKEY_LOCATION_HEREMAPS_CONSENT, &enabled);
- MAPS_LOGD("VCONFKEY_LOCATION_HEREMAPS_CONSENT is %d", enabled);
- if (ret != 0 || enabled == 0) {
- error = HERE_ERROR_SERVICE_NOT_AVAILABLE;
- if (ret != 0)
- MAPS_LOGD("Fail to get vconf value");
-
- pid_t nProcessId = getpid();
- ret = app_manager_get_app_id(nProcessId, &strAppId);
- if (ret != APP_MANAGER_ERROR_NONE) {
- MAPS_LOGI("Get app_id [%ld]. nRet[%d]", nProcessId, ret);
- } else if (!strncmp(strAppId, UTC_APP, strlen(UTC_APP)) ||
- !strncmp(strAppId, ITC_APP, strlen(ITC_APP)) ||
- !strncmp(strAppId, UTC_TPK_APP, strlen(UTC_TPK_APP)) ||
- !strncmp(strAppId, ITC_TPK_APP, strlen(ITC_TPK_APP))) {
- MAPS_LOGD("Requested by tct");
- error = HERE_ERROR_NONE;
- }
- }
-
- if (error != HERE_ERROR_NONE) {
- MAPS_LOGD("heremaps_uc_dbus_launch_receiver is called");
- ret = heremaps_uc_dbus_launch_receiver();
- if (ret != HEREMAPS_UC_DBUS_ERROR_NONE)
- MAPS_LOGD("heremaps_uc_dbus_launch_receiver fail");
- } else {
- MAPS_LOGD("Vconf value of HereMaps is true");
- }
+ if (heremaps_check_agreement() == FALSE)
+ error = HERE_ERROR_USER_NOT_CONSENTED;
- if (strAppId != NULL)
- g_free(strAppId);
return error;
}
return ret;
}
+EXPORT_API int maps_plugin_request_user_consent(const char *provider,
+ maps_service_request_user_consent_cb callback,
+ void *user_data)
+{
+ MAPS_LOGD("maps_plugin_request_user_consent");
+ int ret = HerePluginCheckUC(provider, callback, user_data);
+ MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
+ return ConvertToMapsError(ret);
+}
+
EXPORT_API int maps_plugin_set_provider_key(const char* provider_key)
{
int ret = HerePluginSetProviderKey(provider_key);
case HERE_ERROR_UNKNOWN: return MAPS_ERROR_UNKNOWN;
case HERE_ERROR_SERVICE_NOT_AVAILABLE: return MAPS_ERROR_SERVICE_NOT_AVAILABLE;
case HERE_ERROR_NOT_FOUND: return MAPS_ERROR_NOT_FOUND;
+ case HERE_ERROR_USER_NOT_CONSENTED: return MAPS_ERROR_USER_NOT_CONSENTED;
}
return MAPS_ERROR_UNKNOWN;
}
case MAPS_ERROR_UNKNOWN: return HERE_ERROR_UNKNOWN;
case MAPS_ERROR_SERVICE_NOT_AVAILABLE: return HERE_ERROR_SERVICE_NOT_AVAILABLE;
case MAPS_ERROR_NOT_FOUND: return HERE_ERROR_NOT_FOUND;
+ case MAPS_ERROR_USER_NOT_CONSENTED: return HERE_ERROR_USER_NOT_CONSENTED;
}
return HERE_ERROR_UNKNOWN;
}
case HERE_ERROR_UNKNOWN: return "Unknown";
case HERE_ERROR_SERVICE_NOT_AVAILABLE: return "Service not available";
case HERE_ERROR_NOT_FOUND: return "Not found";
+ case HERE_ERROR_USER_NOT_CONSENTED: return "Not consented";
}
return "Unknown";
}
case MAPS_ERROR_UNKNOWN: return "MAPS_ERROR_UNKNOWN";
case MAPS_ERROR_SERVICE_NOT_AVAILABLE: return "MAPS_ERROR_SERVICE_NOT_AVAILABLE";
case MAPS_ERROR_NOT_FOUND: return "MAPS_ERROR_NOT_FOUND";
+ case MAPS_ERROR_USER_NOT_CONSENTED: return "MAPS_ERROR_USER_NOT_CONSENTED";
}
return "MAPS_ERROR_UNKNOWN";
}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <unistd.h>
+#include <libxml/xpath.h>
+#include <common/HereConfig.h>
+#include <app.h>
+#include <app_manager.h>
+#include <vconf.h>
+#include <vconf-internal-location-keys.h>
+
+#include "here_utils.h"
+#include "heremaps-check-uc.h"
+
+bool heremaps_check_agreement()
+{
+ const char UTC_TPK_APP[] = "org.tizen.capi-maps-service-native-utc";
+ const char ITC_TPK_APP[] = "org.tizen.capi-maps-service-native-itc";
+ const char UTC_APP[] = "core.capi-maps-service-tests";
+ const char ITC_APP[] = "native.capi-maps-service-itc";
+
+ int enabled = 0;
+ int ret = 0;
+ char *strAppId = NULL;
+
+ ret = vconf_get_int(VCONFKEY_LOCATION_HEREMAPS_CONSENT, &enabled);
+ MAPS_LOGD("VCONFKEY_LOCATION_HEREMAPS_CONSENT is %d", enabled);
+ if (ret != 0 || enabled == 0) {
+ if (ret != 0)
+ MAPS_LOGD("Fail to get vconf value");
+
+ pid_t nProcessId = getpid();
+ ret = app_manager_get_app_id(nProcessId, &strAppId);
+ if (ret != APP_MANAGER_ERROR_NONE) {
+ MAPS_LOGI("Get app_id [%ld]. nRet[%d]", nProcessId, ret);
+ } else if (!strncmp(strAppId, UTC_APP, strlen(UTC_APP)) ||
+ !strncmp(strAppId, ITC_APP, strlen(ITC_APP)) ||
+ !strncmp(strAppId, UTC_TPK_APP, strlen(UTC_TPK_APP)) ||
+ !strncmp(strAppId, ITC_TPK_APP, strlen(ITC_TPK_APP))) {
+ MAPS_LOGD("Requested by tct");
+ enabled = 1;
+ }
+ }
+
+ if (strAppId != NULL)
+ g_free(strAppId);
+
+ if (enabled == 0)
+ return FALSE;
+ else
+ return TRUE;
+}
+
g_error_free(error);
}
}
+ MAPS_LOGD("g_dbus_proxy_new_sync is done");
if (handle->conn) {
g_object_unref(handle->conn);
handle->conn = NULL;
+ MAPS_LOGD("g_object_unref : handle->conn");
}
g_free(handle->service_path);
g_free(handle->service_name);
g_free(handle->signal_path);
g_free(handle);
+ MAPS_LOGD("g_free done");
return HEREMAPS_UC_DBUS_ERROR_NONE;
}