diff options
author | jkoan <jkoan@gmx.de> | 2020-08-14 21:33:24 +0200 |
---|---|---|
committer | jkoan <jkoan@users.noreply.github.com> | 2020-11-18 15:57:09 +0100 |
commit | c5e8008919743d18a595b0a99d3751d376990283 (patch) | |
tree | 2320ed3846427dc0d48df1618ae21abfb5cf2236 | |
parent | 6a3c215157ae1fb1ba05744cbf97ac6f0fab3c5c (diff) | |
download | navit-c5e8008919743d18a595b0a99d3751d376990283.tar.gz |
fix:vehicle:Fix codestyle
-rw-r--r-- | navit/vehicle/geoclue/vehicle_geoclue.c | 187 |
1 files changed, 88 insertions, 99 deletions
diff --git a/navit/vehicle/geoclue/vehicle_geoclue.c b/navit/vehicle/geoclue/vehicle_geoclue.c index aca3d5a11..2220b24bb 100644 --- a/navit/vehicle/geoclue/vehicle_geoclue.c +++ b/navit/vehicle/geoclue/vehicle_geoclue.c @@ -67,95 +67,90 @@ static void vehicle_geoclue_destroy(struct vehicle_priv *priv) { g_clear_object(&priv->simple); } -static void -print_location(GClueSimple *simple, - GParamSpec *pspec, - gpointer user_data) -{ - GClueLocation *location; - gdouble altitude; - gdouble speed; - gdouble direction; - GVariant *timestamp; - struct vehicle_priv *priv = user_data; - - location = gclue_simple_get_location(simple); - - priv->geo.lat = gclue_location_get_latitude(location); - priv->geo.lng = gclue_location_get_longitude(location); - priv->accuracy = gclue_location_get_accuracy(location); - altitude = gclue_location_get_altitude(location); - if(altitude != -G_MAXDOUBLE){ - priv->height=altitude; - } - speed = gclue_location_get_altitude(location); - if(speed != -G_MAXDOUBLE){ - priv->speed=speed; - } - direction = gclue_location_get_altitude(location); - if(direction != -G_MAXDOUBLE){ - priv->direction=direction; - } +static void print_location(GClueSimple *simple, + GParamSpec *pspec, + gpointer user_data) { + GClueLocation *location; + gdouble altitude; + gdouble speed; + gdouble direction; + GVariant *timestamp; + struct vehicle_priv *priv = user_data; + + location = gclue_simple_get_location(simple); + + priv->geo.lat = gclue_location_get_latitude(location); + priv->geo.lng = gclue_location_get_longitude(location); + priv->accuracy = gclue_location_get_accuracy(location); + altitude = gclue_location_get_altitude(location); + if(altitude != -G_MAXDOUBLE) { + priv->height=altitude; + } + speed = gclue_location_get_altitude(location); + if(speed != -G_MAXDOUBLE) { + priv->speed=speed; + } + direction = gclue_location_get_altitude(location); + if(direction != -G_MAXDOUBLE) { + priv->direction=direction; + } - timestamp= gclue_location_get_timestamp(location); - if(timestamp) { - GDateTime *date_time; - glong second_since_epoch; + timestamp= gclue_location_get_timestamp(location); + if(timestamp) { + GDateTime *date_time; + glong second_since_epoch; - g_variant_get (timestamp, "(tt)", &second_since_epoch, NULL); + g_variant_get (timestamp, "(tt)", &second_since_epoch, NULL); - date_time = g_date_time_new_from_unix_local (second_since_epoch); + date_time = g_date_time_new_from_unix_local (second_since_epoch); - priv->time_str = g_date_time_format_iso8601(g_date_time_to_utc(date_time)); + priv->time_str = g_date_time_format_iso8601(g_date_time_to_utc(date_time)); - } - callback_list_call_attr_0(priv->cbl, attr_position_coord_geo); + } + callback_list_call_attr_0(priv->cbl, attr_position_coord_geo); } -static void -on_client_active_notify(GClueClient *client, - GParamSpec *pspec, - gpointer user_data) -{ - if(gclue_client_get_active(client)) - return; +static void on_client_active_notify(GClueClient *client, + GParamSpec *pspec, + gpointer user_data) { + if(gclue_client_get_active(client)) + return; - g_print("Geolocation disabled. Quitting..\n"); - //vehicle_geoclue_destroy(&user_data); + g_print("Geolocation disabled. Quitting..\n"); + //vehicle_geoclue_destroy(&user_data); } -static void -on_simple_ready(GObject *source_object, - GAsyncResult *res, - gpointer user_data){ - GError *error = NULL; +static void on_simple_ready(GObject *source_object, + GAsyncResult *res, + gpointer user_data) { + GError *error = NULL; - struct vehicle_priv* priv = user_data; + struct vehicle_priv* priv = user_data; - priv->simple = gclue_simple_new_finish(res, &error); - if(error != NULL) { - dbg(lvl_error,"Failed to connect to GeoClue2 service: %s", error->message); + priv->simple = gclue_simple_new_finish(res, &error); + if(error != NULL) { + dbg(lvl_error,"Failed to connect to GeoClue2 service: %s", error->message); - exit(-1); - } - client = gclue_simple_get_client(priv->simple); - if(client) { - g_object_ref(client); - dbg(lvl_debug,"Client object: %s\n", - g_dbus_proxy_get_object_path(G_DBUS_PROXY(client))); - - g_signal_connect(client, - "notify::active", - G_CALLBACK(on_client_active_notify), - NULL); - } - print_location(priv->simple,NULL,priv); + exit(-1); + } + client = gclue_simple_get_client(priv->simple); + if(client) { + g_object_ref(client); + dbg(lvl_debug,"Client object: %s\n", + g_dbus_proxy_get_object_path(G_DBUS_PROXY(client))); + + g_signal_connect(client, + "notify::active", + G_CALLBACK(on_client_active_notify), + NULL); + } + print_location(priv->simple,NULL,priv); - g_signal_connect(priv->simple, - "notify::location", - G_CALLBACK(print_location), - priv); + g_signal_connect(priv->simple, + "notify::location", + G_CALLBACK(print_location), + priv); } /** @@ -181,21 +176,15 @@ static int vehicle_geoclue_position_attr_get(struct vehicle_priv *priv, case attr_position_qual: attr->u.num = priv->accuracy; break; - /*case attr_position_sats_used: - attr->u.num = priv->sats_used; - break;*/ case attr_position_coord_geo: attr->u.coord_geo = &priv->geo; break; case attr_position_time_iso8601: - if(!priv->time_str){ + if(!priv->time_str) { return 0; } attr->u.str=priv->time_str; break; - /* - attr->u.str=priv->time_str; - break;*/ case attr_active: return 1; default: @@ -219,23 +208,23 @@ struct vehicle_methods vehicle_geoclue_methods = { * @returns vehicle_priv The newly created Vehicle priv */ static struct vehicle_priv *vehicle_geoclue_new(struct vehicle_methods *meth, - struct callback_list *cbl, - struct attr **attrs) { - struct vehicle_priv *ret; - dbg(lvl_debug, "enter"); - - *meth = vehicle_geoclue_methods; - - ret = (struct vehicle_priv*)g_new0(struct vehicle_priv, 1); - ret->cbl = cbl; - ret->time.tm_year=0; - gclue_simple_new("navit", - GCLUE_ACCURACY_LEVEL_EXACT, - NULL, - on_simple_ready, - ret - ); - return ret; + struct callback_list *cbl, + struct attr **attrs) { + struct vehicle_priv *ret; + dbg(lvl_debug, "enter"); + + *meth = vehicle_geoclue_methods; + + ret = (struct vehicle_priv*)g_new0(struct vehicle_priv, 1); + ret->cbl = cbl; + ret->time.tm_year=0; + gclue_simple_new("navit", + GCLUE_ACCURACY_LEVEL_EXACT, + NULL, + on_simple_ready, + ret + ); + return ret; }; /** @@ -243,7 +232,7 @@ static struct vehicle_priv *vehicle_geoclue_new(struct vehicle_methods *meth, * * @returns nothing */ -void plugin_init(void){ +void plugin_init(void) { dbg(lvl_error, "enter"); plugin_register_category_vehicle("geoclue", vehicle_geoclue_new); }; |