iface-modem-messaging: don't allow method calls if not enabled
This commit is contained in:
@@ -91,6 +91,20 @@ handle_delete (MmGdbusModemMessaging *skeleton,
|
|||||||
MMIfaceModemMessaging *self)
|
MMIfaceModemMessaging *self)
|
||||||
{
|
{
|
||||||
MMSmsList *list = NULL;
|
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,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
|
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
|
||||||
@@ -121,6 +135,20 @@ handle_create (MmGdbusModemMessaging *skeleton,
|
|||||||
MMSmsList *list = NULL;
|
MMSmsList *list = NULL;
|
||||||
MMCommonSmsProperties *properties;
|
MMCommonSmsProperties *properties;
|
||||||
MMSms *sms;
|
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 */
|
/* Parse input properties */
|
||||||
properties = mm_common_sms_properties_new_from_dictionary (dictionary, &error);
|
properties = mm_common_sms_properties_new_from_dictionary (dictionary, &error);
|
||||||
@@ -166,6 +194,21 @@ handle_list (MmGdbusModemMessaging *skeleton,
|
|||||||
{
|
{
|
||||||
GStrv paths;
|
GStrv paths;
|
||||||
MMSmsList *list = NULL;
|
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,
|
g_object_get (self,
|
||||||
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
|
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
|
||||||
|
Reference in New Issue
Block a user