libmm-glib,3gpp: make MMModem3gppNetwork a boxed type

So that bindings know how to free the list of structs.

This commit ends up triggering an API break in the bindings generated
via GObject introspection, because the methods to access the items of
a MMModem3gppNetwork are no longer treated as Modem3gpp class methods.

E.g. instead of:
  ModemManager.Modem3gpp.network_get_operator_code(network)
We should now do:
  network.get_operator_code()

There is no API break in libmm-glib.
This commit is contained in:
Aleksander Morgado
2019-12-13 18:04:02 +01:00
parent 248cd55f0e
commit fcbffbd123
4 changed files with 31 additions and 5 deletions

View File

@@ -318,7 +318,9 @@ MM_MODEM_3GPP
MM_MODEM_3GPP_CLASS
MM_MODEM_3GPP_GET_CLASS
MM_TYPE_MODEM_3GPP
MM_TYPE_MODEM_3GPP_NETWORK
mm_modem_3gpp_get_type
mm_modem_3gpp_network_get_type
</SECTION>
<SECTION>

View File

@@ -47,10 +47,10 @@ if __name__ == "__main__":
if networks:
for network in networks:
print('%s: %s - %s (%s, %s)' % (
ModemManager.Modem3gpp.network_get_operator_code(network),
ModemManager.Modem3gpp.network_get_operator_short(network),
ModemManager.Modem3gpp.network_get_operator_short(network),
ModemManager.modem_access_technology_build_string_from_mask (ModemManager.Modem3gpp.network_get_access_technology(network)),
ModemManager.Modem3gppNetworkAvailability.get_string(ModemManager.Modem3gpp.network_get_availability(network))))
network.get_operator_code(),
network.get_operator_short(),
network.get_operator_short(),
ModemManager.modem_access_technology_build_string_from_mask (network.get_access_technology()),
ModemManager.Modem3gppNetworkAvailability.get_string(network.get_availability())))
else:
print('no networks found')

View File

@@ -549,6 +549,23 @@ mm_modem_3gpp_network_free (MMModem3gppNetwork *network)
g_slice_free (MMModem3gppNetwork, network);
}
static MMModem3gppNetwork *
modem_3gpp_network_copy (MMModem3gppNetwork *network)
{
MMModem3gppNetwork *network_copy;
network_copy = g_slice_new0 (MMModem3gppNetwork);
network_copy->availability = network->availability;
network_copy->operator_long = g_strdup (network->operator_long);
network_copy->operator_short = g_strdup (network->operator_short);
network_copy->operator_code = g_strdup (network->operator_code);
network_copy->access_technology = network->access_technology;
return network_copy;
}
G_DEFINE_BOXED_TYPE (MMModem3gppNetwork, mm_modem_3gpp_network, (GBoxedCopyFunc)modem_3gpp_network_copy, (GBoxedFreeFunc)mm_modem_3gpp_network_free)
/**
* mm_modem_3gpp_network_get_availability:
* @network: A #MMModem3gppNetwork.

View File

@@ -116,6 +116,9 @@ gboolean mm_modem_3gpp_register_sync (MMModem3gpp *self,
*/
typedef struct _MMModem3gppNetwork MMModem3gppNetwork;
#define MM_TYPE_MODEM_3GPP_NETWORK (mm_modem_3gpp_network_get_type ())
GType mm_modem_3gpp_network_get_type (void);
MMModem3gppNetworkAvailability mm_modem_3gpp_network_get_availability (const MMModem3gppNetwork *network);
const gchar *mm_modem_3gpp_network_get_operator_long (const MMModem3gppNetwork *network);
const gchar *mm_modem_3gpp_network_get_operator_short (const MMModem3gppNetwork *network);
@@ -123,6 +126,10 @@ const gchar *mm_modem_3gpp_network_get_operator_code (con
MMModemAccessTechnology mm_modem_3gpp_network_get_access_technology (const MMModem3gppNetwork *network);
void mm_modem_3gpp_network_free (MMModem3gppNetwork *network);
#if GLIB_CHECK_VERSION(2, 44, 0)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMModem3gppNetwork, mm_modem_3gpp_network_free)
#endif
void mm_modem_3gpp_scan (MMModem3gpp *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,