summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/qmi-service-nas.json1
-rw-r--r--src/libqmi-glib/qmi-compat.c61
-rw-r--r--src/libqmi-glib/qmi-compat.h4
-rw-r--r--src/libqmi-glib/test/test-generated.c164
4 files changed, 226 insertions, 4 deletions
diff --git a/data/qmi-service-nas.json b/data/qmi-service-nas.json
index 7dcf0e0d..aa5daad2 100644
--- a/data/qmi-service-nas.json
+++ b/data/qmi-service-nas.json
@@ -1789,6 +1789,7 @@
"service" : "NAS",
"id" : "0x0043",
"since" : "1.10",
+ "output-compat" : "yes",
"output" : [ { "common-ref" : "Operation Result" },
{ "name" : "GERAN Info v2",
"id" : "0x10",
diff --git a/src/libqmi-glib/qmi-compat.c b/src/libqmi-glib/qmi-compat.c
index 4e8225a6..e10c29e5 100644
--- a/src/libqmi-glib/qmi-compat.c
+++ b/src/libqmi-glib/qmi-compat.c
@@ -1129,6 +1129,32 @@ qmi_message_nas_get_home_network_output_get_home_network_3gpp2 (
#if defined HAVE_QMI_MESSAGE_NAS_GET_CELL_LOCATION_INFO
+typedef struct {
+ GArray *geran_info_cell;
+} MessageNasGetCellLocationInfoOutputCompatContext;
+
+static void
+message_nas_get_cell_location_info_output_compat_context_free (MessageNasGetCellLocationInfoOutputCompatContext *ctx)
+{
+ if (ctx->geran_info_cell)
+ g_array_unref (ctx->geran_info_cell);
+ g_slice_free (MessageNasGetCellLocationInfoOutputCompatContext, ctx);
+}
+
+static MessageNasGetCellLocationInfoOutputCompatContext *
+message_nas_get_cell_location_info_output_get_compat_context (QmiMessageNasGetCellLocationInfoOutput *self)
+{
+ MessageNasGetCellLocationInfoOutputCompatContext *ctx;
+
+ ctx = qmi_message_nas_get_cell_location_info_output_get_compat_context (self);
+ if (!ctx) {
+ ctx = g_slice_new0 (MessageNasGetCellLocationInfoOutputCompatContext);
+ qmi_message_nas_get_cell_location_info_output_set_compat_context (self, ctx, (GDestroyNotify)message_nas_get_cell_location_info_output_compat_context_free);
+ }
+
+ return ctx;
+}
+
/* This PLMN string is returned because it's a 3-char long valid UTF-8. */
static const gchar invalid_plmn_str[] = " ";
@@ -1215,6 +1241,8 @@ qmi_message_nas_get_cell_location_info_output_get_geran_info (
GArray **value_geran_info_cell,
GError **error)
{
+ GArray *geran_info_v2_cell = NULL;
+
if (!qmi_message_nas_get_cell_location_info_output_get_geran_info_v2 (
self,
value_geran_info_cell_id,
@@ -1224,14 +1252,41 @@ qmi_message_nas_get_cell_location_info_output_get_geran_info (
value_geran_info_base_station_identity_code,
value_geran_info_timing_advance,
value_geran_info_rx_level,
- NULL,
+ &geran_info_v2_cell,
error))
return FALSE;
if (value_geran_info_plmn)
*value_geran_info_plmn = invalid_plmn_str;
- if (value_geran_info_cell)
- *value_geran_info_cell = NULL;
+
+ if (value_geran_info_cell) {
+ MessageNasGetCellLocationInfoOutputCompatContext *ctx;
+
+ /* We have an array of QmiMessageNasGetCellLocationInfoOutputGeranInfoV2CellElement elements,
+ * we need to return an array of QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement elements
+ * instead.
+ */
+ ctx = message_nas_get_cell_location_info_output_get_compat_context (self);
+ if (!ctx->geran_info_cell) {
+ guint i;
+
+ ctx->geran_info_cell = g_array_sized_new (FALSE, FALSE, sizeof (QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement), geran_info_v2_cell->len);
+ for (i = 0; i < geran_info_v2_cell->len; i++) {
+ QmiMessageNasGetCellLocationInfoOutputGeranInfoV2CellElement *elemv2;
+ QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement elem;
+
+ elemv2 = &g_array_index (geran_info_v2_cell, QmiMessageNasGetCellLocationInfoOutputGeranInfoV2CellElement, i);
+ elem.cell_id = elemv2->cell_id;
+ elem.plmn = (gchar *)invalid_plmn_str;
+ elem.lac = elemv2->lac;
+ elem.geran_absolute_rf_channel_number = elemv2->geran_absolute_rf_channel_number;
+ elem.base_station_identity_code = elemv2->base_station_identity_code;
+ elem.rx_level = elemv2->rx_level;
+ g_array_append_val (ctx->geran_info_cell, elem);
+ }
+ }
+ *value_geran_info_cell = ctx->geran_info_cell;
+ }
return TRUE;
}
diff --git a/src/libqmi-glib/qmi-compat.h b/src/libqmi-glib/qmi-compat.h
index 8c982895..0a08ae2a 100644
--- a/src/libqmi-glib/qmi-compat.h
+++ b/src/libqmi-glib/qmi-compat.h
@@ -2156,6 +2156,8 @@ gboolean qmi_message_nas_get_home_network_output_get_home_network_3gpp2 (
*
* GERAN info cell.
*
+ * This type is deprecated and returns always an empty @plmn string.
+ *
* Since: 1.10
* Deprecated: 1.26.6.
*/
@@ -2310,7 +2312,7 @@ gboolean qmi_message_nas_get_cell_location_info_output_get_umts_info (
* Get the 'GERAN Info' field from @self.
*
* This method is deprecated and returns an empty @value_geran_info_plmn
- * string and an empty @value_geran_info_cell array.
+ * string.
*
* Returns: (skip): %TRUE if the field is found, %FALSE otherwise.
*
diff --git a/src/libqmi-glib/test/test-generated.c b/src/libqmi-glib/test/test-generated.c
index 550979ed..19d2e5cd 100644
--- a/src/libqmi-glib/test/test-generated.c
+++ b/src/libqmi-glib/test/test-generated.c
@@ -821,6 +821,169 @@ test_generated_nas_get_cell_location_info_invalid (TestFixture *fixture)
test_fixture_loop_run (fixture);
}
+static void
+test_compat_nas_get_cell_location_info_geran_info_ready (QmiClientNas *client,
+ GAsyncResult *res,
+ TestFixture *fixture)
+{
+ QmiMessageNasGetCellLocationInfoOutput *output;
+ GError *error = NULL;
+ gboolean st;
+
+ output = qmi_client_nas_get_cell_location_info_finish (client, res, &error);
+ g_assert_no_error (error);
+ g_assert (output);
+
+ st = qmi_message_nas_get_cell_location_info_output_get_result (output, &error);
+ g_assert_no_error (error);
+ g_assert (st);
+
+ {
+ guint32 geran_info_v2_cell_id = 0;
+ GArray *geran_info_v2_plmn = NULL;
+ guint16 geran_info_v2_lac = 0;
+ guint16 geran_info_v2_geran_absolute_rf_channel_number = 0;
+ guint8 geran_info_v2_base_station_identity_code = 0;
+ guint32 geran_info_v2_timing_advance = 0;
+ guint16 geran_info_v2_rx_level = 0;
+ GArray *geran_info_v2_cell = NULL;
+
+ st = qmi_message_nas_get_cell_location_info_output_get_geran_info_v2 (output,
+ &geran_info_v2_cell_id,
+ &geran_info_v2_plmn,
+ &geran_info_v2_lac,
+ &geran_info_v2_geran_absolute_rf_channel_number,
+ &geran_info_v2_base_station_identity_code,
+ &geran_info_v2_timing_advance,
+ &geran_info_v2_rx_level,
+ &geran_info_v2_cell,
+ &error);
+ g_assert_no_error (error);
+ g_assert (st);
+
+#ifndef QMI_DISABLE_DEPRECATED
+ {
+ guint i;
+ guint32 geran_info_cell_id = 0;
+ const gchar *geran_info_plmn = NULL;
+ guint16 geran_info_lac = 0;
+ guint16 geran_info_geran_absolute_rf_channel_number = 0;
+ guint8 geran_info_base_station_identity_code = 0;
+ guint32 geran_info_timing_advance = 0;
+ guint16 geran_info_rx_level = 0;
+ GArray *geran_info_cell = NULL;
+
+ st = qmi_message_nas_get_cell_location_info_output_get_geran_info (output,
+ &geran_info_cell_id,
+ &geran_info_plmn,
+ &geran_info_lac,
+ &geran_info_geran_absolute_rf_channel_number,
+ &geran_info_base_station_identity_code,
+ &geran_info_timing_advance,
+ &geran_info_rx_level,
+ &geran_info_cell,
+ &error);
+ g_assert_no_error (error);
+ g_assert (st);
+
+ g_assert_cmpuint (geran_info_v2_cell_id, ==, geran_info_cell_id);
+ /* plmn won't be equal, as it's broken in v1 */
+ g_assert_cmpuint (geran_info_v2_lac, ==, geran_info_lac);
+ g_assert_cmpuint (geran_info_v2_geran_absolute_rf_channel_number, ==, geran_info_geran_absolute_rf_channel_number);
+ g_assert_cmpuint (geran_info_v2_base_station_identity_code, ==, geran_info_base_station_identity_code);
+ g_assert_cmpuint (geran_info_v2_timing_advance, ==, geran_info_timing_advance);
+ g_assert_cmpuint (geran_info_v2_rx_level, ==, geran_info_rx_level);
+
+ g_assert (geran_info_cell);
+ g_assert_cmpuint (geran_info_cell->len, ==, geran_info_v2_cell->len);
+ for (i = 0; i < geran_info_v2_cell->len; i++) {
+ QmiMessageNasGetCellLocationInfoOutputGeranInfoV2CellElement *elemv2;
+ QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement *elem;
+
+ elemv2 = &g_array_index (geran_info_v2_cell, QmiMessageNasGetCellLocationInfoOutputGeranInfoV2CellElement, i);
+ elem = &g_array_index (geran_info_cell, QmiMessageNasGetCellLocationInfoOutputGeranInfoCellElement, i);
+ g_assert_cmpuint (elem->cell_id, ==, elemv2->cell_id);
+ /* plmn won't be equal, as it's broken in v1 */
+ g_assert_cmpuint (elem->lac, ==, elemv2->lac);
+ g_assert_cmpuint (elem->geran_absolute_rf_channel_number, ==, elemv2->geran_absolute_rf_channel_number);
+ g_assert_cmpuint (elem->base_station_identity_code, ==, elemv2->base_station_identity_code);
+ g_assert_cmpuint (elem->rx_level, ==, elemv2->rx_level);
+ }
+ }
+#endif /* QMI_DISABLE_DEPRECATED */
+ }
+
+ qmi_message_nas_get_cell_location_info_output_unref (output);
+
+ test_fixture_loop_stop (fixture);
+}
+
+static void
+test_compat_nas_get_cell_location_info_geran_info (TestFixture *fixture)
+{
+ guint8 request[] = {
+ 0x01, 0x0C, 0x00, 0x00, 0x03, 0x01, 0x00, 0x01,
+ 0x00, 0x43, 0x00, 0x00, 0x00
+ };
+ guint8 response[] = {
+ 0x01, 0x58, 0x01, 0x80, 0x03, 0x01, 0x02, 0x01,
+ 0x00, 0x43, 0x00, 0x4C, 0x01, 0x02, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x67, 0x00, 0x02,
+ 0x09, 0x00, 0x00, 0x12, 0xF4, 0x30, 0x76, 0x04,
+ 0xDD, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32,
+ 0x00, 0x06, 0x8E, 0x08, 0x00, 0x00, 0x12, 0xF4,
+ 0x30, 0x76, 0x04, 0xD0, 0x03, 0x28, 0x28, 0x00,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xD6, 0x03, 0x0B, 0x1C, 0x00, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD5,
+ 0x03, 0x24, 0x1A, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xD7, 0x03, 0x01,
+ 0x18, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xDF, 0x03, 0x22, 0x17, 0x00,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xDA, 0x03, 0x08, 0x10, 0x00, 0x1B, 0x04,
+ 0x00, 0xFF, 0xFF, 0xDD, 0x03, 0x21, 0xC7, 0x00,
+ 0x02, 0x09, 0x00, 0x00, 0x12, 0xF4, 0x30, 0x76,
+ 0x04, 0xDD, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x32, 0x00, 0x06, 0x8E, 0x08, 0x00, 0x00, 0x12,
+ 0xF4, 0x30, 0x76, 0x04, 0xD0, 0x03, 0x28, 0x28,
+ 0x00, 0x24, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xD6, 0x03, 0x0B, 0x1C, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xD5, 0x03, 0x24, 0x1A, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD7, 0x03,
+ 0x01, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xDF, 0x03, 0x22, 0x17,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xDA, 0x03, 0x08, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24,
+ 0x03, 0x00, 0x00, 0xFF, 0xFF, 0x25, 0x01, 0x00,
+ 0x00
+ };
+
+ test_port_context_set_command (fixture->ctx,
+ request, G_N_ELEMENTS (request),
+ response, G_N_ELEMENTS (response),
+ fixture->service_info[QMI_SERVICE_NAS].transaction_id++);
+
+ qmi_client_nas_get_cell_location_info (QMI_CLIENT_NAS (fixture->service_info[QMI_SERVICE_NAS].client), NULL, 3, NULL,
+ (GAsyncReadyCallback) test_compat_nas_get_cell_location_info_geran_info_ready,
+ fixture);
+
+ test_fixture_loop_run (fixture);
+}
+
#endif /* HAVE_QMI_MESSAGE_NAS_GET_CELL_LOCATION_INFO */
/*****************************************************************************/
@@ -1099,6 +1262,7 @@ int main (int argc, char **argv)
TEST_ADD ("/libqmi-glib/generated/nas/get-cell-location-info/1", test_generated_nas_get_cell_location_info_1);
TEST_ADD ("/libqmi-glib/generated/nas/get-cell-location-info/2", test_generated_nas_get_cell_location_info_2);
TEST_ADD ("/libqmi-glib/generated/nas/get-cell-location-info/invalid", test_generated_nas_get_cell_location_info_invalid);
+ TEST_ADD ("/libqmi-glib/compat/nas/get-cell-location-info/geran-info", test_compat_nas_get_cell_location_info_geran_info);
#endif
#if defined HAVE_QMI_MESSAGE_NAS_GET_SERVING_SYSTEM
TEST_ADD ("/libqmi-glib/generated/nas/get-serving-system", test_generated_nas_get_serving_system);