From: kj7.sung Date: Mon, 2 May 2016 05:14:18 +0000 (+0900) Subject: Applied Tizen coding rules X-Git-Tag: submit/tizen/20160503.075433^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=89cc3656ceadbdd3a7512fcdb2b226dd1eeba6de;p=platform%2Fcore%2Flocation%2Flbs-server-plugin-replay.git Applied Tizen coding rules Change-Id: Ifcf22593d75b130339c9286f0dfd1097d34b1fa3 Signed-off-by: kj7.sung --- diff --git a/gps-plugin/include/gps_plugin_debug.h b/gps-plugin/include/gps_plugin_debug.h index ac6278d..ba358da 100644 --- a/gps-plugin/include/gps_plugin_debug.h +++ b/gps-plugin/include/gps_plugin_debug.h @@ -39,11 +39,11 @@ extern "C" { #define DBG_ERR LOG_ERROR #ifdef GPS_DLOG_DEBUG /* Debug mode */ -#define LOG_PLUGIN(dbg_lvl,fmt,args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args) -#define SECLOG_PLUGIN(dbg_lvl,fmt,args...) SECURE_SLOG(dbg_lvl, TAG_GPS_PLUGIN, "[%-40s: %-4d] "fmt, __FILE__, __LINE__, ##args) +#define LOG_PLUGIN(dbg_lvl, fmt, args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args) +#define SECLOG_PLUGIN(dbg_lvl, fmt, args...) SECURE_SLOG(dbg_lvl, TAG_GPS_PLUGIN, "[%-40s: %-4d] "fmt, __FILE__, __LINE__, ##args) #else /* Release(commercial) mode */ -#define LOG_PLUGIN(dbg_lvl,fmt,args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args) -#define SECLOG_PLUGIN(dbg_lvl,fmt,args...) SECURE_SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args) +#define LOG_PLUGIN(dbg_lvl, fmt, args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args) +#define SECLOG_PLUGIN(dbg_lvl, fmt, args...) SECURE_SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args) #endif #endif diff --git a/gps-plugin/src/gps_plugin_replay.c b/gps-plugin/src/gps_plugin_replay.c index c5a44a9..544ca63 100644 --- a/gps-plugin/src/gps_plugin_replay.c +++ b/gps-plugin/src/gps_plugin_replay.c @@ -103,9 +103,8 @@ void gps_plugin_replay_pos_event(pos_data_t *data) gps_event.event_data.pos_ind.pos.ver_accuracy = data->ver_accuracy; } - if (g_gps_event_cb != NULL) { + if (g_gps_event_cb != NULL) g_gps_event_cb(&gps_event, g_user_data); - } } void gps_plugin_replay_batch_event(pos_data_t *data, replay_timeout *timer) @@ -143,22 +142,20 @@ void gps_plugin_replay_batch_event(pos_data_t *data, replay_timeout *timer) LOG_PLUGIN(DBG_LOW, "Add location info to batch file [%s]", buf); ret = fwrite(buf, 1, strlen(buf), timer->batch_fd); - if (ret != strlen(buf)) { + if (ret != strlen(buf)) LOG_PLUGIN(DBG_ERR, "Fail to write file[%s]", batch_path); - } (timer->num_of_batch)++ ; } } if (timer->lcd_mode == VCONFKEY_PM_STATE_NORMAL) { - if ((timestamp - timer->batch_start_time) >= timer->batch_interval) { + if ((timestamp - timer->batch_start_time) >= timer->batch_interval) timer->is_flush = TRUE; - } + } else { - if ((timestamp - timer->batch_start_time) >= timer->batch_period) { + if ((timestamp - timer->batch_start_time) >= timer->batch_period) timer->is_flush = TRUE; - } } if (timer->is_flush) { @@ -218,9 +215,8 @@ void gps_plugin_replay_sv_event(sv_data_t *data) } } - if (g_gps_event_cb != NULL) { + if (g_gps_event_cb != NULL) g_gps_event_cb(&gps_event, g_user_data); - } } void gps_plugin_replay_nmea_event(nmea_data_t *data) @@ -253,9 +249,8 @@ void gps_plugin_replay_nmea_event(nmea_data_t *data) memcpy(gps_event.event_data.nmea_ind.nmea.data, data->data, data->len); } - if (g_gps_event_cb != NULL) { + if (g_gps_event_cb != NULL) g_gps_event_cb(&gps_event, g_user_data); - } if (gps_event.event_data.nmea_ind.nmea.data != NULL) { free(gps_event.event_data.nmea_ind.nmea.data); @@ -268,15 +263,13 @@ void gps_plugin_respond_start_session(gboolean ret) gps_event_info_t gps_event; gps_event.event_id = GPS_EVENT_START_SESSION; - if (ret == TRUE) { + if (ret == TRUE) gps_event.event_data.start_session_rsp.error = GPS_ERR_NONE; - } else { + else gps_event.event_data.start_session_rsp.error = GPS_ERR_COMMUNICATION; - } - if (g_gps_event_cb != NULL) { + if (g_gps_event_cb != NULL) g_gps_event_cb(&gps_event, g_user_data); - } } void gps_plugin_respond_stop_session(void) @@ -286,9 +279,8 @@ void gps_plugin_respond_stop_session(void) gps_event.event_id = GPS_EVENT_STOP_SESSION; gps_event.event_data.stop_session_rsp.error = GPS_ERR_NONE; - if (g_gps_event_cb != NULL) { + if (g_gps_event_cb != NULL) g_gps_event_cb(&gps_event, g_user_data); - } } gboolean gps_plugin_replay_read_nmea(replay_timeout *timer, char *nmea_data) @@ -410,9 +402,9 @@ gboolean gps_plugin_replay_timeout_cb(gpointer data) } if (g_gps_event_cb != NULL) { - if (err != READ_NOT_FIXED) { + if (err != READ_NOT_FIXED) gps_plugin_replay_pos_event(timer->pos_data); - } + gps_plugin_replay_sv_event(timer->sv_data); } ret = TRUE; @@ -464,9 +456,8 @@ gboolean gps_plugin_batch_replay_timeout_cb(gpointer data) } if (g_gps_event_cb != NULL) { - if (timer->batch_mode == BATCH_MODE_ON) { + if (timer->batch_mode == BATCH_MODE_ON) gps_plugin_replay_batch_event(timer->pos_data, timer); - } } ret = TRUE; return ret; @@ -474,9 +465,9 @@ gboolean gps_plugin_batch_replay_timeout_cb(gpointer data) void gps_plugin_stop_replay_mode(replay_timeout *timer) { - if (timer->replay_mode == REPLAY_NMEA && fclose(timer->fd) != 0) { + if (timer->replay_mode == REPLAY_NMEA && fclose(timer->fd) != 0) LOG_PLUGIN(DBG_ERR, "fclose failed"); - } + timer->fd = NULL; if (timer->timeout_src != NULL && timer->default_context != NULL && !g_source_is_destroyed(timer->timeout_src)) { @@ -504,9 +495,9 @@ gboolean gps_plugin_get_nmea_fd(replay_timeout *timer) char *str; str = setting_get_string(VCONFKEY_LOCATION_NMEA_FILE_NAME); - if (str == NULL) { + if (str == NULL) return FALSE; - } + const char *nmea_file_path = tzplatform_mkpath(TZ_SYS_MEDIA, "lbs-server/replay/"); snprintf(replay_file_path, sizeof(replay_file_path), "%s%s", nmea_file_path, str); SECLOG_PLUGIN(DBG_ERR, "replay file name : %s", replay_file_path); @@ -530,16 +521,15 @@ gboolean gps_plugin_start_replay_mode(replay_timeout *timer) gboolean ret = FALSE; if (timer->replay_mode == REPLAY_NMEA) { - if (gps_plugin_get_nmea_fd(timer) == FALSE) { + if (gps_plugin_get_nmea_fd(timer) == FALSE) return FALSE; - } } if (timer->default_context == NULL) { timer->default_context = g_main_context_default(); - if (timer->default_context == NULL) { + + if (timer->default_context == NULL) return ret; - } } if (timer->timeout_src != NULL) { @@ -574,16 +564,15 @@ gboolean gps_plugin_start_batch_mode(replay_timeout *timer, int batch_interval, time(×tamp); if (timer->replay_mode == REPLAY_NMEA) { - if (gps_plugin_get_nmea_fd(timer) == FALSE) { + if (gps_plugin_get_nmea_fd(timer) == FALSE) return FALSE; - } } if (timer->default_context == NULL) { timer->default_context = g_main_context_default(); - if (timer->default_context == NULL) { + + if (timer->default_context == NULL) return ret; - } } if (timer->timeout_src != NULL) { @@ -615,9 +604,8 @@ gboolean gps_plugin_start_batch_mode(replay_timeout *timer, int batch_interval, void gps_plugin_stop_batch_mode(replay_timeout *timer) { - if (timer->batch_mode == BATCH_MODE_ON) { + if (timer->batch_mode == BATCH_MODE_ON) timer->batch_mode = BATCH_MODE_OFF; - } if (timer->batch_fd != NULL) { fclose(timer->batch_fd); @@ -628,14 +616,13 @@ void gps_plugin_stop_batch_mode(replay_timeout *timer) static void replay_mode_changed_cb(keynode_t *key, void *data) { - if (setting_get_int(VCONFKEY_LOCATION_REPLAY_MODE, &g_replay_timer->replay_mode) == FALSE) { + if (setting_get_int(VCONFKEY_LOCATION_REPLAY_MODE, &g_replay_timer->replay_mode) == FALSE) g_replay_timer->replay_mode = REPLAY_OFF; - } if (g_replay_timer->replay_mode == REPLAY_NMEA) { - if (gps_plugin_get_nmea_fd(g_replay_timer) == FALSE) { + if (gps_plugin_get_nmea_fd(g_replay_timer) == FALSE) LOG_PLUGIN(DBG_ERR, "Fail to get nmea fd."); - } + } else { if (g_replay_timer->fd != NULL) { fclose(g_replay_timer->fd); @@ -652,9 +639,8 @@ static void display_mode_changed_cb(keynode_t * key, void *data) g_replay_timer->lcd_mode = VCONFKEY_PM_STATE_LCDOFF; } - if (g_replay_timer->lcd_mode == VCONFKEY_PM_STATE_NORMAL) { + if (g_replay_timer->lcd_mode == VCONFKEY_PM_STATE_NORMAL) g_replay_timer->is_flush = TRUE; - } return; } @@ -677,14 +663,14 @@ replay_timeout *gps_plugin_replay_timer_init() timer->batch_mode = BATCH_MODE_OFF; timer->is_flush = FALSE; - if (setting_get_int(VCONFKEY_LOCATION_REPLAY_MODE, &timer->replay_mode) == FALSE) { + if (setting_get_int(VCONFKEY_LOCATION_REPLAY_MODE, &timer->replay_mode) == FALSE) timer->replay_mode = REPLAY_OFF; - } + setting_notify_key_changed(VCONFKEY_LOCATION_REPLAY_MODE, replay_mode_changed_cb); - if (setting_get_int(VCONFKEY_PM_STATE, &timer->lcd_mode) == FALSE) { + if (setting_get_int(VCONFKEY_PM_STATE, &timer->lcd_mode) == FALSE) timer->lcd_mode = VCONFKEY_PM_STATE_LCDOFF; - } + setting_notify_key_changed(VCONFKEY_PM_STATE, display_mode_changed_cb); timer->pos_data = (pos_data_t *) malloc(sizeof(pos_data_t)); @@ -729,9 +715,8 @@ replay_timeout *gps_plugin_replay_timer_init() void gps_plugin_replay_timer_deinit(replay_timeout *timer) { - if (timer == NULL) { + if (timer == NULL) return; - } if (timer->pos_data != NULL) { free(timer->pos_data); @@ -775,30 +760,30 @@ int gps_plugin_replay_gps_request(gps_action_t gps_action, void *gps_action_data gps_action_start_data_t *gps_start_data = gps_action_data; switch (gps_action) { - case GPS_ACTION_SEND_PARAMS: - break; - case GPS_ACTION_START_SESSION: - gps_plugin_start_replay_mode(g_replay_timer); - break; - case GPS_ACTION_STOP_SESSION: - gps_plugin_stop_replay_mode(g_replay_timer); - break; - case GPS_ACTION_START_BATCH: - gps_plugin_start_batch_mode(g_replay_timer, gps_start_data->interval, gps_start_data->period); - break; - case GPS_ACTION_STOP_BATCH: - gps_plugin_stop_batch_mode(g_replay_timer); - gps_plugin_stop_replay_mode(g_replay_timer); - break; - case GPS_INDI_SUPL_VERIFICATION: - case GPS_INDI_SUPL_DNSQUERY: - case GPS_ACTION_START_FACTTEST: - case GPS_ACTION_STOP_FACTTEST: - case GPS_ACTION_REQUEST_SUPL_NI: - LOG_PLUGIN(DBG_LOW, "Don't use action type : [ %d ]", gps_action); - break; - default: - break; + case GPS_ACTION_SEND_PARAMS: + break; + case GPS_ACTION_START_SESSION: + gps_plugin_start_replay_mode(g_replay_timer); + break; + case GPS_ACTION_STOP_SESSION: + gps_plugin_stop_replay_mode(g_replay_timer); + break; + case GPS_ACTION_START_BATCH: + gps_plugin_start_batch_mode(g_replay_timer, gps_start_data->interval, gps_start_data->period); + break; + case GPS_ACTION_STOP_BATCH: + gps_plugin_stop_batch_mode(g_replay_timer); + gps_plugin_stop_replay_mode(g_replay_timer); + break; + case GPS_INDI_SUPL_VERIFICATION: + case GPS_INDI_SUPL_DNSQUERY: + case GPS_ACTION_START_FACTTEST: + case GPS_ACTION_STOP_FACTTEST: + case GPS_ACTION_REQUEST_SUPL_NI: + LOG_PLUGIN(DBG_LOW, "Don't use action type : [ %d ]", gps_action); + break; + default: + break; } return TRUE; diff --git a/gps-plugin/src/nmea_parser.c b/gps-plugin/src/nmea_parser.c index 3ebee56..d8bf178 100644 --- a/gps-plugin/src/nmea_parser.c +++ b/gps-plugin/src/nmea_parser.c @@ -46,11 +46,10 @@ int used_sat[MAX_GPS_NUM_SAT_USED] = { 0, }; static unsigned char nmea_parser_c2n(unsigned char ch) { - if (ch <= '9') { + if (ch <= '9') return ch - '0'; - } else { + else return (ch - 'A') + 10; - } } int nmea_parser_verify_checksum(char *nmea_sen) @@ -60,13 +59,11 @@ int nmea_parser_verify_checksum(char *nmea_sen) int checksum = 0; int sum = 0; - for (i = 0; i < strlen(nmea_sen) && (nmea_sen[i] != '*'); i++) { + for (i = 0; i < strlen(nmea_sen) && (nmea_sen[i] != '*'); i++) checksum ^= nmea_sen[i]; - } - if (++i + 1 < strlen(nmea_sen)) { + if (++i + 1 < strlen(nmea_sen)) sum = (nmea_parser_c2n(nmea_sen[i]) << 4) + nmea_parser_c2n(nmea_sen[i + 1]); - } if (sum == checksum) { ret = 0; @@ -90,20 +87,20 @@ int nmea_parser_tokenize(char input[], char *token[]) while ((*s != 0) && (num_tokens < MAX_TOEKNS)) { switch (state) { - case 0: - if (*s == ',') { - *s = 0; - state = 1; - } - break; - case 1: - token[num_tokens++] = s; - if (*s == ',') { - *s = 0; - } else { - state = 0; - } - break; + case 0: + if (*s == ',') { + *s = 0; + state = 1; + } + break; + case 1: + token[num_tokens++] = s; + if (*s == ',') + *s = 0; + else + state = 0; + + break; } s++; } @@ -117,9 +114,8 @@ static double nmea_parser_get_latitude(const char *lat, const char *bearing) int deg; double remainder; - if ((*lat == 0) || (*bearing == 0)) { + if ((*lat == 0) || (*bearing == 0)) return latitude; - } ns = (*bearing == 'N') ? NORTH : SOUTH; @@ -138,9 +134,8 @@ static double nmea_parser_get_longitude(const char *lon, const char *bearing) int deg; double remainder; - if (*lon == 0 || (*bearing == 0)) { + if (*lon == 0 || (*bearing == 0)) return longitude; - } ew = (*bearing == 'E') ? EAST : WEST; @@ -156,9 +151,8 @@ static double nmea_parser_get_altitude(const char *alt, const char *unit) { double altitude; - if (*alt == 0) { + if (*alt == 0) return 0.0; - } altitude = atof(alt); altitude = (*unit == 'M') ? altitude : altitude * METER_TO_FEET; @@ -256,9 +250,9 @@ static int nmea_parser_gpgsa(char *token[], pos_data_t *pos) /* selection_type = *token[1]; */ memset(used_sat, 0, sizeof(used_sat)); - for (i = 0; i < MAX_GPS_NUM_SAT_USED; i++) { + for (i = 0; i < MAX_GPS_NUM_SAT_USED; i++) used_sat[i] = atoi(token[i + 3]); - } + /* pdop = atof(token[15]); */ /* hdop = atof(token[16]); */ @@ -324,21 +318,21 @@ static int nmea_parser_gpgsv(char *token[], sv_data_t *sv) int nmea_parser_sentence(char *sentence, char *token[], pos_data_t *pos, sv_data_t *sv) { int ret = READ_SUCCESS; - if (strcmp(sentence, "GPGGA") == 0) { + if (strcmp(sentence, "GPGGA") == 0) ret = nmea_parser_gpgga(token, pos, sv); - } else if (strcmp(sentence, "GPRMC") == 0) { + else if (strcmp(sentence, "GPRMC") == 0) ret = nmea_parser_gprmc(token, pos); - } else if (strcmp(sentence, "GPGLL") == 0) { + else if (strcmp(sentence, "GPGLL") == 0) ret = nmea_parser_gpgll(token, pos); - } else if (strcmp(sentence, "GPGSA") == 0) { + else if (strcmp(sentence, "GPGSA") == 0) ret = nmea_parser_gpgsa(token, pos); - } else if (strcmp(sentence, "GPVTG") == 0) { + else if (strcmp(sentence, "GPVTG") == 0) ret = nmea_parser_gpvtg(token, pos); - } else if (strcmp(sentence, "GPGSV") == 0) { + else if (strcmp(sentence, "GPGSV") == 0) ret = nmea_parser_gpgsv(token, sv); - } else { + else LOG_PLUGIN(DBG_LOW, "Unsupported sentence : [%s]\n", sentence); - } + return ret; } diff --git a/xps-plugin/include/geoclue_plugin_debug.h b/xps-plugin/include/geoclue_plugin_debug.h index 71bba23..669a38e 100755 --- a/xps-plugin/include/geoclue_plugin_debug.h +++ b/xps-plugin/include/geoclue_plugin_debug.h @@ -39,9 +39,9 @@ extern "C" { #define DBG_ERR LOG_ERROR #ifdef GPS_DLOG_DEBUG /* Debug mode */ -#define LOG_PLUGIN(dbg_lvl,fmt,args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, "[%-40s: %-4d] "fmt, __FILE__, __LINE__, ##args) +#define LOG_PLUGIN(dbg_lvl, fmt, args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, "[%-40s: %-4d] "fmt, __FILE__, __LINE__, ##args) #else /* Release(commercial) mode */ -#define LOG_PLUGIN(dbg_lvl,fmt,args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args) +#define LOG_PLUGIN(dbg_lvl, fmt, args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args) #endif #endif diff --git a/xps-plugin/src/geoclue_xps_plugin_replay.c b/xps-plugin/src/geoclue_xps_plugin_replay.c index a605770..bc0d9f5 100755 --- a/xps-plugin/src/geoclue_xps_plugin_replay.c +++ b/xps-plugin/src/geoclue_xps_plugin_replay.c @@ -68,47 +68,47 @@ static gboolean update_fake_position(gpointer data) if (xps_plugin) { if (xps_plugin->location) { - if (xps_plugin->location->latitude < 90) { + if (xps_plugin->location->latitude < 90) xps_plugin->location->latitude++; - } else { + else xps_plugin->location->latitude = 0; - } - if (xps_plugin->location->longitude < 180) { + + if (xps_plugin->location->longitude < 180) xps_plugin->location->longitude++; - } else { + else xps_plugin->location->longitude = 0; - } - if (xps_plugin->location->age < 10000) { + + if (xps_plugin->location->age < 10000) xps_plugin->location->age++; - } else { + else xps_plugin->location->age = 0; - } - if (xps_plugin->location->altitude < 5000) { + + if (xps_plugin->location->altitude < 5000) xps_plugin->location->altitude++; - } else { + else xps_plugin->location->altitude = 0; - } - if (xps_plugin->location->bearing < 90) { + + if (xps_plugin->location->bearing < 90) xps_plugin->location->bearing++; - } else { + else xps_plugin->location->bearing = 0; - } - if (xps_plugin->location->hpe < 100) { + + if (xps_plugin->location->hpe < 100) xps_plugin->location->hpe++; - } else { + else xps_plugin->location->hpe = 0; - } - if (xps_plugin->location->speed < 250) { + + if (xps_plugin->location->speed < 250) xps_plugin->location->speed++; - } else { + else xps_plugin->location->speed = 0; - } + } /* called intervals */ - if (xps_plugin->location_cb) { + if (xps_plugin->location_cb) xps_plugin->location_cb(xps_plugin->arg, xps_plugin->location, NULL); - } + } return TRUE; @@ -205,9 +205,9 @@ int geoclue_plugin_test_cancel(void *handle, CancelCallback cb, void *arg) } /* call CancelCallback */ - if (cb) { + if (cb) cb(arg); - } + return TRUE; } diff --git a/xps-plugin/src/geoclue_xps_plugin_test.c b/xps-plugin/src/geoclue_xps_plugin_test.c index a0f6baf..fa78a3b 100755 --- a/xps-plugin/src/geoclue_xps_plugin_test.c +++ b/xps-plugin/src/geoclue_xps_plugin_test.c @@ -68,47 +68,47 @@ static gboolean update_fake_position(gpointer data) if (xps_plugin) { if (xps_plugin->location) { - if (xps_plugin->location->latitude < 90) { + if (xps_plugin->location->latitude < 90) xps_plugin->location->latitude++; - } else { + else xps_plugin->location->latitude = 0; - } - if (xps_plugin->location->longitude < 180) { + + if (xps_plugin->location->longitude < 180) xps_plugin->location->longitude++; - } else { + else xps_plugin->location->longitude = 0; - } - if (xps_plugin->location->age < 10000) { + + if (xps_plugin->location->age < 10000) xps_plugin->location->age++; - } else { + else xps_plugin->location->age = 0; - } - if (xps_plugin->location->altitude < 5000) { + + if (xps_plugin->location->altitude < 5000) xps_plugin->location->altitude++; - } else { + else xps_plugin->location->altitude = 0; - } - if (xps_plugin->location->bearing < 90) { + + if (xps_plugin->location->bearing < 90) xps_plugin->location->bearing++; - } else { + else xps_plugin->location->bearing = 0; - } - if (xps_plugin->location->hpe < 100) { + + if (xps_plugin->location->hpe < 100) xps_plugin->location->hpe++; - } else { + else xps_plugin->location->hpe = 0; - } - if (xps_plugin->location->speed < 250) { + + if (xps_plugin->location->speed < 250) xps_plugin->location->speed++; - } else { + else xps_plugin->location->speed = 0; - } + } /* called intervals */ - if (xps_plugin->location_cb) { + if (xps_plugin->location_cb) xps_plugin->location_cb(xps_plugin->arg, xps_plugin->location, NULL); - } + } return TRUE; @@ -205,9 +205,9 @@ int geoclue_plugin_test_cancel(void *handle, CancelCallback cb, void *arg) } /* call CancelCallback */ - if (cb) { + if (cb) cb(arg); - } + return TRUE; }