diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2013-04-03 16:30:48 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-04-05 17:48:51 +0200 |
commit | f9105bff875ae0e7263718a317e156948957a6d0 (patch) | |
tree | 417299f51a7d17d7d5bd30692fd7b5ffd98092de /libmm-glib | |
parent | 372a49bbf661c95110852c86df54008a7bad2774 (diff) |
api,introspection: update 'Validity' property in the SMS interface
We don't want to support only 'relative' validity, so don't assume that the
Validity property will always be a uint32 value.
Instead, we define the Validity propery as '(uv)' tuple, where the first value
(a MMSmsValidityType) specifies the type of validity, and the second value is
a variant formatted accordingly to what the validity type specifies (e.g. a
uint32 value if the type is MM_SMS_VALIDITY_TYPE_RELATIVE).
Diffstat (limited to 'libmm-glib')
-rw-r--r-- | libmm-glib/mm-sms.c | 59 | ||||
-rw-r--r-- | libmm-glib/mm-sms.h | 3 |
2 files changed, 55 insertions, 7 deletions
diff --git a/libmm-glib/mm-sms.c b/libmm-glib/mm-sms.c index 3a0bd5f5..a69b5dc7 100644 --- a/libmm-glib/mm-sms.c +++ b/libmm-glib/mm-sms.c @@ -375,19 +375,66 @@ mm_sms_dup_discharge_timestamp (MMSms *self) /*****************************************************************************/ /** - * mm_sms_get_validity: + * mm_sms_get_validity_type: * @self: A #MMSms. * - * Gets the validity time of the SMS. + * Gets the type of validity information in the SMS. * - * Returns: the validity time or 0 if unknown. + * Returns: the validity type or #MM_SMS_VALIDITY_TYPE_UNKNOWN. + */ +MMSmsValidityType +mm_sms_get_validity_type (MMSms *self) +{ + GVariant *variant; + guint type; + GVariant *value; + + g_return_val_if_fail (MM_IS_SMS (self), MM_SMS_VALIDITY_TYPE_UNKNOWN); + + variant = mm_gdbus_sms_dup_validity (MM_GDBUS_SMS (self)); + if (!variant) + return MM_SMS_VALIDITY_TYPE_UNKNOWN; + + g_variant_get (variant, "(uv)", &type, &value); + g_variant_unref (variant); + g_variant_unref (value); + + return (MMSmsValidityType)type; +} + +/** + * mm_sms_get_validity_relative: + * @self: A #MMSms. + * + * Gets the length of the validity period, in minutes. + * + * Only applicable if the type of validity is #MM_SMS_VALIDITY_TYPE_RELATIVE. + * + * Returns: the length of the validity period, or 0 if unknown. */ guint -mm_sms_get_validity (MMSms *self) +mm_sms_get_validity_relative (MMSms *self) { - g_return_val_if_fail (MM_IS_SMS (self), 0); + GVariant *variant; + guint type; + GVariant *value; + guint value_integer = 0; + + g_return_val_if_fail (MM_IS_SMS (self), MM_SMS_VALIDITY_TYPE_UNKNOWN); + + variant = mm_gdbus_sms_dup_validity (MM_GDBUS_SMS (self)); + if (!variant) + return 0; + + g_variant_get (variant, "(uv)", &type, &value); + + if (type == MM_SMS_VALIDITY_TYPE_RELATIVE) + value_integer = g_variant_get_uint32 (value); + + g_variant_unref (variant); + g_variant_unref (value); - return mm_gdbus_sms_get_validity (MM_GDBUS_SMS (self)); + return value_integer; } /*****************************************************************************/ diff --git a/libmm-glib/mm-sms.h b/libmm-glib/mm-sms.h index 6cfb5b78..cb5b2b9d 100644 --- a/libmm-glib/mm-sms.h +++ b/libmm-glib/mm-sms.h @@ -86,7 +86,8 @@ gchar *mm_sms_dup_timestamp (MMSms *self); const gchar *mm_sms_get_discharge_timestamp (MMSms *self); gchar *mm_sms_dup_discharge_timestamp (MMSms *self); -guint mm_sms_get_validity (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); |