base-sms: determine 3GPP vs. CDMA at creation time
It won't ever change over the lifetime of the BaseSMS. Signed-off-by: Dan Williams <dan@ioncontrol.co>
This commit is contained in:
+21
-20
@@ -55,6 +55,7 @@ enum {
|
||||
PROP_IS_MULTIPART,
|
||||
PROP_MAX_PARTS,
|
||||
PROP_MULTIPART_REFERENCE,
|
||||
PROP_IS_3GPP,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
@@ -88,6 +89,9 @@ struct _MMBaseSmsPrivate {
|
||||
/* Set to true when all needed parts were received,
|
||||
* parsed and assembled */
|
||||
gboolean is_assembled;
|
||||
|
||||
/* TRUE for 3GPP SMS; FALSE for CDMA */
|
||||
gboolean is_3gpp;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -310,25 +314,7 @@ static gboolean
|
||||
generate_submit_pdus (MMBaseSms *self,
|
||||
GError **error)
|
||||
{
|
||||
MMBaseModem *modem;
|
||||
gboolean is_3gpp;
|
||||
|
||||
/* First; decide which kind of PDU we'll generate, based on the current modem caps */
|
||||
|
||||
g_object_get (self,
|
||||
MM_BASE_SMS_MODEM, &modem,
|
||||
NULL);
|
||||
g_assert (modem != NULL);
|
||||
|
||||
is_3gpp = mm_iface_modem_is_3gpp (MM_IFACE_MODEM (modem));
|
||||
g_object_unref (modem);
|
||||
|
||||
/* On a 3GPP-capable modem, create always a 3GPP SMS (even if the modem is 3GPP+3GPP2) */
|
||||
if (is_3gpp)
|
||||
return generate_3gpp_submit_pdus (self, error);
|
||||
|
||||
/* Otherwise, create a 3GPP2 SMS */
|
||||
return generate_cdma_submit_pdus (self, error);
|
||||
return self->priv->is_3gpp ? generate_3gpp_submit_pdus (self, error) : generate_cdma_submit_pdus (self, error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -1801,11 +1787,12 @@ mm_base_sms_multipart_take_part (MMBaseSms *self,
|
||||
}
|
||||
|
||||
MMBaseSms *
|
||||
mm_base_sms_new (MMBaseModem *modem)
|
||||
mm_base_sms_new (MMBaseModem *modem, gboolean is_3gpp)
|
||||
{
|
||||
return MM_BASE_SMS (g_object_new (MM_TYPE_BASE_SMS,
|
||||
MM_BASE_SMS_MODEM, modem,
|
||||
MM_BIND_TO, modem,
|
||||
MM_BASE_SMS_IS_3GPP, is_3gpp,
|
||||
NULL));
|
||||
}
|
||||
|
||||
@@ -2021,6 +2008,9 @@ set_property (GObject *object,
|
||||
case PROP_MULTIPART_REFERENCE:
|
||||
self->priv->multipart_reference = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_IS_3GPP:
|
||||
self->priv->is_3gpp = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -2057,6 +2047,9 @@ get_property (GObject *object,
|
||||
case PROP_MULTIPART_REFERENCE:
|
||||
g_value_set_uint (value, self->priv->multipart_reference);
|
||||
break;
|
||||
case PROP_IS_3GPP:
|
||||
g_value_set_boolean (value, self->priv->is_3gpp);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -2192,4 +2185,12 @@ mm_base_sms_class_init (MMBaseSmsClass *klass)
|
||||
0, G_MAXUINT, 0,
|
||||
G_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class, PROP_MULTIPART_REFERENCE, properties[PROP_MULTIPART_REFERENCE]);
|
||||
|
||||
properties[PROP_IS_3GPP] =
|
||||
g_param_spec_boolean (MM_BASE_SMS_IS_3GPP,
|
||||
"Is 3GPP",
|
||||
"Whether the SMS is a 3GPP one or a CDMA one",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property (object_class, PROP_IS_3GPP, properties[PROP_IS_3GPP]);
|
||||
}
|
||||
|
||||
+3
-1
@@ -52,6 +52,7 @@ typedef struct _MMBaseSmsPrivate MMBaseSmsPrivate;
|
||||
#define MM_BASE_SMS_IS_MULTIPART "sms-is-multipart"
|
||||
#define MM_BASE_SMS_MAX_PARTS "sms-max-parts"
|
||||
#define MM_BASE_SMS_MULTIPART_REFERENCE "sms-multipart-reference"
|
||||
#define MM_BASE_SMS_IS_3GPP "sms-is-3gpp"
|
||||
|
||||
struct _MMBaseSms {
|
||||
MmGdbusSmsSkeleton parent;
|
||||
@@ -91,7 +92,8 @@ GType mm_base_sms_get_type (void);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMBaseSms, g_object_unref)
|
||||
|
||||
/* This one can be overridden by plugins */
|
||||
MMBaseSms *mm_base_sms_new (MMBaseModem *modem);
|
||||
MMBaseSms *mm_base_sms_new (MMBaseModem *modem,
|
||||
gboolean is_3gpp);
|
||||
MMBaseSms *mm_base_sms_new_from_properties (MMBaseModem *modem,
|
||||
MMSmsProperties *properties,
|
||||
GError **error);
|
||||
|
||||
@@ -9233,7 +9233,8 @@ enable_unsolicited_events_messaging (MMIfaceModemMessaging *_self,
|
||||
static MMBaseSms *
|
||||
messaging_create_sms (MMIfaceModemMessaging *self)
|
||||
{
|
||||
return mm_sms_mbim_new (MM_BASE_MODEM (self));
|
||||
return mm_sms_mbim_new (MM_BASE_MODEM (self),
|
||||
mm_iface_modem_is_3gpp (MM_IFACE_MODEM (self)));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -8882,7 +8882,8 @@ messaging_create_sms (MMIfaceModemMessaging *_self)
|
||||
return iface_modem_messaging_parent->create_sms (_self);
|
||||
}
|
||||
|
||||
return mm_sms_qmi_new (MM_BASE_MODEM (self));
|
||||
return mm_sms_qmi_new (MM_BASE_MODEM (self),
|
||||
mm_iface_modem_is_3gpp (MM_IFACE_MODEM (self)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8225,7 +8225,8 @@ modem_messaging_load_initial_sms_parts (MMIfaceModemMessaging *self,
|
||||
static MMBaseSms *
|
||||
modem_messaging_create_sms (MMIfaceModemMessaging *self)
|
||||
{
|
||||
return mm_base_sms_new (MM_BASE_MODEM (self));
|
||||
return mm_base_sms_new (MM_BASE_MODEM (self),
|
||||
mm_iface_modem_is_3gpp (MM_IFACE_MODEM (self)));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -6616,25 +6616,25 @@ mm_iface_modem_get_current_capabilities (MMIfaceModem *self)
|
||||
gboolean
|
||||
mm_iface_modem_is_3gpp (MMIfaceModem *self)
|
||||
{
|
||||
return (mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_3GPP);
|
||||
return !!(mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_3GPP);
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_iface_modem_is_3gpp_lte (MMIfaceModem *self)
|
||||
{
|
||||
return (mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_LTE);
|
||||
return !!(mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_LTE);
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_iface_modem_is_3gpp_5gnr (MMIfaceModem *self)
|
||||
{
|
||||
return (mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_5GNR);
|
||||
return !!(mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_5GNR);
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_iface_modem_is_cdma (MMIfaceModem *self)
|
||||
{
|
||||
return (mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_CDMA_EVDO);
|
||||
return !!(mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_CDMA_EVDO);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@@ -6643,13 +6643,13 @@ mm_iface_modem_is_3gpp_only (MMIfaceModem *self)
|
||||
MMModemCapability capabilities;
|
||||
|
||||
capabilities = mm_iface_modem_get_current_capabilities (self);
|
||||
return (capabilities & MM_MODEM_CAPABILITY_3GPP) && !((MM_MODEM_CAPABILITY_3GPP ^ capabilities) & capabilities);
|
||||
return !!((capabilities & MM_MODEM_CAPABILITY_3GPP) && !((MM_MODEM_CAPABILITY_3GPP ^ capabilities) & capabilities));
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_iface_modem_is_cdma_only (MMIfaceModem *self)
|
||||
{
|
||||
return (mm_iface_modem_get_current_capabilities (self) == MM_MODEM_CAPABILITY_CDMA_EVDO);
|
||||
return !!(mm_iface_modem_get_current_capabilities (self) == MM_MODEM_CAPABILITY_CDMA_EVDO);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
+2
-1
@@ -332,11 +332,12 @@ sms_delete (MMBaseSms *self,
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBaseSms *
|
||||
mm_sms_mbim_new (MMBaseModem *modem)
|
||||
mm_sms_mbim_new (MMBaseModem *modem, gboolean is_3gpp)
|
||||
{
|
||||
return MM_BASE_SMS (g_object_new (MM_TYPE_SMS_MBIM,
|
||||
MM_BASE_SMS_MODEM, modem,
|
||||
MM_BIND_TO, G_OBJECT (modem),
|
||||
MM_BASE_SMS_IS_3GPP, is_3gpp,
|
||||
NULL));
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -45,6 +45,7 @@ struct _MMSmsMbimClass {
|
||||
GType mm_sms_mbim_get_type (void);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMSmsMbim, g_object_unref)
|
||||
|
||||
MMBaseSms *mm_sms_mbim_new (MMBaseModem *modem);
|
||||
MMBaseSms *mm_sms_mbim_new (MMBaseModem *modem,
|
||||
gboolean is_3gpp);
|
||||
|
||||
#endif /* MM_SMS_MBIM_H */
|
||||
|
||||
+2
-1
@@ -786,11 +786,12 @@ sms_delete (MMBaseSms *self,
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBaseSms *
|
||||
mm_sms_qmi_new (MMBaseModem *modem)
|
||||
mm_sms_qmi_new (MMBaseModem *modem, gboolean is_3gpp)
|
||||
{
|
||||
return MM_BASE_SMS (g_object_new (MM_TYPE_SMS_QMI,
|
||||
MM_BASE_SMS_MODEM, modem,
|
||||
MM_BIND_TO, G_OBJECT (modem),
|
||||
MM_BASE_SMS_IS_3GPP, is_3gpp,
|
||||
NULL));
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -47,6 +47,7 @@ struct _MMSmsQmiClass {
|
||||
GType mm_sms_qmi_get_type (void);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMSmsQmi, g_object_unref)
|
||||
|
||||
MMBaseSms *mm_sms_qmi_new (MMBaseModem *modem);
|
||||
MMBaseSms *mm_sms_qmi_new (MMBaseModem *modem,
|
||||
gboolean is_3gpp);
|
||||
|
||||
#endif /* MM_SMS_QMI_H */
|
||||
|
||||
Reference in New Issue
Block a user