fix UC popup as wearable style
[platform/core/location/maps-plugin-here.git] / src / heremaps-check-uc.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <unistd.h>
18 #include <libxml/xpath.h>
19 #include <common/HereConfig.h>
20 #include <app.h>
21 #include <app_manager.h>
22 #include <vconf.h>
23 #include <vconf-internal-location-keys.h>
24
25 #include "here_utils.h"
26 #include "heremaps-check-uc.h"
27
28 bool heremaps_check_agreement()
29 {
30         const char UTC_TPK_APP[] = "org.tizen.capi-maps-service-native-utc";
31         const char ITC_TPK_APP[] = "org.tizen.capi-maps-service-native-itc";
32         const char UTC_APP[] = "core.capi-maps-service-tests";
33         const char ITC_APP[] = "native.capi-maps-service-itc";
34
35         int enabled = 0;
36         int ret = 0;
37         char *strAppId = NULL;
38
39         ret = vconf_get_int(VCONFKEY_LOCATION_HEREMAPS_CONSENT, &enabled);
40         MAPS_LOGD("VCONFKEY_LOCATION_HEREMAPS_CONSENT is %d", enabled);
41         if (ret != 0 || enabled != 1) {
42                 if (ret != 0)
43                         MAPS_LOGD("Fail to get vconf value");
44
45                 pid_t nProcessId = getpid();
46                 ret = app_manager_get_app_id(nProcessId, &strAppId);
47                 if (ret != APP_MANAGER_ERROR_NONE) {
48                         MAPS_LOGI("Get app_id [%ld]. nRet[%d]", nProcessId, ret);
49                 } else if (!strncmp(strAppId, UTC_APP, strlen(UTC_APP)) ||
50                                 !strncmp(strAppId, ITC_APP, strlen(ITC_APP)) ||
51                                 !strncmp(strAppId, UTC_TPK_APP, strlen(UTC_TPK_APP)) ||
52                                 !strncmp(strAppId, ITC_TPK_APP, strlen(ITC_TPK_APP))) {
53                         MAPS_LOGD("Requested by tct");
54                         enabled = 1;
55                 }
56         }
57
58         if (strAppId != NULL)
59                 g_free(strAppId);
60
61         if (enabled != 1)
62                 return FALSE;
63         else
64                 return TRUE;
65 }
66