SET(common_dp "glib-2.0 geofence-dbus dlog gio-2.0 capi-appfw-app-manager")
SET(server_dp "${common_dp} network vconf vconf-internal-keys gthread-2.0 gio-unix-2.0 sqlite3 db-util alarm-service deviced capi-location-manager capi-network-bluetooth capi-network-wifi libcore-context-manager")
-SET(module_dp "${common_dp} gmodule-2.0")
+SET(module_dp "${common_dp} gmodule-2.0 capi-geofence-manager")
# Set required packages
INCLUDE(FindPkgConfig)
SET(MODULE_EXTRA_CFLAGS "${MODULE_EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs -fvisibility=hidden ")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs ")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fvisibility=hidden -fPIC")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -fvisibility=hidden -fPIC")
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter -Wno-missing-field-initializers -Wno-missing-declarations -Wall -Wcast-align -Wno-sign-compare")
SET(SERVER_SRCS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/geofence-server")
+++ /dev/null
-/* Copyright 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 __GEOFENCE_MODULE_H__
-#define __GEOFENCE_MODULE_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @file geofence-module.h
- * @brief This file contains the structure and enumeration for geofence plug-in development.
- */
-
-
-/**
- * @brief This represents geofence parameter.
- */
-typedef enum {
- GEOFENCE_TYPE_GEOPOINT = 1, /**< Geofence is specified by geo position */
- GEOFENCE_TYPE_WIFI, /**< Geofence is specified by WiFi hotspot */
- GEOFENCE_TYPE_BT, /**< Geofence is specified BT */
-} geofence_type_e;
-
-typedef enum {
- ACCESS_TYPE_PRIVATE = 1,
- ACCESS_TYPE_PUBLIC,
- ACCESS_TYPE_UNKNOWN,
-} access_type_e;
-
-/**
- * @brief The geofence manager handle.
- */
-typedef struct place_params_s *place_params_h;
-/**
- * @brief The geofence params handle.
- */
-typedef struct geofence_params_s *geofence_params_h;
-
-/**
- * @brief This represents a geofence callback function for geofence plug-in.
- */
-typedef void (*GeofenceModCB) (int fence_id, int state, gpointer userdata);
-
-typedef void (*GeofenceModEventCB) (int place_id, int fence_id, int error, int state, gpointer userdata);
-
-/**
- * @brief This represents APIs declared in a Geofence plug-in for Geofence modules.
- */
-typedef struct {
- int (*create) (void *handle, GeofenceModCB geofence_cb, GeofenceModEventCB geofence_event_cb, void *userdata);
- int (*destroy) (void *handle);
- int (*enable_service) (void *handle, int fence_id, bool enable);
- int (*add_geopoint) (void *handle, int place_id, double latitude, double longitude, int radius, const char *address, int *fence_id);
- int (*add_bssid) (void *handle, int place_id, const char *bssid, const char *ssid, geofence_type_e type, int *fence_id);
- int (*add_place) (void *handle, const char *place_name, int *place_id);
- int (*update_place) (void *handle, int place_id, const char *place_name);
- int (*remove_geofence) (void *handle, int fence_id);
- int (*remove_place) (void *handle, int place_id);
- int (*start_geofence) (void *handle, int fence_id);
- int (*stop_geofence) (void *handle, int fence_id);
- int (*get_place_name) (void *handle, int place_id, char **place_name);
- int (*get_list) (void *handle, int place_id, int *fence_amount, int **fence_ids, struct geofence_params_s **params);
- int (*get_place_list) (void *handle, int *place_amount, int **place_ids, struct place_params_s **params);
-} GeofenceModOps;
-
-/**
- * @} @}
- */
-#ifdef __cplusplus
-}
-#endif
-#endif
/* Tizen Geofence Server Error */
#if !defined(TIZEN_ERROR_GEOFENCE_SERVER)
-#define TIZEN_ERROR_GEOFENCE_SERVER -0x02C10000
+#define TIZEN_ERROR_GEOFENCE_SERVER TIZEN_ERROR_GEOFENCE_MANAGER
#endif
/**
typedef enum {
GEOFENCE_STATUS_UNABAILABLE = 0,
GEOFENCE_STATUS_ABAILABLE = 1,
-} geofence_status_t;
+}
+geofence_status_t;
/**
* This enumeration descript the geofence fence state.
*/
typedef enum {
- GEOFENCE_EMIT_STATE_UNCERTAIN = 0,
- GEOFENCE_EMIT_STATE_IN = 1,
- GEOFENCE_EMIT_STATE_OUT = 2,
+ GEOFENCE_EMIT_STATE_UNCERTAIN = 0,
+ GEOFENCE_EMIT_STATE_IN = 1,
+ GEOFENCE_EMIT_STATE_OUT = 2,
} geofence_emit_state_e;
/**
* This enumeration descript the geofence fence state.
*/
typedef enum {
- GEOFENCE_FENCE_STATE_UNCERTAIN = -1,
- GEOFENCE_FENCE_STATE_OUT = 0,
- GEOFENCE_FENCE_STATE_IN = 1,
+ GEOFENCE_FENCE_STATE_UNCERTAIN = -1,
+ GEOFENCE_FENCE_STATE_OUT = 0,
+ GEOFENCE_FENCE_STATE_IN = 1,
} geofence_fence_state_e;
/**
* This enumeration descript the geofence state.
*/
typedef enum {
- GEOFENCE_DIRECTION_BOTH = 0,
- GEOFENCE_DIRECTION_ENTER,
- GEOFENCE_DIRECTION_EXIT,
+ GEOFENCE_DIRECTION_BOTH = 0,
+ GEOFENCE_DIRECTION_ENTER,
+ GEOFENCE_DIRECTION_EXIT,
} geofence_direction_e;
/**
*/
typedef enum {
- FENCE_ERR_NONE = 0, /** No error */
- FENCE_ERR_SQLITE_FAIL = -100,
- FENCE_ERR_INVALID_PARAMETER = -101,
- FENCE_ERR_INTERNAL = -102,
- FENCE_ERR_FENCE_ID = -103,
- FENCE_ERR_PREPARE = -104,
- FENCE_ERR_FENCE_TYPE = -105, /* geofence type ERROR */
- FENCE_ERR_STRING_TRUNCATED = -106, /* String truncated */
- FENCE_ERR_COUNT = -107, /* count <= 0 */
- FENCE_ERR_UNKNOWN = -108
+ FENCE_ERR_NONE = 0, /** No error */
+ FENCE_ERR_SQLITE_FAIL = -100,
+ FENCE_ERR_INVALID_PARAMETER = -101,
+ FENCE_ERR_INTERNAL = -102,
+ FENCE_ERR_FENCE_ID = -103,
+ FENCE_ERR_PREPARE = -104,
+ FENCE_ERR_FENCE_TYPE = -105, /* geofence type ERROR */
+ FENCE_ERR_STRING_TRUNCATED = -106, /* String truncated */
+ FENCE_ERR_COUNT = -107, /* count <= 0 */
+ FENCE_ERR_UNKNOWN = -108
} fence_err_e;
/**
* @since_tizen 2.4
*/
typedef enum {
- GEOFENCE_SERVER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Success */
- GEOFENCE_SERVER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- GEOFENCE_SERVER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- GEOFENCE_SERVER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
- GEOFENCE_SERVER_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
- GEOFENCE_SERVER_ERROR_NOT_INITIALIZED = TIZEN_ERROR_GEOFENCE_SERVER | 0x01, /**< Geofence Manager is not initialized */
- GEOFENCE_SERVER_ERROR_ID_NOT_EXIST = TIZEN_ERROR_GEOFENCE_SERVER | 0x02, /**< Geofence ID is not exist */
- GEOFENCE_SERVER_ERROR_EXCEPTION = TIZEN_ERROR_GEOFENCE_SERVER | 0x03, /**< exception is occured */
- GEOFENCE_SERVER_ERROR_ALREADY_STARTED = TIZEN_ERROR_GEOFENCE_SERVER | 0x04, /**< Geofence is already started */
- GEOFENCE_SERVER_ERROR_TOO_MANY_GEOFENCE = TIZEN_ERROR_GEOFENCE_SERVER | 0x05, /**< Too many Geofence */
- GEOFENCE_SERVER_ERROR_IPC = TIZEN_ERROR_GEOFENCE_SERVER | 0x06, /**< Error occured in GPS/WIFI/BT */
- GEOFENCE_SERVER_ERROR_DATABASE = TIZEN_ERROR_GEOFENCE_SERVER | 0x07, /**< DB error occured in the server side */
- GEOFENCE_SERVER_ERROR_PLACE_ACCESS_DENIED = TIZEN_ERROR_GEOFENCE_SERVER | 0x08, /**< Access to specified place is denied */
- GEOFENCE_SERVER_ERROR_GEOFENCE_ACCESS_DENIED = TIZEN_ERROR_GEOFENCE_SERVER | 0x09, /**< Access to specified geofence is denied */
+ GEOFENCE_SERVER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Success */
+ GEOFENCE_SERVER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ GEOFENCE_SERVER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ GEOFENCE_SERVER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ GEOFENCE_SERVER_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
+ GEOFENCE_SERVER_ERROR_NOT_INITIALIZED = TIZEN_ERROR_GEOFENCE_SERVER | 0x01, /**< Geofence Manager is not initialized */
+ GEOFENCE_SERVER_ERROR_ID_NOT_EXIST = TIZEN_ERROR_GEOFENCE_SERVER | 0x02, /**< Geofence ID is not exist */
+ GEOFENCE_SERVER_ERROR_EXCEPTION = TIZEN_ERROR_GEOFENCE_SERVER | 0x03, /**< exception is occured */
+ GEOFENCE_SERVER_ERROR_ALREADY_STARTED = TIZEN_ERROR_GEOFENCE_SERVER | 0x04, /**< Geofence is already started */
+ GEOFENCE_SERVER_ERROR_TOO_MANY_GEOFENCE = TIZEN_ERROR_GEOFENCE_SERVER | 0x05, /**< Too many Geofence */
+ GEOFENCE_SERVER_ERROR_IPC = TIZEN_ERROR_GEOFENCE_SERVER | 0x06, /**< Error occured in GPS/WIFI/BT */
+ GEOFENCE_SERVER_ERROR_DATABASE = TIZEN_ERROR_GEOFENCE_SERVER | 0x07, /**< DB error occured in the server side */
+ GEOFENCE_SERVER_ERROR_PLACE_ACCESS_DENIED = TIZEN_ERROR_GEOFENCE_SERVER | 0x08, /**< Access to specified place is denied */
+ GEOFENCE_SERVER_ERROR_GEOFENCE_ACCESS_DENIED = TIZEN_ERROR_GEOFENCE_SERVER | 0x09, /**< Access to specified geofence is denied */
} geofence_server_error_e;
/**
* This enumeration describes the geofence param state
*/
typedef enum {
- GEOFENCE_MANAGE_FENCE_ADDED = 0x00,
- GEOFENCE_MANAGE_FENCE_REMOVED,
- GEOFENCE_MANAGE_FENCE_STARTED,
- GEOFENCE_MANAGE_FENCE_STOPPED,
+ GEOFENCE_MANAGE_FENCE_ADDED = 0x00,
+ GEOFENCE_MANAGE_FENCE_REMOVED,
+ GEOFENCE_MANAGE_FENCE_STARTED,
+ GEOFENCE_MANAGE_FENCE_STOPPED,
- GEOFENCE_MANAGE_PLACE_ADDED = 0x10,
- GEOFENCE_MANAGE_PLACE_REMOVED,
- GEOFENCE_MANAGE_PLACE_UPDATED,
+ GEOFENCE_MANAGE_PLACE_ADDED = 0x10,
+ GEOFENCE_MANAGE_PLACE_REMOVED,
+ GEOFENCE_MANAGE_PLACE_UPDATED,
- GEOFENCE_MANAGE_SETTING_ENABLED = 0x20,
- GEOFENCE_MANAGE_SETTING_DISABLED
+ GEOFENCE_MANAGE_SETTING_ENABLED = 0x20,
+ GEOFENCE_MANAGE_SETTING_DISABLED
} geofence_manage_e;
/**
* This enumeration descript the Smart Assistant State
*/
typedef enum {
- GEOFENCE_SMART_ASSIST_STOP = 0,
- GEOFENCE_SMART_ASSIST_START
+ GEOFENCE_SMART_ASSIST_STOP = 0,
+ GEOFENCE_SMART_ASSIST_START
} geofence_smart_assist_state_e;
+typedef enum {
+ GEOFENCE_TYPE_GEOPOINT = 1, /**< Geofence is specified by geospatial coordinate */
+ GEOFENCE_TYPE_WIFI, /**< Geofence is specified by Wi-Fi access point */
+ GEOFENCE_TYPE_BT, /**< Geofence is specified by Blutetooth device */
+} geofence_type_e;
+
+typedef enum {
+ ACCESS_TYPE_PRIVATE = 1,
+ ACCESS_TYPE_PUBLIC,
+ ACCESS_TYPE_UNKNOWN,
+} access_type_e;
+
#ifdef __cplusplus
}
#endif
GEOFENCE_ZONE_IN = 0x00,
GEOFENCE_ZONE_OUT = 0x01,
GEOFENCE_ZONE_UNCERTAIN = 0x02,
-} geofence_zone_state_t;
+}
+geofence_zone_state_t;
#ifdef __cplusplus
}
#define LOGI_GEOFENCE(fmt, args...) SLOG(LOG_INFO, TAG_GEOFENCE_SERVER, fmt, ##args)
#define LOGW_GEOFENCE(fmt, args...) SLOG(LOG_WARN, TAG_GEOFENCE_SERVER, fmt, ##args)
#define LOGE_GEOFENCE(fmt, args...) SLOG(LOG_ERROR, TAG_GEOFENCE_SERVER, fmt, ##args)
-#define FUNC_ENTRANCE_SERVER LOGD_GEOFENCE("[%s] Entered!!\n", __func__);
+#define FUNC_ENTRANCE_SERVER LOGD_GEOFENCE("ENTER >>>");
#ifdef __cplusplus
}
#include "geofence_server_log.h"
#endif
-#define GEOFENCE_SERVER_SERVICE_NAME "org.tizen.lbs.Providers.GeofenceServer"
-#define GEOFENCE_SERVER_SERVICE_PATH "/org/tizen/lbs/Providers/GeofenceServer"
#define TIME_INTERVAL 5
-
#define SMART_ASSIST_HOME 1
-
#define SMART_ASSIST_TIMEOUT 60 /* Refer to LPP */
#define GEOFENCE_DEFAULT_RADIUS 200 /* Default 200 m */
-
#define NPS_TIMEOUT 180
#define MYPLACES_APPID "org.tizen.myplace"
static int __nps_alarm_cb(alarm_id_t alarm_id, void *user_data);
static int __nps_timeout_cb(alarm_id_t alarm_id, void *user_data);
static void __add_left_fences(gpointer user_data);
-static void __stop_geofence_service(gint fence_id, const gchar *app_id, gpointer userdata);
static void __start_activity_service(GeofenceServer *geofence_server);
static void __stop_activity_service(GeofenceServer *geofence_server);
static void __activity_cb(activity_type_e type, const activity_data_h data, double timestamp, activity_error_e error, void *user_data);
static const char *__convert_wifi_error_to_string(wifi_error_e err_type)
{
switch (err_type) {
- case WIFI_ERROR_NONE:
- return "NONE";
- case WIFI_ERROR_INVALID_PARAMETER:
- return "INVALID_PARAMETER";
- case WIFI_ERROR_OUT_OF_MEMORY:
- return "OUT_OF_MEMORY";
- case WIFI_ERROR_INVALID_OPERATION:
- return "INVALID_OPERATION";
- case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
- return "ADDRESS_FAMILY_NOT_SUPPORTED";
- case WIFI_ERROR_OPERATION_FAILED:
- return "OPERATION_FAILED";
- case WIFI_ERROR_NO_CONNECTION:
- return "NO_CONNECTION";
- case WIFI_ERROR_NOW_IN_PROGRESS:
- return "NOW_IN_PROGRESS";
- case WIFI_ERROR_ALREADY_EXISTS:
- return "ALREADY_EXISTS";
- case WIFI_ERROR_OPERATION_ABORTED:
- return "OPERATION_ABORTED";
- case WIFI_ERROR_DHCP_FAILED:
- return "DHCP_FAILED";
- case WIFI_ERROR_INVALID_KEY:
- return "INVALID_KEY";
- case WIFI_ERROR_NO_REPLY:
- return "NO_REPLY";
- case WIFI_ERROR_SECURITY_RESTRICTED:
- return "SECURITY_RESTRICTED";
- case WIFI_ERROR_PERMISSION_DENIED:
- return "PERMISSION_DENIED";
- default:
- return "NOT Defined";
+ case WIFI_ERROR_NONE:
+ return "NONE";
+ case WIFI_ERROR_INVALID_PARAMETER:
+ return "INVALID_PARAMETER";
+ case WIFI_ERROR_OUT_OF_MEMORY:
+ return "OUT_OF_MEMORY";
+ case WIFI_ERROR_INVALID_OPERATION:
+ return "INVALID_OPERATION";
+ case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "ADDRESS_FAMILY_NOT_SUPPORTED";
+ case WIFI_ERROR_OPERATION_FAILED:
+ return "OPERATION_FAILED";
+ case WIFI_ERROR_NO_CONNECTION:
+ return "NO_CONNECTION";
+ case WIFI_ERROR_NOW_IN_PROGRESS:
+ return "NOW_IN_PROGRESS";
+ case WIFI_ERROR_ALREADY_EXISTS:
+ return "ALREADY_EXISTS";
+ case WIFI_ERROR_OPERATION_ABORTED:
+ return "OPERATION_ABORTED";
+ case WIFI_ERROR_DHCP_FAILED:
+ return "DHCP_FAILED";
+ case WIFI_ERROR_INVALID_KEY:
+ return "INVALID_KEY";
+ case WIFI_ERROR_NO_REPLY:
+ return "NO_REPLY";
+ case WIFI_ERROR_SECURITY_RESTRICTED:
+ return "SECURITY_RESTRICTED";
+ case WIFI_ERROR_PERMISSION_DENIED:
+ return "PERMISSION_DENIED";
+ default:
+ return "NOT Defined";
}
}
static const char *__bt_get_error_message(bt_error_e err)
{
switch (err) {
- case BT_ERROR_NONE:
- return "BT_ERROR_NONE";
- case BT_ERROR_CANCELLED:
- return "BT_ERROR_CANCELLED";
- case BT_ERROR_INVALID_PARAMETER:
- return "BT_ERROR_INVALID_PARAMETER";
- case BT_ERROR_OUT_OF_MEMORY:
- return "BT_ERROR_OUT_OF_MEMORY";
- case BT_ERROR_RESOURCE_BUSY:
- return "BT_ERROR_RESOURCE_BUSY";
- case BT_ERROR_TIMED_OUT:
- return "BT_ERROR_TIMED_OUT";
- case BT_ERROR_NOW_IN_PROGRESS:
- return "BT_ERROR_NOW_IN_PROGRESS";
- case BT_ERROR_NOT_INITIALIZED:
- return "BT_ERROR_NOT_INITIALIZED";
- case BT_ERROR_NOT_ENABLED:
- return "BT_ERROR_NOT_ENABLED";
- case BT_ERROR_ALREADY_DONE:
- return "BT_ERROR_ALREADY_DONE";
- case BT_ERROR_OPERATION_FAILED:
- return "BT_ERROR_OPERATION_FAILED";
- case BT_ERROR_NOT_IN_PROGRESS:
- return "BT_ERROR_NOT_IN_PROGRESS";
- case BT_ERROR_REMOTE_DEVICE_NOT_BONDED:
- return "BT_ERROR_REMOTE_DEVICE_NOT_BONDED";
- case BT_ERROR_AUTH_REJECTED:
- return "BT_ERROR_AUTH_REJECTED";
- case BT_ERROR_AUTH_FAILED:
- return "BT_ERROR_AUTH_FAILED";
- case BT_ERROR_REMOTE_DEVICE_NOT_FOUND:
- return "BT_ERROR_REMOTE_DEVICE_NOT_FOUND";
- case BT_ERROR_SERVICE_SEARCH_FAILED:
- return "BT_ERROR_SERVICE_SEARCH_FAILED";
- case BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED:
- return "BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED";
+ case BT_ERROR_NONE:
+ return "BT_ERROR_NONE";
+ case BT_ERROR_CANCELLED:
+ return "BT_ERROR_CANCELLED";
+ case BT_ERROR_INVALID_PARAMETER:
+ return "BT_ERROR_INVALID_PARAMETER";
+ case BT_ERROR_OUT_OF_MEMORY:
+ return "BT_ERROR_OUT_OF_MEMORY";
+ case BT_ERROR_RESOURCE_BUSY:
+ return "BT_ERROR_RESOURCE_BUSY";
+ case BT_ERROR_TIMED_OUT:
+ return "BT_ERROR_TIMED_OUT";
+ case BT_ERROR_NOW_IN_PROGRESS:
+ return "BT_ERROR_NOW_IN_PROGRESS";
+ case BT_ERROR_NOT_INITIALIZED:
+ return "BT_ERROR_NOT_INITIALIZED";
+ case BT_ERROR_NOT_ENABLED:
+ return "BT_ERROR_NOT_ENABLED";
+ case BT_ERROR_ALREADY_DONE:
+ return "BT_ERROR_ALREADY_DONE";
+ case BT_ERROR_OPERATION_FAILED:
+ return "BT_ERROR_OPERATION_FAILED";
+ case BT_ERROR_NOT_IN_PROGRESS:
+ return "BT_ERROR_NOT_IN_PROGRESS";
+ case BT_ERROR_REMOTE_DEVICE_NOT_BONDED:
+ return "BT_ERROR_REMOTE_DEVICE_NOT_BONDED";
+ case BT_ERROR_AUTH_REJECTED:
+ return "BT_ERROR_AUTH_REJECTED";
+ case BT_ERROR_AUTH_FAILED:
+ return "BT_ERROR_AUTH_FAILED";
+ case BT_ERROR_REMOTE_DEVICE_NOT_FOUND:
+ return "BT_ERROR_REMOTE_DEVICE_NOT_FOUND";
+ case BT_ERROR_SERVICE_SEARCH_FAILED:
+ return "BT_ERROR_SERVICE_SEARCH_FAILED";
+ case BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED:
+ return "BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED";
#ifndef TIZEN_TV
- case BT_ERROR_PERMISSION_DENIED:
- return "BT_ERROR_PERMISSION_DENIED";
- case BT_ERROR_SERVICE_NOT_FOUND:
- return "BT_ERROR_SERVICE_NOT_FOUND";
+ case BT_ERROR_PERMISSION_DENIED:
+ return "BT_ERROR_PERMISSION_DENIED";
+ case BT_ERROR_SERVICE_NOT_FOUND:
+ return "BT_ERROR_SERVICE_NOT_FOUND";
#endif
- default:
- return "NOT Defined";
+ default:
+ return "NOT Defined";
}
}
#endif
FUNC_ENTRANCE_SERVER;
g_return_val_if_fail(geofence_server, -1);
+ LOGD_GEOFENCE("place_id: %d, fence_id: %d, access_type: %d, error: %d, state: %d", place_id, fence_id, access_type, error, state);
+
geofence_dbus_server_send_geofence_event_changed(geofence_server->geofence_dbus_server, place_id, fence_id, access_type, app_id, error, state);
return 0;
}
if (state == GEOFENCE_FENCE_STATE_IN) {
LOGD_GEOFENCE("FENCE_IN to be set, current state: %d",
- item_data->common_info.status);
+ item_data->common_info.status);
if (item_data->common_info.status != GEOFENCE_FENCE_STATE_IN) {
geofence_dbus_server_send_geofence_inout_changed(geofence_server->geofence_dbus_server, item_data->common_info.appid, fence_id, item_data->common_info.access_type, GEOFENCE_EMIT_STATE_IN);
if (item_data->client_status == GEOFENCE_CLIENT_STATUS_START) {
} else if (state == GEOFENCE_FENCE_STATE_OUT) {
LOGD_GEOFENCE("FENCE_OUT to be set, current state: %d",
- item_data->common_info.status);
+ item_data->common_info.status);
if (item_data->common_info.status != GEOFENCE_FENCE_STATE_OUT) {
geofence_dbus_server_send_geofence_inout_changed(geofence_server->geofence_dbus_server, item_data->common_info.appid, fence_id, item_data->common_info.access_type, GEOFENCE_EMIT_STATE_OUT);
if (item_data->client_status == GEOFENCE_CLIENT_STATUS_START) {
FUNC_ENTRANCE_SERVER;
GeofenceServer *geofence_server = (GeofenceServer *) user_data;
location_accuracy_level_e level;
- double hor_acc = 0.0;
+ double hor_acc = 0.0;
double ver_acc = 0.0;
int ret = 0;
int fence_id = 0;
}
static void __check_tracking_list(const char *bssid, void *user_data,
- geofence_type_e type)
+ geofence_type_e type)
{
FUNC_ENTRANCE_SERVER;
GeofenceServer *geofence_server = (GeofenceServer *) user_data;
}
}
} else {
- LOGI_GEOFENCE("%s %s", discovery_info->remote_address, discovery_info->remote_name);
+ LOGI_GEOFENCE("%s, %s", discovery_info->remote_address, discovery_info->remote_name);
LOGI_GEOFENCE("rssi: %d is_bonded: %d", discovery_info->rssi, discovery_info->is_bonded);
if (geofence_server->running_bt_cnt > 0) {
int tracking_fence_id = 0;
switch (event_cb->Event) {
- case NET_EVENT_WIFI_SCAN_IND:
-
- LOGD_GEOFENCE("Got WIFI scan Ind : %d\n", event_cb->Error);
+ case NET_EVENT_WIFI_SCAN_IND:
+ LOGD_GEOFENCE("Got WIFI scan Ind : %d\n", event_cb->Error);
- net_profile_info_t *profiles = NULL;
- int num_of_profile = 0;
+ net_profile_info_t *profiles = NULL;
+ int num_of_profile = 0;
- if (geofence_server->running_wifi_cnt > 0) { /*Check only if some wifi fence is running*/
- if (NET_ERR_NONE != net_get_profile_list(NET_DEVICE_WIFI, &profiles, &num_of_profile)) {
- LOGD_GEOFENCE("Failed to get the scanned list");
- } else {
- LOGD_GEOFENCE("Scan results retrieved successfully. No.of profiles: %d", num_of_profile);
- if (num_of_profile > 0 && profiles != NULL) {
- int cnt;
- for (cnt = 0; cnt < num_of_profile; cnt++) {
- net_wifi_profile_info_t *ap_info = &profiles[cnt].ProfileInfo.Wlan;
- LOGD_GEOFENCE("BSSID %s", ap_info->bssid);
- __check_tracking_list(ap_info->bssid, geofence_server, GEOFENCE_TYPE_WIFI);
- }
- LOGD_GEOFENCE("Comparing fences with scan results is done.Now emit the status to the application");
- while (tracking_fences) {
+ if (geofence_server->running_wifi_cnt > 0) { /*Check only if some wifi fence is running*/
+ if (NET_ERR_NONE != net_get_profile_list(NET_DEVICE_WIFI, &profiles, &num_of_profile)) {
+ LOGD_GEOFENCE("Failed to get the scanned list");
+ } else {
+ LOGD_GEOFENCE("Scan results retrieved successfully. No.of profiles: %d", num_of_profile);
+ if (num_of_profile > 0 && profiles != NULL) {
+ int cnt;
+ for (cnt = 0; cnt < num_of_profile; cnt++) {
+ net_wifi_profile_info_t *ap_info = &profiles[cnt].ProfileInfo.Wlan;
+ LOGD_GEOFENCE("BSSID %s", ap_info->bssid);
+ __check_tracking_list(ap_info->bssid, geofence_server, GEOFENCE_TYPE_WIFI);
+ }
+ LOGD_GEOFENCE("Comparing fences with scan results is done.Now emit the status to the application");
+ while (tracking_fences) {
tracking_fence_id = GPOINTER_TO_INT(tracking_fences->data);
- tracking_fences = g_list_next(tracking_fences);
- item_data = __get_item_by_fence_id(tracking_fence_id, geofence_server);
- if (item_data && item_data->common_info.type == GEOFENCE_TYPE_WIFI) {
- if (item_data->is_wifi_status_in == true) {
- __emit_fence_inout(geofence_server, item_data->common_info.fence_id, GEOFENCE_FENCE_STATE_IN);
- } else {
- __emit_fence_inout(geofence_server, item_data->common_info.fence_id, GEOFENCE_FENCE_STATE_OUT);
+ tracking_fences = g_list_next(tracking_fences);
+ item_data = __get_item_by_fence_id(tracking_fence_id, geofence_server);
+ if (item_data && item_data->common_info.type == GEOFENCE_TYPE_WIFI) {
+ if (item_data->is_wifi_status_in == true) {
+ __emit_fence_inout(geofence_server, item_data->common_info.fence_id, GEOFENCE_FENCE_STATE_IN);
+ } else {
+ __emit_fence_inout(geofence_server, item_data->common_info.fence_id, GEOFENCE_FENCE_STATE_OUT);
+ }
+ item_data->is_wifi_status_in = false;
}
- item_data->is_wifi_status_in = false;
}
}
}
}
- }
- break;
- default:
- break;
+ break;
+ default:
+ break;
}
}
}
geofence_server->loc_started = FALSE;
ret = location_manager_unset_position_updated_cb
- (geofence_server->loc_manager);
+ (geofence_server->loc_manager);
if (ret != LOCATIONS_ERROR_NONE) {
return;
}
}
static void gps_setting_changed_cb(location_method_e method, bool enable,
- void *user_data)
+ void *user_data)
{
FUNC_ENTRANCE_SERVER;
GeofenceServer *geofence_server = (GeofenceServer *) user_data;
/*stop the timeout alarm if it is running...*/
if (geofence_server->nps_timeout_alarm_id != -1) {
LOGI_GEOFENCE("Timeout timer removed. ID[%d]",
- geofence_server->nps_timeout_alarm_id);
+ geofence_server->nps_timeout_alarm_id);
geofence_server->nps_timeout_alarm_id = _geofence_remove_alarm(geofence_server->nps_timeout_alarm_id);
}
while (tracking_fences) {
return 1;
}
-static int __add_fence(const gchar *app_id,
- gint place_id,
- gint geofence_type,
- gdouble latitude,
- gdouble longitude,
- gint radius,
- const gchar *address,
- const gchar *bssid, const gchar *ssid, gpointer userdata)
+static void __stop_geofence_service(gint fence_id, const gchar *app_id, gpointer userdata)
+{
+ FUNC_ENTRANCE_SERVER;
+ g_return_if_fail(userdata);
+
+ GeofenceServer *geofence_server = (GeofenceServer *) userdata;
+ GeofenceItemData *item_data = NULL;
+ int tracking_status = -1;
+ int ret = FENCE_ERR_NONE;
+ int place_id = -1;
+ access_type_e access_type = ACCESS_TYPE_UNKNOWN;
+
+ item_data = __get_item_by_fence_id(fence_id, geofence_server); /*Fetch the fence details from add_list*/
+ if (item_data == NULL) {
+ LOGI_GEOFENCE("Invalid fence id - no fence exists with this fence id");
+ __emit_fence_event(geofence_server, -1, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_ID_NOT_EXIST, GEOFENCE_MANAGE_FENCE_STOPPED);
+ return; /*Invalid fence id - no fence exists with this fence id*/
+ }
+ ret = geofence_manager_get_place_id(fence_id, &place_id);
+ if (ret != FENCE_ERR_NONE) {
+ LOGI_GEOFENCE("Error fetching the place_id from the DB for fence: %d", fence_id);
+ __emit_fence_event(geofence_server, -1, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_DATABASE, GEOFENCE_MANAGE_FENCE_STOPPED);
+ return;
+ }
+ ret = geofence_manager_get_access_type(fence_id, -1, &access_type);
+ if (ret != FENCE_ERR_NONE) {
+ LOGI_GEOFENCE("Error fetching the access type from the DB for fence: %d", fence_id);
+ __emit_fence_event(geofence_server, place_id, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_DATABASE, GEOFENCE_MANAGE_FENCE_STOPPED);
+ return;
+ }
+ ret = __check_fence_permission(fence_id, app_id);
+ if (ret != 1) {
+ LOGE("Permission denied or DB error occured while accessing the fence[%d]", fence_id);
+ if (ret == 0) {
+ __emit_fence_event(geofence_server, place_id, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_GEOFENCE_ACCESS_DENIED, GEOFENCE_MANAGE_FENCE_STOPPED);
+ } else {
+ __emit_fence_event(geofence_server, place_id, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_DATABASE, GEOFENCE_MANAGE_FENCE_STOPPED);
+ }
+ return;
+ }
+ ret = geofence_manager_get_running_status(fence_id, &tracking_status);
+ if (ret != FENCE_ERR_NONE) {
+ LOGI_GEOFENCE("Error fetching the running status from the DB for fence: %d", fence_id);
+ __emit_fence_event(geofence_server, place_id, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_DATABASE, GEOFENCE_MANAGE_FENCE_STOPPED);
+ return;
+ }
+
+ if (tracking_status == 0) {
+ /*This fence is not in the tracking mode currently - nothing to do, just return saying the error*/
+ LOGI_GEOFENCE("Fence ID: %d, is not in the tracking mode", fence_id);
+ __emit_fence_event(geofence_server, place_id, fence_id, access_type, app_id, GEOFENCE_SERVER_ERROR_NONE, GEOFENCE_MANAGE_FENCE_STOPPED);
+ return;
+ }
+
+ if (tracking_status > 0) {
+ LOGI_GEOFENCE("Remove from tracklist: Fence id: %d", fence_id);
+ item_data = __get_item_by_fence_id(fence_id, geofence_server);
+
+ /*Item needs to be removed from the fence list*/
+ if (item_data != NULL) {
+ /*Main DB table should be updated here with the unsetting of running status flag*/
+ tracking_status = tracking_status - 1;
+ ret = geofence_manager_set_running_status(fence_id, tracking_status);
+ if (ret != FENCE_ERR_NONE) {
+ LOGI_GEOFENCE("Error resetting the running status in DB for fence: %d", fence_id);
+ __emit_fence_event(geofence_server, place_id, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_DATABASE, GEOFENCE_MANAGE_FENCE_STOPPED);
+ return;
+ }
+ /*Update the geofence count according to the type of geofence*/
+ if (item_data->common_info.type == GEOFENCE_TYPE_GEOPOINT) {
+ geofence_server->running_geopoint_cnt--;
+ LOGI_GEOFENCE("Removed geopoint fence: %d from tracking list", fence_id);
+
+ if (geofence_server->running_geopoint_cnt <= 0) {
+ /*Stopping GPS...*/
+ __stop_gps_positioning(geofence_server);
+
+ /*Stop the interval alarm if it is running...*/
+ if (geofence_server->nps_alarm_id != -1) {
+ LOGI_GEOFENCE("Interval timer removed. ID[%d]", geofence_server->nps_alarm_id);
+ geofence_server->nps_alarm_id = _geofence_remove_alarm(geofence_server->nps_alarm_id);
+ }
+ /*Stop the timeout alarm if it is running...*/
+ if (geofence_server->nps_timeout_alarm_id != -1) {
+ LOGI_GEOFENCE("Timeout timer removed. ID[%d]", geofence_server->nps_timeout_alarm_id);
+ geofence_server->nps_timeout_alarm_id = _geofence_remove_alarm(geofence_server->nps_timeout_alarm_id);
+ }
+
+ __stop_activity_service(geofence_server);
+ }
+ } else if (item_data->common_info.type == GEOFENCE_TYPE_BT) {
+ geofence_server->running_bt_cnt--;
+ LOGI_GEOFENCE("Removed bt fence: %d from tracking list", fence_id);
+
+ if (geofence_server->running_bt_cnt <= 0) {
+ /*May be unsetting the cb for bt discovery can be done here*/
+ }
+ } else if (item_data->common_info.type == GEOFENCE_TYPE_WIFI) {
+ /*NOTHING NEED TO BE DONE HERE EXCEPT DECREMENTING THE COUNT*/
+ geofence_server->running_wifi_cnt--;
+ }
+
+ if (tracking_status == 0) {
+ /*Remove the fence from the tracklist*/
+ LOGD_GEOFENCE("Setting the fence status as uncertain here...");
+ item_data->common_info.status = GEOFENCE_FENCE_STATE_UNCERTAIN;
+ geofence_server->tracking_list = g_list_remove(geofence_server->tracking_list, GINT_TO_POINTER(fence_id));
+ if (g_list_length(geofence_server->tracking_list) == 0) {
+ g_list_free(geofence_server->tracking_list);
+ geofence_server->tracking_list = NULL;
+ }
+ }
+ } else {
+ LOGI_GEOFENCE("Geofence service is not running for this fence");
+ }
+
+ }
+ /* Emit the error code */
+ __emit_fence_event(geofence_server, place_id, fence_id, access_type, app_id, GEOFENCE_SERVER_ERROR_NONE, GEOFENCE_MANAGE_FENCE_STOPPED);
+}
+
+static int dbus_add_fence_cb(const gchar *app_id,
+ gint place_id,
+ gint geofence_type,
+ gdouble latitude,
+ gdouble longitude,
+ gint radius,
+ const gchar *address,
+ const gchar *bssid, const gchar *ssid, gpointer userdata)
{
FUNC_ENTRANCE_SERVER;
GeofenceServer *geofence_server = (GeofenceServer *) userdata;
return fence_id;
}
-static int __add_place(const gchar *app_id,
- const gchar *place_name, gpointer userdata)
+static int dbus_add_place_cb(const gchar *app_id,
+ const gchar *place_name, gpointer userdata)
{
FUNC_ENTRANCE_SERVER;
int place_id = -1;
return place_id;
}
-static void __enable_service(gint fence_id, const gchar *app_id, gboolean enable, gpointer userdata)
+static void dbus_enable_geofence_cb(gint fence_id, const gchar *app_id, gboolean enable, gpointer userdata)
{
FUNC_ENTRANCE_SERVER;
g_return_if_fail(userdata);
__emit_fence_event(geofence_server, place_id, fence_id, access_type, app_id, GEOFENCE_SERVER_ERROR_NONE, manage_enum);
}
-static void __update_place(gint place_id, const gchar *app_id, const gchar *place_name, gpointer userdata)
+static void dbus_update_place_cb(gint place_id, const gchar *app_id, const gchar *place_name, gpointer userdata)
{
FUNC_ENTRANCE_SERVER;
int ret = FENCE_ERR_NONE;
g_free(place_info);
}
-static void __remove_fence(gint fence_id, const gchar *app_id, gpointer userdata)
+static void dbus_remove_fence_cb(gint fence_id, const gchar *app_id, gpointer userdata)
{
FUNC_ENTRANCE_SERVER;
GeofenceServer *geofence_server = (GeofenceServer *) userdata;
__emit_fence_event(geofence_server, place_id, fence_id, access_type, app_id, GEOFENCE_SERVER_ERROR_NONE, GEOFENCE_MANAGE_FENCE_REMOVED);
}
-static void __get_place_name(gint place_id, const gchar *app_id, char **place_name, int *error_code, gpointer userdata)
+static void dbus_get_place_name_cb(gint place_id, const gchar *app_id, char **place_name, int *error_code, gpointer userdata)
{
FUNC_ENTRANCE_SERVER;
access_type_e access_type = ACCESS_TYPE_UNKNOWN;
*error_code = GEOFENCE_SERVER_ERROR_NONE;
}
-static void __remove_place(gint place_id, const gchar *app_id,
- gpointer userdata)
+static void dbus_remove_place_cb(gint place_id, const gchar *app_id,
+ gpointer userdata)
{
FUNC_ENTRANCE_SERVER;
g_return_if_fail(userdata);
}
place_info_s *place_info =
- (place_info_s *) g_malloc0(sizeof(place_info_s));
+ (place_info_s *) g_malloc0(sizeof(place_info_s));
ret = geofence_manager_get_place_info(place_id, &place_info);
if (ret != FENCE_ERR_NONE) {
LOGI_GEOFENCE("Place_id does not exist or DB error in getting the place info for place_id[%d].", place_id);
__emit_fence_event(geofence_server, place_id, -1, access_type, app_id, GEOFENCE_SERVER_ERROR_NONE, GEOFENCE_MANAGE_PLACE_REMOVED);
}
-static void __start_geofence_service(gint fence_id, const gchar *app_id, gpointer userdata)
+static void dbus_start_geofence_cb(gint fence_id, const gchar *app_id, gpointer userdata)
{
FUNC_ENTRANCE_SERVER;
g_return_if_fail(userdata);
}
if (enable == 0) {
LOGI_GEOFENCE("Error - Fence[%d] is not enabled",
- fence_id);
+ fence_id);
__emit_fence_event(geofence_server, place_id, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_GEOFENCE_ACCESS_DENIED, GEOFENCE_MANAGE_FENCE_STARTED);
return;
}
return;
}
geofence_server->running_geopoint_cnt++;
-
+
__start_activity_service(geofence_server);
} else if (item_data->common_info.type == GEOFENCE_TYPE_BT) {
LOGI_GEOFENCE("fence_type [GEOFENCE_TYPE_BT]");
}
} else {
LOGI_GEOFENCE("Invalid fence_type[%d]",
- item_data->common_info.type);
+ item_data->common_info.type);
return;
}
/*Adding the fence to the tracking list*/
}
}
-static void __stop_geofence_service(gint fence_id, const gchar *app_id, gpointer userdata)
+static void dbus_stop_geofence_cb(gint fence_id, const gchar *app_id, gpointer userdata)
{
- FUNC_ENTRANCE_SERVER;
- g_return_if_fail(userdata);
-
- GeofenceServer *geofence_server = (GeofenceServer *) userdata;
- GeofenceItemData *item_data = NULL;
- int tracking_status = -1;
- int ret = FENCE_ERR_NONE;
- int place_id = -1;
- access_type_e access_type = ACCESS_TYPE_UNKNOWN;
-
- item_data = __get_item_by_fence_id(fence_id, geofence_server); /*Fetch the fence details from add_list*/
- if (item_data == NULL) {
- LOGI_GEOFENCE("Invalid fence id - no fence exists with this fence id");
- __emit_fence_event(geofence_server, -1, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_ID_NOT_EXIST, GEOFENCE_MANAGE_FENCE_STOPPED);
- return; /*Invalid fence id - no fence exists with this fence id*/
- }
- ret = geofence_manager_get_place_id(fence_id, &place_id);
- if (ret != FENCE_ERR_NONE) {
- LOGI_GEOFENCE("Error fetching the place_id from the DB for fence: %d", fence_id);
- __emit_fence_event(geofence_server, -1, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_DATABASE, GEOFENCE_MANAGE_FENCE_STOPPED);
- return;
- }
- ret = geofence_manager_get_access_type(fence_id, -1, &access_type);
- if (ret != FENCE_ERR_NONE) {
- LOGI_GEOFENCE("Error fetching the access type from the DB for fence: %d", fence_id);
- __emit_fence_event(geofence_server, place_id, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_DATABASE, GEOFENCE_MANAGE_FENCE_STOPPED);
- return;
- }
- ret = __check_fence_permission(fence_id, app_id);
- if (ret != 1) {
- LOGE("Permission denied or DB error occured while accessing the fence[%d]", fence_id);
- if (ret == 0) {
- __emit_fence_event(geofence_server, place_id, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_GEOFENCE_ACCESS_DENIED, GEOFENCE_MANAGE_FENCE_STOPPED);
- } else {
- __emit_fence_event(geofence_server, place_id, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_DATABASE, GEOFENCE_MANAGE_FENCE_STOPPED);
- }
- return;
- }
- ret = geofence_manager_get_running_status(fence_id, &tracking_status);
- if (ret != FENCE_ERR_NONE) {
- LOGI_GEOFENCE("Error fetching the running status from the DB for fence: %d", fence_id);
- __emit_fence_event(geofence_server, place_id, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_DATABASE, GEOFENCE_MANAGE_FENCE_STOPPED);
- return;
- }
-
- if (tracking_status == 0) {
- /*This fence is not in the tracking mode currently - nothing to do, just return saying the error*/
- LOGI_GEOFENCE("Fence ID: %d, is not in the tracking mode", fence_id);
- __emit_fence_event(geofence_server, place_id, fence_id, access_type, app_id, GEOFENCE_SERVER_ERROR_NONE, GEOFENCE_MANAGE_FENCE_STOPPED);
- return;
- }
-
- if (tracking_status > 0) {
- LOGI_GEOFENCE("Remove from tracklist: Fence id: %d", fence_id);
- item_data = __get_item_by_fence_id(fence_id, geofence_server);
-
- /*Item needs to be removed from the fence list*/
- if (item_data != NULL) {
- /*Main DB table should be updated here with the unsetting of running status flag*/
- tracking_status = tracking_status - 1;
- ret = geofence_manager_set_running_status(fence_id, tracking_status);
- if (ret != FENCE_ERR_NONE) {
- LOGI_GEOFENCE("Error resetting the running status in DB for fence: %d", fence_id);
- __emit_fence_event(geofence_server, place_id, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_DATABASE, GEOFENCE_MANAGE_FENCE_STOPPED);
- return;
- }
- /*Update the geofence count according to the type of geofence*/
- if (item_data->common_info.type == GEOFENCE_TYPE_GEOPOINT) {
- geofence_server->running_geopoint_cnt--;
- LOGI_GEOFENCE("Removed geopoint fence: %d from tracking list", fence_id);
-
- if (geofence_server->running_geopoint_cnt <= 0) {
- /*Stopping GPS...*/
- __stop_gps_positioning(geofence_server);
-
- /*Stop the interval alarm if it is running...*/
- if (geofence_server->nps_alarm_id != -1) {
- LOGI_GEOFENCE("Interval timer removed. ID[%d]", geofence_server->nps_alarm_id);
- geofence_server->nps_alarm_id = _geofence_remove_alarm(geofence_server->nps_alarm_id);
- }
- /*Stop the timeout alarm if it is running...*/
- if (geofence_server->nps_timeout_alarm_id != -1) {
- LOGI_GEOFENCE("Timeout timer removed. ID[%d]", geofence_server->nps_timeout_alarm_id);
- geofence_server->nps_timeout_alarm_id = _geofence_remove_alarm(geofence_server->nps_timeout_alarm_id);
- }
-
- __stop_activity_service(geofence_server);
- }
- } else if (item_data->common_info.type == GEOFENCE_TYPE_BT) {
- geofence_server->running_bt_cnt--;
- LOGI_GEOFENCE("Removed bt fence: %d from tracking list", fence_id);
-
- if (geofence_server->running_bt_cnt <= 0) {
- /*May be unsetting the cb for bt discovery can be done here*/
- }
- } else if (item_data->common_info.type == GEOFENCE_TYPE_WIFI) {
- /*NOTHING NEED TO BE DONE HERE EXCEPT DECREMENTING THE COUNT*/
- geofence_server->running_wifi_cnt--;
- }
-
- if (tracking_status == 0) {
- /*Remove the fence from the tracklist*/
- LOGD_GEOFENCE("Setting the fence status as uncertain here...");
- item_data->common_info.status = GEOFENCE_FENCE_STATE_UNCERTAIN;
- geofence_server->tracking_list = g_list_remove(geofence_server->tracking_list, GINT_TO_POINTER(fence_id));
- if (g_list_length(geofence_server->tracking_list) == 0) {
- g_list_free(geofence_server->tracking_list);
- geofence_server->tracking_list = NULL;
- }
- }
- } else {
- LOGI_GEOFENCE("Geofence service is not running for this fence");
- }
-
- }
- /* Emit the error code */
- __emit_fence_event(geofence_server, place_id, fence_id, access_type, app_id, GEOFENCE_SERVER_ERROR_NONE, GEOFENCE_MANAGE_FENCE_STOPPED);
+ __stop_geofence_service(fence_id, app_id, userdata);
}
static void __start_activity_service(GeofenceServer *geofence_server)
}
}
-static GVariant *__get_list(int place_id, const gchar *app_id, int *fenceCnt, int *errorCode, gpointer userdata)
+static GVariant *dbus_get_geofences_cb(int place_id, const gchar *app_id, int *fenceCnt, int *errorCode, gpointer userdata)
{
geofence_info_s *item;
GVariantBuilder b;
LOGI_GEOFENCE("fence_id: %d, place_id: %d, latitude: %f, longitude: %f, radius: %d", item->fence_id, item->param.place_id, item->param.latitude, item->param.longitude, item->param.radius);
switch (item->param.type) {
- case GEOFENCE_TYPE_GEOPOINT:{
- g_variant_builder_add(&b, "{sv}", "place_id", g_variant_new_int32(item->param.place_id));
- g_variant_builder_add(&b, "{sv}", "geofence_type", g_variant_new_int32(item->param.type));
- g_variant_builder_add(&b, "{sv}", "latitude", g_variant_new_double(item->param.latitude));
- g_variant_builder_add(&b, "{sv}", "longitude", g_variant_new_double(item->param.longitude));
- g_variant_builder_add(&b, "{sv}", "radius", g_variant_new_int32(item->param.radius));
- g_variant_builder_add(&b, "{sv}", "address", g_variant_new_string(item->param.address));
- g_variant_builder_add(&b, "{sv}", "bssid", g_variant_new_string("NA"));
- g_variant_builder_add(&b, "{sv}", "ssid", g_variant_new_string("NA"));
- }
- break;
- case GEOFENCE_TYPE_WIFI:
- case GEOFENCE_TYPE_BT:{
- g_variant_builder_add(&b, "{sv}", "place_id", g_variant_new_int32(item->param.place_id));
- g_variant_builder_add(&b, "{sv}", "geofence_type", g_variant_new_int32(item->param.type));
- g_variant_builder_add(&b, "{sv}", "latitude", g_variant_new_double(0.0));
- g_variant_builder_add(&b, "{sv}", "longitude", g_variant_new_double(0.0));
- g_variant_builder_add(&b, "{sv}", "radius", g_variant_new_int32(0.0));
- g_variant_builder_add(&b, "{sv}", "address", g_variant_new_string("NA"));
- g_variant_builder_add(&b, "{sv}", "bssid", g_variant_new_string(item->param.bssid));
- g_variant_builder_add(&b, "{sv}", "ssid", g_variant_new_string(item->param.ssid));
- }
- break;
- default:
- LOGI_GEOFENCE("Unsupported type: [%d]", item->param.type);
- break;
+ case GEOFENCE_TYPE_GEOPOINT: {
+ g_variant_builder_add(&b, "{sv}", "place_id", g_variant_new_int32(item->param.place_id));
+ g_variant_builder_add(&b, "{sv}", "geofence_type", g_variant_new_int32(item->param.type));
+ g_variant_builder_add(&b, "{sv}", "latitude", g_variant_new_double(item->param.latitude));
+ g_variant_builder_add(&b, "{sv}", "longitude", g_variant_new_double(item->param.longitude));
+ g_variant_builder_add(&b, "{sv}", "radius", g_variant_new_int32(item->param.radius));
+ g_variant_builder_add(&b, "{sv}", "address", g_variant_new_string(item->param.address));
+ g_variant_builder_add(&b, "{sv}", "bssid", g_variant_new_string("NA"));
+ g_variant_builder_add(&b, "{sv}", "ssid", g_variant_new_string("NA"));
+ }
+ break;
+ case GEOFENCE_TYPE_WIFI:
+ case GEOFENCE_TYPE_BT: {
+ g_variant_builder_add(&b, "{sv}", "place_id", g_variant_new_int32(item->param.place_id));
+ g_variant_builder_add(&b, "{sv}", "geofence_type", g_variant_new_int32(item->param.type));
+ g_variant_builder_add(&b, "{sv}", "latitude", g_variant_new_double(0.0));
+ g_variant_builder_add(&b, "{sv}", "longitude", g_variant_new_double(0.0));
+ g_variant_builder_add(&b, "{sv}", "radius", g_variant_new_int32(0.0));
+ g_variant_builder_add(&b, "{sv}", "address", g_variant_new_string("NA"));
+ g_variant_builder_add(&b, "{sv}", "bssid", g_variant_new_string(item->param.bssid));
+ g_variant_builder_add(&b, "{sv}", "ssid", g_variant_new_string(item->param.ssid));
+ }
+ break;
+ default:
+ LOGI_GEOFENCE("Unsupported type: [%d]", item->param.type);
+ break;
}
/* Close container*/
return g_variant_builder_end(&b);
}
-static GVariant *__get_place_list(const gchar *app_id, int *placeCnt, int *errorCode, gpointer userdata)
+static GVariant *dbus_get_places_cb(const gchar *app_id, int *placeCnt, int *errorCode, gpointer userdata)
{
place_info_s *item;
GVariantBuilder b;
if (FENCE_ERR_NONE != geofence_manager_get_access_type(fence_id, -1, &item_data->common_info.access_type))
return FENCE_ERR_SQLITE_FAIL;
-
+
if (FENCE_ERR_NONE != geofence_manager_get_enable_status(fence_id, &item_data->common_info.enable))
return FENCE_ERR_SQLITE_FAIL;
-
+
if (FENCE_ERR_NONE != geofence_manager_get_appid_from_geofence(fence_id, &app_id)) {
g_free(app_id);
return FENCE_ERR_SQLITE_FAIL;
}
if (FENCE_ERR_NONE != geofence_manager_get_placeid_from_geofence(fence_id, &item_data->common_info.place_id))
return FENCE_ERR_SQLITE_FAIL;
-
+
if (FENCE_ERR_NONE != geofence_manager_get_running_status(fence_id, &item_data->common_info.running_status))
return FENCE_ERR_SQLITE_FAIL;
#endif
/* This call goes to Geofence_dbus_server.c and creates the actual server dbus connection who will interact with the client*/
- geofence_dbus_server_create(GEOFENCE_SERVER_SERVICE_NAME, GEOFENCE_SERVER_SERVICE_PATH, "geofence_manager", "geofence manager provider", &(geofenceserver->geofence_dbus_server), __add_fence, __add_place, __enable_service, __update_place, __remove_fence, __remove_place, __get_place_name, __get_list, __get_place_list, __start_geofence_service, __stop_geofence_service, (void *) geofenceserver);
+ geofence_dbus_callback_s *dbus_callback;
+ dbus_callback = g_new0(geofence_dbus_callback_s, 1);
+ g_return_val_if_fail(dbus_callback, GEOFENCE_DBUS_SERVER_ERROR_MEMORY);
+
+ dbus_callback->add_geofence_cb = dbus_add_fence_cb;
+ dbus_callback->delete_geofence_cb = dbus_remove_fence_cb;
+ dbus_callback->get_geofences_cb = dbus_get_geofences_cb;
+ dbus_callback->enable_geofence_cb = dbus_enable_geofence_cb;
+ dbus_callback->start_geofence_cb = dbus_start_geofence_cb;
+ dbus_callback->stop_geofence_cb = dbus_stop_geofence_cb;
+ dbus_callback->add_place_cb = dbus_add_place_cb;
+ dbus_callback->update_place_cb = dbus_update_place_cb;
+ dbus_callback->delete_place_cb = dbus_remove_place_cb;
+ dbus_callback->get_place_name_cb = dbus_get_place_name_cb;
+ dbus_callback->get_places_cb = dbus_get_places_cb;
+
+ geofence_dbus_server_create(&(geofenceserver->geofence_dbus_server), dbus_callback, (void *) geofenceserver);
LOGD_GEOFENCE("lbs_geofence_server_creation done");
geofence_dbus_server_destroy(geofenceserver->geofence_dbus_server);
LOGD_GEOFENCE("lbs_server_destroy called");
+ g_free(dbus_callback);
g_main_loop_unref(geofenceserver->loop);
+ g_free(geofenceserver);
/*Closing the DB and the handle is aquired again when geofence server comes up.*/
geofence_manager_close_db();
- g_free(geofenceserver);
-
return 0;
}
* @Param[in] user_data The user data to be returned
* @see None.
*/
-typedef void (*geofence_bt_conn_state_changed_cb) (gboolean connected, bt_device_connection_info_s *conn_info, void *user_data);
+typedef void (*geofence_bt_conn_state_changed_cb)(gboolean connected, bt_device_connection_info_s *conn_info, void *user_data);
/**
* @brief Bluetooth adapter disabled callback
* @Param[in] user_data The user data to be returned
* @see None.
*/
-typedef void (*geofence_bt_adapter_disable_cb) (gboolean connected, void *user_data);
+typedef void (*geofence_bt_adapter_disable_cb)(gboolean connected, void *user_data);
/**
* @brief Wifi connection status change callback
* @Param[in] user_data The user data to be returned
* @see None.
*/
-typedef void (*geofence_wifi_conn_state_changed_cb) (wifi_connection_state_e state, wifi_ap_h ap, void *user_data);
+typedef void (*geofence_wifi_conn_state_changed_cb)(wifi_connection_state_e state, wifi_ap_h ap, void *user_data);
/**
* @brief Wifi device status change callback
* @Param[in] user_data The user data to be returned
* @see None.
*/
-typedef void (*geofence_wifi_device_state_changed_cb) (wifi_device_state_e state, void *user_data);
+typedef void (*geofence_wifi_device_state_changed_cb)(wifi_device_state_e state, void *user_data);
/**
* @brief Network scan status change callback
* @Param[in] user_data The user data to be returned
* @see None.
*/
-typedef void (*geofence_network_event_cb) (net_event_info_t *event_cb, void *user_data);
+typedef void (*geofence_network_event_cb)(net_event_info_t *event_cb, void *user_data);
/**
* @brief BT Discovery status change callback
* @Param[in] user_data The user data to be returned
* @see None.
*/
-typedef void (*geofence_bt_adapter_device_discovery_state_changed_cb) (int result, bt_adapter_device_discovery_state_e discovery_state, bt_adapter_device_discovery_info_s *discovery_info, void *user_data);
+typedef void (*geofence_bt_adapter_device_discovery_state_changed_cb)(int result, bt_adapter_device_discovery_state_e discovery_state, bt_adapter_device_discovery_info_s *discovery_info, void *user_data);
/**
* @brief Called when the state of location method is changed.
* @see location_manager_set_setting_changed_cb()
* @see location_manager_unset_setting_changed_cb()
*/
-typedef void (*geofence_gps_setting_changed_cb) (location_method_e method, bool enable, void *user_data);
+typedef void (*geofence_gps_setting_changed_cb)(location_method_e method, bool enable, void *user_data);
/**
* Geofence callback structure.
* This enumeration describe the smart assistant status.
*/
typedef enum {
- GEOFENCE_SMART_ASSIST_NONE,
- GEOFENCE_SMART_ASSIST_ENABLED,
- GEOFENCE_SMART_ASSIST_DISABLED,
- GEOFENCE_SMART_ASSIST_COLLECTING,
+ GEOFENCE_SMART_ASSIST_NONE,
+ GEOFENCE_SMART_ASSIST_ENABLED,
+ GEOFENCE_SMART_ASSIST_DISABLED,
+ GEOFENCE_SMART_ASSIST_COLLECTING,
} smart_assist_status_e;
/**
* This enumeration describe the cell geofence in and out status.
*/
typedef enum {
- CELL_UNKNOWN = -1,
- CELL_OUT = 0,
- CELL_IN = 1
+ CELL_UNKNOWN = -1,
+ CELL_OUT = 0,
+ CELL_IN = 1
} cell_status_e;
/**
* This enumeration describe the wifi geofence in and out status.
*/
typedef enum {
- WIFI_DIRECTION_UNKNOWN = -1,
- WIFI_DIRECTION_OUT = 0,
- WIFI_DIRECTION_IN = 1
+ WIFI_DIRECTION_UNKNOWN = -1,
+ WIFI_DIRECTION_OUT = 0,
+ WIFI_DIRECTION_IN = 1
} wifi_status_e;
/**
* This enumeration describe the geofence client status.
*/
typedef enum {
- GEOFENCE_CLIENT_STATUS_NONE,
- GEOFENCE_CLIENT_STATUS_FIRST_LOCATION,
- GEOFENCE_CLIENT_STATUS_START,
- GEOFENCE_CLIENT_STATUS_RUNNING
+ GEOFENCE_CLIENT_STATUS_NONE,
+ GEOFENCE_CLIENT_STATUS_FIRST_LOCATION,
+ GEOFENCE_CLIENT_STATUS_START,
+ GEOFENCE_CLIENT_STATUS_RUNNING
} geofence_client_status_e;
#endif
static void emit_bt_geofence_inout_changed(GeofenceServer *geofence_server, GeofenceItemData *item_data, int fence_status)
{
FUNC_ENTRANCE_SERVER
- char *app_id = (char *)g_malloc0(sizeof(char)*APP_ID_LEN);
+ char *app_id = (char *)g_malloc0(sizeof(char) * APP_ID_LEN);
g_strlcpy(app_id, item_data->common_info.appid, APP_ID_LEN);
if (app_id == NULL) {
LOGD_GEOFENCE("get app_id failed. fence_id [%d]", item_data->common_info.fence_id);
continue;
fence_type = item_data->common_info.type;
-
+
if (fence_type != GEOFENCE_TYPE_BT)
continue;
-
+
bt_info_from_list = (bssid_info_s *) item_data->priv;
if (bt_info_from_list == NULL || bt_info_from_list->enabled == FALSE)
continue;
-
+
ret = geofence_manager_get_bssid_info(fence_id, &bt_info_from_db);
if (bt_info_from_db == NULL) {
void bt_adp_disable(gboolean connected, void *user_data)
{
FUNC_ENTRANCE_SERVER
- GeofenceServer * geofence_server = (GeofenceServer *) user_data;
+ GeofenceServer *geofence_server = (GeofenceServer *) user_data;
g_return_if_fail(geofence_server);
int fence_id = 0;
#define GEOFENCE_SERVER_DB_FILE ".geofence-server.db"
#define GEOFENCE_SERVER_DB_PATH "/opt/dbspace/"GEOFENCE_SERVER_DB_FILE
-#define FENCE_SQL_LEN_MAX 256
#define MAX_DATA_NAME 20
-#define DATA_LEN 20
+#define DATA_LEN 20
#define GEOFENCE_INVALID 0
const char *col_radius = "r";
typedef enum {
- FENCE_MAIN_TABLE = 0, /*GeoFence */
- FENCE_GEOCOORDINATE_TAB, /*FenceGeocoordinate */
- FENCE_GEOPOINT_WIFI_TABLE, /*FenceCurrentLocation */
- FENCE_BSSID_TABLE /*FenceBluetoothBssid */
+ FENCE_MAIN_TABLE = 0, /*GeoFence */
+ FENCE_GEOCOORDINATE_TAB, /*FenceGeocoordinate */
+ FENCE_GEOPOINT_WIFI_TABLE, /*FenceCurrentLocation */
+ FENCE_BSSID_TABLE /*FenceBluetoothBssid */
} fence_table_type_e;
static struct {
};
#define SQLITE3_RETURN(ret, msg, state) \
- if (ret != SQLITE_OK) { \
- LOGI_GEOFENCE("sqlite3 Error[%d] : %s", ret, msg); \
- sqlite3_reset(state); \
- sqlite3_clear_bindings(state); \
- sqlite3_finalize(state); \
- return FENCE_ERR_SQLITE_FAIL; \
- }
+ if (ret != SQLITE_OK) { \
+ LOGI_GEOFENCE("sqlite3 Error[%d] : %s", ret, msg); \
+ sqlite3_reset(state); \
+ sqlite3_clear_bindings(state); \
+ sqlite3_finalize(state); \
+ return FENCE_ERR_SQLITE_FAIL; \
+ }
/*
* \note
char *bssid = NULL;
char *query = sqlite3_mprintf("INSERT INTO %Q(fence_id, bssid, ssid) VALUES (?, ?, ?)", menu_table[FENCE_BSSID_TABLE]);
- bssid = (char *)g_malloc0(sizeof(char)*WLAN_BSSID_LEN);
+ bssid = (char *)g_malloc0(sizeof(char) * WLAN_BSSID_LEN);
g_strlcpy(bssid, bssid_info, WLAN_BSSID_LEN);
LOGI_GEOFENCE("fence_id[%d], bssid[%s], ssid[%s]", fence_id, bssid, ssid);
const char *tail;
char *bssid = NULL;
wifi_info = (wifi_info_s *) data;
- bssid = (char *)g_malloc0(sizeof(char)*WLAN_BSSID_LEN);
+ bssid = (char *)g_malloc0(sizeof(char) * WLAN_BSSID_LEN);
g_strlcpy(bssid, wifi_info->bssid, WLAN_BSSID_LEN);
LOGI_GEOFENCE("fence_id[%d] bssid[%s]", *fence_id, wifi_info->bssid);
char *place_name = NULL;
char *query = sqlite3_mprintf("INSERT INTO Places (access_type, place_name, app_id) VALUES (?, ?, ?)");
- place_name = (char *)g_malloc0(sizeof(char)*PLACE_NAME_LEN);
+ place_name = (char *)g_malloc0(sizeof(char) * PLACE_NAME_LEN);
g_strlcpy(place_name, place_info->place_name, PLACE_NAME_LEN);
- appid = (char *)g_malloc0(sizeof(char)*APP_ID_LEN);
+ appid = (char *)g_malloc0(sizeof(char) * APP_ID_LEN);
g_strlcpy(appid, place_info->appid, APP_ID_LEN);
ret = sqlite3_prepare_v2(db_info_s.handle, query, -1, &state, &tail);
const char *tail;
char *appid = NULL;
char *query = sqlite3_mprintf("INSERT INTO GeoFence (place_id, enable, app_id, geofence_type, access_type, running_status) VALUES (?, ?, ?, ?, ?, ?)");
- appid = (char *)g_malloc0(sizeof(char)*APP_ID_LEN);
+ appid = (char *)g_malloc0(sizeof(char) * APP_ID_LEN);
g_strlcpy(appid, fence_info->appid, APP_ID_LEN);
ret = sqlite3_prepare_v2(db_info_s.handle, query, -1, &state, &tail);
int ret = SQLITE_OK;
char *place_name = NULL;
- place_name = (char *)g_malloc0(sizeof(char)*PLACE_NAME_LEN);
+ place_name = (char *)g_malloc0(sizeof(char) * PLACE_NAME_LEN);
g_strlcpy(place_name, place_info_name, PLACE_NAME_LEN);
char *query = sqlite3_mprintf("UPDATE Places SET place_name = %Q where place_id = %d", place_name, place_id);
__geofence_manager_genarate_password(password);
/* ssa_put : latitude*/
- ret = snprintf(data_name_lat, DATA_LEN, "%lf", geocoordinate_info->latitude);
+ ret = snprintf(data_name_lat, MAX_DATA_NAME, "%lf", geocoordinate_info->latitude);
ret = sqlite3_bind_text(state, ++index, data_name_lat, -1, SQLITE_STATIC);
*geocoordinate_info = (geocoordinate_info_s *)g_malloc0(sizeof(geocoordinate_info_s));
g_return_val_if_fail(*geocoordinate_info, FENCE_ERR_INVALID_PARAMETER);
-
+
if (password == NULL)
__geofence_manager_genarate_password(password);
geocoordinate_info = (geocoordinate_info_s *)item_data->priv;
/* get_current_position/ check_fence_in/out for geoPoint*/
location_manager_get_distance(cur_lat, cur_lon, geocoordinate_info->latitude, geocoordinate_info->longitude, &distance);
- if (distance < min_dist)
+ if (distance < min_dist)
min_dist = distance;
}
item_list = g_list_next(item_list);
if (cur_time != NULL)
sprintf(buf, "[%02d:%02d:%02d] -- START -- \n", cur_time->tm_hour, cur_time->tm_min, cur_time->tm_sec);
LOGI_GEOFENCE("BUF[%s]", buf);
-/* write(fd, buf, strlen(buf));*/
+ /* write(fd, buf, strlen(buf));*/
}
void _deinit_log()
if (cur_time != NULL)
sprintf(buf, "[%02d:%02d:%02d] -- END -- \n", cur_time->tm_hour, cur_time->tm_min, cur_time->tm_sec);
LOGI_GEOFENCE("BUF[%s]", buf);
-/* write(fd, buf, strlen(buf));*/
+ /* write(fd, buf, strlen(buf));*/
close(fd);
fd = -1;
sprintf(buf, "[%02d:%02d:%02d] %s\n", cur_time->tm_hour, cur_time->tm_min, cur_time->tm_sec, str);
LOGI_GEOFENCE("BUF %s", buf);
-/* write(fd, buf, strlen(buf));*/
+ /* write(fd, buf, strlen(buf));*/
}
char buf[256] = {0, }; \
sprintf(buf, " [%s:%d] Status[%s]", __func__, __LINE__, #state); \
_print_log(buf); \
- }
+ }
#define GEOFENCE_PRINT_LOG_WITH_ID(state, id) { \
char buf[256] = {0, }; \
sprintf(buf, " [%s:%d] Status[%s]. ID[%d]", __func__, __LINE__, #state, id); \
_print_log(buf); \
- }
+ }
#endif /* _GEOFENCE_MANAGER_LOG_H_ */
#define __GEOFENCE_MANAGER_PRIVATE_H__
#include <geofence_dbus_server.h>
-#include "geofence-module.h"
#include <locations.h>
#include <alarm.h>
#include <network-wifi-intf.h>
/** Length of bssid */
#define WLAN_BSSID_LEN 18
-#define APP_ID_LEN 64
-#define ADDRESS_LEN 64
+#define APP_ID_LEN 64
+#define ADDRESS_LEN 64
#define PLACE_NAME_LEN 64
/**
char ssid[WLAN_BSSID_LEN];
} geofence_s;
-/* This can be substituded to GeofenceData*/
typedef struct _geofence_info_s {
int fence_id;
char app_id[APP_ID_LEN];
typedef struct {
GMainLoop *loop;
geofence_dbus_server_h geofence_dbus_server;
- GList *geofence_list; /* list of GeofenceData for multi clients */
+ GList *geofence_list; /* list of geofence list for multi clients */
GList *tracking_list; /* list of geofence ids for tracking */
time_t last_loc_time;
time_t last_result_time;
int running_geopoint_cnt;
int running_bt_cnt;
int running_wifi_cnt;
+#if USE_HW_GEOFENCE
GeofenceModCB geofence_cb;
+#endif
gpointer userdata;
/* for Geometry's GPS positioning*/
location_manager_h loc_manager;
#include <wifi.h>
typedef enum {
- GEOFENCE_STATE_AVAILABLE,
- GEOFENCE_STATE_OUT_OF_SERVICE,
- GEOFENCE_STATE_TEMPORARILY_UNAVAILABLE,
+ GEOFENCE_STATE_AVAILABLE,
+ GEOFENCE_STATE_OUT_OF_SERVICE,
+ GEOFENCE_STATE_TEMPORARILY_UNAVAILABLE,
} geofence_state_t;
/**
SET (CLIENT_SRCS
module_geofence_server.c
- module_internal.c
)
ADD_LIBRARY(${geofence_module} SHARED ${CLIENT_SRCS})
#include <dlog.h>
#define TAG_GEOFENCE_MOD "GEOFENCE_MOD"
-#define LOGD_GEOFENCE(fmt, args...) LOG(LOG_DEBUG, TAG_GEOFENCE_MOD, fmt, ##args)
-#define LOGI_GEOFENCE(fmt, args...) LOG(LOG_INFO, TAG_GEOFENCE_MOD, fmt, ##args)
-#define LOGW_GEOFENCE(fmt, args...) LOG(LOG_WARN, TAG_GEOFENCE_MOD, fmt, ##args)
-#define LOGE_GEOFENCE(fmt, args...) LOG(LOG_ERROR, TAG_GEOFENCE_SERVER_MOD, fmt, ##args)
-
#define MOD_LOGD(fmt, args...) LOG(LOG_DEBUG, TAG_GEOFENCE_MOD, fmt, ##args)
#define MOD_LOGW(fmt, args...) LOG(LOG_WARN, TAG_GEOFENCE_MOD, fmt, ##args)
#define MOD_LOGI(fmt, args...) LOG(LOG_INFO, TAG_GEOFENCE_MOD, fmt, ##args)
#include <app_manager.h>
#include <dlfcn.h>
#include <geofence_client.h>
-#include "module_internal.h"
+#include <geofence_module.h>
#include "log.h"
-#define GEOFENCE_MODULE_API __attribute__((visibility("default"))) G_MODULE_EXPORT
+#define GEOFENCE_SERVER_SERVICE_NAME "org.tizen.lbs.Providers.GeofenceServer"
+#define GEOFENCE_SERVER_SERVICE_PATH "/org/tizen/lbs/Providers/GeofenceServer"
+
#define MYPLACES_APP_ID "org.tizen.myplace"
-/**
- * This enumeration descript the geofence type.
- * Should be SYNC to geofence_mananger_data_types.h
- */
typedef enum {
- GEOFENCE_SERVER_TYPE_INVALID = 0,
- GEOFENCE_SERVER_TYPE_GEOPOINT = 1,
- GEOFENCE_SERVER_TYPE_WIFI,
- GEOFENCE_SERVER_TYPE_BT
-} geofence_server_type_e;
-
-/**
- * Enumerations of the geofence bssid type.
- */
-typedef enum {
- GEOFENCE_BSSID_TYPE_WIFI = 0,
- GEOFENCE_BSSID_TYPE_BT
-} geofence_bssid_type_e;
-
-#define GEOFENCE_STATE_UNCERTAIN 0
-#define GEOFENCE_STATE_IN 1
-#define GEOFENCE_STATE_OUT 2
-#define _WLAN_BSSID_LEN 18/* bssid 17 + "null"*/
-
-typedef struct {
- int enabled;
- int geofence_type;
- gint geofence_id;
- gdouble latitude;
- gdouble longitude;
- gint radius;
- char bssid[_WLAN_BSSID_LEN];
-} GeofenceData;
+ ACCESS_TYPE_PRIVATE = 1,
+ ACCESS_TYPE_PUBLIC,
+ ACCESS_TYPE_UNKNOWN,
+} access_type_e;
typedef struct {
geofence_client_dbus_h geofence_client;
- GList *geofence_list;
GeofenceModCB geofence_cb;
GeofenceModEventCB geofence_event_cb;
+ gchar *app_id;
gpointer userdata;
} GeofenceManagerData;
-#define GEOFENCE_SERVER_SERVICE_NAME "org.tizen.lbs.Providers.GeofenceServer"
-#define GEOFENCE_SERVER_SERVICE_PATH "/org/tizen/lbs/Providers/GeofenceServer"
-
-GEOFENCE_MODULE_API int add_geopoint(void *handle, int place_id, double latitude, double longitude, int radius, const char *address, int *fence_id)
+EXPORT_API int add_geopoint(void *handle, int place_id, double latitude, double longitude, int radius, const char *address, int *fence_id)
{
MOD_LOGD("add_geopoint");
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle;
- g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_EXCEPTION);
- int geofence_id = -1;
+ g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
+ int new_fence_id = -1;
- geofence_id = geo_client_add_geofence(geofence_manager->geofence_client, place_id, GEOFENCE_TYPE_GEOPOINT, latitude, longitude, radius, address, "", "");
- if (geofence_id == -1)
- return GEOFENCE_MANAGER_ERROR_EXCEPTION;
- *fence_id = geofence_id;
+ new_fence_id = geo_client_add_geofence(geofence_manager->geofence_client, geofence_manager->app_id, place_id, GEOFENCE_TYPE_GEOPOINT, latitude, longitude, radius, address, "", "");
+ *fence_id = new_fence_id;
+
+ if (new_fence_id == -1)
+ return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
return GEOFENCE_MANAGER_ERROR_NONE;
}
-GEOFENCE_MODULE_API int add_bssid(void *handle, int place_id, const char *bssid, const char *ssid, geofence_type_e type, int *fence_id)
+EXPORT_API int add_bssid(void *handle, int place_id, const char *bssid, const char *ssid, geofence_type_e type, int *fence_id)
{
MOD_LOGD("add_bssid");
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle;
- g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_EXCEPTION);
- int geofence_id = -1;
+ g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
+ int new_fence_id = -1;
- geofence_id = geo_client_add_geofence(geofence_manager->geofence_client, place_id, type, -1, -1, -1, "", bssid, ssid);
- if (geofence_id == -1)
- return GEOFENCE_MANAGER_ERROR_EXCEPTION;
- *fence_id = geofence_id;
+ new_fence_id = geo_client_add_geofence(geofence_manager->geofence_client, geofence_manager->app_id, place_id, type, -1, -1, -1, "", bssid, ssid);
+ *fence_id = new_fence_id;
+
+ if (new_fence_id == -1)
+ return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
return GEOFENCE_MANAGER_ERROR_NONE;
}
-GEOFENCE_MODULE_API int add_place(void *handle, const char *place_name, int *place_id)
+EXPORT_API int add_place(void *handle, const char *place_name, int *place_id)
{
MOD_LOGD("add_place");
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle;
- g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_EXCEPTION);
- int placeid = -1;
+ g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
+ int new_place_id = -1;
- placeid = geo_client_add_place(geofence_manager->geofence_client, place_name);
- if (placeid == -1)
- return GEOFENCE_MANAGER_ERROR_EXCEPTION;
- *place_id = placeid;
+ new_place_id = geo_client_add_place(geofence_manager->geofence_client, geofence_manager->app_id, place_name);
+ *place_id = new_place_id;
+
+ if (new_place_id == -1)
+ return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
return GEOFENCE_MANAGER_ERROR_NONE;
}
-GEOFENCE_MODULE_API int update_place(void *handle, int place_id, const char *place_name)
+EXPORT_API int update_place(void *handle, int place_id, const char *place_name)
{
MOD_LOGD("update_place");
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle;
- g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_EXCEPTION);
+ g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
- int ret = geo_client_update_place(geofence_manager->geofence_client, place_id, place_name);
+ int ret = geo_client_update_place(geofence_manager->geofence_client, geofence_manager->app_id, place_id, place_name);
if (ret != GEOFENCE_CLIENT_ERROR_NONE)
- return GEOFENCE_MANAGER_ERROR_EXCEPTION;
+ return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
return GEOFENCE_MANAGER_ERROR_NONE;
}
-GEOFENCE_MODULE_API int remove_geofence(void *handle, int fence_id)
+EXPORT_API int remove_geofence(void *handle, int fence_id)
{
MOD_LOGD("remove_geofence");
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle;
- g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_EXCEPTION);
+ g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
- int ret = geo_client_delete_geofence(geofence_manager->geofence_client, fence_id);
+ int ret = geo_client_delete_geofence(geofence_manager->geofence_client, geofence_manager->app_id, fence_id);
if (ret != GEOFENCE_CLIENT_ERROR_NONE)
- return GEOFENCE_MANAGER_ERROR_EXCEPTION;
+ return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
return GEOFENCE_MANAGER_ERROR_NONE;
}
-GEOFENCE_MODULE_API int remove_place(void *handle, int place_id)
+EXPORT_API int remove_place(void *handle, int place_id)
{
MOD_LOGD("remove_place");
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle;
- g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_EXCEPTION);
+ g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
- int ret = geo_client_delete_place(geofence_manager->geofence_client, place_id);
+ int ret = geo_client_delete_place(geofence_manager->geofence_client, geofence_manager->app_id, place_id);
if (ret != GEOFENCE_CLIENT_ERROR_NONE)
- return GEOFENCE_MANAGER_ERROR_EXCEPTION;
+ return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
return GEOFENCE_MANAGER_ERROR_NONE;
}
-GEOFENCE_MODULE_API int enable_service(void *handle, int fence_id, bool enable)
+EXPORT_API int enable_service(void *handle, int fence_id, bool enable)
{
MOD_LOGD("enable_service");
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle;
- g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_EXCEPTION);
+ g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
- int ret = geo_client_enable_service(geofence_manager->geofence_client, fence_id, enable);
+ int ret = geo_client_enable_geofence(geofence_manager->geofence_client, geofence_manager->app_id, fence_id, enable);
if (ret != GEOFENCE_CLIENT_ERROR_NONE)
- return GEOFENCE_MANAGER_ERROR_EXCEPTION;
+ return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
return GEOFENCE_MANAGER_ERROR_NONE;
}
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)user_data;
int fence_id, access_type, state;
char *app_id = NULL;
- pid_t pid = 0;
- char *appid_from_app = NULL;
- g_variant_get(param, "(siii)", &app_id, &fence_id, &access_type, &state);
- MOD_LOGI("Getting the app id");
- pid = getpid();
- int ret = app_manager_get_app_id(pid, &appid_from_app);
- if (ret != APP_MANAGER_ERROR_NONE) {
- MOD_LOGE("Fail to get app_id from module_geofence_server. Err[%d]", ret);
- return;
- }
- MOD_LOGI("APP ID from server : %s", app_id);
- MOD_LOGI("APP ID from app manager : %s", appid_from_app);
+ g_variant_get(param, "(siii)", &app_id, &fence_id, &access_type, &state);
if (access_type == ACCESS_TYPE_PRIVATE) {
- if (!(g_strcmp0(appid_from_app, app_id))) { /*Sending the alert only the app-id matches in case of private fence*/
+ if (!(g_strcmp0(geofence_manager->app_id, app_id))) { /*Sending the alert only the app-id matches in case of private fence*/
if (geofence_manager->geofence_cb)
geofence_manager->geofence_cb(fence_id, state, geofence_manager->userdata);
}
if (geofence_manager->geofence_cb) /*Here filteration is done in the manager as public fences cannot be restricted/filtered.*/
geofence_manager->geofence_cb(fence_id, state, geofence_manager->userdata);
}
- if (appid_from_app)
- g_free(appid_from_app);
- if (app_id)
- g_free(app_id);
}
static void geofence_event_callback(GVariant *param, void *user_data)
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)user_data;
int place_id, fence_id, access_type, error, state;
char *app_id = NULL;
- pid_t pid = 0;
- char *appid = NULL;
+
g_variant_get(param, "(iiisii)", &place_id, &fence_id, &access_type, &app_id, &error, &state);
- MOD_LOGI("Getting the app id");
- pid = getpid();
- int ret = app_manager_get_app_id(pid, &appid);
- if (ret != APP_MANAGER_ERROR_NONE) {
- MOD_LOGE("Fail to get app_id from module_geofence_server. Err[%d]", ret);
- return;
- }
- MOD_LOGI("APP ID from server : %s", app_id);
- MOD_LOGI("APP ID from app manager : %s", appid);
- MOD_LOGI("Fence_ID: %d, Error: %d, State: %d", fence_id, error, state);
- if (access_type == ACCESS_TYPE_PRIVATE) {
- if (!(g_strcmp0(appid, app_id))) {
- if (geofence_manager->geofence_event_cb)
- geofence_manager->geofence_event_cb(place_id, fence_id, error, state, geofence_manager->userdata);
- }
- } else if (access_type == ACCESS_TYPE_PUBLIC) {
- if (!g_strcmp0(app_id, MYPLACES_APP_ID) || !g_strcmp0(appid, app_id)) {
+ MOD_LOGD("place_id: %d, fence_id: %d, Error: %d, State: %d(0x%x", place_id, fence_id, error, state, state);
+ MOD_LOGD("app_id: %s", geofence_manager->app_id);
+
+ if (access_type == ACCESS_TYPE_PUBLIC) {
+ if (!g_strcmp0(app_id, MYPLACES_APP_ID) || !g_strcmp0(geofence_manager->app_id, app_id)) {
if (geofence_manager->geofence_event_cb)
geofence_manager->geofence_event_cb(place_id, fence_id, error, state, geofence_manager->userdata);
}
} else {
- if (!(g_strcmp0(appid, app_id))) {
+ if (!(g_strcmp0(geofence_manager->app_id, app_id))) {
if (geofence_manager->geofence_event_cb)
geofence_manager->geofence_event_cb(place_id, fence_id, error, state, geofence_manager->userdata);
}
}
- if (appid)
- g_free(appid);
- if (app_id)
- g_free(app_id);
}
-GEOFENCE_MODULE_API int get_place_name(void *handle, int place_id, char **place_name)
+EXPORT_API int get_place_name(void *handle, int place_id, char **place_name)
{
GeofenceManagerData *geofence_manager = (GeofenceManagerData *) handle;
- g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_EXCEPTION);
- g_return_val_if_fail(place_name, GEOFENCE_MANAGER_ERROR_EXCEPTION);
+ g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
+ g_return_val_if_fail(place_name, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
int error_code = GEOFENCE_MANAGER_ERROR_NONE;
- int ret = geo_client_get_place_name(geofence_manager->geofence_client, place_id, place_name, &error_code);
+ int ret = geo_client_get_place_name(geofence_manager->geofence_client, geofence_manager->app_id, place_id, place_name, &error_code);
if (ret != GEOFENCE_CLIENT_ERROR_NONE)
- return GEOFENCE_MANAGER_ERROR_EXCEPTION;
+ return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
return error_code;
}
-GEOFENCE_MODULE_API int get_list(void *handle, int place_id, int *fence_amount, int **fence_ids, struct geofence_params_s **params)
+EXPORT_API int get_geofences(void *handle, int place_id, int *fence_amount, int **fence_ids, geofence_s **params)
{
GeofenceManagerData *geofence_manager = (GeofenceManagerData *) handle;
- g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_EXCEPTION);
- g_return_val_if_fail(fence_amount, GEOFENCE_MANAGER_ERROR_EXCEPTION);
- g_return_val_if_fail(fence_ids, GEOFENCE_MANAGER_ERROR_EXCEPTION);
- g_return_val_if_fail(params, GEOFENCE_MANAGER_ERROR_EXCEPTION);
+ g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
+ g_return_val_if_fail(fence_amount, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
+ g_return_val_if_fail(fence_ids, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
+ g_return_val_if_fail(params, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
if (!geofence_manager) {
*fence_amount = 0;
int fence_cnt = 0;
int error_code = GEOFENCE_MANAGER_ERROR_NONE;
- /*Call the geofence_client api here....*/
- geo_client_get_list(geofence_manager->geofence_client, place_id, &iter, &fence_cnt, &error_code);
+ int ret = geo_client_get_geofences(geofence_manager->geofence_client, geofence_manager->app_id, place_id, &iter, &fence_cnt, &error_code);
if (error_code != GEOFENCE_MANAGER_ERROR_NONE)
return error_code;
+ else if (ret != GEOFENCE_MANAGER_ERROR_NONE)
+ return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
*fence_amount = fence_cnt;
- MOD_LOGI("Total fence count : %d", *fence_amount);
- int *fence_id_array = (int *) g_slice_alloc0(sizeof(int)*fence_cnt);
- geofence_params_s *p = (geofence_params_s *)g_slice_alloc0(sizeof(geofence_params_s)*fence_cnt);
+ MOD_LOGD("Total fence count : %d", *fence_amount);
+ int *fence_id_array = (int *) g_slice_alloc0(sizeof(int) * fence_cnt);
+ geofence_s *p = (geofence_s *) g_slice_alloc0(sizeof(geofence_s) * fence_cnt);
if (iter == NULL) {
MOD_LOGI("Iterator is null");
while (g_variant_iter_loop(iter_row, "{sv}", &key, &value)) {
if (!g_strcmp0(key, "fence_id")) {
fence_id_array[index] =
- g_variant_get_int32(value);
+ g_variant_get_int32(value);
} else if (!g_strcmp0(key, "place_id")) {
p[index].place_id = g_variant_get_int32(value);
} else if (!g_strcmp0(key, "geofence_type")) {
} else if (!g_strcmp0(key, "radius")) {
p[index].radius = g_variant_get_int32(value);
} else if (!g_strcmp0(key, "address")) {
- g_strlcpy(p[index].address, g_variant_get_string(value, NULL), _ADDRESS_LEN);
+ g_strlcpy(p[index].address, g_variant_get_string(value, NULL), ADDRESS_LEN);
} else if (!g_strcmp0(key, "bssid")) {
- g_strlcpy(p[index].bssid, g_variant_get_string(value, NULL), _WLAN_BSSID_LEN);
+ g_strlcpy(p[index].bssid, g_variant_get_string(value, NULL), WLAN_BSSID_LEN);
} else if (!g_strcmp0(key, "ssid")) {
- g_strlcpy(p[index].ssid, g_variant_get_string(value, NULL), _WLAN_BSSID_LEN);
+ g_strlcpy(p[index].ssid, g_variant_get_string(value, NULL), WLAN_BSSID_LEN);
}
}
MOD_LOGI("Fence_id: %d, Place_id: %d, Type: %d, lat: %f, lon: %f, rad: %d, address: %s, bssid: %s, ssid: %s", fence_id_array[index], p[index].place_id, p[index].type, p[index].latitude, p[index].longitude, p[index].radius, p[index].address, p[index].bssid, p[index].ssid);
g_variant_iter_free(iter_row);
}
g_variant_iter_free(iter);
- *params = (struct geofence_params_s *) p;
+ *params = (geofence_s *) p;
*fence_ids = fence_id_array;
return GEOFENCE_MANAGER_ERROR_NONE;
}
-GEOFENCE_MODULE_API int get_place_list(void *handle, int *place_amount, int **place_ids, struct place_params_s **params)
+EXPORT_API int get_places(void *handle, int *place_amount, int **place_ids, place_s **params)
{
GeofenceManagerData *geofence_manager = (GeofenceManagerData *) handle;
- g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_EXCEPTION);
- g_return_val_if_fail(place_amount, GEOFENCE_MANAGER_ERROR_EXCEPTION);
- g_return_val_if_fail(place_ids, GEOFENCE_MANAGER_ERROR_EXCEPTION);
- g_return_val_if_fail(params, GEOFENCE_MANAGER_ERROR_EXCEPTION);
+ g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
+ g_return_val_if_fail(place_amount, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
+ g_return_val_if_fail(place_ids, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
+ g_return_val_if_fail(params, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
if (!geofence_manager) {
*place_amount = 0;
int error_code = -1;
/*Call the geofence_client api here....*/
- geo_client_get_place_list(geofence_manager->geofence_client, &iter, &place_cnt, &error_code);
+ geo_client_get_places(geofence_manager->geofence_client, geofence_manager->app_id, &iter, &place_cnt, &error_code);
if (error_code != GEOFENCE_MANAGER_ERROR_NONE)
return error_code;
*place_amount = place_cnt;
MOD_LOGI("Total place count : %d", *place_amount);
- int *place_id_array = (int *)g_slice_alloc0(sizeof(int)*place_cnt);
- place_params_s *p = (place_params_s *)g_slice_alloc0(sizeof(place_params_s)*place_cnt);
+ int *place_id_array = (int *)g_slice_alloc0(sizeof(int) * place_cnt);
+ place_s *p = (place_s *)g_slice_alloc0(sizeof(place_s) * place_cnt);
if (iter == NULL)
MOD_LOGI("Iterator is null");
if (!g_strcmp0(key, "place_id")) {
place_id_array[index] = g_variant_get_int32(value);
} else if (!g_strcmp0(key, "place_name")) {
- g_strlcpy(p[index].place_name, g_variant_get_string(value, NULL), _PLACE_NAME_LEN);
+ g_strlcpy(p[index].place_name, g_variant_get_string(value, NULL), PLACE_NAME_LEN);
}
}
MOD_LOGI("place_id: %d, place_name: %s", place_id_array[index], p[index].place_name);
g_variant_iter_free(iter_row);
}
g_variant_iter_free(iter);
- *params = (struct place_params_s *) p;
+ *params = (place_s *)p;
+
*place_ids = place_id_array;
return GEOFENCE_MANAGER_ERROR_NONE;
}
}
-GEOFENCE_MODULE_API int start_geofence(void *handle, int fence_id)
+EXPORT_API int start_geofence(void *handle, int fence_id)
{
MOD_LOGD("start_geofence");
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle;
MOD_LOGD("geofence-server(%x)", geofence_manager);
- ret = geo_client_start_geofence(geofence_manager->geofence_client, fence_id);
+ ret = geo_client_start_geofence(geofence_manager->geofence_client, geofence_manager->app_id, fence_id);
if (ret != GEOFENCE_MANAGER_ERROR_NONE) {
MOD_LOGE("Fail to start geofence_client_h. Error[%d]", ret);
- return GEOFENCE_MANAGER_ERROR_EXCEPTION;
+ return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
}
return GEOFENCE_MANAGER_ERROR_NONE;
}
-GEOFENCE_MODULE_API int stop_geofence(void *handle, int fence_id)
+EXPORT_API int stop_geofence(void *handle, int fence_id)
{
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle;
MOD_LOGD("geofence_manager->geofence_cb : %x", geofence_manager->geofence_cb);
- g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_EXCEPTION);
- g_return_val_if_fail(geofence_manager->geofence_client, GEOFENCE_MANAGER_ERROR_EXCEPTION);
+ g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
+ g_return_val_if_fail(geofence_manager->geofence_client, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
int ret = GEOFENCE_CLIENT_ERROR_NONE;
- ret = geo_client_stop_geofence(geofence_manager->geofence_client, fence_id);
+ ret = geo_client_stop_geofence(geofence_manager->geofence_client, geofence_manager->app_id, fence_id);
if (ret != GEOFENCE_MANAGER_ERROR_NONE) {
MOD_LOGE("Fail to stop. Error[%d]", ret);
- return GEOFENCE_MANAGER_ERROR_EXCEPTION;
+ return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
}
return GEOFENCE_MANAGER_ERROR_NONE;
}
-GEOFENCE_MODULE_API int create(void *handle, GeofenceModCB geofence_cb,
- GeofenceModEventCB geofence_event_cb, void *userdata)
+EXPORT_API int create(void *handle, GeofenceModCB geofence_cb,
+ GeofenceModEventCB geofence_event_cb, void *userdata)
{
GeofenceManagerData *geofence_manager = (GeofenceManagerData *) handle;
- g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_EXCEPTION);
- g_return_val_if_fail(geofence_cb, GEOFENCE_MANAGER_ERROR_EXCEPTION);
+ g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
+ g_return_val_if_fail(geofence_cb, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
/* create connnection */
int ret = GEOFENCE_MANAGER_ERROR_NONE;
ret = geo_client_create(&(geofence_manager->geofence_client));
if (ret != GEOFENCE_CLIENT_ERROR_NONE || !geofence_manager->geofence_client) {
MOD_LOGE("Fail to create geofence_client_dbus_h. Error[%d]", ret);
- return GEOFENCE_MANAGER_ERROR_EXCEPTION;
+ return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
}
- ret = geo_client_start(GEOFENCE_SERVER_SERVICE_NAME, GEOFENCE_SERVER_SERVICE_PATH, geofence_manager->geofence_client, on_signal_callback, on_signal_callback, geofence_manager);
+ MOD_LOGD("geofence_manager->geofence_client: %p", geofence_manager->geofence_client);
+ ret = geo_client_start(geofence_manager->geofence_client, on_signal_callback, geofence_manager);
+#if 0
+ ret = geo_client_start(geofence_manager->geofence_client, on_signal_callback, geofence_manager);
+#endif
+
if (ret != GEOFENCE_CLIENT_ERROR_NONE) {
if (ret == GEOFENCE_CLIENT_ACCESS_DENIED) {
MOD_LOGE("Access denied[%d]", ret);
geo_client_destroy(geofence_manager->geofence_client);
geofence_manager->geofence_client = NULL;
- return GEOFENCE_CLIENT_ERROR_UNKNOWN;
+ return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
}
return GEOFENCE_MANAGER_ERROR_NONE;
}
-GEOFENCE_MODULE_API int destroy(void *handle)
+EXPORT_API int destroy(void *handle)
{
MOD_LOGD("destroy");
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle;
- g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_EXCEPTION);
- g_return_val_if_fail(geofence_manager->geofence_client, GEOFENCE_MANAGER_ERROR_EXCEPTION);
+ g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
+ g_return_val_if_fail(geofence_manager->geofence_client, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
int ret = GEOFENCE_MANAGER_ERROR_NONE;
MOD_LOGE("Fail to stop. Error[%d]", ret);
geo_client_destroy(geofence_manager->geofence_client);
geofence_manager->geofence_client = NULL;
- return GEOFENCE_CLIENT_ERROR_UNKNOWN;
+ return GEOFENCE_MANAGER_ERROR_IPC;
}
ret = geo_client_destroy(geofence_manager->geofence_client);
if (ret != GEOFENCE_CLIENT_ERROR_NONE) {
MOD_LOGE("Fail to destroy. Error[%d]", ret);
- return GEOFENCE_CLIENT_ERROR_UNKNOWN;
+ return GEOFENCE_MANAGER_ERROR_IPC;
}
geofence_manager->geofence_client = NULL;
geofence_manager->geofence_cb = NULL;
return GEOFENCE_MANAGER_ERROR_NONE;
}
-GEOFENCE_MODULE_API gpointer init(GeofenceModOps *ops)
+static void __get_caller_app_id(void *handle)
+{
+ GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle;
+ g_return_if_fail(geofence_manager);
+
+ gchar *app_id = NULL;
+ int ret = 0;
+
+ pid_t pid = 0;
+ pid = getpid();
+ ret = app_manager_get_app_id(pid, &app_id);
+ if (ret != APP_MANAGER_ERROR_NONE) {
+ MOD_LOGE("Fail to get app_id from module_geofence_server. Err[%d]", ret);
+ } else {
+ MOD_LOGD("app_id: %s", app_id);
+ geofence_manager->app_id = app_id;
+ }
+}
+
+EXPORT_API gpointer init(GeofenceModOps *ops)
{
MOD_LOGD("init");
ops->stop_geofence = stop_geofence;
ops->add_geopoint = add_geopoint;
ops->add_bssid = add_bssid;
+ ops->remove_geofence = remove_geofence;
+ ops->get_geofences = get_geofences;
+
ops->add_place = add_place;
ops->update_place = update_place;
- ops->remove_geofence = remove_geofence;
ops->remove_place = remove_place;
ops->get_place_name = get_place_name;
- ops->get_list = get_list;
- ops->get_place_list = get_place_list;
+ ops->get_places = get_places;
GeofenceManagerData *geofence_manager = g_new0(GeofenceManagerData, 1);
g_return_val_if_fail(geofence_manager, NULL);
geofence_manager->geofence_event_cb = NULL;
geofence_manager->userdata = NULL;
+ __get_caller_app_id(geofence_manager);
+
return (gpointer) geofence_manager;
}
-GEOFENCE_MODULE_API void shutdown(gpointer handle)
+EXPORT_API void shutdown(gpointer handle)
{
MOD_LOGD("shutdown");
g_return_if_fail(handle);
}
geofence_manager->geofence_cb = NULL;
-
+ g_free(geofence_manager->app_id);
g_free(geofence_manager);
geofence_manager = NULL;
}
+++ /dev/null
-/* Copyright 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 <stdbool.h>
-#include "module_internal.h"
-#include "log.h"
-
-/** Length of bssid */
-#define WLAN_BSSID_LEN 18
-#define APP_ID_LEN 64
-#define FENCE_NAME_LEN 64
-
-#define GEOFENCE_DEFAULT_RADIUS 200 /* Default 200 m */
-
-/*
-* TODO: after transiting geofence-server package on CMake build following structures must be elliminated,
-* because they are copying existing structures in a sub-folder geofence-server
-*/
-
-/**
- * This enumeration describe the cell geofence in and out status.
- */
-typedef enum {
- CELL_UNKNOWN = -1,
- CELL_OUT = 0,
- CELL_IN = 1
-} cell_status_e;
-
-/**
- * This enumeration descript the geofence fence state.
- */
-typedef enum {
- GEOFENCE_FENCE_STATE_UNCERTAIN = -1,
- GEOFENCE_FENCE_STATE_OUT = 0,
- GEOFENCE_FENCE_STATE_IN = 1,
-} geofence_fence_state_e;
-
-/**
- * The geofence common information structure
- */
-typedef struct {
- int fence_id;
- geofence_fence_state_e status;
- geofence_manager_type_e type; /* Geocoordinate/WIFI/CurrentLocation/Bluetooth */
- char fence_name[FENCE_NAME_LEN];
- char appid[APP_ID_LEN];
- int smart_assist_id;
- gboolean cell_db;
- time_t last_update;
-} fence_common_info_s;
-
-/**
- *The geocoordinate structure
- */
-typedef struct {
- double latitude;
- double longitude;
- double radius;
-} geocoordinate_info_s;
-
-/**
- *The wifi info structure
- */
-typedef struct {
- char bssid[WLAN_BSSID_LEN];
-} wifi_info_s;
-
-/**
- *The bluetooth info structure
- */
-typedef struct {
- char bssid[WLAN_BSSID_LEN];
- gboolean enabled; /* bluetooth callback receive or not */
-} bssid_info_s;
-
-typedef enum {
- GEOFENCE_CLIENT_STATUS_NONE,
- GEOFENCE_CLIENT_STATUS_FIRST_LOCATION,
- GEOFENCE_CLIENT_STATUS_START,
- GEOFENCE_CLIENT_STATUS_RUNNING
-} geofence_client_status_e;
-
-/**
- *The GeofenceItemData structure
- */
-typedef struct {
- double distance;
-#ifdef __WIFI_DB_SUPPORTED__
- int wifi_db_set;
- wifi_status_e wifi_direction;
- wifi_status_e priv_wifi_direction;
-#endif
- geofence_client_status_e client_status;
- cell_status_e cell_status;
- fence_common_info_s common_info;
- void *priv; /* Save (latitude, longitude and radius) or AP list */
-
- bool is_wifi_status_in;
- bool is_bt_status_in;
-} GeofenceItemData;
-
-static gint __find_custom_item_by_fence_id(gconstpointer data, gconstpointer compare_with)
-{
- g_return_val_if_fail(data, 1);
- g_return_val_if_fail(compare_with, -1);
- int ret = -1;
-
- GeofenceItemData *item_data = (GeofenceItemData *) data;
- int *fence_id = (int *) compare_with;
- if (item_data->common_info.fence_id == *fence_id) {
- ret = 0;
- }
-
- return ret;
-}
-
-GeofenceItemData *__get_item_by_fence_id(gint fence_id, GList *geofence_list)
-{
- g_return_val_if_fail(geofence_list, NULL);
-
- geofence_list = g_list_first(geofence_list);
- GList *found_item = NULL;
- found_item = g_list_find_custom(geofence_list, &fence_id, __find_custom_item_by_fence_id);
- if (found_item == NULL || found_item->data == NULL) {
- MOD_LOGD("item_data is not found. found_item[%d]", found_item);
- return NULL;
- }
-
- /*Get the item from the list and return it*/
- return (GeofenceItemData *) found_item->data;
-}
+++ /dev/null
-/* Copyright 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 __GEOFENCE_MANAGER_PRIVATE_ITEM_DATA_H__
-#define __GEOFENCE_MANAGER_PRIVATE_ITEM_DATA_H__
-
-#include <glib.h>
-#include <tizen_type.h>
-#include <tizen_error.h>
-#include "geofence-module.h"
-
-typedef enum {
- GEOFENCE_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Success */
- GEOFENCE_MANAGER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- GEOFENCE_MANAGER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
- GEOFENCE_MANAGER_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
- GEOFENCE_MANAGER_ERROR_NOT_INITIALIZED = TIZEN_ERROR_GEOFENCE_MANAGER | 0x01, /**< Geofence Manager is not initialized */
- GEOFENCE_MANAGER_ERROR_INVALID_ID = TIZEN_ERROR_GEOFENCE_MANAGER | 0x02, /**< Geofence ID is not exist */
- GEOFENCE_MANAGER_ERROR_EXCEPTION = TIZEN_ERROR_GEOFENCE_MANAGER | 0x03, /**< exception is occured */
- GEOFENCE_MANAGER_ERROR_ALREADY_STARTED = TIZEN_ERROR_GEOFENCE_MANAGER | 0x04, /**< Geofence is already started */
- GEOFENCE_MANAGER_ERROR_TOO_MANY_GEOFENCE = TIZEN_ERROR_GEOFENCE_MANAGER | 0x05, /**< Too many Geofence */
- GEOFENCE_MANAGER_ERROR_IPC = TIZEN_ERROR_GEOFENCE_MANAGER | 0x06, /**< Error occured in GPS/WIFI/BT */
- GEOFENCE_MANAGER_ERROR_DATABASE = TIZEN_ERROR_GEOFENCE_MANAGER | 0x07, /**< DB error occured in the server side */
- GEOFENCE_MANAGER_ERROR_PLACE_ACCESS_DENIED = TIZEN_ERROR_GEOFENCE_MANAGER | 0x08, /**< Access to specified place is denied */
- GEOFENCE_MANAGER_ERROR_GEOFENCE_ACCESS_DENIED = TIZEN_ERROR_GEOFENCE_MANAGER | 0x09, /**< Access to specified geofence is denied */
-} geofence_manager_error_e;
-
-typedef enum {
- GEOFENCE_MANAGER_TYPE_GEOPOINT = 1,
- GEOFENCE_MANAGER_TYPE_WIFI,
- GEOFENCE_MANAGER_TYPE_BT,
-} geofence_manager_type_e;
-
-typedef enum {
- GEOFENCE_MANAGER_ACCESS_TYPE_PRIVATE = 1,
- GEOFENCE_MANAGER_ACCESS_TYPE_PUBLIC,
- GEOFENCE_MANAGER_ACCESS_TYPE_UNKNOWN,
-} geofence_manager_access_type_e;
-
-typedef enum {
- GEOFENCE_STATE_UNCERTAIN = 0,
- GEOFENCE_STATE_IN,
- GEOFENCE_STATE_OUT,
-} geofence_state_e;
-
-#define _WLAN_BSSID_LEN 18
-#define _PLACE_NAME_LEN 64
-#define _ADDRESS_LEN 64
-#define _APP_ID_LEN 64
-
-typedef struct {
- geofence_manager_type_e type;
- double latitude;
- double longitude;
- int radius;
- char address[_ADDRESS_LEN];
- char bssid[_WLAN_BSSID_LEN];
- char ssid[_WLAN_BSSID_LEN];
- int place_id;
-} geofence_params_s;
-
-typedef struct {
- char place_name[_PLACE_NAME_LEN];
-} place_params_s;
-
-typedef struct {
- geofence_state_e state;
- int seconds;
-} geofence_status_s;
-
-/* This can be substituted to GeofenceData*/
-typedef struct _geofence_info_s {
- int fence_id;
- geofence_params_s param;
-} geofence_info_s;
-
-typedef struct _place_info_s {
- int place_id;
- place_params_s param;
-} place_info_s;
-
-int geofence_item_data_get_fence_id(gpointer data, int *fence_id);
-int geofence_item_data_get_params(gpointer data, geofence_params_s *p);
-int geofence_item_data_get_fence_status(gpointer data, geofence_status_s *s);
-int add_fence_to_list(int fence_id, const char *fence_name, const double latitude, const double longitude, int radius, const char *bssid, geofence_type_e geofence_type, GList **geofence_list);
-void remove_fence_from_list(int fence_id, GList **geofence_list);
-void update_fence_state(int fence_id, geofence_state_e state, GList *geofence_list);
-
-#endif /* __GEOFENCE_MANAGER_PRIVATE_ITEM_DATA_H__ */
Name: geofence-server
Summary: Geofence Server for Tizen
-Version: 0.3.9
+Version: 0.4.0
Release: 1
Group: Location/Service
License: Apache-2.0
BuildRequires: cmake
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(network)
-#BuildRequires: pkgconfig(tapi)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(geofence-dbus)
BuildRequires: pkgconfig(vconf-internal-keys)
BuildRequires: pkgconfig(capi-appfw-app-manager)
BuildRequires: pkgconfig(capi-location-manager)
-#BuildRequires: pkgconfig(capi-geofence-manager)
-#BuildRequires: pkgconfig(capi-telephony-network-info)
-BuildRequires: pkgconfig(capi-network-wifi)
-BuildRequires: pkgconfig(capi-network-bluetooth)
-#BuildRequires: pkgconfig(capi-context-manager)
-BuildRequires: pkgconfig(secure-storage)
-BuildRequires: pkgconfig(libcore-context-manager)
+BuildRequires: pkgconfig(capi-network-wifi)
+BuildRequires: pkgconfig(capi-network-bluetooth)
+BuildRequires: pkgconfig(secure-storage)
+BuildRequires: pkgconfig(libcore-context-manager)
+#BuildRequires: pkgconfig(tapi)
+#BuildRequires: pkgconfig(capi-telephony-network-info)
+#BuildRequires: pkgconfig(capi-context-manager)
+BuildRequires: pkgconfig(capi-geofence-manager)
+BuildRequires: capi-geofence-manager-plugin-devel
Requires: sys-assert
%description
Geofence Server for Tizen
-%package -n location-geofence-server
-Summary: Geofence Server for Tizen
-Group: Location/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description -n location-geofence-server
-Geofence Server for Tizen
-
-%package -n geofence-server-devel
-Summary: Geofence Server for Tizen (Development)
-Group: Location/Development
-Requires: %{name} = %{version}-%{release}
-
-%description -n geofence-server-devel
-Geofence Server for Tizen (Development)
%prep
%setup -q
/opt/dbspace/.*.db*
%config %{_sysconfdir}/dbus-1/system.d/geofence-server.conf
+%package -n location-geofence-server
+Summary: Geofence Server for Tizen
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description -n location-geofence-server
+Geofence Server for Tizen
+
+%post -n location-geofence-server
+/sbin/ldconfig
+
+%postun -n location-geofence-server
+/sbin/ldconfig
+
%files -n location-geofence-server
%manifest location-geofence-server.manifest
%{_libdir}/geofence/module/libgeofence.so*