)
INCLUDE_DIRECTORIES(
- src
+ src
include
)
INSTALL(DIRECTORY include/ DESTINATION ${INCLUDE_DIR}/lbs-server-plugin FILES_MATCHING PATTERN "*.h")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BIN_DIR})
\ No newline at end of file
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BIN_DIR})
<deny send_destination="org.tizen.lbs.Providers.LbsServer"/>
<allow receive_sender="org.tizen.lbs.Providers.LbsServer"/>
- <check send_destination="org.tizen.lbs.Providers.LbsServer"
- send_interface="org.tizen.lbs.Manager"
- privilege="http://tizen.org/privilege/location" />
- <check send_destination="org.tizen.lbs.Providers.LbsServer"
- send_interface="org.tizen.lbs.Position"
- privilege="http://tizen.org/privilege/location" />
- <check send_destination="org.tizen.lbs.Providers.LbsServer"
- send_interface="org.tizen.lbs.Nmea"
- privilege="http://tizen.org/privilege/location" />
- <check send_destination="org.tizen.lbs.Providers.LbsServer"
- send_interface="org.tizen.lbs.Satellite"
- privilege="http://tizen.org/privilege/location" />
- <check send_destination="org.tizen.lbs.Providers.LbsServer"
- send_interface="org.tizen.lbs.Batch"
- privilege="http://tizen.org/privilege/location" />
- <check receive_sender="org.tizen.lbs.Providers.LbsServer"
- receive_interface="org.tizen.lbs.Manager"
- privilege="http://tizen.org/privilege/location" />
- <check receive_sender="org.tizen.lbs.Providers.LbsServer"
- receive_interface="org.tizen.lbs.Position"
- privilege="http://tizen.org/privilege/location" />
- <check receive_sender="org.tizen.lbs.Providers.LbsServer"
- receive_interface="org.tizen.lbs.Position"
- privilege="http://tizen.org/privilege/location" />
- <check receive_sender="org.tizen.lbs.Providers.LbsServer"
- receive_interface="org.tizen.lbs.Nmea"
- privilege="http://tizen.org/privilege/location" />
- <check receive_sender="org.tizen.lbs.Providers.LbsServer"
- receive_interface="org.tizen.lbs.Satellite"
- privilege="http://tizen.org/privilege/location" />
- <check receive_sender="org.tizen.lbs.Providers.LbsServer"
- receive_interface="org.tizen.lbs.Batch"
- privilege="http://tizen.org/privilege/location" />
+ <check send_destination="org.tizen.lbs.Providers.LbsServer" send_interface="org.tizen.lbs.Manager" privilege="http://tizen.org/privilege/location" />
+ <check send_destination="org.tizen.lbs.Providers.LbsServer" send_interface="org.tizen.lbs.Position" privilege="http://tizen.org/privilege/location" />
+ <check send_destination="org.tizen.lbs.Providers.LbsServer" send_interface="org.tizen.lbs.Nmea" privilege="http://tizen.org/privilege/location" />
+ <check send_destination="org.tizen.lbs.Providers.LbsServer" send_interface="org.tizen.lbs.Satellite" privilege="http://tizen.org/privilege/location" />
+ <check send_destination="org.tizen.lbs.Providers.LbsServer" send_interface="org.tizen.lbs.Batch" privilege="http://tizen.org/privilege/location" />
+ <check receive_sender="org.tizen.lbs.Providers.LbsServer" receive_interface="org.tizen.lbs.Manager" privilege="http://tizen.org/privilege/location" />
+ <check receive_sender="org.tizen.lbs.Providers.LbsServer" receive_interface="org.tizen.lbs.Position" privilege="http://tizen.org/privilege/location" />
+ <check receive_sender="org.tizen.lbs.Providers.LbsServer" receive_interface="org.tizen.lbs.Position" privilege="http://tizen.org/privilege/location" />
+ <check receive_sender="org.tizen.lbs.Providers.LbsServer" receive_interface="org.tizen.lbs.Nmea" privilege="http://tizen.org/privilege/location" />
+ <check receive_sender="org.tizen.lbs.Providers.LbsServer" receive_interface="org.tizen.lbs.Satellite" privilege="http://tizen.org/privilege/location" />
+ <check receive_sender="org.tizen.lbs.Providers.LbsServer" receive_interface="org.tizen.lbs.Batch" privilege="http://tizen.org/privilege/location" />
<!-- This tag is for HW geofence
<allow send_interface="org.tizen.lbs.Geofence"/>
void pdp_evt_cb(net_event_info_t *event_cb, void *user_data)
{
switch (event_cb->Event) {
- case NET_EVENT_OPEN_RSP: {
- LOG_GPS(DBG_LOW, "event_cb->Error : [%d]\n", event_cb->Error);
- if (get_connection_status() != ACTIVATING) {
- LOG_GPS(DBG_LOW, "Not Activating status\n");
- } else if (event_cb->Error == NET_ERR_NONE || event_cb->Error == NET_ERR_ACTIVE_CONNECTION_EXISTS) {
- LOG_GPS(DBG_LOW, "Successful PDP Activation\n");
- net_profile_info_t *prof_info = NULL;
- net_dev_info_t *net_info = NULL;
-
- prof_info = (net_profile_info_t *) event_cb->Data;
- net_info = &(prof_info->ProfileInfo.Pdp.net_info);
-
- strncpy(profile_name, net_info->ProfileName, NET_PROFILE_NAME_LEN_MAX);
-
- set_connection_status(ACTIVATED);
- pdp_proxy_conf();
- noti_resp_noti(pdp_pipe_fds, TRUE);
- } else {
- LOG_GPS(DBG_ERR, " PDP Activation Failed - PDP Error[%d]\n", event_cb->Error);
- set_connection_status(DEACTIVATED);
- noti_resp_noti(pdp_pipe_fds, FALSE);
- }
- }
- break;
-
- case NET_EVENT_CLOSE_RSP:
- if (get_connection_status() != ACTIVATED && get_connection_status() != DEACTIVATING) {
- LOG_GPS(DBG_ERR, "Not Activated && Deactivating status\n");
- } else if (event_cb->Error == NET_ERR_NONE || event_cb->Error == NET_ERR_UNKNOWN) {
- LOG_GPS(DBG_LOW, "Successful PDP De-Activation\n");
- set_connection_status(DEACTIVATED);
- noti_resp_noti(pdp_pipe_fds, TRUE);
- } else {
- LOG_GPS(DBG_ERR, " PDP DeActivation Failed - PDP Error[%d]\n", event_cb->Error);
- noti_resp_noti(pdp_pipe_fds, FALSE);
- }
- break;
-
- case NET_EVENT_CLOSE_IND:
- if (get_connection_status() != ACTIVATED && get_connection_status() != DEACTIVATING) {
- LOG_GPS(DBG_ERR, "Not Activated && Deactivating status\n");
- } else if (event_cb->Error == NET_ERR_NONE || event_cb->Error == NET_ERR_UNKNOWN) {
- LOG_GPS(DBG_LOW, "Successful PDP De-Activation\n");
- set_connection_status(DEACTIVATED);
- noti_resp_noti(pdp_pipe_fds, TRUE);
- } else {
- LOG_GPS(DBG_ERR, " PDP DeActivation Failed - PDP Error[%d]\n", event_cb->Error);
- noti_resp_noti(pdp_pipe_fds, FALSE);
- }
- break;
- case NET_EVENT_OPEN_IND:
- break;
- default:
- break;
+ case NET_EVENT_OPEN_RSP: {
+ LOG_GPS(DBG_LOW, "event_cb->Error : [%d]\n", event_cb->Error);
+ if (get_connection_status() != ACTIVATING) {
+ LOG_GPS(DBG_LOW, "Not Activating status\n");
+ } else if (event_cb->Error == NET_ERR_NONE || event_cb->Error == NET_ERR_ACTIVE_CONNECTION_EXISTS) {
+ LOG_GPS(DBG_LOW, "Successful PDP Activation\n");
+ net_profile_info_t *prof_info = NULL;
+ net_dev_info_t *net_info = NULL;
+
+ prof_info = (net_profile_info_t *) event_cb->Data;
+ net_info = &(prof_info->ProfileInfo.Pdp.net_info);
+
+ strncpy(profile_name, net_info->ProfileName, NET_PROFILE_NAME_LEN_MAX);
+
+ set_connection_status(ACTIVATED);
+ pdp_proxy_conf();
+ noti_resp_noti(pdp_pipe_fds, TRUE);
+ } else {
+ LOG_GPS(DBG_ERR, " PDP Activation Failed - PDP Error[%d]\n", event_cb->Error);
+ set_connection_status(DEACTIVATED);
+ noti_resp_noti(pdp_pipe_fds, FALSE);
+ }
+ }
+ break;
+
+ case NET_EVENT_CLOSE_RSP:
+ if (get_connection_status() != ACTIVATED && get_connection_status() != DEACTIVATING) {
+ LOG_GPS(DBG_ERR, "Not Activated && Deactivating status\n");
+ } else if (event_cb->Error == NET_ERR_NONE || event_cb->Error == NET_ERR_UNKNOWN) {
+ LOG_GPS(DBG_LOW, "Successful PDP De-Activation\n");
+ set_connection_status(DEACTIVATED);
+ noti_resp_noti(pdp_pipe_fds, TRUE);
+ } else {
+ LOG_GPS(DBG_ERR, " PDP DeActivation Failed - PDP Error[%d]\n", event_cb->Error);
+ noti_resp_noti(pdp_pipe_fds, FALSE);
+ }
+ break;
+
+ case NET_EVENT_CLOSE_IND:
+ if (get_connection_status() != ACTIVATED && get_connection_status() != DEACTIVATING) {
+ LOG_GPS(DBG_ERR, "Not Activated && Deactivating status\n");
+ } else if (event_cb->Error == NET_ERR_NONE || event_cb->Error == NET_ERR_UNKNOWN) {
+ LOG_GPS(DBG_LOW, "Successful PDP De-Activation\n");
+ set_connection_status(DEACTIVATED);
+ noti_resp_noti(pdp_pipe_fds, TRUE);
+ } else {
+ LOG_GPS(DBG_ERR, " PDP DeActivation Failed - PDP Error[%d]\n", event_cb->Error);
+ noti_resp_noti(pdp_pipe_fds, FALSE);
+ }
+ break;
+ case NET_EVENT_OPEN_IND:
+ break;
+ default:
+ break;
}
}
LOG_GPS(DBG_WARN, "Error in net_open_connection_with_preference() [%d]\n", err);
set_connection_status(DEACTIVATED);
err = net_deregister_client();
- if (err == NET_ERR_NONE) {
+ if (err == NET_ERR_NONE)
LOG_GPS(DBG_LOW, "Client deregistered successfully\n");
- } else {
+ else
LOG_GPS(DBG_ERR, "Error deregistering the client\n");
- }
+
noti_resp_deinit(pdp_pipe_fds);
return FALSE;
}
noti_resp_deinit(pdp_pipe_fds);
err = net_deregister_client();
- if (err == NET_ERR_NONE) {
+ if (err == NET_ERR_NONE)
LOG_GPS(DBG_LOW, "Client deregistered successfully\n");
- } else {
+ else
LOG_GPS(DBG_ERR, "Error deregistering the client\n");
- }
+
return FALSE;
}
} else {
noti_resp_deinit(pdp_pipe_fds);
err = net_deregister_client();
- if (err == NET_ERR_NONE) {
+ if (err == NET_ERR_NONE)
LOG_GPS(DBG_LOW, "Client deregistered successfully\n");
- } else {
+ else
LOG_GPS(DBG_ERR, "Error deregistering the client\n");
- }
+
return FALSE;
}
}
return FALSE;
}
if (noti_resp_wait(pdp_pipe_fds) > 0) {
- if (noti_resp_check(pdp_pipe_fds)) {
+ if (noti_resp_check(pdp_pipe_fds))
LOG_GPS(DBG_LOW, "Close Connection success\n");
- } else {
+ else
LOG_GPS(DBG_ERR, "Close connection failed\n");
- }
}
noti_resp_deinit(pdp_pipe_fds);
tmpbuf = malloc(tmplen);
if (!tmpbuf) return FALSE;
- while ((res = gethostbyname_r(pdns_lookup_addr, &hostbuf, tmpbuf, tmplen, &he, &herr)) == ERANGE)
- {
+ while ((res = gethostbyname_r(pdns_lookup_addr, &hostbuf, tmpbuf, tmplen, &he, &herr)) == ERANGE) {
/* Enlarge the buffer. */
tmplen *= 2;
void *tmp = realloc(tmpbuf, tmplen);
free(tmpbuf);
LOG_GPS(DBG_ERR, "Failed to reallocate memories.");
return FALSE;
- }
- else {
+ } else {
tmpbuf = tmp;
}
}
int noti_resp_init(int *noti_pipe_fds)
{
- if (pipe(noti_pipe_fds) < 0) {
+ if (pipe(noti_pipe_fds) < 0)
return 0;
- } else {
+ else
return 1;
- }
}
int noti_resp_wait(int *noti_pipe_fds)
int activation = 0;
ssize_t ret_val = 0;
ret_val = read(*noti_pipe_fds, &activation, sizeof(int));
- if (ret_val == 0) {
+ if (ret_val == 0)
LOG_GPS(DBG_ERR, "No data");
- }
+
return activation;
}
{
int err;
err = close(*noti_pipe_fds);
- if (err != 0) {
+ if (err != 0)
LOG_GPS(DBG_ERR, "ERROR closing fds1.\n");
- }
err = close(*(noti_pipe_fds + 1));
- if (err != 0) {
+ if (err != 0)
LOG_GPS(DBG_ERR, "ERROR closing fds2.\n");
- }
return err;
}
#define DBG_WARN LOG_WARN
#define DBG_ERR LOG_ERROR
-#define LOG_GPS(dbg_lvl,fmt,args...) SLOG(dbg_lvl, TAG_GPS_MANAGER, fmt, ##args)
-#define LOG_NPS(dbg_lvl,fmt,args...) SLOG(dbg_lvl, TAG_NPS_MANAGER, fmt,##args)
-#define LOG_MOCK(dbg_lvl,fmt,args...) SLOG(dbg_lvl, TAG_MOCK_MANAGER, fmt,##args)
-#define LOG_SEC(fmt,args...) SECURE_SLOG(LOG_DEBUG, TAG_MOCK_MANAGER, fmt, ##args)
+#define LOG_GPS(dbg_lvl, fmt, args...) SLOG(dbg_lvl, TAG_GPS_MANAGER, fmt, ##args)
+#define LOG_NPS(dbg_lvl, fmt, args...) SLOG(dbg_lvl, TAG_NPS_MANAGER, fmt, ##args)
+#define LOG_MOCK(dbg_lvl, fmt, args...) SLOG(dbg_lvl, TAG_MOCK_MANAGER, fmt, ##args)
+#define LOG_SEC(fmt, args...) SECURE_SLOG(LOG_DEBUG, TAG_MOCK_MANAGER, fmt, ##args)
#define FUNC_ENTRANCE_SERVER LOG_GPS(DBG_LOW, "[%s] Entered!!", __func__);
int fd = -1;
-struct tm * __get_current_time(struct tm *cur_time) {
+struct tm * __get_current_time(struct tm *cur_time)
+{
time_t now;
time(&now);
return localtime_r(&now, cur_time);
g_snprintf(buf, 256, "[%02d:%02d:%02d] -- START GPS -- \n", cur_time.tm_hour, cur_time.tm_min, cur_time.tm_sec);
ret = write(fd, buf, strlen(buf));
- if (ret == -1) {
+
+ if (ret == -1)
LOG_GPS(DBG_ERR, "Fail to write file[%s]", GPG_DUMP_LOG);
- }
}
void gps_deinit_log()
} else {
g_snprintf(buf, 256, "[%02d:%02d:%02d] -- END GPS -- \n", cur_time.tm_hour, cur_time.tm_min, cur_time.tm_sec);
ret = write(fd, buf, strlen(buf));
- if (ret == -1) {
+
+ if (ret == -1)
LOG_GPS(DBG_ERR, "Fail to write file[%s]", GPG_DUMP_LOG);
- }
}
close(fd);
fd = -1;
return;
}
- if (app_id == NULL) {
+ if (app_id == NULL)
g_snprintf(buf, 256, "[%02d:%02d:%02d] %s\n", cur_time.tm_hour, cur_time.tm_min, cur_time.tm_sec, str);
- } else {
+ else
g_snprintf(buf, 256, "[%02d:%02d:%02d] %s from [%s]\n", cur_time.tm_hour, cur_time.tm_min, cur_time.tm_sec, str, app_id);
- }
+
LOG_GPS(DBG_ERR, "Add dump log [%s", buf);
ret = write(fd, buf, strlen(buf));
- if (ret == -1) {
+ if (ret == -1)
LOG_GPS(DBG_ERR, "Fail to write file[%s]", GPG_DUMP_LOG);
- }
}
setting_get_int(VCONFKEY_LOCATION_NV_LAST_GPS_TIMESTAMP, &last_timestamp);
- if ((timestamp - last_timestamp) > UPDATE_INTERVAL) {
+ if ((timestamp - last_timestamp) > UPDATE_INTERVAL)
gps_set_last_position(pos);
- }
}
void gps_get_last_position(pos_data_t *last_pos)
setting_get_int(VCONFKEY_LOCATION_LAST_GPS_TIMESTAMP, ×tamp);
str = setting_get_string(VCONFKEY_LOCATION_NV_LAST_GPS_LOCATION);
if (str == NULL) {
+ LOG_GPS(DBG_LOW, "last location is null");
return;
}
snprintf(location, sizeof(location), "%s", str);
last_location[index] = (char *)strtok_r(location, ";", &last);
while (last_location[index] != NULL) {
switch (index) {
- case 0:
- last_pos->latitude = strtod(last_location[index], NULL);
- break;
- case 1:
- last_pos->longitude = strtod(last_location[index], NULL);
- break;
- case 2:
- last_pos->altitude = strtod(last_location[index], NULL);
- break;
- case 3:
- last_pos->speed = strtod(last_location[index], NULL);
- break;
- case 4:
- last_pos->bearing = strtod(last_location[index], NULL);
- break;
- case 5:
- last_pos->hor_accuracy = strtod(last_location[index], NULL);
- break;
- case 6:
- last_pos->ver_accuracy = strtod(last_location[index], NULL);
- break;
- default:
- break;
+ case 0:
+ last_pos->latitude = strtod(last_location[index], NULL);
+ break;
+ case 1:
+ last_pos->longitude = strtod(last_location[index], NULL);
+ break;
+ case 2:
+ last_pos->altitude = strtod(last_location[index], NULL);
+ break;
+ case 3:
+ last_pos->speed = strtod(last_location[index], NULL);
+ break;
+ case 4:
+ last_pos->bearing = strtod(last_location[index], NULL);
+ break;
+ case 5:
+ last_pos->hor_accuracy = strtod(last_location[index], NULL);
+ break;
+ case 6:
+ last_pos->ver_accuracy = strtod(last_location[index], NULL);
+ break;
+ default:
+ break;
}
if (++index == MAX_GPS_LOC_ITEM) break;
last_location[index] = (char *)strtok_r(NULL, ";", &last);
} dynamic_interval_updator_user_data;
static gboolean gps_remove_all_clients(lbs_server_s *lbs_server);
-static NpsManagerPositionExt g_mock_position;
-static void set_mock_location_cb(gint method, gdouble latitude, gdouble longitude, gdouble altitude,
- gdouble speed, gdouble direction, gdouble accuracy, gpointer userdata);
+static NpsManagerPositionExt g_mock_position;
+static void set_mock_location_cb(gint method, gdouble latitude, gdouble longitude, gdouble altitude, gdouble speed, gdouble direction, gdouble accuracy, gpointer userdata);
static int mock_start_tracking(lbs_server_s *lbs_server);
static int mock_stop_tracking(lbs_server_s *lbs_server);
static void mock_set_status(lbs_server_s *lbs_server, LbsStatus status);
if (onoff == 0) {
ret = gps_remove_all_clients(lbs_server);
- if (ret == FALSE) {
+
+ if (ret == FALSE)
LOG_GPS(DBG_LOW, "already removed.");
- }
}
}
setting_get_int(VCONFKEY_LOCATION_NV_LAST_WPS_TIMESTAMP, &last_timestamp);
LOG_NPS(DBG_LOW, "last_time stamp: %d, pos.timestamp: %d, UPDATE_INTERVAL: %d ", last_timestamp, pos.timestamp, UPDATE_INTERVAL);
- if ((pos.timestamp - last_timestamp) > UPDATE_INTERVAL) {
+ if ((pos.timestamp - last_timestamp) > UPDATE_INTERVAL)
nps_set_last_position(pos);
- }
-
}
static void nps_set_status(lbs_server_s *lbs_server_nps, LbsStatus status)
lbs_server_nps->status = status;
- if (lbs_server_nps->status == LBS_STATUS_AVAILABLE) {
+ if (lbs_server_nps->status == LBS_STATUS_AVAILABLE)
setting_set_int(VCONFKEY_LOCATION_WPS_STATE, POSITION_CONNECTED);
- } else if (lbs_server_nps->status == LBS_STATUS_ACQUIRING) {
+ else if (lbs_server_nps->status == LBS_STATUS_ACQUIRING)
setting_set_int(VCONFKEY_LOCATION_WPS_STATE, POSITION_SEARCHING);
- } else {
+ else
setting_set_int(VCONFKEY_LOCATION_WPS_STATE, POSITION_OFF);
- }
- if (status != LBS_STATUS_AVAILABLE) {
+ if (status != LBS_STATUS_AVAILABLE)
lbs_server_nps->pos.fields = LBS_POSITION_FIELDS_NONE;
- }
lbs_server_emit_status_changed(lbs_server_nps->lbs_dbus_server, LBS_SERVER_METHOD_NPS, status);
}
g_mutex_unlock(&lbs_server_nps->mutex);
time(×tamp);
- if (timestamp == lbs_server_nps->last_pos.timestamp) {
+ if (timestamp == lbs_server_nps->last_pos.timestamp)
return FALSE;
- }
nps_set_status(lbs_server_nps, LBS_STATUS_AVAILABLE);
/* save the token in persistent storage */
g_mutex_lock(&lbs_server_nps->mutex);
lbs_server_nps->token = g_new0(unsigned char, tokenSize);
- if (lbs_server_nps->token) {
+
+ if (lbs_server_nps->token)
memcpy(lbs_server_nps->token, token, tokenSize);
- }
+
g_mutex_unlock(&lbs_server_nps->mutex);
}
LOG_NPS(DBG_LOW, "_nps_token_callback ended");
int ret = 0;
switch (method) {
- case LBS_SERVER_METHOD_GPS:
+ case LBS_SERVER_METHOD_GPS:
+
+ g_mutex_lock(&lbs_server->mutex);
+ lbs_server->gps_client_count++;
+ g_mutex_unlock(&lbs_server->mutex);
+
+ if (lbs_server->is_gps_running == TRUE) {
+ LOG_GPS(DBG_LOW, "gps is already running");
+ return;
+ }
+ LOG_GPS(DBG_LOW, "start_tracking GPS");
+ lbs_server->status = LBS_STATUS_ACQUIRING;
+ if (request_start_session((int)(lbs_server->optimized_interval_array[method])) == TRUE) {
g_mutex_lock(&lbs_server->mutex);
- lbs_server->gps_client_count++;
+ lbs_server->is_gps_running = TRUE;
g_mutex_unlock(&lbs_server->mutex);
- if (lbs_server->is_gps_running == TRUE) {
- LOG_GPS(DBG_LOW, "gps is already running");
- return;
- }
- LOG_GPS(DBG_LOW, "start_tracking GPS");
- lbs_server->status = LBS_STATUS_ACQUIRING;
+ lbs_server->is_needed_changing_interval = FALSE;
- if (request_start_session((int)(lbs_server->optimized_interval_array[method])) == TRUE) {
- g_mutex_lock(&lbs_server->mutex);
- lbs_server->is_gps_running = TRUE;
- g_mutex_unlock(&lbs_server->mutex);
+ /* ADD notify */
+ setting_notify_key_changed(VCONFKEY_LOCATION_ENABLED, __setting_gps_cb, lbs_server);
+ } else {
+ LOG_GPS(DBG_ERR, "Failed to request_start_session");
+ }
- lbs_server->is_needed_changing_interval = FALSE;
+ break;
- /* ADD notify */
- setting_notify_key_changed(VCONFKEY_LOCATION_ENABLED, __setting_gps_cb, lbs_server);
- } else {
- LOG_GPS(DBG_ERR, "Failed to request_start_session");
- }
+ case LBS_SERVER_METHOD_NPS:
+ g_mutex_lock(&lbs_server->mutex);
+ lbs_server->nps_client_count++;
+ g_mutex_unlock(&lbs_server->mutex);
- break;
+ if (lbs_server->is_nps_running == TRUE) {
+ LOG_NPS(DBG_LOW, "nps is already running");
+ return;
+ }
- case LBS_SERVER_METHOD_NPS:
- g_mutex_lock(&lbs_server->mutex);
- lbs_server->nps_client_count++;
- g_mutex_unlock(&lbs_server->mutex);
+ LOG_NPS(DBG_LOW, "start_tracking - LBS_SERVER_METHOD_NPS");
+ nps_set_status(lbs_server, LBS_STATUS_ACQUIRING);
- if (lbs_server->is_nps_running == TRUE) {
- LOG_NPS(DBG_LOW, "nps is already running");
- return;
- }
+ void *handle_str = NULL;
+ ret = get_nps_plugin_module()->start(lbs_server->period, __nps_callback, lbs_server, &(handle_str));
+ LOG_NPS(DBG_LOW, "after get_nps_plugin_module()->location");
- LOG_NPS(DBG_LOW, "start_tracking - LBS_SERVER_METHOD_NPS");
- nps_set_status(lbs_server, LBS_STATUS_ACQUIRING);
+ if (ret) {
+ lbs_server->handle = handle_str;
+ g_mutex_lock(&lbs_server->mutex);
+ lbs_server->is_nps_running = TRUE;
+ g_mutex_unlock(&lbs_server->mutex);
+ /* calling key_changed API was comment out.
+ vconf_ignore_key_changed(VCONFKEY_LOCATION_NETWORK_ENABLED, _network_enabled_cb);
+ */
+ return;
+ }
- void *handle_str = NULL;
- ret = get_nps_plugin_module()->start(lbs_server->period, __nps_callback, lbs_server, &(handle_str));
- LOG_NPS(DBG_LOW, "after get_nps_plugin_module()->location");
+ if (nps_is_dummy_plugin_module() != TRUE)
+ nps_offline_location(lbs_server);
- if (ret) {
- lbs_server->handle = handle_str;
- g_mutex_lock(&lbs_server->mutex);
- lbs_server->is_nps_running = TRUE;
- g_mutex_unlock(&lbs_server->mutex);
- /* calling key_changed API was comment out.
- vconf_ignore_key_changed(VCONFKEY_LOCATION_NETWORK_ENABLED, _network_enabled_cb);
- */
- return;
- }
+ LOG_NPS(DBG_ERR, "Filed to start NPS");
+ nps_set_status(lbs_server, LBS_STATUS_ERROR);
+ break;
- if (nps_is_dummy_plugin_module() != TRUE) {
- nps_offline_location(lbs_server);
- }
+ case LBS_SERVER_METHOD_MOCK:
+ g_mutex_lock(&lbs_server->mutex);
+ lbs_server->mock_client_count++;
+ g_mutex_unlock(&lbs_server->mutex);
- LOG_NPS(DBG_ERR, "Filed to start NPS");
- nps_set_status(lbs_server, LBS_STATUS_ERROR);
- break;
+ if (lbs_server->is_mock_running == TRUE) {
+ LOG_MOCK(DBG_LOW, "mock is already running");
+ return;
+ }
- case LBS_SERVER_METHOD_MOCK:
+ LOG_MOCK(DBG_LOW, "start_tracking MOCK");
+ ret = mock_start_tracking(lbs_server);
+ if (ret) {
g_mutex_lock(&lbs_server->mutex);
- lbs_server->mock_client_count++;
+ lbs_server->is_mock_running = TRUE;
g_mutex_unlock(&lbs_server->mutex);
- if (lbs_server->is_mock_running == TRUE) {
- LOG_MOCK(DBG_LOW, "mock is already running");
- return;
- }
-
- LOG_MOCK(DBG_LOW, "start_tracking MOCK");
- ret = mock_start_tracking(lbs_server);
- if (ret) {
- g_mutex_lock(&lbs_server->mutex);
- lbs_server->is_mock_running = TRUE;
- g_mutex_unlock(&lbs_server->mutex);
-
- /* ADD notify */
- setting_notify_key_changed(VCONFKEY_LOCATION_MOCK_ENABLED, __setting_mock_cb, lbs_server);
- return;
- } else {
- LOG_MOCK(DBG_ERR, "Failed to start MOCK");
- }
- break;
+ /* ADD notify */
+ setting_notify_key_changed(VCONFKEY_LOCATION_MOCK_ENABLED, __setting_mock_cb, lbs_server);
+ return;
+ } else {
+ LOG_MOCK(DBG_ERR, "Failed to start MOCK");
+ }
+ break;
- default:
- LOG_GPS(DBG_LOW, "start_tracking Invalid");
- break;
+ default:
+ LOG_GPS(DBG_LOW, "start_tracking Invalid");
+ break;
}
}
int ret = get_nps_plugin_module()->stop(lbs_server_nps->handle, __nps_cancel_callback, lbs_server_nps);
if (ret) {
g_mutex_lock(&lbs_server_nps->mutex);
- while (lbs_server_nps->is_nps_running) {
+
+ while (lbs_server_nps->is_nps_running)
g_cond_wait(&lbs_server_nps->cond, &lbs_server_nps->mutex);
- }
+
lbs_server_nps->is_nps_running = FALSE;
g_mutex_unlock(&lbs_server_nps->mutex);
}
static void stop_tracking(lbs_server_s *lbs_server, lbs_server_method_e method)
{
switch (method) {
- case LBS_SERVER_METHOD_GPS:
- LOG_GPS(DBG_LOW, "stop_tracking GPS");
+ case LBS_SERVER_METHOD_GPS:
+ LOG_GPS(DBG_LOW, "stop_tracking GPS");
- gps_set_last_position(&lbs_server->position);
+ gps_set_last_position(&lbs_server->position);
+ g_mutex_lock(&lbs_server->mutex);
+ lbs_server->gps_client_count--;
+ g_mutex_unlock(&lbs_server->mutex);
+
+ if (lbs_server->is_gps_running == FALSE) {
+ LOG_GPS(DBG_LOW, "gps is already stopped");
+ return;
+ }
+
+ if (lbs_server->gps_client_count <= 0) {
g_mutex_lock(&lbs_server->mutex);
- lbs_server->gps_client_count--;
- g_mutex_unlock(&lbs_server->mutex);
+ lbs_server->gps_client_count = 0;
- if (lbs_server->is_gps_running == FALSE) {
- LOG_GPS(DBG_LOW, "gps is already stopped");
- return;
+ if (request_stop_session() == TRUE) {
+ lbs_server->is_gps_running = FALSE;
+ lbs_server->sv_used = FALSE;
+ /* remove notify */
+ setting_ignore_key_changed(VCONFKEY_LOCATION_ENABLED, __setting_gps_cb);
}
+ g_mutex_unlock(&lbs_server->mutex);
+ }
- if (lbs_server->gps_client_count <= 0) {
- g_mutex_lock(&lbs_server->mutex);
- lbs_server->gps_client_count = 0;
+ lbs_server->status = LBS_STATUS_UNAVAILABLE;
+ lbs_server_emit_status_changed(lbs_server->lbs_dbus_server, LBS_SERVER_METHOD_GPS, LBS_STATUS_UNAVAILABLE);
- if (request_stop_session() == TRUE) {
- lbs_server->is_gps_running = FALSE;
- lbs_server->sv_used = FALSE;
- /* remove notify */
- setting_ignore_key_changed(VCONFKEY_LOCATION_ENABLED, __setting_gps_cb);
- }
- g_mutex_unlock(&lbs_server->mutex);
- }
+ break;
+ case LBS_SERVER_METHOD_NPS:
+ LOG_NPS(DBG_LOW, "stop_tracking NPS");
- lbs_server->status = LBS_STATUS_UNAVAILABLE;
- lbs_server_emit_status_changed(lbs_server->lbs_dbus_server, LBS_SERVER_METHOD_GPS,
- LBS_STATUS_UNAVAILABLE);
+ g_mutex_lock(&lbs_server->mutex);
+ lbs_server->nps_client_count--;
+ g_mutex_unlock(&lbs_server->mutex);
- break;
- case LBS_SERVER_METHOD_NPS:
- LOG_NPS(DBG_LOW, "stop_tracking NPS");
+ if (lbs_server->is_nps_running == FALSE) {
+ LOG_NPS(DBG_LOW, "nps is already stopped");
+ return;
+ }
+ if (lbs_server->nps_client_count <= 0) {
g_mutex_lock(&lbs_server->mutex);
- lbs_server->nps_client_count--;
+ lbs_server->nps_client_count = 0;
g_mutex_unlock(&lbs_server->mutex);
- if (lbs_server->is_nps_running == FALSE) {
- LOG_NPS(DBG_LOW, "nps is already stopped");
- return;
- }
+ LOG_NPS(DBG_LOW, "lbs_server_nps Normal stop");
+ nps_stop(lbs_server);
+ }
- if (lbs_server->nps_client_count <= 0) {
- g_mutex_lock(&lbs_server->mutex);
- lbs_server->nps_client_count = 0;
- g_mutex_unlock(&lbs_server->mutex);
+ break;
+ case LBS_SERVER_METHOD_MOCK:
+ LOG_NPS(DBG_LOW, "stop_tracking MOCK");
- LOG_NPS(DBG_LOW, "lbs_server_nps Normal stop");
- nps_stop(lbs_server);
- }
+ g_mutex_lock(&lbs_server->mutex);
+ lbs_server->mock_client_count--;
+ g_mutex_unlock(&lbs_server->mutex);
- break;
- case LBS_SERVER_METHOD_MOCK:
- LOG_NPS(DBG_LOW, "stop_tracking MOCK");
+ if (lbs_server->is_mock_running == FALSE) {
+ LOG_NPS(DBG_LOW, "mock is already stopped");
+ return;
+ }
+ if (lbs_server->mock_client_count <= 0) {
g_mutex_lock(&lbs_server->mutex);
- lbs_server->mock_client_count--;
+ lbs_server->mock_client_count = 0;
g_mutex_unlock(&lbs_server->mutex);
- if (lbs_server->is_mock_running == FALSE) {
- LOG_NPS(DBG_LOW, "mock is already stopped");
- return;
- }
-
- if (lbs_server->mock_client_count <= 0) {
- g_mutex_lock(&lbs_server->mutex);
- lbs_server->mock_client_count = 0;
- g_mutex_unlock(&lbs_server->mutex);
-
- LOG_NPS(DBG_LOW, "lbs_server_mock Normal stop");
- mock_stop_tracking(lbs_server);
- setting_ignore_key_changed(VCONFKEY_LOCATION_MOCK_ENABLED, __setting_mock_cb);
- }
+ LOG_NPS(DBG_LOW, "lbs_server_mock Normal stop");
+ mock_stop_tracking(lbs_server);
+ setting_ignore_key_changed(VCONFKEY_LOCATION_MOCK_ENABLED, __setting_mock_cb);
+ }
- break;
- default:
- LOG_GPS(DBG_LOW, "stop_tracking Invalid");
- break;
+ break;
+ default:
+ LOG_GPS(DBG_LOW, "stop_tracking Invalid");
+ break;
}
}
int method = updator_ud->method;
LOG_GPS(DBG_LOW, "method:[%d], key:[%s] interval:[%u], current optimized interval [%u]", method, (char *)key, interval_array[method], lbs_server->optimized_interval_array[method]);
- if ((lbs_server->temp_minimum_interval > interval_array[method])) {
+ if ((lbs_server->temp_minimum_interval > interval_array[method]))
lbs_server->temp_minimum_interval = interval_array[method];
- }
}
static gboolean update_pos_tracking_interval(lbs_server_interval_manipulation_type type, const gchar *client, int method, guint interval, gpointer userdata)
if (is_need_remove_client_from_table) {
LOG_GPS(DBG_LOW, "is_need_remove_client_from_table is TRUE");
- if (!g_hash_table_remove(lbs_server->dynamic_interval_table, client)) {
+ if (!g_hash_table_remove(lbs_server->dynamic_interval_table, client))
LOG_GPS(DBG_ERR, "g_hash_table_remove is failed.");
- }
+
LOG_GPS(DBG_LOW, "REMOVE done.");
}
break;
if (g_hash_table_size(lbs_server->dynamic_interval_table) == 0) {
LOG_GPS(DBG_LOW, "dynamic_interval_table size is zero. It will be updated all value as 0");
int i = 0;
- for (i = 0; i < LBS_SERVER_METHOD_SIZE; i++) {
+ for (i = 0; i < LBS_SERVER_METHOD_SIZE; i++)
lbs_server->optimized_interval_array[i] = 0;
- }
+
ret_val = FALSE;
} else {
LOG_GPS(DBG_LOW, "dynamic_interval_table size is not zero.");
lbs_server->is_needed_changing_interval = TRUE;
}
- if (lbs_server->is_needed_changing_interval) {
+ if (lbs_server->is_needed_changing_interval)
ret_val = TRUE;
- } else {
+ else
ret_val = FALSE;
- }
}
LOG_GPS(DBG_LOW, "update_pos_tracking_interval done.");
return ret_val;
lbs_server_s *lbs_server = (lbs_server_s *)userdata;
switch (method) {
- case LBS_SERVER_METHOD_GPS:
- request_change_pos_update_interval_standalone_gps(lbs_server->optimized_interval_array[method]);
- break;
- default:
- break;
+ case LBS_SERVER_METHOD_GPS:
+ request_change_pos_update_interval_standalone_gps(lbs_server->optimized_interval_array[method]);
+ break;
+ default:
+ break;
}
}
}
}
- if (client) {
+ if (client)
update_pos_tracking_interval(LBS_SERVER_INTERVAL_ADD, client, method, interval, lbs_server);
- }
if (app_id) {
- if (LBS_SERVER_METHOD_GPS == method) {
+ if (LBS_SERVER_METHOD_GPS == method)
gps_dump_log("START GPS", app_id);
- }
+
free(app_id);
}
}
}
- if (client) {
+ if (client)
update_pos_tracking_interval(LBS_SERVER_INTERVAL_REMOVE, client, method, interval, lbs_server);
- }
if (app_id) {
- if (LBS_SERVER_METHOD_GPS == method) {
+ if (LBS_SERVER_METHOD_GPS == method)
gps_dump_log("STOP GPS", app_id);
- }
+
free(app_id);
}
}
}
- if (client) {
+ if (client)
update_pos_tracking_interval(LBS_SERVER_INTERVAL_ADD, client, method, batch_interval, lbs_server);
- }
start_batch_tracking(lbs_server, batch_interval, batch_period);
} else if (!g_strcmp0(g_variant_get_string(value, &length), "STOP_BATCH")) {
- if (client) {
+ if (client)
update_pos_tracking_interval(LBS_SERVER_INTERVAL_REMOVE, client, method, interval, lbs_server);
- }
stop_batch_tracking(lbs_server);
LOG_GPS(DBG_ERR, "option [%s]", option);
if (!g_strcmp0(option, "DELGPS")) {
- if (request_delete_gps_data() != TRUE) {
+ if (request_delete_gps_data() != TRUE)
LOG_GPS(DBG_ERR, "Fail to request_delete_gps_data");
- }
} else if (!g_strcmp0(option, "USE_SV")) {
g_mutex_lock(&lbs_server->mutex);
if (lbs_server->sv_used == FALSE)
if (shutdown_arr[LBS_SERVER_METHOD_GPS]) {
LOG_GPS(DBG_LOW, "-> shutdown GPS");
if (lbs_server->is_gps_running) {
- if (gps_remove_all_clients(lbs_server)) {
+ if (gps_remove_all_clients(lbs_server))
LOG_GPS(DBG_ERR, "<<<< Abnormal shutdown >>>>");
- }
}
}
int enabled = 0;
setting_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED, &enabled);
if (enabled == 0) {
- if (lbs_server->loop != NULL) {
+ if (lbs_server->loop != NULL)
g_main_loop_quit(lbs_server->loop);
- }
} else {
- if (vconf_notify_key_changed(VCONFKEY_LOCATION_NETWORK_ENABLED, _network_enabled_cb, lbs_server)) {
+ if (vconf_notify_key_changed(VCONFKEY_LOCATION_NETWORK_ENABLED, _network_enabled_cb, lbs_server))
LOG_NPS(DBG_ERR, "fail to notify VCONFKEY_LOCATION_NETWORK_ENABLED");
- }
}
#endif
}
fields = (LBS_POSITION_EXT_FIELDS_LATITUDE | LBS_POSITION_EXT_FIELDS_LONGITUDE | LBS_POSITION_EXT_FIELDS_ALTITUDE | LBS_POSITION_EXT_FIELDS_SPEED | LBS_POSITION_EXT_FIELDS_DIRECTION);
accuracy = g_variant_new("(idd)", LBS_ACCURACY_LEVEL_DETAILED, pos->hor_accuracy, pos->ver_accuracy);
- if (NULL == accuracy) {
+ if (NULL == accuracy)
LOG_GPS(DBG_LOW, "accuracy is NULL");
- }
- lbs_server_emit_position_changed(lbs_server->lbs_dbus_server, LBS_SERVER_METHOD_GPS,
- fields, pos->timestamp, pos->latitude, pos->longitude, pos->altitude,
- pos->speed, pos->bearing, 0.0, accuracy);
+ lbs_server_emit_position_changed(lbs_server->lbs_dbus_server, LBS_SERVER_METHOD_GPS, fields, pos->timestamp,
+ pos->latitude, pos->longitude, pos->altitude, pos->speed, pos->bearing, 0.0, accuracy);
}
static void gps_update_batch_cb(batch_data_t *batch, void *user_data)
lbs_server->nmea.data[nmea->len] = '\0';
lbs_server->nmea.len = nmea->len;
- if (lbs_server->nmea_used == FALSE) {
+ if (lbs_server->nmea_used == FALSE)
return;
- }
+
LOG_GPS(DBG_LOW, "[%d] %s", lbs_server->nmea.timestamp, lbs_server->nmea.data);
lbs_server_emit_nmea_changed(lbs_server->lbs_dbus_server, lbs_server->nmea.timestamp, lbs_server->nmea.data);
}
setting_get_int(VCONFKEY_LOCATION_NV_LAST_WPS_TIMESTAMP, ×tamp);
str = setting_get_string(VCONFKEY_LOCATION_NV_LAST_WPS_LOCATION);
- if (str == NULL) {
+ if (str == NULL)
return;
- }
+
snprintf(location, sizeof(location), "%s", str);
free(str);
while (last_location[index] != NULL) {
switch (index) {
- case 0:
- lbs_server_nps->last_pos.latitude = strtod(last_location[index], NULL);
- break;
- case 1:
- lbs_server_nps->last_pos.longitude = strtod(last_location[index], NULL);
- break;
- case 2:
- lbs_server_nps->last_pos.altitude = strtod(last_location[index], NULL);
- break;
- case 3:
- lbs_server_nps->last_pos.speed = strtod(last_location[index], NULL);
- break;
- case 4:
- lbs_server_nps->last_pos.direction = strtod(last_location[index], NULL);
- break;
- case 5:
- lbs_server_nps->last_pos.hor_accuracy = strtod(last_location[index], NULL);
- break;
- default:
- break;
+ case 0:
+ lbs_server_nps->last_pos.latitude = strtod(last_location[index], NULL);
+ break;
+ case 1:
+ lbs_server_nps->last_pos.longitude = strtod(last_location[index], NULL);
+ break;
+ case 2:
+ lbs_server_nps->last_pos.altitude = strtod(last_location[index], NULL);
+ break;
+ case 3:
+ lbs_server_nps->last_pos.speed = strtod(last_location[index], NULL);
+ break;
+ case 4:
+ lbs_server_nps->last_pos.direction = strtod(last_location[index], NULL);
+ break;
+ case 5:
+ lbs_server_nps->last_pos.hor_accuracy = strtod(last_location[index], NULL);
+ break;
+ default:
+ break;
}
if (++index == MAX_NPS_LOC_ITEM) break;
last_location[index] = (char *)strtok_r(NULL, ";", &last);
lbs_server_nps->last_pos.speed = 0.0;
lbs_server_nps->last_pos.direction = 0.0;
-#if !GLIB_CHECK_VERSION (2, 31, 0)
+#if !GLIB_CHECK_VERSION(2, 31, 0)
GMutex *mutex_temp = g_mutex_new();
lbs_server_nps->mutex = *mutex_temp;
GCond *cond_temp = g_cond_new();
lbs_server_nps->is_nps_running = FALSE;
lbs_server_nps->nps_client_count = 0;
-#if !GLIB_CHECK_VERSION (2, 31, 0)
+#if !GLIB_CHECK_VERSION(2, 31, 0)
g_cond_free(&lbs_server_nps->cond);
g_mutex_free(&lbs_server_nps->mutex);
#endif
cb.sv_cb = gps_update_satellite_cb;
cb.nmea_cb = gps_update_nmea_cb;
-#if !GLIB_CHECK_VERSION (2, 31, 0)
- if (!g_thread_supported()) {
+#if !GLIB_CHECK_VERSION(2, 31, 0)
+ if (!g_thread_supported())
g_thread_init(NULL);
- }
#endif
-#if !GLIB_CHECK_VERSION (2, 35, 0)
+#if !GLIB_CHECK_VERSION(2, 35, 0)
g_type_init();
#endif
g_mock_position.fields = LBS_POSITION_EXT_FIELDS_NONE;
LOG_SEC("[%ld] lat = %lf, lng = %lf", lbs_server->mock_position.timestamp, lbs_server->mock_position.latitude, lbs_server->mock_position.longitude);
- if (lbs_server->mock_position.latitude >= -90 && lbs_server->mock_position.latitude <= 90 ) {
+ if (lbs_server->mock_position.latitude >= -90 && lbs_server->mock_position.latitude <= 90)
lbs_server->mock_position.fields |= LBS_POSITION_EXT_FIELDS_LATITUDE;
- }
- if (lbs_server->mock_position.longitude >= -180 && lbs_server->mock_position.longitude <= 180 ) {
+ if (lbs_server->mock_position.longitude >= -180 && lbs_server->mock_position.longitude <= 180)
lbs_server->mock_position.fields |= LBS_POSITION_EXT_FIELDS_LONGITUDE;
- }
lbs_server->mock_position.fields |= LBS_POSITION_EXT_FIELDS_ALTITUDE;
- if (lbs_server->mock_position.speed >= 0) {
+ if (lbs_server->mock_position.speed >= 0)
lbs_server->mock_position.fields |= LBS_POSITION_EXT_FIELDS_SPEED;
- }
- if (lbs_server->mock_position.direction >= 0 && lbs_server->mock_position.direction <= 360) {
+ if (lbs_server->mock_position.direction >= 0 && lbs_server->mock_position.direction <= 360)
lbs_server->mock_position.fields |= LBS_POSITION_EXT_FIELDS_DIRECTION;
- }
lbs_server->mock_accuracy = g_variant_ref_sink(g_variant_new("(idd)", LBS_ACCURACY_LEVEL_DETAILED, lbs_server->mock_position.hor_accuracy, -1));
}
} else if (lbs_server->mock_status == LBS_STATUS_AVAILABLE) {
if (g_mock_position.timestamp) {
- if (g_mock_position.fields & LBS_POSITION_EXT_FIELDS_DIRTY){
- __copy_mock_location(lbs_server);
- }
-
+ if (g_mock_position.fields & LBS_POSITION_EXT_FIELDS_DIRTY)
+ __copy_mock_location(lbs_server);
+
time_t timestamp;
time(×tamp);
- LOG_SEC("[%d] lat = %lf, lng = %lf", lbs_server->mock_position.timestamp,
+ LOG_SEC("[%d] lat = %lf, lng = %lf", lbs_server->mock_position.timestamp,
lbs_server->mock_position.latitude, lbs_server->mock_position.longitude);
lbs_server->mock_position.timestamp = timestamp;
static gboolean mock_start_tracking(lbs_server_s *lbs_server)
{
-
LOG_MOCK(DBG_LOW, "ENTER >>>");
if (!lbs_server) {
LOG_MOCK(DBG_ERR, "lbs_server is NULL!!");
__copy_mock_location(lbs_server);
mock_set_status(lbs_server, LBS_STATUS_ACQUIRING);
- if (!lbs_server->mock_timer) {
+ if (!lbs_server->mock_timer)
lbs_server->mock_timer = g_timeout_add_seconds(1, __mock_position_update_cb, lbs_server);
- }
return TRUE;
}
lbs_server->mock_timer = 0;
g_variant_unref(lbs_server->mock_accuracy);
- if (lbs_server->is_mock_running){
+ if (lbs_server->is_mock_running) {
g_mutex_lock(&lbs_server->mutex);
lbs_server->is_mock_running = FALSE;
g_mutex_unlock(&lbs_server->mutex);
lbs_server->mock_status = status;
- if (lbs_server->mock_status == LBS_STATUS_AVAILABLE) {
+ if (lbs_server->mock_status == LBS_STATUS_AVAILABLE)
setting_set_int(VCONFKEY_LOCATION_MOCK_STATE, POSITION_CONNECTED);
- } else if (lbs_server->mock_status == LBS_STATUS_ACQUIRING) {
+ else if (lbs_server->mock_status == LBS_STATUS_ACQUIRING)
setting_set_int(VCONFKEY_LOCATION_MOCK_STATE, POSITION_SEARCHING);
- } else {
+ else
setting_set_int(VCONFKEY_LOCATION_MOCK_STATE, POSITION_OFF);
- }
lbs_server_emit_status_changed(lbs_server->lbs_dbus_server, LBS_SERVER_METHOD_MOCK, status);
}
if (onoff == 0) {
ret = mock_remove_all_clients(lbs_server);
- if (ret == FALSE) {
+
+ if (ret == FALSE)
LOG_MOCK(DBG_LOW, "already removed.");
- }
}
}
LBS_POSITION_EXT_FIELDS_SPEED = 1 << 3,
LBS_POSITION_EXT_FIELDS_DIRECTION = 1 << 4,
LBS_POSITION_EXT_FIELDS_CLIMB = 1 << 5,
- LBS_POSITION_EXT_FIELDS_DIRTY= 1 << 6
+ LBS_POSITION_EXT_FIELDS_DIRTY = 1 << 6
} LbsPositionExtFields;
/**
raw_nmea_fd = open(filepath, O_RDWR | O_APPEND | O_CREAT, 0644);
- if (raw_nmea_fd < 0) {
+ if (raw_nmea_fd < 0)
LOG_GPS(DBG_ERR, "FAILED to open nmea_data file, error[%d]", errno);
- } else {
+ else
LOG_GPS(DBG_LOW, "Success :: raw_nmea_fd [%d]", raw_nmea_fd);
- }
return;
}
if (raw_nmea_fd != -1) {
close_ret_val = close(raw_nmea_fd);
- if (close_ret_val < 0) {
+ if (close_ret_val < 0)
LOG_GPS(DBG_ERR, "FAILED to close raw_nmea_fd[%d], error[%d]", raw_nmea_fd, errno);
- }
+
raw_nmea_fd = -1;
}
return;
dlclose(plugin_handle);
- if (g_plugin) {
+ if (g_plugin)
g_plugin = NULL;
- }
+
return TRUE;
}
#include <glib.h>
#include <glib-object.h>
-#if !GLIB_CHECK_VERSION (2, 31, 0)
+#if !GLIB_CHECK_VERSION(2, 31, 0)
#include <glib/gthread.h>
#endif
static void __nps_plugin_handler_deinit(void)
{
- if (g_nps_plugin.handle != NULL) {
+ if (g_nps_plugin.handle != NULL)
g_nps_plugin.handle = NULL;
- }
}
static int _gps_server_gps_event_cb(gps_event_info_t *gps_event_info, void *user_data);
char *module_name;
gps_failure_reason_t ReasonCode = GPS_FAILURE_CAUSE_NORMAL;
- if (server->replay_enabled == TRUE) {
+ if (server->replay_enabled == TRUE)
module_name = REPLAY_MODULE;
- } else {
+ else
module_name = server->gps_plugin.name;
- }
LOG_GPS(DBG_LOW, "replay_enabled:%d, Loading plugin.name: %s", server->replay_enabled, module_name);
{
int val;
- if (setting_get_int(VCONFKEY_LOCATION_GPS_STATE, &val) == FALSE) {
+ if (setting_get_int(VCONFKEY_LOCATION_GPS_STATE, &val) == FALSE)
val = POSITION_OFF;
- }
return val;
}
int ret;
switch (gps_state) {
- case POSITION_CONNECTED:
+ case POSITION_CONNECTED:
ret = setting_set_int(VCONFKEY_LOCATION_GPS_STATE, POSITION_CONNECTED);
gps_dump_log("GPS state : POSITION_CONNECTED", NULL);
break;
- case POSITION_SEARCHING:
+ case POSITION_SEARCHING:
ret = setting_set_int(VCONFKEY_LOCATION_GPS_STATE, POSITION_SEARCHING);
gps_dump_log("GPS state : POSITION_SEARCHING", NULL);
break;
- case POSITION_OFF:
+ case POSITION_OFF:
ret = setting_set_int(VCONFKEY_LOCATION_GPS_STATE, POSITION_OFF);
gps_dump_log("GPS state : POSITION_OFF", NULL);
break;
- default:
+ default:
ret = setting_set_int(VCONFKEY_LOCATION_GPS_STATE, POSITION_OFF);
break;
}
- if (ret == TRUE) {
+ if (ret == TRUE)
LOG_GPS(DBG_LOW, "Succeed to set VCONFKEY_LOCATION_GPS_STATE");
- } else {
+ else
LOG_GPS(DBG_ERR, "Fail to set VCONF_LOCATION_GPS_STATE");
- }
}
int request_change_pos_update_interval_standalone_gps(unsigned int interval)
static void _gps_plugin_handler_deinit(gps_server_t *server)
{
- if (server->gps_plugin.handle != NULL) {
+ if (server->gps_plugin.handle != NULL)
server->gps_plugin.handle = NULL;
- }
if (server->gps_plugin.name != NULL) {
free(server->gps_plugin.name);
if (server->pos_data == NULL) {
server->pos_data = (pos_data_t *) malloc(sizeof(pos_data_t));
- if (server->pos_data == NULL) {
+ if (server->pos_data == NULL)
LOG_GPS(DBG_WARN, "//callback: server->pos_data re-malloc Failed!!");
- } else {
+ else
memset(server->pos_data, 0x00, sizeof(pos_data_t));
- }
}
if (server->batch_data == NULL) {
server->batch_data = (batch_data_t *) malloc(sizeof(batch_data_t));
- if (server->batch_data == NULL) {
+ if (server->batch_data == NULL)
LOG_GPS(DBG_WARN, "//callback: server->batch_data re-malloc Failed!!");
- } else {
+ else
memset(server->batch_data, 0x00, sizeof(batch_data_t));
- }
}
if (server->sv_data == NULL) {
server->sv_data = (sv_data_t *) malloc(sizeof(sv_data_t));
- if (server->sv_data == NULL) {
+ if (server->sv_data == NULL)
LOG_GPS(DBG_WARN, "//callback: server->sv_data re-malloc Failed!!");
- } else {
+ else
memset(server->sv_data, 0x00, sizeof(sv_data_t));
- }
}
if (server->nmea_data == NULL) {
server->nmea_data = (nmea_data_t *) malloc(sizeof(nmea_data_t));
- if (server->nmea_data == NULL) {
+ if (server->nmea_data == NULL)
LOG_GPS(DBG_WARN, "//callback: server->nmea_data re-malloc Failed!!");
- } else {
+ else
memset(server->nmea_data, 0x00, sizeof(nmea_data_t));
- }
}
_gps_server_set_gps_state(POSITION_SEARCHING);
{
LOG_GPS(DBG_LOW, "Enter _gps_server_close_data_connection");
- if (server->dnet_used > 0) {
+ if (server->dnet_used > 0)
server->dnet_used--;
- }
if (server->dnet_used != 0) {
LOG_GPS(DBG_LOW, "Cannot stop the data connection! [ dnet_used : %d ]", server->dnet_used);
}
switch (event) {
- case GEOFENCE_ADD_FENCE:
- LOG_GPS(DBG_LOW, "Geofence ID[%d], Success ADD_GEOFENCE", geofence_id);
- break;
- case GEOFENCE_DELETE_FENCE:
- LOG_GPS(DBG_LOW, "Geofence ID[%d], Success DELETE_GEOFENCE", geofence_id);
- break;
- case GEOFENCE_PAUSE_FENCE:
- LOG_GPS(DBG_LOW, "Geofence ID[%d], Success PAUSE_GEOFENCE", geofence_id);
- break;
- case GEOFENCE_RESUME_FENCE:
- LOG_GPS(DBG_LOW, "Geofence ID[%d], Success RESUME_GEOFENCE", geofence_id);
- break;
- default:
- break;
+ case GEOFENCE_ADD_FENCE:
+ LOG_GPS(DBG_LOW, "Geofence ID[%d], Success ADD_GEOFENCE", geofence_id);
+ break;
+ case GEOFENCE_DELETE_FENCE:
+ LOG_GPS(DBG_LOW, "Geofence ID[%d], Success DELETE_GEOFENCE", geofence_id);
+ break;
+ case GEOFENCE_PAUSE_FENCE:
+ LOG_GPS(DBG_LOW, "Geofence ID[%d], Success PAUSE_GEOFENCE", geofence_id);
+ break;
+ case GEOFENCE_RESUME_FENCE:
+ LOG_GPS(DBG_LOW, "Geofence ID[%d], Success RESUME_GEOFENCE", geofence_id);
+ break;
+ default:
+ break;
}
}
}
switch (gps_event_info->event_id) {
- case GPS_EVENT_START_SESSION:
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_START_SESSION :::::::::::::::");
- if (gps_event_info->event_data.start_session_rsp.error == GPS_ERR_NONE) {
- _gps_server_start_event(server);
- } else {
- LOG_GPS(DBG_ERR, "//Start Session Failed, error : %d",
- gps_event_info->event_data.start_session_rsp.error);
- }
- break;
- case GPS_EVENT_SET_OPTION: {
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_SET_OPTION :::::::::::::::");
- if (gps_event_info->event_data.set_option_rsp.error != GPS_ERR_NONE) {
- LOG_GPS(DBG_ERR, "//Set Option Failed, error : %d",
- gps_event_info->event_data.set_option_rsp.error);
- }
- }
- break;
-
- case GPS_EVENT_STOP_SESSION:
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_STOP_SESSION :::::::::::::::");
- if (gps_event_info->event_data.stop_session_rsp.error == GPS_ERR_NONE) {
- _gps_server_close_data_connection(server);
- _gps_server_stop_event(server);
- } else {
- LOG_GPS(DBG_ERR, "//Stop Session Failed, error : %d",
- gps_event_info->event_data.stop_session_rsp.error);
- }
-
- break;
- case GPS_EVENT_CHANGE_INTERVAL:
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_CHANGE_INTERVAL :::::::::::::::");
- if (gps_event_info->event_data.change_interval_rsp.error == GPS_ERR_NONE) {
- LOG_GPS(DBG_LOW, "Change interval success.");
- } else {
- LOG_GPS(DBG_ERR, "//Change interval Failed, error : %d",
- gps_event_info->event_data.change_interval_rsp.error);
- }
- break;
- case GPS_EVENT_REPORT_POSITION:
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_POSITION :::::::::::::::");
- if (gps_event_info->event_data.pos_ind.error == GPS_ERR_NONE) {
- _report_pos_event(server, gps_event_info);
- } else {
- LOG_GPS(DBG_ERR, "GPS_EVENT_POSITION Failed, error : %d", gps_event_info->event_data.pos_ind.error);
- }
- break;
- case GPS_EVENT_REPORT_BATCH:
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_BATCH :::::::::::::::");
- if (gps_event_info->event_data.batch_ind.error == GPS_ERR_NONE) {
- _report_batch_event(server, gps_event_info);
- } else {
- LOG_GPS(DBG_ERR, "GPS_EVENT_BATCH Failed, error : %d", gps_event_info->event_data.batch_ind.error);
- }
- break;
- case GPS_EVENT_REPORT_SATELLITE:
- if (gps_event_info->event_data.sv_ind.error == GPS_ERR_NONE) {
- if (gps_event_info->event_data.sv_ind.sv.pos_valid) {
- if (_gps_server_get_gps_state() != POSITION_CONNECTED)
- _gps_server_set_gps_state(POSITION_CONNECTED);
- } else {
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_SATELLITE :::::::::::::::");
- if (_gps_server_get_gps_state() != POSITION_SEARCHING)
- _gps_server_set_gps_state(POSITION_SEARCHING);
- }
- _report_sv_event(server, gps_event_info);
- } else {
- LOG_GPS(DBG_ERR, "GPS_EVENT_SATELLITE Failed, error : %d", gps_event_info->event_data.sv_ind.error);
- }
- break;
- case GPS_EVENT_REPORT_NMEA:
- if (_gps_server_get_gps_state() != POSITION_CONNECTED) {
- /*LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_NMEA :::::::::::::::"); */
- }
+ case GPS_EVENT_START_SESSION:
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_START_SESSION :::::::::::::::");
+ if (gps_event_info->event_data.start_session_rsp.error == GPS_ERR_NONE)
+ _gps_server_start_event(server);
+ else
+ LOG_GPS(DBG_ERR, "//Start Session Failed, error : %d", gps_event_info->event_data.start_session_rsp.error);
+
+ break;
+ case GPS_EVENT_SET_OPTION:
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_SET_OPTION :::::::::::::::");
+ if (gps_event_info->event_data.set_option_rsp.error != GPS_ERR_NONE)
+ LOG_GPS(DBG_ERR, "//Set Option Failed, error : %d", gps_event_info->event_data.set_option_rsp.error);
+
+ break;
+ case GPS_EVENT_STOP_SESSION:
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_STOP_SESSION :::::::::::::::");
+ if (gps_event_info->event_data.stop_session_rsp.error == GPS_ERR_NONE) {
+ _gps_server_close_data_connection(server);
+ _gps_server_stop_event(server);
+ } else {
+ LOG_GPS(DBG_ERR, "//Stop Session Failed, error : %d", gps_event_info->event_data.stop_session_rsp.error);
+ }
- if (gps_event_info->event_data.nmea_ind.error == GPS_ERR_NONE) {
- _report_nmea_event(server, gps_event_info);
+ break;
+ case GPS_EVENT_CHANGE_INTERVAL:
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_CHANGE_INTERVAL :::::::::::::::");
+ if (gps_event_info->event_data.change_interval_rsp.error == GPS_ERR_NONE)
+ LOG_GPS(DBG_LOW, "Change interval success.");
+ else
+ LOG_GPS(DBG_ERR, "//Change interval Failed, error : %d", gps_event_info->event_data.change_interval_rsp.error);
+
+ break;
+ case GPS_EVENT_REPORT_POSITION:
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_POSITION :::::::::::::::");
+ if (gps_event_info->event_data.pos_ind.error == GPS_ERR_NONE)
+ _report_pos_event(server, gps_event_info);
+ else
+ LOG_GPS(DBG_ERR, "GPS_EVENT_POSITION Failed, error : %d", gps_event_info->event_data.pos_ind.error);
+
+ break;
+ case GPS_EVENT_REPORT_BATCH:
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_BATCH :::::::::::::::");
+ if (gps_event_info->event_data.batch_ind.error == GPS_ERR_NONE)
+ _report_batch_event(server, gps_event_info);
+ else
+ LOG_GPS(DBG_ERR, "GPS_EVENT_BATCH Failed, error : %d", gps_event_info->event_data.batch_ind.error);
+
+ break;
+ case GPS_EVENT_REPORT_SATELLITE:
+ if (gps_event_info->event_data.sv_ind.error == GPS_ERR_NONE) {
+ if (gps_event_info->event_data.sv_ind.sv.pos_valid) {
+ if (_gps_server_get_gps_state() != POSITION_CONNECTED)
+ _gps_server_set_gps_state(POSITION_CONNECTED);
} else {
- LOG_GPS(DBG_ERR, "GPS_EVENT_NMEA Failed, error : %d", gps_event_info->event_data.nmea_ind.error);
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_SATELLITE :::::::::::::::");
+ if (_gps_server_get_gps_state() != POSITION_SEARCHING)
+ _gps_server_set_gps_state(POSITION_SEARCHING);
}
- break;
- case GPS_EVENT_ERR_CAUSE:
- break;
- case GPS_EVENT_AGPS_VERIFICATION_INDI:
- break;
- case GPS_EVENT_GET_IMSI:
- break;
- case GPS_EVENT_GET_REF_LOCATION:
- break;
- case GPS_EVENT_OPEN_DATA_CONNECTION: {
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_OPEN_DATA_CONNECTION :::::::::::::::");
- result = _gps_server_open_data_connection(server);
- }
- break;
- case GPS_EVENT_CLOSE_DATA_CONNECTION: {
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_CLOSE_DATA_CONNECTION :::::::::::::::");
- result = _gps_server_close_data_connection(server);
- }
- break;
- case GPS_EVENT_DNS_LOOKUP_IND:
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_DNS_LOOKUP_IND :::::::::::::::");
- if (gps_event_info->event_data.dns_query_ind.error == GPS_ERR_NONE) {
- result = _gps_server_resolve_dns(gps_event_info->event_data.dns_query_ind.domain_name);
- } else {
- result = FALSE;
- }
- if (result == TRUE) {
- LOG_GPS(DBG_LOW, "Success to get the DNS Query about [ %s ]",
- gps_event_info->event_data.dns_query_ind.domain_name);
- }
- break;
- case GPS_EVENT_FACTORY_TEST:
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_FACTORY_TEST :::::::::::::::");
- if (gps_event_info->event_data.factory_test_rsp.error == GPS_ERR_NONE) {
- LOG_GPS(DBG_LOW, "[LBS server] Response Factory test result success");
- _gps_server_send_facttest_result(gps_event_info->event_data.factory_test_rsp.snr,
+ _report_sv_event(server, gps_event_info);
+ } else {
+ LOG_GPS(DBG_ERR, "GPS_EVENT_SATELLITE Failed, error : %d", gps_event_info->event_data.sv_ind.error);
+ }
+ break;
+ case GPS_EVENT_REPORT_NMEA:
+ /* if (_gps_server_get_gps_state() != POSITION_CONNECTED) */
+ /*LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_NMEA :::::::::::::::"); */
+
+ if (gps_event_info->event_data.nmea_ind.error == GPS_ERR_NONE)
+ _report_nmea_event(server, gps_event_info);
+ else
+ LOG_GPS(DBG_ERR, "GPS_EVENT_NMEA Failed, error : %d", gps_event_info->event_data.nmea_ind.error);
+
+ break;
+ case GPS_EVENT_ERR_CAUSE:
+ break;
+ case GPS_EVENT_AGPS_VERIFICATION_INDI:
+ break;
+ case GPS_EVENT_GET_IMSI:
+ break;
+ case GPS_EVENT_GET_REF_LOCATION:
+ break;
+ case GPS_EVENT_OPEN_DATA_CONNECTION: {
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_OPEN_DATA_CONNECTION :::::::::::::::");
+ result = _gps_server_open_data_connection(server);
+ }
+ break;
+ case GPS_EVENT_CLOSE_DATA_CONNECTION: {
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_CLOSE_DATA_CONNECTION :::::::::::::::");
+ result = _gps_server_close_data_connection(server);
+ }
+ break;
+ case GPS_EVENT_DNS_LOOKUP_IND:
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_DNS_LOOKUP_IND :::::::::::::::");
+ if (gps_event_info->event_data.dns_query_ind.error == GPS_ERR_NONE)
+ result = _gps_server_resolve_dns(gps_event_info->event_data.dns_query_ind.domain_name);
+ else
+ result = FALSE;
+
+ if (result == TRUE)
+ LOG_GPS(DBG_LOW, "Success to get the DNS Query about [ %s ]", gps_event_info->event_data.dns_query_ind.domain_name);
+
+ break;
+ case GPS_EVENT_FACTORY_TEST:
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_FACTORY_TEST :::::::::::::::");
+ if (gps_event_info->event_data.factory_test_rsp.error == GPS_ERR_NONE) {
+ LOG_GPS(DBG_LOW, "[LBS server] Response Factory test result success");
+ _gps_server_send_facttest_result(gps_event_info->event_data.factory_test_rsp.snr,
gps_event_info->event_data.factory_test_rsp.prn, TRUE);
- } else {
- LOG_GPS(DBG_ERR, "//[LBS server] Response Factory test result ERROR");
- _gps_server_send_facttest_result(gps_event_info->event_data.factory_test_rsp.snr,
+ } else {
+ LOG_GPS(DBG_ERR, "//[LBS server] Response Factory test result ERROR");
+ _gps_server_send_facttest_result(gps_event_info->event_data.factory_test_rsp.snr,
gps_event_info->event_data.factory_test_rsp.prn, FALSE);
- }
- break;
- case GPS_EVENT_GEOFENCE_TRANSITION:
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_GEOFENCE_TRANSITION :::::::::::::::");
- _report_geofence_transition(gps_event_info->event_data.geofence_transition_ind.geofence_id,
- gps_event_info->event_data.geofence_transition_ind.state,
- gps_event_info->event_data.geofence_transition_ind.pos.latitude,
- gps_event_info->event_data.geofence_transition_ind.pos.longitude,
- gps_event_info->event_data.geofence_transition_ind.pos.altitude,
- gps_event_info->event_data.geofence_transition_ind.pos.speed,
- gps_event_info->event_data.geofence_transition_ind.pos.bearing,
- gps_event_info->event_data.geofence_transition_ind.pos.hor_accuracy);
- break;
- case GPS_EVENT_GEOFENCE_STATUS:
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_GEOFENCE_STATUS :::::::::::::::");
- _report_geofence_service_status(gps_event_info->event_data.geofence_status_ind.status);
- break;
- case GPS_EVENT_ADD_GEOFENCE:
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_ADD_GEOFENCE :::::::::::::::");
- _gps_server_send_geofence_result(GEOFENCE_ADD_FENCE,
- gps_event_info->event_data.geofence_event_rsp.geofence_id,
- gps_event_info->event_data.geofence_event_rsp.error);
- break;
- case GPS_EVENT_DELETE_GEOFENCE:
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_DELETE_GEOFENCE :::::::::::::::");
- _gps_server_send_geofence_result(GEOFENCE_DELETE_FENCE,
- gps_event_info->event_data.geofence_event_rsp.geofence_id,
- gps_event_info->event_data.geofence_event_rsp.error);
- break;
- case GPS_EVENT_PAUSE_GEOFENCE:
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_PAUSE_GEOFENCE :::::::::::::::");
- _gps_server_send_geofence_result(GEOFENCE_PAUSE_FENCE,
- gps_event_info->event_data.geofence_event_rsp.geofence_id,
- gps_event_info->event_data.geofence_event_rsp.error);
- break;
- case GPS_EVENT_RESUME_GEOFENCE:
- LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_RESUME_GEOFENCE :::::::::::::::");
- _gps_server_send_geofence_result(GEOFENCE_RESUME_FENCE,
- gps_event_info->event_data.geofence_event_rsp.geofence_id,
- gps_event_info->event_data.geofence_event_rsp.error);
- break;
- default:
- LOG_GPS(DBG_WARN, "//Error: Isettingalid Event Type %d", gps_event_info->event_id);
- break;
+ }
+ break;
+ case GPS_EVENT_GEOFENCE_TRANSITION:
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_GEOFENCE_TRANSITION :::::::::::::::");
+ _report_geofence_transition(gps_event_info->event_data.geofence_transition_ind.geofence_id,
+ gps_event_info->event_data.geofence_transition_ind.state,
+ gps_event_info->event_data.geofence_transition_ind.pos.latitude,
+ gps_event_info->event_data.geofence_transition_ind.pos.longitude,
+ gps_event_info->event_data.geofence_transition_ind.pos.altitude,
+ gps_event_info->event_data.geofence_transition_ind.pos.speed,
+ gps_event_info->event_data.geofence_transition_ind.pos.bearing,
+ gps_event_info->event_data.geofence_transition_ind.pos.hor_accuracy);
+ break;
+ case GPS_EVENT_GEOFENCE_STATUS:
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_GEOFENCE_STATUS :::::::::::::::");
+ _report_geofence_service_status(gps_event_info->event_data.geofence_status_ind.status);
+ break;
+ case GPS_EVENT_ADD_GEOFENCE:
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_ADD_GEOFENCE :::::::::::::::");
+ _gps_server_send_geofence_result(GEOFENCE_ADD_FENCE,
+ gps_event_info->event_data.geofence_event_rsp.geofence_id,
+ gps_event_info->event_data.geofence_event_rsp.error);
+ break;
+ case GPS_EVENT_DELETE_GEOFENCE:
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_DELETE_GEOFENCE :::::::::::::::");
+ _gps_server_send_geofence_result(GEOFENCE_DELETE_FENCE,
+ gps_event_info->event_data.geofence_event_rsp.geofence_id,
+ gps_event_info->event_data.geofence_event_rsp.error);
+ break;
+ case GPS_EVENT_PAUSE_GEOFENCE:
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_PAUSE_GEOFENCE :::::::::::::::");
+ _gps_server_send_geofence_result(GEOFENCE_PAUSE_FENCE,
+ gps_event_info->event_data.geofence_event_rsp.geofence_id,
+ gps_event_info->event_data.geofence_event_rsp.error);
+ break;
+ case GPS_EVENT_RESUME_GEOFENCE:
+ LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_RESUME_GEOFENCE :::::::::::::::");
+ _gps_server_send_geofence_result(GEOFENCE_RESUME_FENCE,
+ gps_event_info->event_data.geofence_event_rsp.geofence_id,
+ gps_event_info->event_data.geofence_event_rsp.error);
+ break;
+ default:
+ LOG_GPS(DBG_WARN, "//Error: Isettingalid Event Type %d", gps_event_info->event_id);
+ break;
}
return result;
}
info.msg_size = ni_data->msg_size;
info.status = TRUE;
- if (!get_plugin_module()->request(GPS_ACTION_REQUEST_SUPL_NI, &info, &reason_code)) {
+ if (!get_plugin_module()->request(GPS_ACTION_REQUEST_SUPL_NI, &info, &reason_code))
LOG_GPS(DBG_ERR, "Failed to request SUPL NI (code:%d)", reason_code);
- }
free(ni_data);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- if (pthread_create(&server->popup_thread, &attr, request_supl_ni_session, new_message) != 0) {
+ if (pthread_create(&server->popup_thread, &attr, request_supl_ni_session, new_message) != 0)
LOG_GPS(DBG_WARN, "Can not make pthread......");
- }
}
static void _gps_supl_networkinit_wappushcb(msg_handle_t hMsgHandle, const char *pPushHeader, const char *pPushBody,
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- if (pthread_create(&server->popup_thread, &attr, request_supl_ni_session, new_message) != 0) {
+ if (pthread_create(&server->popup_thread, &attr, request_supl_ni_session, new_message) != 0)
LOG_GPS(DBG_WARN, "Can not make pthread......");
- }
}
static void *_gps_register_msgfwcb(void *data)
}
#ifdef _TIZEN_PUBLIC_
- if (pthread_create(&g_gps_server->msg_thread, NULL, _gps_register_msgfwcb, g_gps_server) != 0) {
+ if (pthread_create(&g_gps_server->msg_thread, NULL, _gps_register_msgfwcb, g_gps_server) != 0)
LOG_GPS(DBG_WARN, "Can not make pthread......");
- }
#endif
LOG_GPS(DBG_LOW, "Initialization-gps is completed.");
_gps_ignore_params();
- if (!get_plugin_module()->deinit(&ReasonCode)) {
+ if (!get_plugin_module()->deinit(&ReasonCode))
LOG_GPS(DBG_WARN, "Fail to gps module de-initialization");
- }
+
unload_plugin_module(g_gps_server->gps_plugin.handle);
_gps_plugin_handler_deinit(g_gps_server);
char *ret_str;
ret_str = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
- if (ret_str == NULL) {
+ if (ret_str == NULL)
return FALSE;
- }
memcpy(device_name, ret_str, strlen(ret_str) + 1);
static void on_signal_callback(const gchar *sig, GVariant *param, gpointer user_data)
{
- if (!g_strcmp0(sig, "SatelliteChanged")) {
+ if (!g_strcmp0(sig, "SatelliteChanged"))
satellite_callback(param, user_data);
- } else if (!g_strcmp0(sig, "PositionChanged")) {
+ else if (!g_strcmp0(sig, "PositionChanged"))
position_callback(param, user_data);
- } else if (!g_strcmp0(sig, "StatusChanged")) {
+ else if (!g_strcmp0(sig, "StatusChanged"))
status_callback(param, user_data);
- } else {
+ else
MOD_LOGD("Invaild signal[%s]", sig);
- }
}
static int start_batch(gpointer handle, LocModBatchExtCB batch_cb, guint batch_interval, guint batch_period, gpointer userdata)
}
MOD_LOGD("gps-manger(%p) pos_cb (%p) user_data(%p)", gps_manager, gps_manager->pos_cb, gps_manager->userdata);
- ret = lbs_client_start(gps_manager->lbs_client, pos_update_interval,
- LBS_CLIENT_LOCATION_CB | LBS_CLIENT_LOCATION_STATUS_CB | LBS_CLIENT_SATELLITE_CB | LBS_CLIENT_NMEA_CB, on_signal_callback, gps_manager);
+ ret = lbs_client_start(gps_manager->lbs_client, pos_update_interval, LBS_CLIENT_LOCATION_CB | LBS_CLIENT_LOCATION_STATUS_CB | LBS_CLIENT_SATELLITE_CB | LBS_CLIENT_NMEA_CB, on_signal_callback, gps_manager);
if (ret != LBS_CLIENT_ERROR_NONE) {
if (ret == LBS_CLIENT_ERROR_ACCESS_DENIED) {
MOD_LOGE("Access denied[%d]", ret);
}
gps_manager->lbs_client = NULL;
- if (gps_manager->status_cb) {
+ if (gps_manager->status_cb)
gps_manager->status_cb(FALSE, LOCATION_STATUS_NO_FIX, gps_manager->userdata);
- }
gps_manager->status_cb = NULL;
gps_manager->pos_cb = NULL;
}
} else {
if (vconf_get_int(VCONFKEY_LOCATION_NV_LAST_GPS_TIMESTAMP, ×tamp)) {
+ MOD_LOGD("Error to get VCONFKEY_LOCATION_NV_LAST_GPS_TIMESTAMP");
return LOCATION_ERROR_NOT_AVAILABLE;
}
str = vconf_get_str(VCONFKEY_LOCATION_NV_LAST_GPS_LOCATION);
if (str == NULL) {
+ MOD_LOGD("Error to get VCONFKEY_LOCATION_NV_LAST_GPS_LOCATION");
return LOCATION_ERROR_NOT_AVAILABLE;
}
snprintf(location, sizeof(location), "%s", str);
last_location[index] = (char *)strtok_r(location, ";", &last);
while (last_location[index] != NULL) {
switch (index) {
- case 0:
- latitude = strtod(last_location[index], NULL);
- break;
- case 1:
- longitude = strtod(last_location[index], NULL);
- break;
- case 2:
- altitude = strtod(last_location[index], NULL);
- break;
- case 3:
- speed = strtod(last_location[index], NULL);
- break;
- case 4:
- direction = strtod(last_location[index], NULL);
- break;
- case 5:
- hor_accuracy = strtod(last_location[index], NULL);
- break;
- case 6:
- ver_accuracy = strtod(last_location[index], NULL);
- break;
- default:
- break;
+ case 0:
+ latitude = strtod(last_location[index], NULL);
+ break;
+ case 1:
+ longitude = strtod(last_location[index], NULL);
+ break;
+ case 2:
+ altitude = strtod(last_location[index], NULL);
+ break;
+ case 3:
+ speed = strtod(last_location[index], NULL);
+ break;
+ case 4:
+ direction = strtod(last_location[index], NULL);
+ break;
+ case 5:
+ hor_accuracy = strtod(last_location[index], NULL);
+ break;
+ case 6:
+ ver_accuracy = strtod(last_location[index], NULL);
+ break;
+ default:
+ break;
}
if (++index == MAX_GPS_LOC_ITEM) break;
last_location[index] = (char *)strtok_r(NULL, ";", &last);
}
}
- if (timestamp) {
+ if (timestamp)
status = LOCATION_STATUS_3D_FIX;
- } else {
+ else
return LOCATION_ERROR_NOT_AVAILABLE;
- }
level = LOCATION_ACCURACY_LEVEL_DETAILED;
*position = location_position_new(timestamp, latitude, longitude, altitude, status);
ops->set_position_update_interval = set_position_update_interval;
Dl_info info;
- if (dladdr(&get_last_position, &info) == 0) {
+ if (dladdr(&get_last_position, &info) == 0)
MOD_LOGE("Failed to get module name");
- } else if (g_strrstr(info.dli_fname, "gps")) {
+ else if (g_strrstr(info.dli_fname, "gps"))
ops->get_nmea = get_nmea;
- } else {
+ else
MOD_LOGE("Invalid module name");
- }
GpsManagerData *gps_manager = g_new0(GpsManagerData, 1);
g_return_val_if_fail(gps_manager, NULL);
#include <dlog.h>
#define TAG_LOCATION "LOCATION_GPS"
-#define MOD_LOGD(fmt,args...) LOG(LOG_DEBUG, TAG_LOCATION, fmt, ##args)
-#define MOD_LOGW(fmt,args...) LOG(LOG_WARN, TAG_LOCATION, fmt, ##args)
-#define MOD_LOGI(fmt,args...) LOG(LOG_INFO, TAG_LOCATION, fmt, ##args)
-#define MOD_LOGE(fmt,args...) LOG(LOG_ERROR, TAG_LOCATION, fmt, ##args)
-#define MOD_SECLOG(fmt,args...) SECURE_LOG(LOG_DEBUG, TAG_LOCATION, fmt, ##args)
+#define MOD_LOGD(fmt, args...) LOG(LOG_DEBUG, TAG_LOCATION, fmt, ##args)
+#define MOD_LOGW(fmt, args...) LOG(LOG_WARN, TAG_LOCATION, fmt, ##args)
+#define MOD_LOGI(fmt, args...) LOG(LOG_INFO, TAG_LOCATION, fmt, ##args)
+#define MOD_LOGE(fmt, args...) LOG(LOG_ERROR, TAG_LOCATION, fmt, ##args)
+#define MOD_SECLOG(fmt, args...) SECURE_LOG(LOG_DEBUG, TAG_LOCATION, fmt, ##args)
#define TAG_MOD_NPS "LOCATION_NPS"
-#define MOD_NPS_LOGD(fmt,args...) LOG(LOG_DEBUG, TAG_MOD_NPS, fmt, ##args)
-#define MOD_NPS_LOGW(fmt,args...) LOG(LOG_WARN, TAG_MOD_NPS, fmt, ##args)
-#define MOD_NPS_LOGI(fmt,args...) LOG(LOG_INFO, TAG_MOD_NPS, fmt, ##args)
-#define MOD_NPS_LOGE(fmt,args...) LOG(LOG_ERROR, TAG_MOD_NPS, fmt, ##args)
-#define MOD_NPS_SECLOG(fmt,args...) SECURE_LOG(LOG_DEBUG, TAG_MOD_NPS, fmt, ##args)
+#define MOD_NPS_LOGD(fmt, args...) LOG(LOG_DEBUG, TAG_MOD_NPS, fmt, ##args)
+#define MOD_NPS_LOGW(fmt, args...) LOG(LOG_WARN, TAG_MOD_NPS, fmt, ##args)
+#define MOD_NPS_LOGI(fmt, args...) LOG(LOG_INFO, TAG_MOD_NPS, fmt, ##args)
+#define MOD_NPS_LOGE(fmt, args...) LOG(LOG_ERROR, TAG_MOD_NPS, fmt, ##args)
+#define MOD_NPS_SECLOG(fmt, args...) SECURE_LOG(LOG_DEBUG, TAG_MOD_NPS, fmt, ##args)
#define TAG_MOD_MOCK "LOCATION_MOCK"
-#define MOD_MOCK_LOGD(fmt,args...) LOG(LOG_DEBUG, TAG_MOD_MOCK, fmt, ##args)
-#define MOD_MOCK_LOGW(fmt,args...) LOG(LOG_WARN, TAG_MOD_MOCK, fmt, ##args)
-#define MOD_MOCK_LOGI(fmt,args...) LOG(LOG_INFO, TAG_MOD_MOCK, fmt, ##args)
-#define MOD_MOCK_LOGE(fmt,args...) LOG(LOG_ERROR, TAG_MOD_MOCK, fmt, ##args)
-#define MOD_MOCK_SECLOG(fmt,args...) SECURE_LOG(LOG_DEBUG, TAG_MOD_MOCK, fmt, ##args)
+#define MOD_MOCK_LOGD(fmt, args...) LOG(LOG_DEBUG, TAG_MOD_MOCK, fmt, ##args)
+#define MOD_MOCK_LOGW(fmt, args...) LOG(LOG_WARN, TAG_MOD_MOCK, fmt, ##args)
+#define MOD_MOCK_LOGI(fmt, args...) LOG(LOG_INFO, TAG_MOD_MOCK, fmt, ##args)
+#define MOD_MOCK_LOGE(fmt, args...) LOG(LOG_ERROR, TAG_MOD_MOCK, fmt, ##args)
+#define MOD_MOCK_SECLOG(fmt, args...) SECURE_LOG(LOG_DEBUG, TAG_MOD_MOCK, fmt, ##args)
#endif
} ModMockData;
typedef enum {
- LBS_STATUS_ERROR, //from lbs-server
- LBS_STATUS_UNAVAILABLE, //from lbs-server
- LBS_STATUS_ACQUIRING, // from lbs-server
- LBS_STATUS_AVAILABLE, // from lbs-server
- LBS_STATUS_BATCH, //from lbs-server
- LBS_STATUS_MOCK_SET, //from lbs-dbus status for mock location
- LBS_STATUS_MOCK_FAIL, // from lbs-dbus status fro mock location
+ LBS_STATUS_ERROR, /* from lbs-server */
+ LBS_STATUS_UNAVAILABLE,
+ LBS_STATUS_ACQUIRING,
+ LBS_STATUS_AVAILABLE,
+ LBS_STATUS_BATCH,
+ LBS_STATUS_MOCK_SET, /* from lbs-dbus status for mock location */
+ LBS_STATUS_MOCK_FAIL,
} LbsStatus;
static void __status_callback(GVariant *param, void *user_data)
static void __on_signal_callback(const gchar *sig, GVariant *param, gpointer user_data)
{
- if (!g_strcmp0(sig, "PositionChanged")) {
+ if (!g_strcmp0(sig, "PositionChanged"))
__position_callback(param, user_data);
- } else if (!g_strcmp0(sig, "StatusChanged")) {
+ else if (!g_strcmp0(sig, "StatusChanged"))
__status_callback(param, user_data);
- } else {
+ else
MOD_MOCK_LOGD("Invaild signal[%s]", sig);
- }
}
-//static int start(gpointer handle, guint pos_update_interval, LocModStatusCB status_cb, LocModPositionExtCB pos_cb, gpointer userdata)
+/*static int start(gpointer handle, guint pos_update_interval, LocModStatusCB status_cb, LocModPositionExtCB pos_cb, gpointer userdata)*/
static int start(gpointer handle, LocModStatusCB status_cb, LocModPositionExtCB pos_cb, gpointer userdata)
{
MOD_MOCK_LOGD("ENTER >>>");
}
MOD_MOCK_LOGD("mod_mock(%p) pos_cb(%p) user_data(%p)", mod_mock, mod_mock->pos_cb, mod_mock->userdata);
- ret = lbs_client_start(mod_mock->lbs_client, 1,
- LBS_CLIENT_LOCATION_CB | LBS_CLIENT_LOCATION_STATUS_CB, __on_signal_callback, mod_mock);
+ ret = lbs_client_start(mod_mock->lbs_client, 1, LBS_CLIENT_LOCATION_CB | LBS_CLIENT_LOCATION_STATUS_CB, __on_signal_callback, mod_mock);
if (ret != LBS_CLIENT_ERROR_NONE) {
if (ret == LBS_CLIENT_ERROR_ACCESS_DENIED) {
MOD_MOCK_LOGE("Access denied[%d]", ret);
}
mod_mock->lbs_client = NULL;
- if (mod_mock->status_cb) {
+ if (mod_mock->status_cb)
mod_mock->status_cb(FALSE, LOCATION_STATUS_NO_FIX, mod_mock->userdata);
- }
+
mod_mock->status_cb = NULL;
mod_mock->pos_cb = NULL;
if (mod_mock->last_pos)
*position = location_position_copy(mod_mock->last_pos);
+
if (mod_mock->last_vel)
*velocity = location_velocity_copy(mod_mock->last_vel);
- if (mod_mock->last_acc) {
+
+ if (mod_mock->last_acc)
*accuracy = location_accuracy_copy(mod_mock->last_acc);
- }
return LOCATION_ERROR_NONE;
}
LocationVelocity *vel = NULL;
LocationAccuracy *acc = NULL;
- if (altitude) {
+ if (altitude)
pos = location_position_new(timestamp, latitude, longitude, altitude, LOCATION_STATUS_3D_FIX);
- } else {
+ else
pos = location_position_new(timestamp, latitude, longitude, 0.0, LOCATION_STATUS_2D_FIX);
- }
vel = location_velocity_new(timestamp, speed, direction, climb);
acc = location_accuracy_new(LOCATION_ACCURACY_LEVEL_DETAILED, horizontal, vertical);
static void on_signal_callback(const gchar *sig, GVariant *param, gpointer user_data)
{
- if (!g_strcmp0(sig, "PositionChanged")) {
+ if (!g_strcmp0(sig, "PositionChanged"))
position_callback(param, user_data);
- } else if (!g_strcmp0(sig, "StatusChanged")) {
+ else if (!g_strcmp0(sig, "StatusChanged"))
status_callback(param, user_data);
- } else {
+ else
MOD_NPS_LOGD("Invaild signal[%s]", sig);
- }
-
}
static int start(gpointer handle, LocModStatusCB status_cb, LocModPositionExtCB pos_cb, gpointer userdata)
return LOCATION_ERROR_NOT_AVAILABLE;
}
- ret = lbs_client_start(mod_nps->lbs_client, 1,
- LBS_CLIENT_LOCATION_CB | LBS_CLIENT_LOCATION_STATUS_CB, on_signal_callback, mod_nps);
+ ret = lbs_client_start(mod_nps->lbs_client, 1, LBS_CLIENT_LOCATION_CB | LBS_CLIENT_LOCATION_STATUS_CB, on_signal_callback, mod_nps);
if (ret != LBS_CLIENT_ERROR_NONE) {
if (ret == LBS_CLIENT_ERROR_ACCESS_DENIED) {
MOD_NPS_LOGE("Access denied[%d]", ret);
lbs_client_destroy(mod_nps->lbs_client);
mod_nps->lbs_client = NULL;
- if (mod_nps->status_cb) {
+ if (mod_nps->status_cb)
mod_nps->status_cb(FALSE, LOCATION_STATUS_NO_FIX, mod_nps->userdata);
- }
mod_nps->status_cb = NULL;
mod_nps->pos_cb = NULL;
}
} else {
if (vconf_get_int(VCONFKEY_LOCATION_NV_LAST_WPS_TIMESTAMP, ×tamp)) {
+ MOD_NPS_LOGD("Last timestamp failed");
return LOCATION_ERROR_NOT_AVAILABLE;
}
str = vconf_get_str(VCONFKEY_LOCATION_NV_LAST_WPS_LOCATION);
if (str == NULL) {
+ MOD_NPS_LOGD("Last wps is null");
return LOCATION_ERROR_NOT_AVAILABLE;
}
snprintf(location, sizeof(location), "%s", str);
break;
last_location[index] = (char *)strtok_r(NULL, ";", &last);
}
+
if (index != MAX_NPS_LOC_ITEM) {
+ MOD_NPS_LOGD("Error item index");
return LOCATION_ERROR_NOT_AVAILABLE;
}
index = 0;
}
level = LOCATION_ACCURACY_LEVEL_STREET;
- if (timestamp) {
+
+ if (timestamp)
status = LOCATION_STATUS_3D_FIX;
- } else {
+ else
return LOCATION_ERROR_NOT_AVAILABLE;
- }
*position = location_position_new((guint) timestamp, latitude, longitude, altitude, status);
*velocity = location_velocity_new((guint) timestamp, speed, direction, 0.0);
g_return_if_fail(mod_nps);
if (mod_nps->lbs_client) {
- if (mod_nps->is_started) {
+ if (mod_nps->is_started)
lbs_client_stop(mod_nps->lbs_client);
- }
+
lbs_client_destroy(mod_nps->lbs_client);
mod_nps->lbs_client = NULL;
}