Refactor: Send NotAttached error
authorDenis Kenzior <denkenz@gmail.com>
Wed, 18 Nov 2009 19:23:13 +0000 (13:23 -0600)
committerDenis Kenzior <denkenz@gmail.com>
Wed, 18 Nov 2009 19:23:13 +0000 (13:23 -0600)
If one tries to activate the context and we're currently not attached to
GPRS, report a NotAttached error instead of a failure

src/dbus.c
src/gprs.c
src/ofono.h

index b74481f..25af2ec 100644 (file)
@@ -316,6 +316,12 @@ DBusMessage *__ofono_error_in_use(DBusMessage *msg)
                        "The resource is currently in use");
 }
 
+DBusMessage *__ofono_error_not_attached(DBusMessage *msg)
+{
+       return g_dbus_create_error(msg, DBUS_GSM_ERROR_INTERFACE ".NotAttached",
+                       "GPRS is not attached");
+}
+
 void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply)
 {
        DBusConnection *conn = ofono_dbus_get_connection();
index 6b88fcb..7c31679 100644 (file)
@@ -603,12 +603,12 @@ static DBusMessage *pri_set_property(DBusConnection *conn,
                if (ctx->active == (ofono_bool_t) value)
                        return dbus_message_new_method_return(msg);
 
+               if (value && !ctx->gprs->attached)
+                       return __ofono_error_not_attached(msg);
+
                if (ctx->gprs->flags & GPRS_FLAG_ATTACHING)
                        return __ofono_error_busy(msg);
 
-               if (value && !ctx->gprs->attached)
-                       return __ofono_error_failed(msg);
-
                if (gc == NULL || gc->driver->activate_primary == NULL ||
                                gc->driver->deactivate_primary == NULL)
                        return __ofono_error_not_implemented(msg);
index b03dafc..037c403 100644 (file)
@@ -51,6 +51,7 @@ DBusMessage *__ofono_error_not_supported(DBusMessage *msg);
 DBusMessage *__ofono_error_timed_out(DBusMessage *msg);
 DBusMessage *__ofono_error_sim_not_ready(DBusMessage *msg);
 DBusMessage *__ofono_error_in_use(DBusMessage *msg);
+DBusMessage *__ofono_error_not_attached(DBusMessage *msg);
 
 void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply);