const char *wps_feature = "http://tizen.org/feature/location.wps";
bool is_wps_supported = false;
system_info_get_platform_bool(wps_feature, &is_wps_supported);
- if (is_wps_supported == true) {
+ if (is_wps_supported == true)
location_manager_is_enabled_method(LOCATIONS_METHOD_WPS, &is_wps_supported);
- }
return is_wps_supported;
}
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";
}
}
LOGD_GEOFENCE("Scanning for BLE and read DB");
g_stpcpy(geofence_server->ble_info, "");
ret = bt_adapter_le_start_scan(bt_le_scan_result_display_cb, geofence_server);
- if (ret != BT_ERROR_NONE) {
+ if (ret != BT_ERROR_NONE)
LOGE_GEOFENCE("Fail to start ble scan. %d", ret);
- }
+
}
} else if (state == DISPLAY_STATE_SCREEN_DIM)
LOGI_GEOFENCE("State: DIM");
/*LOGD_GEOFENCE("FENCE_IN to be set, current state: %d", 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) {
+ if (item_data->client_status == GEOFENCE_CLIENT_STATUS_START)
item_data->client_status = GEOFENCE_CLIENT_STATUS_RUNNING;
- }
+
LOGD_GEOFENCE("%d : FENCE_IN", fence_id);
#ifdef TIZEN_ENGINEER_MODE
GEOFENCE_PRINT_LOG("FENCE_IN");
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);
__emit_fence_proximity(geofence_server, fence_id, GEOFENCE_PROXIMITY_UNCERTAIN);
- if (item_data->client_status == GEOFENCE_CLIENT_STATUS_START) {
+ if (item_data->client_status == GEOFENCE_CLIENT_STATUS_START)
item_data->client_status = GEOFENCE_CLIENT_STATUS_RUNNING;
- }
+
LOGD_GEOFENCE("%d : FENCE_OUT", fence_id);
#ifdef TIZEN_ENGINEER_MODE
GEOFENCE_PRINT_LOG("FENCE_OUT");
geofence_proximity_provider_e provider = GEOFENCE_PROXIMITY_PROVIDER_LOCATION;
GeofenceItemData *item_data = __get_item_by_fence_id(fence_id, geofence_server);
if (item_data) {
- if (item_data->common_info.type == GEOFENCE_TYPE_WIFI) {
+ if (item_data->common_info.type == GEOFENCE_TYPE_WIFI)
provider = GEOFENCE_PROXIMITY_PROVIDER_WIFI;
- } else if (item_data->common_info.type == GEOFENCE_TYPE_BT) {
+ else if (item_data->common_info.type == GEOFENCE_TYPE_BT)
provider = GEOFENCE_PROXIMITY_PROVIDER_BLUETOOTH;
- }
+
geofence_dbus_server_send_geofence_proximity_changed(geofence_server->geofence_dbus_server, item_data->common_info.appid, fence_id, item_data->common_info.access_type, state, provider);
item_data->common_info.proximity_status = state;
} else {
int ret = BT_ERROR_NONE;
geofence_proximity_state_e state = GEOFENCE_PROXIMITY_UNCERTAIN;
GeofenceServer *geofence_server = (GeofenceServer *) user_data;
- if (distance <= 50.0) {
+ if (distance <= 50.0)
state = GEOFENCE_PROXIMITY_IMMEDIATE;
- } else if (distance > 50.0 && distance <= 100.0) {
+ else if (distance > 50.0 && distance <= 100.0)
state = GEOFENCE_PROXIMITY_NEAR;
- } else if (distance > 100.0 && distance <= radius) {
+ else if (distance > 100.0 && distance <= radius)
state = GEOFENCE_PROXIMITY_FAR;
- }
+
if (current_state != state) {
LOGD_GEOFENCE("PROXIMITY ALERTING for fence: %d, alert: %d, distance: %f", fence_id, state, distance);
__emit_fence_proximity(geofence_server, fence_id, state);
LOGD_GEOFENCE("Scanning for BLE and storing in DB");
g_stpcpy(geofence_server->ble_info, "");
ret = bt_adapter_le_start_scan(bt_le_scan_result_cb, geofence_server);
- if (ret != BT_ERROR_NONE) {
+ if (ret != BT_ERROR_NONE)
LOGE_GEOFENCE("Fail to start ble scan. %d", ret);
- }
} else if (current_state == GEOFENCE_PROXIMITY_IMMEDIATE) { /* Stopping the scan if state changes */
ret = bt_adapter_le_stop_scan();
if (ret != BT_ERROR_NONE)
__check_proximity_for_fence(distance, item_data->common_info.fence_id, geocoordinate_info->radius, item_data->common_info.proximity_status, geofence_server);
/*}*/
- if (__emit_fence_inout(geofence_server, item_data->common_info.fence_id, status) == 0 && status == GEOFENCE_FENCE_STATE_IN) {
+ if (__emit_fence_inout(geofence_server, item_data->common_info.fence_id, status) == 0 && status == GEOFENCE_FENCE_STATE_IN)
LOGD_GEOFENCE("Disable timer");
- }
}
static void __stop_gps_alarms(void *user_data)
int ret = 0;
if (geofence_server->loc_gps_started == TRUE) {
ret = location_manager_stop(geofence_server->loc_gps_manager);
- if (ret != LOCATIONS_ERROR_NONE) {
+ if (ret != LOCATIONS_ERROR_NONE)
return;
- }
geofence_server->loc_gps_started = FALSE;
ret = location_manager_unset_position_updated_cb(geofence_server->loc_gps_manager);
- if (ret != LOCATIONS_ERROR_NONE) {
+ if (ret != LOCATIONS_ERROR_NONE)
return;
- }
}
if (geofence_server->loc_gps_manager != NULL) {
ret = location_manager_destroy(geofence_server->loc_gps_manager);
- if (ret != LOCATIONS_ERROR_NONE) {
+ if (ret != LOCATIONS_ERROR_NONE)
return;
- }
geofence_server->loc_gps_manager = NULL;
}
}
int gpsdiff = 0;
int wpsdiff = 0;
-
+
/* Check if any of the fix is null just return. It doesn't make sense to compare if only one fix is available*/
if (geofence_server->gps_fix_info == NULL || geofence_server->wps_fix_info == NULL)
return;
int ret = LOCATIONS_ERROR_NONE;
/* Allocate memory for the location_info structure */
- if (geofence_server->gps_fix_info == NULL) {
+ if (geofence_server->gps_fix_info == NULL)
geofence_server->gps_fix_info = (location_fix_info_s *)g_malloc(sizeof(location_fix_info_s));
- }
+
/* Store the location information in the structure for future use*/
if (geofence_server->gps_fix_info != NULL) {
geofence_server->gps_fix_info->latitude = latitude;
}
/* Allocate memory for the location_info structure */
- if (geofence_server->gps_fix_info == NULL) {
+ if (geofence_server->gps_fix_info == NULL)
geofence_server->gps_fix_info = (location_fix_info_s *)g_malloc(sizeof(location_fix_info_s));
- }
/* Store the location information in the structure for future use*/
if (geofence_server->gps_fix_info != NULL) {
} else {
LOGD_GEOFENCE("Invalid GPS fix data");
return;
- }
+ }
geofence_server->last_loc_time = timestamp;
if (geofence_server->wps_fix_info && __get_time_diff(geofence_server->wps_fix_info->timestamp) <= 20 && geofence_server->gps_fix_info->accuracy <= 50.0) {
int interval = 0;
/* Allocate memory for the location_info structure */
- if (geofence_server->wps_fix_info == NULL) {
+ if (geofence_server->wps_fix_info == NULL)
geofence_server->wps_fix_info = (location_fix_info_s *)g_malloc(sizeof(location_fix_info_s));
- }
/*Remove the timeout callback that might be running when requesting for fix.*/
if (geofence_server->wps_timeout_alarm_id != -1) {
/*LOGI_GEOFENCE("Removing the timeout alarm from restart gps");*/
return;/* There is no valid fence with this fence id. So return*/
geocoordinate_info_s *geocoordinate_info = (geocoordinate_info_s *)item_data->priv;
-
+
double interval_dist = (min_distance - geocoordinate_info->radius) - geofence_server->wps_fix_info->accuracy;
LOGI_GEOFENCE("Distance for interval: %f", interval_dist);
- if (interval_dist < 15000) {
+ if (interval_dist < 15000)
interval = interval_dist/25; /*secs*/ /*Assuming 90 km/hr of speed - So 25 mtrs covered in 1 sec*/
- } else if (interval_dist >= 15000 && interval_dist < 18000) {
+ else if (interval_dist >= 15000 && interval_dist < 18000)
interval = 10 * 60; /* 10 mins */
- } else if (interval_dist >= 18000 && interval_dist < 20000) {
+ else if (interval_dist >= 18000 && interval_dist < 20000)
interval = 12 * 60; /* 12 mins */
- } else if (interval_dist >= 20000) {
+ else if (interval_dist >= 20000)
interval = 15 * 60; /*15 mins*/
- }
if (interval < 15)
interval = 15; /*15 sec */
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_BT) {
- if (item_data->is_bt_status_in == true) {
+ if (item_data->is_bt_status_in == true)
__emit_fence_inout(geofence_server, item_data->common_info.fence_id, GEOFENCE_FENCE_STATE_IN);
- } else {
+ else
__emit_fence_inout(geofence_server, item_data->common_info.fence_id, GEOFENCE_FENCE_STATE_OUT);
- }
item_data->is_bt_status_in = false;
}
}
LOGI_GEOFENCE("rssi: %d is_bonded: %d", discovery_info->rssi, discovery_info->is_bonded);
if (geofence_server->running_bt_cnt > 0) {
- for (i = 0; i < discovery_info->service_count; i++) {
+ for (i = 0; i < discovery_info->service_count; i++)
LOGI_GEOFENCE("uuid: %s", discovery_info->service_uuid[i]);
- }
LOGI_GEOFENCE("Tracking list is being checked for the BT geofence");
__check_tracking_list(discovery_info->remote_address, geofence_server, GEOFENCE_TYPE_BT);
}
}
if (gps_state == 1) {
ret = __start_gps_positioning(geofence_server, __geofence_standalone_gps_position_changed_cb);
- if (ret != FENCE_ERR_NONE) {
+ if (ret != FENCE_ERR_NONE)
LOGE_GEOFENCE("Fail to start standalone gps positioning. Error[%d]", ret);
- }
}
} else {
if (__isDataConnected() == true) {/*&& wps_state == 1) {*/
__stop_gps_alarms(geofence_server);
/**** Start the WPS as mobile data is connected and wifi and wps are on *******/
ret = __start_wps_positioning(geofence_server, __geofence_wps_position_changed_cb);
- if (ret != FENCE_ERR_NONE) {
+ if (ret != FENCE_ERR_NONE)
LOGE_GEOFENCE("Fail to start wps positioning. Error[%d]", ret);
- }
}
}
}
if (geofence_server->loc_gps_started_by_wps == false && geofence_server->loc_gps_started == true) {
__stop_gps_positioning(geofence_server); /*GPS should be stopped only if it is running standalone*/
__stop_gps_alarms(geofence_server);
- }
+ }
ret = __start_wps_positioning(geofence_server, __geofence_wps_position_changed_cb);
- if (ret != FENCE_ERR_NONE) {
+ if (ret != FENCE_ERR_NONE)
LOGE_GEOFENCE("Fail to start wps positioning. Error[%d]", ret);
- }
}
break;
case NET_EVENT_CLOSE_IND:
geofence_server->loc_gps_started_by_wps = false;
}
ret = __start_gps_positioning(geofence_server, __geofence_standalone_gps_position_changed_cb);
- if (ret != FENCE_ERR_NONE) {
+ if (ret != FENCE_ERR_NONE)
LOGE_GEOFENCE("Fail to start standalone gps positioning. Error[%d]", ret);
- }
}
break;
default:
geofence_server->gps_timeout_alarm_id = -1; /*resetting the alarm id*/
/*Stop the gps for sometime when there is no fix*/
__stop_gps_positioning(geofence_server);
- if (geofence_server->loc_gps_started_by_wps == FALSE) {
+ if (geofence_server->loc_gps_started_by_wps == FALSE)
geofence_server->gps_alarm_id = _geofence_add_alarm(1 * 60, __gps_alarm_cb, geofence_server);
- } else {
+ else
geofence_server->loc_gps_started_by_wps = FALSE;
- }
return 0;
}
}
if (geofence_server->loc_gps_started_by_wps == true) {
ret = __start_gps_positioning(geofence_server, __geofence_gps_position_changed_cb);
- if (ret != FENCE_ERR_NONE) {
+ if (ret != FENCE_ERR_NONE)
LOGE_GEOFENCE("Fail to start gps positioning. Error[%d]", ret);
- }
} else {
ret = __start_gps_positioning(geofence_server, __geofence_standalone_gps_position_changed_cb);
- if (ret != FENCE_ERR_NONE) {
+ if (ret != FENCE_ERR_NONE)
LOGE_GEOFENCE("Fail to start standalone gps positioning. Error[%d]", ret);
- }
}
return 0;
}
}
if (__is_support_wps() == true && __isWifiOn() == true && __isDataConnected() == true) {
ret = __start_wps_positioning(geofence_server, __geofence_wps_position_changed_cb);
- if (ret != FENCE_ERR_NONE) {
+ if (ret != FENCE_ERR_NONE)
LOGE_GEOFENCE("Fail to start wps positioning. Error[%d]", ret);
- }
} else {
ret = __start_gps_positioning(geofence_server, __geofence_standalone_gps_position_changed_cb);
- if (ret != FENCE_ERR_NONE) {
+ if (ret != FENCE_ERR_NONE)
LOGE_GEOFENCE("Fail to start standalone gps positioning. Error[%d]", ret);
- }
}
return 0;
}
-static void gps_setting_changed_cb(location_method_e method, bool enable,
- void *user_data)
+static void gps_setting_changed_cb(location_method_e method, bool enable, void *user_data)
{
FUNC_ENTRANCE_SERVER;
GeofenceServer *geofence_server = (GeofenceServer *) user_data;
}
}
}
- if (geofence_server->loc_gps_started_by_wps == true) {
+ if (geofence_server->loc_gps_started_by_wps == true)
geofence_server->loc_gps_started_by_wps = false; /*So that WPS will use GPS if needed in its next fix(wps fix)*/
- }
} else if (enable == true && geofence_server->running_geopoint_cnt > 0) {
if (method == LOCATIONS_METHOD_GPS) {
geofence_server->loc_gps_started_by_wps = false; /* So that WPS will use GPS if needed in its next fix(wps fix) */
GList *tmp_fence_list = g_list_first(geofence_server->geofence_list);
while (tmp_fence_list) {
GeofenceItemData *tmp_data = (GeofenceItemData *)tmp_fence_list->data;
- if (tmp_data) {
+ if (tmp_data)
g_free(tmp_data);
- }
tmp_fence_list = g_list_next(tmp_fence_list);
}
geofence_server->geofence_list = NULL;
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) {
+ 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 {
+ 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);
} 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--;
{
int network_state = -1;
vconf_get_int(VCONFKEY_WIFI_STATE, &network_state);
- if (network_state == 0)
- return false;
+ if (network_state == 0)
+ return false;
return true;
}
if (network_state == VCONFKEY_NETWORK_CELLULAR_ON) {
rv = vconf_get_int(VCONFKEY_DNET_STATE, &data_state);
if (data_state == VCONFKEY_DNET_NORMAL_CONNECTED) {
- LOGI_GEOFENCE("USING MOBILE DATA");
- isDataConnected = true;
+ LOGI_GEOFENCE("USING MOBILE DATA");
+ isDataConnected = true;
}
}
}
}
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)
+ 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;
ret = __check_place_permission(place_id, app_id);
if (ret != 1) {
LOGE("Unable to add the fence. Permission denied or DB error occured while accessing the place[%d]", place_id);
- if (ret == 0) {
+ 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_ADDED);
- } else {
+ else
__emit_fence_event(geofence_server, place_id, fence_id, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_DATABASE, GEOFENCE_MANAGE_FENCE_ADDED);
- }
return -1;
}
/* create GeofenceItemData item, and append it into geofence_list*/
item_data->client_status = GEOFENCE_CLIENT_STATUS_NONE;
item_data->common_info.type = geofence_type;
/*fences added by myplaces application are public fences by default*/
- if (!g_strcmp0(app_id, MYPLACES_APPID)) {
+ if (!g_strcmp0(app_id, MYPLACES_APPID))
item_data->common_info.access_type = ACCESS_TYPE_PUBLIC;
- } else {
+ else
item_data->common_info.access_type = ACCESS_TYPE_PRIVATE;
- }
item_data->common_info.enable = 1;
item_data->common_info.status = GEOFENCE_FENCE_STATE_UNCERTAIN;
item_data->common_info.proximity_status = GEOFENCE_PROXIMITY_UNCERTAIN;
}
geocoordinate_info->latitude = latitude;
geocoordinate_info->longitude = longitude;
- if (radius < GEOFENCE_DEFAULT_RADIUS) {
+ if (radius < GEOFENCE_DEFAULT_RADIUS)
geocoordinate_info->radius = GEOFENCE_DEFAULT_RADIUS;
- } else {
+ else
geocoordinate_info->radius = radius;
- }
g_strlcpy(geocoordinate_info->address, address, ADDRESS_LEN);
/*Geopoint information is saved in the DB*/
item_data->priv = (void *) bt_info;
}
/*Adding the data to the geofence_list which contains the added geofences list information*/
- if (geofence_server->geofence_list == NULL) {
+ if (geofence_server->geofence_list == NULL)
geofence_server->geofence_list = g_list_append(geofence_server->geofence_list, item_data);
- } else {
+ else
geofence_server->geofence_list = g_list_insert_before(geofence_server->geofence_list, next_item_ptr, item_data);
- }
/*This code is just for testing purpose. It will be removed after the development phase - Karthik*/
int temp_cnt = 0;
GList *temp_list = g_list_first(geofence_server->geofence_list);
return fence_id;
}
-static int dbus_add_place_cb(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;
ret = __check_place_permission(place_id, app_id);
if (ret != 1) {
LOGE("Unable to get the place name. Permission denied or DB error occured while accessing the place[%d]", place_id);
- if (ret == 0) {
+ if (ret == 0)
*error_code = GEOFENCE_SERVER_ERROR_PLACE_ACCESS_DENIED;
- } else {
+ else
*error_code = GEOFENCE_SERVER_ERROR_DATABASE;
- }
return;
}
ret = geofence_manager_get_place_name(place_id, place_name);
*error_code = GEOFENCE_SERVER_ERROR_NONE;
}
-static void dbus_remove_place_cb(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);
return;
}
if (enable == 0) {
- LOGI_GEOFENCE("Error - Fence[%d] is not enabled",
- fence_id);
+ LOGI_GEOFENCE("Error - Fence[%d] is not enabled", 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;
}
LOGI_GEOFENCE("Wifi is on...");
geofence_server->running_wifi_cnt++; /*Incrementing the counter for wifi fence*/
- if (item_data->priv != NULL) {
+ if (item_data->priv != NULL)
wifi_info = (bssid_info_s *) item_data->priv;
- }
rv = wifi_get_connected_ap(&ap_h);
if (rv != WIFI_ERROR_NONE) {
LOGI_GEOFENCE("Fail/not connected to get the connected AP: [%s] , geofence will be added to the fence list", __convert_wifi_error_to_string(rv));
status_to_be_emitted = GEOFENCE_FENCE_STATE_OUT;
}
} else {
- LOGI_GEOFENCE("Invalid fence_type[%d]",
- item_data->common_info.type);
+ LOGI_GEOFENCE("Invalid fence_type[%d]", item_data->common_info.type);
return;
}
/*Adding the fence to the tracking list*/
LOGI_GEOFENCE("Add to tracklist: Fence id: %d", fence_id);
- if (geofence_server->tracking_list == NULL) {
+ if (geofence_server->tracking_list == NULL)
geofence_server->tracking_list = g_list_append(geofence_server->tracking_list, GINT_TO_POINTER(fence_id));
- } else {
+ else
geofence_server->tracking_list = g_list_insert_before(geofence_server->tracking_list, next_item_ptr, GINT_TO_POINTER(fence_id));
- }
LOGI_GEOFENCE("Added fence id: Fence id: %d", fence_id);
__emit_fence_event(geofence_server, place_id, fence_id, access_type, app_id, GEOFENCE_SERVER_ERROR_NONE, GEOFENCE_MANAGE_FENCE_STARTED);
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*/
geofence_server->activity_in_vehicle_h = NULL;
/*Initializing the DB to store the fence informations*/
- if (geofence_manager_db_init() != FENCE_ERR_NONE) {
+ if (geofence_manager_db_init() != FENCE_ERR_NONE)
LOGI_GEOFENCE("Error initalizing the DB");
- }
/*Adding default places in the DB*/
int place_id = DEFAULT_PLACE_HOME;
int count = -1;
while (place_id <= DEFAULT_PLACE_CAR) {
if (geofence_manager_get_place_count_by_placeid(place_id, &count) == FENCE_ERR_NONE) {
if (count == 0) {
- if (place_id == DEFAULT_PLACE_HOME) {
+ if (place_id == DEFAULT_PLACE_HOME)
__add_default_place("Home");
- } else if (place_id == DEFAULT_PLACE_OFFICE) {
+ else if (place_id == DEFAULT_PLACE_OFFICE)
__add_default_place("Office");
- } else if (place_id == DEFAULT_PLACE_CAR) {
+ else if (place_id == DEFAULT_PLACE_CAR)
__add_default_place("Car");
- }
}
} else {
LOGI_GEOFENCE("Error adding the default place: %d", place_id);
#endif
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 {
return FENCE_ERR_SQLITE_FAIL;
}
- if (sqlite3_changes(db_info_s.handle) == 0) {
+ if (sqlite3_changes(db_info_s.handle) == 0)
LOGI_GEOFENCE("No changes to DB");
- }
sqlite3_free(ddl);
return FENCE_ERR_NONE;
}
return FENCE_ERR_SQLITE_FAIL;
}
- if (sqlite3_changes(db_info_s.handle) == 0) {
+ if (sqlite3_changes(db_info_s.handle) == 0)
LOGI_GEOFENCE("No changes to DB");
- }
sqlite3_free(ddl);
return FENCE_ERR_NONE;
}
return FENCE_ERR_SQLITE_FAIL;
}
- if (sqlite3_changes(db_info_s.handle) == 0) {
+ if (sqlite3_changes(db_info_s.handle) == 0)
LOGI_GEOFENCE("No changes to DB");
- }
sqlite3_free(ddl);
return FENCE_ERR_NONE;
}
return FENCE_ERR_SQLITE_FAIL;
}
- if (sqlite3_changes(db_info_s.handle) == 0) {
+ if (sqlite3_changes(db_info_s.handle) == 0)
LOGI_GEOFENCE("No changes to DB");
- }
sqlite3_free(ddl);
return FENCE_ERR_NONE;
}
return FENCE_ERR_NONE;
}
-static int __geofence_manager_db_insert_bssid_info(const int fence_id, const char *bssid_info, const char *ssid)
+static int __geofence_manager_db_insert_bssid_info(const int fence_id, char *bssid_info, const char *ssid)
{
FUNC_ENTRANCE_SERVER;
g_return_val_if_fail(fence_id, FENCE_ERR_INVALID_PARAMETER);
int index = 0;
int count = -1;
const char *tail;
- 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);
- g_strlcpy(bssid, bssid_info, WLAN_BSSID_LEN);
- LOGI_GEOFENCE("fence_id[%d], bssid[%s], ssid[%s]", fence_id, bssid, ssid);
+ LOGI_GEOFENCE("fence_id[%d], bssid[%s], ssid[%s]", fence_id, bssid_info, ssid);
- ret = __geofence_manager_db_get_count_by_fence_id_and_bssid(fence_id, bssid, FENCE_BSSID_TABLE, &count);
+ ret = __geofence_manager_db_get_count_by_fence_id_and_bssid(fence_id, bssid_info, FENCE_BSSID_TABLE, &count);
if (ret != FENCE_ERR_NONE) {
LOGI_GEOFENCE("__geofence_manager_db_get_count_by_fence_id_and_bssid() failed. ERROR(%d)", ret);
sqlite3_free(query);
ret = sqlite3_bind_int(state, ++index, fence_id);
SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state);
- ret = sqlite3_bind_text(state, ++index, bssid, -1, SQLITE_STATIC);
+ ret = sqlite3_bind_text(state, ++index, bssid_info, -1, SQLITE_STATIC);
SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state);
ret = sqlite3_bind_text(state, ++index, ssid, -1, SQLITE_STATIC);
if (ret != SQLITE_DONE) {
LOGI_GEOFENCE("sqlite3_step Error[%d] : %s", ret, sqlite3_errmsg(db_info_s.handle));
sqlite3_finalize(state);
- g_free(bssid);
sqlite3_free(query);
return FENCE_ERR_SQLITE_FAIL;
}
sqlite3_reset(state);
sqlite3_clear_bindings(state);
sqlite3_finalize(state);
- g_free(bssid);
sqlite3_free(query);
LOGI_GEOFENCE("fence_id[%d], bssid[%s], ssid[%s] inserted db table [%s] successfully.", fence_id, bssid_info, ssid, menu_table[FENCE_BSSID_TABLE]);
int index = 0;
int count = -1;
const char *tail;
- char *bssid = NULL;
+
wifi_info = (wifi_info_s *) data;
- 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 *query = sqlite3_mprintf("INSERT INTO FenceGeopointWifi(fence_id, bssid) VALUES (?, ?)");
- ret = __geofence_manager_db_get_count_by_fence_id_and_bssid(*fence_id, bssid, FENCE_GEOPOINT_WIFI_TABLE, &count);
+ ret = __geofence_manager_db_get_count_by_fence_id_and_bssid(*fence_id, wifi_info->bssid, FENCE_GEOPOINT_WIFI_TABLE, &count);
if (count > 0) {
LOGI_GEOFENCE("count = %d", count);
sqlite3_free(query);
ret = sqlite3_bind_int(state, ++index, *fence_id);
SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state);
- ret = sqlite3_bind_text(state, ++index, bssid, -1, SQLITE_STATIC);
+ ret = sqlite3_bind_text(state, ++index, wifi_info->bssid, -1, SQLITE_STATIC);
SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state);
ret = sqlite3_step(state);
if (ret != SQLITE_DONE) {
LOGI_GEOFENCE("sqlite3_step Error[%d] : %s", ret, sqlite3_errmsg(db_info_s.handle));
sqlite3_finalize(state);
- g_free(bssid);
sqlite3_free(query);
return FENCE_ERR_SQLITE_FAIL;
}
sqlite3_reset(state);
sqlite3_clear_bindings(state);
sqlite3_finalize(state);
- g_free(bssid);
sqlite3_free(query);
return FENCE_ERR_NONE;
int ret = 0;
ret = bt_adapter_get_address(&bt_address);
- if (ret != BT_ERROR_NONE) {
+ if (ret != BT_ERROR_NONE)
LOGD_GEOFENCE("bt address get fail %d", ret);
- }
ret = wifi_get_mac_address(&wifi_address);
- if (ret != WIFI_ERROR_NONE) {
+ if (ret != WIFI_ERROR_NONE)
LOGD_GEOFENCE("wifi address get fail %d", ret);
- }
if (bt_address) {
token = strtok_r(bt_address, ":", &save_token);
{
int fd = -1;
- fd = open(GEOFENCE_DB_FILE, O_RDONLY);
- if (fd < 0) {
- LOGW_GEOFENCE("DB file(%s) is not exist.", GEOFENCE_DB_FILE);
- return -1;
- }
- close(fd);
- return 0;
+ fd = open(GEOFENCE_DB_FILE, O_RDONLY);
+ if (fd < 0) {
+ LOGW_GEOFENCE("DB file(%s) is not exist.", GEOFENCE_DB_FILE);
+ return -1;
+ }
+ close(fd);
+ return 0;
}
/**
int ret = SQLITE_OK;
int index = 0;
const char *tail;
- char *appid = NULL;
- 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);
- g_strlcpy(place_name, place_info->place_name, PLACE_NAME_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);
if (ret != SQLITE_OK) {
LOGI_GEOFENCE("Error: %s", sqlite3_errmsg(db_info_s.handle));
- g_free(place_name);
- g_free(appid);
sqlite3_free(query);
return FENCE_ERR_PREPARE;
}
- LOGD_GEOFENCE("appid[%s] access_type[%d] place_name[%s]", appid, place_info->access_type, place_info->place_name);
+ LOGD_GEOFENCE("appid[%s] access_type[%d] place_name[%s]", place_info->appid, place_info->access_type, place_info->place_name);
ret = sqlite3_bind_int(state, ++index, place_info->access_type);
SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state);
- ret = sqlite3_bind_text(state, ++index, place_name, -1, SQLITE_STATIC);
+ ret = sqlite3_bind_text(state, ++index, place_info->place_name, -1, SQLITE_STATIC);
SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state);
- ret = sqlite3_bind_text(state, ++index, appid, -1, SQLITE_STATIC);
+ ret = sqlite3_bind_text(state, ++index, place_info->appid, -1, SQLITE_STATIC);
SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state);
ret = sqlite3_step(state);
if (ret != SQLITE_DONE) {
LOGI_GEOFENCE("sqlite3_step Error[%d] : %s", ret, sqlite3_errmsg(db_info_s.handle));
sqlite3_finalize(state);
- g_free(place_name);
- g_free(appid);
sqlite3_free(query);
return FENCE_ERR_SQLITE_FAIL;
}
sqlite3_reset(state);
sqlite3_clear_bindings(state);
sqlite3_finalize(state);
- g_free(place_name);
- g_free(appid);
sqlite3_free(query);
if (*place_id < 1) {
int ret = SQLITE_OK;
int index = 0;
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);
- g_strlcpy(appid, fence_info->appid, APP_ID_LEN);
ret = sqlite3_prepare_v2(db_info_s.handle, query, -1, &state, &tail);
if (ret != SQLITE_OK) {
LOGI_GEOFENCE("Error: %s", sqlite3_errmsg(db_info_s.handle));
- g_free(appid);
sqlite3_free(query);
return FENCE_ERR_PREPARE;
}
- LOGD_GEOFENCE("place_id[%d], enable[%d], appid[%s] geofence_type[%d] access_type[%d] running_status[%d]", fence_info->place_id, fence_info->enable, appid, fence_info->running_status, fence_info->type, fence_info->access_type, fence_info->place_id);
+ LOGD_GEOFENCE("place_id[%d], enable[%d], appid[%s] geofence_type[%d] access_type[%d] running_status[%d]", fence_info->place_id, fence_info->enable, fence_info->appid, fence_info->running_status, fence_info->type, fence_info->access_type, fence_info->place_id);
ret = sqlite3_bind_int(state, ++index, fence_info->place_id);
SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state);
ret = sqlite3_bind_int(state, ++index, fence_info->enable);
SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state);
- ret = sqlite3_bind_text(state, ++index, appid, -1, SQLITE_STATIC);
+ ret = sqlite3_bind_text(state, ++index, fence_info->appid, -1, SQLITE_STATIC);
SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state);
ret = sqlite3_bind_int(state, ++index, fence_info->type);
if (ret != SQLITE_DONE) {
LOGI_GEOFENCE("sqlite3_step Error[%d] : %s", ret, sqlite3_errmsg(db_info_s.handle));
sqlite3_finalize(state);
- g_free(appid);
sqlite3_free(query);
return FENCE_ERR_SQLITE_FAIL;
}
sqlite3_reset(state);
sqlite3_clear_bindings(state);
sqlite3_finalize(state);
- g_free(appid);
sqlite3_free(query);
if (*fence_id < 1) {
sqlite3_stmt *state = NULL;
const char *tail;
int ret = SQLITE_OK;
- char *place_name = NULL;
-
- 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);
+ char *query = sqlite3_mprintf("UPDATE Places SET place_name = %Q where place_id = %d", place_info_name, place_id);
ret = sqlite3_prepare_v2(db_info_s.handle, query, -1, &state, &tail);
if (ret != SQLITE_OK) {
LOGI_GEOFENCE("Error: %s", sqlite3_errmsg(db_info_s.handle));
sqlite3_free(query);
- g_free(place_name);
return FENCE_ERR_PREPARE;
}
if (ret != SQLITE_DONE) {
LOGI_GEOFENCE("sqlite3_step Error[%d] : %s", ret, sqlite3_errmsg(db_info_s.handle));
sqlite3_finalize(state);
- g_free(place_name);
sqlite3_free(query);
return FENCE_ERR_SQLITE_FAIL;
}
sqlite3_finalize(state);
- g_free(place_name);
sqlite3_free(query);
LOGI_GEOFENCE("place_id: %d has been successfully updated.", place_id);
return FENCE_ERR_NONE;
data_name = (char *) sqlite3_column_text(state, ++index);
- if (!data_name || !strlen(data_name)) {
+ if (!data_name || !strlen(data_name))
LOGI_GEOFENCE("ERROR: data_name is NULL!!!");
- } else {
+ else
(*geocoordinate_info)->latitude = atof(data_name);
- }
data_name = (char *) sqlite3_column_text(state, ++index);
- if (!data_name || !strlen(data_name)) {
+ if (!data_name || !strlen(data_name))
LOGI_GEOFENCE("ERROR: data_name is NULL!!!");
- } else {
+ else
(*geocoordinate_info)->longitude = atof(data_name);
- }
data_name = (char *) sqlite3_column_text(state, ++index);
- if (!data_name || !strlen(data_name)) {
+ if (!data_name || !strlen(data_name))
LOGI_GEOFENCE("ERROR: data_name is NULL!!!");
- } else {
+ else
(*geocoordinate_info)->radius = atof(data_name);
- }
g_strlcpy((*geocoordinate_info)->address, (char *) sqlite3_column_text(state, ++index), ADDRESS_LEN);
g_return_val_if_fail(*place_info, FENCE_ERR_INVALID_PARAMETER);
data_name = (char *)sqlite3_column_text(state, ++index);
- if (!data_name || !strlen(data_name)) {
+ if (!data_name || !strlen(data_name))
LOGI_GEOFENCE("ERROR: data_name is NULL!!!");
- } else {
+ else
(*place_info)->access_type = atof(data_name);
- }
g_strlcpy((*place_info)->place_name, (char *)sqlite3_column_text(state, ++index), PLACE_NAME_LEN);
g_strlcpy((*place_info)->appid, (char *)sqlite3_column_text(state, ++index), APP_ID_LEN);
}
tmp = (char *) sqlite3_column_text(state, 0);
- if (!tmp || !strlen(tmp)) {
+ if (!tmp || !strlen(tmp))
LOGI_GEOFENCE("ERROR: name is NULL!!!");
- } else {
+ else
*name = g_strdup(tmp);
- }
sqlite3_finalize(state);
sqlite3_free(query);
}
id = (char *) sqlite3_column_text(state, 0);
- if (!id || !strlen(id)) {
+ if (!id || !strlen(id))
LOGI_GEOFENCE("ERROR: appid is NULL!!!");
- } else {
+ else
*appid = g_strdup(id);
- }
sqlite3_finalize(state);
sqlite3_free(query);
}
id = (char *) sqlite3_column_text(state, 0);
- if (!id || !strlen(id)) {
+ if (!id || !strlen(id))
LOGI_GEOFENCE("ERROR: appid is NULL!!!");
- } else {
+ else
*appid = g_strdup(id);
- }
sqlite3_finalize(state);
sqlite3_free(query);
}
info = (char *) sqlite3_column_text(state, 0);
- if (!info || !strlen(info)) {
+ if (!info || !strlen(info))
LOGI_GEOFENCE("ERROR: ble info is NULL!!!");
- } else {
+ else
*ble_info = g_strdup(info);
- }
sqlite3_finalize(state);
sqlite3_free(query);
FUNC_ENTRANCE_SERVER;
int ret = SQLITE_OK;
- if (db_info_s.handle == NULL) {
+ if (db_info_s.handle == NULL)
return FENCE_ERR_NONE;
- }
ret = db_util_close(db_info_s.handle);
if (ret != SQLITE_OK) {
#define MYPLACES_APP_ID "org.tizen.myplace"
typedef enum {
- ACCESS_TYPE_PRIVATE = 1,
- ACCESS_TYPE_PUBLIC,
- ACCESS_TYPE_UNKNOWN,
+ ACCESS_TYPE_PRIVATE = 1,
+ ACCESS_TYPE_PUBLIC,
+ ACCESS_TYPE_UNKNOWN,
} access_type_e;
typedef struct {
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle;
g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
int new_fence_id = -1;
+ int error_code = GEOFENCE_MANAGER_ERROR_NONE;
- new_fence_id = geo_client_add_geofence(geofence_manager->geofence_client, geofence_manager->app_id, place_id, GEOFENCE_TYPE_GEOPOINT, latitude, longitude, radius, address, "", "");
+ new_fence_id = geo_client_add_geofence(geofence_manager->geofence_client, geofence_manager->app_id, place_id, GEOFENCE_TYPE_GEOPOINT, latitude, longitude, radius, address, "", "", &error_code);
*fence_id = new_fence_id;
- if (new_fence_id == -1)
+ if (error_code != GEOFENCE_MANAGER_ERROR_NONE)
+ return error_code;
+ else if (new_fence_id == -1)
return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
return GEOFENCE_MANAGER_ERROR_NONE;
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle;
g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
int new_fence_id = -1;
+ int error_code = GEOFENCE_MANAGER_ERROR_NONE;
- new_fence_id = geo_client_add_geofence(geofence_manager->geofence_client, geofence_manager->app_id, place_id, type, -1, -1, -1, "", bssid, ssid);
+ new_fence_id = geo_client_add_geofence(geofence_manager->geofence_client, geofence_manager->app_id, place_id, type, -1, -1, -1, "", bssid, ssid, &error_code);
*fence_id = new_fence_id;
- if (new_fence_id == -1)
+ if (error_code != GEOFENCE_MANAGER_ERROR_NONE)
+ return error_code;
+ else if (new_fence_id == -1)
return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
return GEOFENCE_MANAGER_ERROR_NONE;
GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle;
g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER);
int new_place_id = -1;
+ int error_code = GEOFENCE_MANAGER_ERROR_NONE;
- new_place_id = geo_client_add_place(geofence_manager->geofence_client, geofence_manager->app_id, place_name);
+ new_place_id = geo_client_add_place(geofence_manager->geofence_client, geofence_manager->app_id, place_name, &error_code);
*place_id = new_place_id;
- if (new_place_id == -1)
+ if (error_code != GEOFENCE_MANAGER_ERROR_NONE)
+ return error_code;
+ else if (new_place_id == -1)
return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
return GEOFENCE_MANAGER_ERROR_NONE;
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_CLIENT_ERROR_DBUS_CALL;
+ return ret;
return GEOFENCE_MANAGER_ERROR_NONE;
}
int ret = geo_client_delete_geofence(geofence_manager->geofence_client, geofence_manager->app_id, fence_id);
if (ret != GEOFENCE_CLIENT_ERROR_NONE)
- return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
+ return ret;
return GEOFENCE_MANAGER_ERROR_NONE;
}
int ret = geo_client_delete_place(geofence_manager->geofence_client, geofence_manager->app_id, place_id);
if (ret != GEOFENCE_CLIENT_ERROR_NONE)
- return GEOFENCE_CLIENT_ERROR_DBUS_CALL;
+ return ret;
return GEOFENCE_MANAGER_ERROR_NONE;
}
int error_code = GEOFENCE_MANAGER_ERROR_NONE;
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_CLIENT_ERROR_DBUS_CALL;
+ return ret;
return error_code;
}
int error_code = GEOFENCE_MANAGER_ERROR_NONE;
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)
+ if (ret != GEOFENCE_MANAGER_ERROR_NONE)
+ return ret;
+ else 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_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);
+ 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);
while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
while (g_variant_iter_loop(iter_row, "{sv}", &key, &value)) {
gchar *key;
GVariant *value;
int place_cnt = 0;
- int error_code = -1;
+ int error_code = GEOFENCE_MANAGER_ERROR_NONE;
/*Call the geofence_client api here....*/
- geo_client_get_places(geofence_manager->geofence_client, geofence_manager->app_id, &iter, &place_cnt, &error_code);
+ int ret = geo_client_get_places(geofence_manager->geofence_client, geofence_manager->app_id, &iter, &place_cnt, &error_code);
+ if (ret != GEOFENCE_MANAGER_ERROR_NONE)
+ return ret;
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_s *p = (place_s *)g_slice_alloc0(sizeof(place_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");
while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
while (g_variant_iter_loop(iter_row, "{sv}", &key, &value)) {
- if (!g_strcmp0(key, "place_id")) {
+ if (!g_strcmp0(key, "place_id"))
place_id_array[index] = g_variant_get_int32(value);
- } else if (!g_strcmp0(key, "place_name")) {
+ else if (!g_strcmp0(key, "place_name"))
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);
index++;
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_CLIENT_ERROR_DBUS_CALL;
+ return ret;
}
return GEOFENCE_MANAGER_ERROR_NONE;
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_CLIENT_ERROR_DBUS_CALL;
+ return ret;
}
return GEOFENCE_MANAGER_ERROR_NONE;