From ad3b3d0ba772c5d4603abcf2cfe6f5a4842fd92c Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 8 Feb 2012 16:08:53 +0100 Subject: iface-modem-messaging: don't allow method calls if not enabled --- src/mm-iface-modem-messaging.c | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src') diff --git a/src/mm-iface-modem-messaging.c b/src/mm-iface-modem-messaging.c index ae6ad86d..b13e1520 100644 --- a/src/mm-iface-modem-messaging.c +++ b/src/mm-iface-modem-messaging.c @@ -91,6 +91,20 @@ handle_delete (MmGdbusModemMessaging *skeleton, MMIfaceModemMessaging *self) { MMSmsList *list = NULL; + MMModemState modem_state; + + modem_state = MM_MODEM_STATE_UNKNOWN; + g_object_get (self, + MM_IFACE_MODEM_STATE, &modem_state, + NULL); + + if (modem_state < MM_MODEM_STATE_ENABLED) { + g_dbus_method_invocation_return_error (invocation, + MM_CORE_ERROR, + MM_CORE_ERROR_WRONG_STATE, + "Cannot delete SMS: device not yet enabled"); + return TRUE; + } g_object_get (self, MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list, @@ -121,6 +135,20 @@ handle_create (MmGdbusModemMessaging *skeleton, MMSmsList *list = NULL; MMCommonSmsProperties *properties; MMSms *sms; + MMModemState modem_state; + + modem_state = MM_MODEM_STATE_UNKNOWN; + g_object_get (self, + MM_IFACE_MODEM_STATE, &modem_state, + NULL); + + if (modem_state < MM_MODEM_STATE_ENABLED) { + g_dbus_method_invocation_return_error (invocation, + MM_CORE_ERROR, + MM_CORE_ERROR_WRONG_STATE, + "Cannot create SMS: device not yet enabled"); + return TRUE; + } /* Parse input properties */ properties = mm_common_sms_properties_new_from_dictionary (dictionary, &error); @@ -166,6 +194,21 @@ handle_list (MmGdbusModemMessaging *skeleton, { GStrv paths; MMSmsList *list = NULL; + MMModemState modem_state; + + modem_state = MM_MODEM_STATE_UNKNOWN; + g_object_get (self, + MM_IFACE_MODEM_STATE, &modem_state, + NULL); + + if (modem_state < MM_MODEM_STATE_ENABLED) { + g_dbus_method_invocation_return_error (invocation, + MM_CORE_ERROR, + MM_CORE_ERROR_WRONG_STATE, + "Cannot list SMS messages: " + "device not yet enabled"); + return TRUE; + } g_object_get (self, MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list, -- cgit v1.2.3-70-g09d2