cli, location: Fix multi-sentence NMEA message output
Multi-sentence NMEA messages were printed as is, that is with linebreaks, which made mmcli --location-get output look broken. Split NMEA sentences with linebreaks to separate output list items, so that they line up correctly.
This commit is contained in:

committed by
Aleksander Morgado

parent
7177eeea99
commit
fa19b2b9b1
@@ -568,7 +568,7 @@ get_location_process_reply (MMLocation3gpp *location_3gpp,
|
||||
mmcli_output_string_take (MMC_F_LOCATION_3GPP_LAC, lac);
|
||||
mmcli_output_string_take (MMC_F_LOCATION_3GPP_TAC, tac);
|
||||
mmcli_output_string_take (MMC_F_LOCATION_3GPP_CID, cid);
|
||||
mmcli_output_string_array_take (MMC_F_LOCATION_GPS_NMEA, nmea, TRUE);
|
||||
mmcli_output_string_array_multiline_take (MMC_F_LOCATION_GPS_NMEA, nmea);
|
||||
mmcli_output_string (MMC_F_LOCATION_GPS_UTC, gps_utc);
|
||||
mmcli_output_string_take (MMC_F_LOCATION_GPS_LONG, gps_longitude);
|
||||
mmcli_output_string_take (MMC_F_LOCATION_GPS_LAT, gps_latitude);
|
||||
|
@@ -487,6 +487,42 @@ mmcli_output_string_array_take (MmcF field,
|
||||
output_item_new_take_multiple (field, strv, multiline);
|
||||
}
|
||||
|
||||
void
|
||||
mmcli_output_string_array_multiline_take (MmcF field,
|
||||
gchar **strv)
|
||||
{
|
||||
gchar **merged;
|
||||
GPtrArray *pointers;
|
||||
|
||||
merged = NULL;
|
||||
if (strv) {
|
||||
guint i;
|
||||
|
||||
pointers = g_ptr_array_new ();
|
||||
for (i = 0; strv[i]; i++) {
|
||||
gchar **split;
|
||||
|
||||
split = strv[i] ? g_strsplit (strv[i], "\n", -1) : NULL;
|
||||
if (split) {
|
||||
guint n;
|
||||
|
||||
for (n = 0; split[n]; n++) {
|
||||
if (split[n][0]) {
|
||||
g_strstrip (split[n]);
|
||||
g_ptr_array_add (pointers, g_strdup (split[n]));
|
||||
}
|
||||
}
|
||||
g_strfreev (split);
|
||||
}
|
||||
}
|
||||
g_strfreev (strv);
|
||||
g_ptr_array_add (pointers, NULL);
|
||||
merged = (gchar **)g_ptr_array_free (pointers, FALSE);
|
||||
}
|
||||
|
||||
output_item_new_take_multiple (field, merged, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
mmcli_output_string (MmcF field,
|
||||
const gchar *str)
|
||||
|
@@ -341,6 +341,8 @@ void mmcli_output_string_array (MmcF field,
|
||||
void mmcli_output_string_array_take (MmcF field,
|
||||
gchar **strv,
|
||||
gboolean multiline);
|
||||
void mmcli_output_string_array_multiline_take (MmcF field,
|
||||
gchar **strv);
|
||||
void mmcli_output_string_take_typed (MmcF field,
|
||||
gchar *value,
|
||||
const gchar *type);
|
||||
|
Reference in New Issue
Block a user