cli: use new enums/flags string getters/builders
This commit is contained in:
@@ -177,7 +177,7 @@ print_bearer_info (MMBearer *bearer)
|
|||||||
VALIDATE_NONE (mm_bearer_properties_get_user (properties)),
|
VALIDATE_NONE (mm_bearer_properties_get_user (properties)),
|
||||||
VALIDATE_NONE (mm_bearer_properties_get_password (properties)),
|
VALIDATE_NONE (mm_bearer_properties_get_password (properties)),
|
||||||
VALIDATE_NONE (mm_bearer_properties_get_number (properties)),
|
VALIDATE_NONE (mm_bearer_properties_get_number (properties)),
|
||||||
VALIDATE_UNKNOWN (mmcli_get_cdma_rm_protocol_string (
|
VALIDATE_UNKNOWN (mm_modem_cdma_rm_protocol_get_string (
|
||||||
mm_bearer_properties_get_rm_protocol (properties))));
|
mm_bearer_properties_get_rm_protocol (properties))));
|
||||||
g_object_unref (properties);
|
g_object_unref (properties);
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ print_bearer_info (MMBearer *bearer)
|
|||||||
g_print (" -------------------------\n"
|
g_print (" -------------------------\n"
|
||||||
" IPv4 configuration | method: '%s'\n",
|
" IPv4 configuration | method: '%s'\n",
|
||||||
(ipv4_config ?
|
(ipv4_config ?
|
||||||
mmcli_get_bearer_ip_method_string (mm_bearer_ip_config_get_method (ipv4_config)) :
|
mm_bearer_ip_method_get_string (mm_bearer_ip_config_get_method (ipv4_config)) :
|
||||||
"none"));
|
"none"));
|
||||||
if (ipv4_config &&
|
if (ipv4_config &&
|
||||||
mm_bearer_ip_config_get_method (ipv4_config) == MM_BEARER_IP_METHOD_STATIC) {
|
mm_bearer_ip_config_get_method (ipv4_config) == MM_BEARER_IP_METHOD_STATIC) {
|
||||||
@@ -212,7 +212,7 @@ print_bearer_info (MMBearer *bearer)
|
|||||||
g_print (" -------------------------\n"
|
g_print (" -------------------------\n"
|
||||||
" IPv6 configuration | method: '%s'\n",
|
" IPv6 configuration | method: '%s'\n",
|
||||||
(ipv6_config ?
|
(ipv6_config ?
|
||||||
mmcli_get_bearer_ip_method_string (mm_bearer_ip_config_get_method (ipv6_config)) :
|
mm_bearer_ip_method_get_string (mm_bearer_ip_config_get_method (ipv6_config)) :
|
||||||
"none"));
|
"none"));
|
||||||
if (ipv6_config &&
|
if (ipv6_config &&
|
||||||
mm_bearer_ip_config_get_method (ipv6_config) == MM_BEARER_IP_METHOD_STATIC) {
|
mm_bearer_ip_config_get_method (ipv6_config) == MM_BEARER_IP_METHOD_STATIC) {
|
||||||
|
@@ -693,32 +693,6 @@ mmcli_get_sim_sync (GDBusConnection *connection,
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
|
||||||
mmcli_get_bearer_ip_method_string (MMBearerIpMethod method)
|
|
||||||
{
|
|
||||||
static GEnumClass *enum_class = NULL;
|
|
||||||
GEnumValue *value;
|
|
||||||
|
|
||||||
if (!enum_class)
|
|
||||||
enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_BEARER_IP_METHOD));
|
|
||||||
|
|
||||||
value = g_enum_get_value (enum_class, method);
|
|
||||||
return value->value_nick;
|
|
||||||
}
|
|
||||||
|
|
||||||
const gchar *
|
|
||||||
mmcli_get_state_string (MMModemState state)
|
|
||||||
{
|
|
||||||
static GEnumClass *enum_class = NULL;
|
|
||||||
GEnumValue *value;
|
|
||||||
|
|
||||||
if (!enum_class)
|
|
||||||
enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_MODEM_STATE));
|
|
||||||
|
|
||||||
value = g_enum_get_value (enum_class, state);
|
|
||||||
return value->value_nick;
|
|
||||||
}
|
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
mmcli_get_state_reason_string (MMModemStateChangeReason reason)
|
mmcli_get_state_reason_string (MMModemStateChangeReason reason)
|
||||||
{
|
{
|
||||||
@@ -735,71 +709,6 @@ mmcli_get_state_reason_string (MMModemStateChangeReason reason)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
|
||||||
mmcli_get_lock_string (MMModemLock lock)
|
|
||||||
{
|
|
||||||
static GEnumClass *enum_class = NULL;
|
|
||||||
GEnumValue *value;
|
|
||||||
|
|
||||||
if (!enum_class)
|
|
||||||
enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_MODEM_LOCK));
|
|
||||||
|
|
||||||
value = g_enum_get_value (enum_class, lock);
|
|
||||||
return value->value_nick;
|
|
||||||
}
|
|
||||||
|
|
||||||
const gchar *
|
|
||||||
mmcli_get_3gpp_network_availability_string (MMModem3gppNetworkAvailability availability)
|
|
||||||
{
|
|
||||||
static GEnumClass *enum_class = NULL;
|
|
||||||
GEnumValue *value;
|
|
||||||
|
|
||||||
if (!enum_class)
|
|
||||||
enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_MODEM_3GPP_NETWORK_AVAILABILITY));
|
|
||||||
|
|
||||||
value = g_enum_get_value (enum_class, availability);
|
|
||||||
return value->value_nick;
|
|
||||||
}
|
|
||||||
|
|
||||||
const gchar *
|
|
||||||
mmcli_get_3gpp_registration_state_string (MMModem3gppRegistrationState state)
|
|
||||||
{
|
|
||||||
static GEnumClass *enum_class = NULL;
|
|
||||||
GEnumValue *value;
|
|
||||||
|
|
||||||
if (!enum_class)
|
|
||||||
enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_MODEM_3GPP_REGISTRATION_STATE));
|
|
||||||
|
|
||||||
value = g_enum_get_value (enum_class, state);
|
|
||||||
return value->value_nick;
|
|
||||||
}
|
|
||||||
|
|
||||||
const gchar *
|
|
||||||
mmcli_get_cdma_registration_state_string (MMModemCdmaRegistrationState state)
|
|
||||||
{
|
|
||||||
static GEnumClass *enum_class = NULL;
|
|
||||||
GEnumValue *value;
|
|
||||||
|
|
||||||
if (!enum_class)
|
|
||||||
enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_MODEM_CDMA_REGISTRATION_STATE));
|
|
||||||
|
|
||||||
value = g_enum_get_value (enum_class, state);
|
|
||||||
return value->value_nick;
|
|
||||||
}
|
|
||||||
|
|
||||||
const gchar *
|
|
||||||
mmcli_get_cdma_rm_protocol_string (MMModemCdmaRmProtocol protocol)
|
|
||||||
{
|
|
||||||
static GEnumClass *enum_class = NULL;
|
|
||||||
GEnumValue *value;
|
|
||||||
|
|
||||||
if (!enum_class)
|
|
||||||
enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_MODEM_CDMA_RM_PROTOCOL));
|
|
||||||
|
|
||||||
value = g_enum_get_value (enum_class, protocol);
|
|
||||||
return value->value_nick;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Common options */
|
/* Common options */
|
||||||
static gchar *modem_str;
|
static gchar *modem_str;
|
||||||
static gchar *bearer_str;
|
static gchar *bearer_str;
|
||||||
|
@@ -64,15 +64,7 @@ MMSim *mmcli_get_sim_sync (GDBusConnection *connection,
|
|||||||
MMManager **manager,
|
MMManager **manager,
|
||||||
MMObject **object);
|
MMObject **object);
|
||||||
|
|
||||||
const gchar *mmcli_get_bearer_ip_method_string (MMBearerIpMethod method);
|
|
||||||
const gchar *mmcli_get_state_string (MMModemState state);
|
|
||||||
const gchar *mmcli_get_state_reason_string (MMModemStateChangeReason reason);
|
const gchar *mmcli_get_state_reason_string (MMModemStateChangeReason reason);
|
||||||
const gchar *mmcli_get_lock_string (MMModemLock lock);
|
|
||||||
const gchar *mmcli_get_3gpp_network_availability_string (MMModem3gppNetworkAvailability availability);
|
|
||||||
const gchar *mmcli_get_3gpp_registration_state_string (MMModem3gppRegistrationState state);
|
|
||||||
const gchar *mmcli_get_cdma_registration_state_string (MMModemCdmaRegistrationState state);
|
|
||||||
const gchar *mmcli_get_cdma_rm_protocol_string (MMModemCdmaRmProtocol protocol);
|
|
||||||
|
|
||||||
|
|
||||||
GOptionGroup *mmcli_get_common_option_group (void);
|
GOptionGroup *mmcli_get_common_option_group (void);
|
||||||
const gchar *mmcli_get_common_modem_string (void);
|
const gchar *mmcli_get_common_modem_string (void);
|
||||||
|
@@ -139,7 +139,7 @@ print_network_info (MMModem3gppNetwork *network)
|
|||||||
#undef VALIDATE
|
#undef VALIDATE
|
||||||
#define VALIDATE(str) (str ? str : "unknown")
|
#define VALIDATE(str) (str ? str : "unknown")
|
||||||
|
|
||||||
access_technologies = (mm_modem_get_access_technologies_string (
|
access_technologies = (mm_modem_access_technology_build_string_from_mask (
|
||||||
mm_modem_3gpp_network_get_access_technology (network)));
|
mm_modem_3gpp_network_get_access_technology (network)));
|
||||||
|
|
||||||
/* Prefer long name */
|
/* Prefer long name */
|
||||||
@@ -151,7 +151,7 @@ print_network_info (MMModem3gppNetwork *network)
|
|||||||
VALIDATE (mm_modem_3gpp_network_get_operator_code (network)),
|
VALIDATE (mm_modem_3gpp_network_get_operator_code (network)),
|
||||||
VALIDATE (name),
|
VALIDATE (name),
|
||||||
access_technologies,
|
access_technologies,
|
||||||
mmcli_get_3gpp_network_availability_string (
|
mm_modem_3gpp_network_availability_get_string (
|
||||||
mm_modem_3gpp_network_get_availability (network)));
|
mm_modem_3gpp_network_get_availability (network)));
|
||||||
g_free (access_technologies);
|
g_free (access_technologies);
|
||||||
}
|
}
|
||||||
|
@@ -209,7 +209,7 @@ status_process_reply (MMModemSimpleStatusProperties *result,
|
|||||||
|
|
||||||
g_print (" -------------------------\n"
|
g_print (" -------------------------\n"
|
||||||
" Status | state: '%s'\n",
|
" Status | state: '%s'\n",
|
||||||
mmcli_get_state_string (state));
|
mm_modem_state_get_string (state));
|
||||||
|
|
||||||
if (state >= MM_MODEM_STATE_REGISTERED) {
|
if (state >= MM_MODEM_STATE_REGISTERED) {
|
||||||
const MMModemBand *bands = NULL;
|
const MMModemBand *bands = NULL;
|
||||||
@@ -223,8 +223,8 @@ status_process_reply (MMModemSimpleStatusProperties *result,
|
|||||||
result,
|
result,
|
||||||
&signal_quality_recent));
|
&signal_quality_recent));
|
||||||
mm_modem_simple_status_properties_get_bands (result, &bands, &n_bands);
|
mm_modem_simple_status_properties_get_bands (result, &bands, &n_bands);
|
||||||
bands_str = mm_modem_get_bands_string (bands, n_bands);
|
bands_str = mm_common_build_bands_string (bands, n_bands);
|
||||||
access_tech_str = (mm_modem_get_access_technologies_string (
|
access_tech_str = (mm_modem_access_technology_build_string_from_mask (
|
||||||
mm_modem_simple_status_properties_get_access_technologies (result)));
|
mm_modem_simple_status_properties_get_access_technologies (result)));
|
||||||
|
|
||||||
g_print (" | signal quality: '%u' (%s)\n"
|
g_print (" | signal quality: '%u' (%s)\n"
|
||||||
@@ -242,7 +242,7 @@ status_process_reply (MMModemSimpleStatusProperties *result,
|
|||||||
" 3GPP | registration: '%s'\n"
|
" 3GPP | registration: '%s'\n"
|
||||||
" | operator code: '%s'\n"
|
" | operator code: '%s'\n"
|
||||||
" | operator name: '%s'\n",
|
" | operator name: '%s'\n",
|
||||||
mmcli_get_3gpp_registration_state_string (
|
mm_modem_3gpp_registration_state_get_string (
|
||||||
mm_modem_simple_status_properties_get_3gpp_registration_state (result)),
|
mm_modem_simple_status_properties_get_3gpp_registration_state (result)),
|
||||||
VALIDATE_UNKNOWN (mm_modem_simple_status_properties_get_3gpp_operator_code (result)),
|
VALIDATE_UNKNOWN (mm_modem_simple_status_properties_get_3gpp_operator_code (result)),
|
||||||
VALIDATE_UNKNOWN (mm_modem_simple_status_properties_get_3gpp_operator_name (result)));
|
VALIDATE_UNKNOWN (mm_modem_simple_status_properties_get_3gpp_operator_name (result)));
|
||||||
@@ -274,9 +274,9 @@ status_process_reply (MMModemSimpleStatusProperties *result,
|
|||||||
" | EV-DO '%s'\n",
|
" | EV-DO '%s'\n",
|
||||||
VALIDATE_UNKNOWN (sid_str),
|
VALIDATE_UNKNOWN (sid_str),
|
||||||
VALIDATE_UNKNOWN (nid_str),
|
VALIDATE_UNKNOWN (nid_str),
|
||||||
mmcli_get_cdma_registration_state_string (
|
mm_modem_cdma_registration_state_get_string (
|
||||||
mm_modem_simple_status_properties_get_cdma_cdma1x_registration_state (result)),
|
mm_modem_simple_status_properties_get_cdma_cdma1x_registration_state (result)),
|
||||||
mmcli_get_cdma_registration_state_string (
|
mm_modem_cdma_registration_state_get_string (
|
||||||
mm_modem_simple_status_properties_get_cdma_evdo_registration_state (result)));
|
mm_modem_simple_status_properties_get_cdma_evdo_registration_state (result)));
|
||||||
|
|
||||||
g_free (sid_str);
|
g_free (sid_str);
|
||||||
|
@@ -283,31 +283,31 @@ print_modem_info (void)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
unlock = g_strdup_printf ("%s (%u retries)",
|
unlock = g_strdup_printf ("%s (%u retries)",
|
||||||
mmcli_get_lock_string (unlock_required),
|
mm_modem_lock_get_string (unlock_required),
|
||||||
mm_modem_get_unlock_retries (ctx->modem));
|
mm_modem_get_unlock_retries (ctx->modem));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Strings in heap */
|
/* Strings in heap */
|
||||||
capabilities_string = mm_modem_get_capabilities_string (
|
capabilities_string = mm_modem_capability_build_string_from_mask (
|
||||||
mm_modem_get_modem_capabilities (ctx->modem));
|
mm_modem_get_modem_capabilities (ctx->modem));
|
||||||
access_technologies_string = mm_modem_get_access_technologies_string (
|
access_technologies_string = mm_modem_access_technology_build_string_from_mask (
|
||||||
mm_modem_get_access_technologies (ctx->modem));
|
mm_modem_get_access_technologies (ctx->modem));
|
||||||
mm_modem_get_allowed_bands (ctx->modem,
|
mm_modem_get_allowed_bands (ctx->modem,
|
||||||
&bands,
|
&bands,
|
||||||
&n_bands);
|
&n_bands);
|
||||||
allowed_bands_string = mm_modem_get_bands_string (bands, n_bands);
|
allowed_bands_string = mm_common_build_bands_string (bands, n_bands);
|
||||||
g_free (bands);
|
g_free (bands);
|
||||||
mm_modem_get_supported_bands (ctx->modem,
|
mm_modem_get_supported_bands (ctx->modem,
|
||||||
&bands,
|
&bands,
|
||||||
&n_bands);
|
&n_bands);
|
||||||
supported_bands_string = mm_modem_get_bands_string (bands, n_bands);
|
supported_bands_string = mm_common_build_bands_string (bands, n_bands);
|
||||||
g_free (bands);
|
g_free (bands);
|
||||||
allowed_modes_string = mm_modem_get_modes_string (
|
allowed_modes_string = mm_modem_mode_build_string_from_mask (
|
||||||
mm_modem_get_allowed_modes (ctx->modem));
|
mm_modem_get_allowed_modes (ctx->modem));
|
||||||
preferred_mode_string = mm_modem_get_modes_string (
|
preferred_mode_string = mm_modem_mode_build_string_from_mask (
|
||||||
mm_modem_get_preferred_mode (ctx->modem));
|
mm_modem_get_preferred_mode (ctx->modem));
|
||||||
supported_modes_string = mm_modem_get_modes_string (
|
supported_modes_string = mm_modem_mode_build_string_from_mask (
|
||||||
mm_modem_get_supported_modes (ctx->modem));
|
mm_modem_get_supported_modes (ctx->modem));
|
||||||
|
|
||||||
/* Rework possible multiline strings */
|
/* Rework possible multiline strings */
|
||||||
@@ -348,7 +348,7 @@ print_modem_info (void)
|
|||||||
" | state: '%s'\n"
|
" | state: '%s'\n"
|
||||||
" | access tech: '%s'\n",
|
" | access tech: '%s'\n",
|
||||||
VALIDATE_UNKNOWN (unlock),
|
VALIDATE_UNKNOWN (unlock),
|
||||||
VALIDATE_UNKNOWN (mmcli_get_state_string (mm_modem_get_state (ctx->modem))),
|
VALIDATE_UNKNOWN (mm_modem_state_get_string (mm_modem_get_state (ctx->modem))),
|
||||||
VALIDATE_UNKNOWN (access_technologies_string));
|
VALIDATE_UNKNOWN (access_technologies_string));
|
||||||
|
|
||||||
/* Modes */
|
/* Modes */
|
||||||
@@ -377,7 +377,7 @@ print_modem_info (void)
|
|||||||
VALIDATE_UNKNOWN (mm_modem_3gpp_get_imei (ctx->modem_3gpp)),
|
VALIDATE_UNKNOWN (mm_modem_3gpp_get_imei (ctx->modem_3gpp)),
|
||||||
VALIDATE_UNKNOWN (mm_modem_3gpp_get_operator_code (ctx->modem_3gpp)),
|
VALIDATE_UNKNOWN (mm_modem_3gpp_get_operator_code (ctx->modem_3gpp)),
|
||||||
VALIDATE_UNKNOWN (mm_modem_3gpp_get_operator_name (ctx->modem_3gpp)),
|
VALIDATE_UNKNOWN (mm_modem_3gpp_get_operator_name (ctx->modem_3gpp)),
|
||||||
mmcli_get_3gpp_registration_state_string (
|
mm_modem_3gpp_registration_state_get_string (
|
||||||
mm_modem_3gpp_get_registration_state ((ctx->modem_3gpp))));
|
mm_modem_3gpp_get_registration_state ((ctx->modem_3gpp))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,9 +408,9 @@ print_modem_info (void)
|
|||||||
VALIDATE_UNKNOWN (mm_modem_cdma_get_esn (ctx->modem_cdma)),
|
VALIDATE_UNKNOWN (mm_modem_cdma_get_esn (ctx->modem_cdma)),
|
||||||
VALIDATE_UNKNOWN (sid_str),
|
VALIDATE_UNKNOWN (sid_str),
|
||||||
VALIDATE_UNKNOWN (nid_str),
|
VALIDATE_UNKNOWN (nid_str),
|
||||||
mmcli_get_cdma_registration_state_string (
|
mm_modem_cdma_registration_state_get_string (
|
||||||
mm_modem_cdma_get_cdma1x_registration_state ((ctx->modem_cdma))),
|
mm_modem_cdma_get_cdma1x_registration_state ((ctx->modem_cdma))),
|
||||||
mmcli_get_cdma_registration_state_string (
|
mm_modem_cdma_registration_state_get_string (
|
||||||
mm_modem_cdma_get_evdo_registration_state ((ctx->modem_cdma))));
|
mm_modem_cdma_get_evdo_registration_state ((ctx->modem_cdma))));
|
||||||
|
|
||||||
g_free (sid_str);
|
g_free (sid_str);
|
||||||
@@ -743,8 +743,8 @@ state_changed (MMModem *modem,
|
|||||||
{
|
{
|
||||||
g_print ("\t%s: State changed, '%s' --> '%s' (Reason: %s)\n",
|
g_print ("\t%s: State changed, '%s' --> '%s' (Reason: %s)\n",
|
||||||
mm_modem_get_path (modem),
|
mm_modem_get_path (modem),
|
||||||
mmcli_get_state_string (old_state),
|
mm_modem_state_get_string (old_state),
|
||||||
mmcli_get_state_string (new_state),
|
mm_modem_state_get_string (new_state),
|
||||||
mmcli_get_state_reason_string (reason));
|
mmcli_get_state_reason_string (reason));
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
}
|
}
|
||||||
@@ -774,7 +774,7 @@ get_modem_ready (GObject *source,
|
|||||||
current = mm_modem_get_state (ctx->modem);
|
current = mm_modem_get_state (ctx->modem);
|
||||||
g_print ("\t%s: Initial state, '%s'\n",
|
g_print ("\t%s: Initial state, '%s'\n",
|
||||||
mm_object_get_path (ctx->object),
|
mm_object_get_path (ctx->object),
|
||||||
mmcli_get_state_string (current));
|
mm_modem_state_get_string (current));
|
||||||
|
|
||||||
/* If we get cancelled, operation done */
|
/* If we get cancelled, operation done */
|
||||||
g_cancellable_connect (ctx->cancellable,
|
g_cancellable_connect (ctx->cancellable,
|
||||||
|
Reference in New Issue
Block a user