From f9105bff875ae0e7263718a317e156948957a6d0 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 3 Apr 2013 16:30:48 +0200 Subject: 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). --- libmm-glib/mm-sms.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 6 deletions(-) (limited to 'libmm-glib/mm-sms.c') 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; } /*****************************************************************************/ -- cgit v1.2.3-70-g09d2