aboutsummaryrefslogtreecommitdiff
path: root/libmm-glib
diff options
context:
space:
mode:
Diffstat (limited to 'libmm-glib')
-rw-r--r--libmm-glib/mm-sms-properties.c35
-rw-r--r--libmm-glib/mm-sms-properties.h4
-rw-r--r--libmm-glib/mm-sms.c6
-rw-r--r--libmm-glib/mm-sms.h2
4 files changed, 24 insertions, 23 deletions
diff --git a/libmm-glib/mm-sms-properties.c b/libmm-glib/mm-sms-properties.c
index 05d5fd16..a6947269 100644
--- a/libmm-glib/mm-sms-properties.c
+++ b/libmm-glib/mm-sms-properties.c
@@ -51,8 +51,7 @@ struct _MMSmsPropertiesPrivate {
gchar *smsc;
MMSmsValidityType validity_type;
guint validity_relative;
- gboolean class_set;
- guint class;
+ gint class;
gboolean delivery_report_request_set;
gboolean delivery_report_request;
};
@@ -319,17 +318,16 @@ mm_sms_properties_get_validity_relative (MMSmsProperties *self)
/**
* mm_sms_properties_set_class:
* @self: A #MMSmsProperties.
- * @class: The message class.
+ * @class: The message class, or -1 for invalid/unset class.
*
* Sets the 3GPP message class of the SMS.
*/
void
mm_sms_properties_set_class (MMSmsProperties *self,
- guint class)
+ gint class)
{
g_return_if_fail (MM_IS_SMS_PROPERTIES (self));
- self->priv->class_set = TRUE;
self->priv->class = class;
}
@@ -339,12 +337,12 @@ mm_sms_properties_set_class (MMSmsProperties *self,
*
* Gets the 3GPP message class of the SMS.
*
- * Returns: the message class.
+ * Returns: the message class, or -1 for invalid/unset class.
*/
-guint
+gint
mm_sms_properties_get_class (MMSmsProperties *self)
{
- g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), 0);
+ g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), -1);
return self->priv->class;
}
@@ -435,11 +433,11 @@ mm_sms_properties_get_dictionary (MMSmsProperties *self)
PROPERTY_VALIDITY,
g_variant_new ("(uv)", MM_SMS_VALIDITY_TYPE_RELATIVE, g_variant_new_uint32 (self->priv->validity_relative)));
- if (self->priv->class_set)
+ if (self->priv->class >= 0)
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_CLASS,
- g_variant_new_uint32 (self->priv->class));
+ g_variant_new_int32 (self->priv->class));
if (self->priv->delivery_report_request_set)
g_variant_builder_add (&builder,
@@ -517,12 +515,14 @@ consume_string (MMSmsProperties *self,
mm_sms_properties_set_validity_relative (self, n);
} else if (g_str_equal (key, PROPERTY_CLASS)) {
- GError *inner_error = NULL;
- guint n;
-
- n = parse_uint (value, &inner_error);
- if (inner_error) {
- g_propagate_error (error, inner_error);
+ gint n = 0;
+
+ if (!mm_get_int_from_str (value, &n)) {
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_INVALID_ARGS,
+ "Invalid properties string, cannot parse '%s' as int",
+ value);
return FALSE;
}
@@ -642,7 +642,7 @@ consume_variant (MMSmsProperties *properties,
} else if (g_str_equal (key, PROPERTY_CLASS))
mm_sms_properties_set_class (
properties,
- g_variant_get_uint32 (value));
+ g_variant_get_int32 (value));
else if (g_str_equal (key, PROPERTY_DELIVERY_REPORT_REQUEST))
mm_sms_properties_set_delivery_report_request (
properties,
@@ -746,6 +746,7 @@ mm_sms_properties_init (MMSmsProperties *self)
MM_TYPE_SMS_PROPERTIES,
MMSmsPropertiesPrivate);
self->priv->validity_type = MM_SMS_VALIDITY_TYPE_UNKNOWN;
+ self->priv->class = -1;
}
static void
diff --git a/libmm-glib/mm-sms-properties.h b/libmm-glib/mm-sms-properties.h
index 82c65595..b0c290a0 100644
--- a/libmm-glib/mm-sms-properties.h
+++ b/libmm-glib/mm-sms-properties.h
@@ -71,7 +71,7 @@ void mm_sms_properties_set_smsc (MMSmsProperties *self,
void mm_sms_properties_set_validity_relative (MMSmsProperties *self,
guint validity);
void mm_sms_properties_set_class (MMSmsProperties *self,
- guint class);
+ gint class);
void mm_sms_properties_set_delivery_report_request (MMSmsProperties *self,
gboolean request);
@@ -84,7 +84,7 @@ const gchar *mm_sms_properties_get_number (MMSmsProperties *se
const gchar *mm_sms_properties_get_smsc (MMSmsProperties *self);
MMSmsValidityType mm_sms_properties_get_validity_type (MMSmsProperties *self);
guint mm_sms_properties_get_validity_relative (MMSmsProperties *self);
-guint mm_sms_properties_get_class (MMSmsProperties *self);
+gint mm_sms_properties_get_class (MMSmsProperties *self);
gboolean mm_sms_properties_get_delivery_report_request (MMSmsProperties *self);
/*****************************************************************************/
diff --git a/libmm-glib/mm-sms.c b/libmm-glib/mm-sms.c
index a69b5dc7..82290218 100644
--- a/libmm-glib/mm-sms.c
+++ b/libmm-glib/mm-sms.c
@@ -445,12 +445,12 @@ mm_sms_get_validity_relative (MMSms *self)
*
* Gets the 3GPP message class of the SMS.
*
- * Returns: the message class.
+ * Returns: the message class, or -1 for invalid/unset class.
*/
-guint
+gint
mm_sms_get_class (MMSms *self)
{
- g_return_val_if_fail (MM_IS_SMS (self), 0);
+ g_return_val_if_fail (MM_IS_SMS (self), -1);
return mm_gdbus_sms_get_class (MM_GDBUS_SMS (self));
}
diff --git a/libmm-glib/mm-sms.h b/libmm-glib/mm-sms.h
index cb5b2b9d..def70c10 100644
--- a/libmm-glib/mm-sms.h
+++ b/libmm-glib/mm-sms.h
@@ -89,7 +89,7 @@ gchar *mm_sms_dup_discharge_timestamp (MMSms *self);
MMSmsValidityType mm_sms_get_validity_type (MMSms *self);
guint mm_sms_get_validity_relative (MMSms *self);
-guint mm_sms_get_class (MMSms *self);
+gint mm_sms_get_class (MMSms *self);
guint mm_sms_get_message_reference (MMSms *self);