Simplify: Use dbus_message_iter_get_args

This commit is contained in:
Denis Kenzior 2009-09-22 10:59:17 -05:00
parent b8dcd905fb
commit cfcf7e6516
4 changed files with 36 additions and 103 deletions

View File

@ -889,25 +889,21 @@ static DBusMessage *cb_disable_all(DBusConnection *conn, DBusMessage *msg,
void *data, const char *fac)
{
struct ofono_call_barring *cb = data;
DBusMessageIter iter;
const char *passwd = "";
const char *passwd;
if (!cb->driver->set)
return __ofono_error_not_implemented(msg);
if (cb->pending)
return __ofono_error_busy(msg);
if (!dbus_message_iter_init(msg, &iter))
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &passwd,
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __ofono_error_invalid_args(msg);
dbus_message_iter_get_basic(&iter, &passwd);
if (!is_valid_pin(passwd))
return __ofono_error_invalid_format(msg);
if (!cb->driver->set)
return __ofono_error_not_implemented(msg);
cb_set_query_bounds(cb, fac, FALSE);
cb->pending = dbus_message_ref(msg);
@ -939,34 +935,26 @@ static DBusMessage *cb_set_passwd(DBusConnection *conn, DBusMessage *msg,
void *data)
{
struct ofono_call_barring *cb = data;
DBusMessageIter iter;
const char *old_passwd, *new_passwd;
const char *old_passwd;
const char *new_passwd;
if (!cb->driver->set_passwd)
return __ofono_error_not_implemented(msg);
if (cb->pending)
return __ofono_error_busy(msg);
if (!dbus_message_iter_init(msg, &iter))
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &old_passwd,
DBUS_TYPE_STRING, &new_passwd,
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __ofono_error_invalid_args(msg);
dbus_message_iter_get_basic(&iter, &old_passwd);
if (!is_valid_pin(old_passwd))
return __ofono_error_invalid_format(msg);
dbus_message_iter_next(&iter);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __ofono_error_invalid_args(msg);
dbus_message_iter_get_basic(&iter, &new_passwd);
if (!is_valid_pin(new_passwd))
return __ofono_error_invalid_format(msg);
if (!cb->driver->set_passwd)
return __ofono_error_not_implemented(msg);
cb->pending = dbus_message_ref(msg);
cb->driver->set_passwd(cb, "AB", old_passwd, new_passwd,
cb_set_passwd_callback, cb);

View File

@ -701,12 +701,12 @@ static DBusMessage *cf_disable_all(DBusConnection *conn, DBusMessage *msg,
const char *strtype;
int type;
if (cf->pending)
return __ofono_error_busy(msg);
if (!cf->driver->erasure)
return __ofono_error_not_implemented(msg);
if (cf->pending)
return __ofono_error_busy(msg);
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &strtype,
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);

View File

@ -606,26 +606,21 @@ static DBusMessage *cm_acm_reset(DBusConnection *conn, DBusMessage *msg,
void *data)
{
struct ofono_call_meter *cm = data;
DBusMessageIter iter;
const char *pin2;
if (!cm->driver->acm_reset)
return __ofono_error_not_implemented(msg);
if (cm->pending)
return __ofono_error_busy(msg);
if (!dbus_message_iter_init(msg, &iter))
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &pin2,
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __ofono_error_invalid_args(msg);
dbus_message_iter_get_basic(&iter, &pin2);
if (!is_valid_pin(pin2))
return __ofono_error_invalid_format(msg);
if (!cm->driver->acm_reset)
return __ofono_error_not_implemented(msg);
cm->pending = dbus_message_ref(msg);
cm->driver->acm_reset(cm, pin2, acm_reset_callback, cm);

View File

@ -442,7 +442,6 @@ static void sim_lock_cb(const struct ofono_error *error, void *data)
static DBusMessage *sim_lock_or_unlock(struct ofono_sim *sim, int lock,
DBusConnection *conn, DBusMessage *msg)
{
DBusMessageIter iter;
enum ofono_sim_password_type type;
const char *typestr;
const char *pin;
@ -453,14 +452,11 @@ static DBusMessage *sim_lock_or_unlock(struct ofono_sim *sim, int lock,
if (sim->pending)
return __ofono_error_busy(msg);
if (!dbus_message_iter_init(msg, &iter))
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &typestr,
DBUS_TYPE_STRING, &pin,
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __ofono_error_invalid_args(msg);
dbus_message_iter_get_basic(&iter, &typestr);
type = sim_string_to_passwd(typestr);
/* SIM PIN2 cannot be locked / unlocked according to 27.007,
@ -470,12 +466,6 @@ static DBusMessage *sim_lock_or_unlock(struct ofono_sim *sim, int lock,
type == OFONO_SIM_PASSWORD_SIM_PIN2)
return __ofono_error_invalid_format(msg);
dbus_message_iter_next(&iter);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __ofono_error_invalid_args(msg);
dbus_message_iter_get_basic(&iter, &pin);
if (!is_valid_pin(pin))
return __ofono_error_invalid_format(msg);
@ -519,7 +509,6 @@ static DBusMessage *sim_change_pin(DBusConnection *conn, DBusMessage *msg,
void *data)
{
struct ofono_sim *sim = data;
DBusMessageIter iter;
enum ofono_sim_password_type type;
const char *typestr;
const char *old;
@ -531,34 +520,20 @@ static DBusMessage *sim_change_pin(DBusConnection *conn, DBusMessage *msg,
if (sim->pending)
return __ofono_error_busy(msg);
if (!dbus_message_iter_init(msg, &iter))
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &typestr,
DBUS_TYPE_STRING, &old,
DBUS_TYPE_STRING, &new,
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __ofono_error_invalid_args(msg);
dbus_message_iter_get_basic(&iter, &typestr);
type = sim_string_to_passwd(typestr);
if (password_is_pin(type) == FALSE)
return __ofono_error_invalid_format(msg);
dbus_message_iter_next(&iter);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __ofono_error_invalid_args(msg);
dbus_message_iter_get_basic(&iter, &old);
if (!is_valid_pin(old))
return __ofono_error_invalid_format(msg);
dbus_message_iter_next(&iter);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __ofono_error_invalid_args(msg);
dbus_message_iter_get_basic(&iter, &new);
if (!is_valid_pin(new))
return __ofono_error_invalid_format(msg);
@ -591,7 +566,6 @@ static DBusMessage *sim_enter_pin(DBusConnection *conn, DBusMessage *msg,
void *data)
{
struct ofono_sim *sim = data;
DBusMessageIter iter;
const char *typestr;
enum ofono_sim_password_type type;
const char *pin;
@ -602,25 +576,16 @@ static DBusMessage *sim_enter_pin(DBusConnection *conn, DBusMessage *msg,
if (sim->pending)
return __ofono_error_busy(msg);
if (!dbus_message_iter_init(msg, &iter))
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &typestr,
DBUS_TYPE_STRING, &pin,
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __ofono_error_invalid_args(msg);
dbus_message_iter_get_basic(&iter, &typestr);
type = sim_string_to_passwd(typestr);
if (type == OFONO_SIM_PASSWORD_NONE || type != sim->pin_type)
return __ofono_error_invalid_format(msg);
dbus_message_iter_next(&iter);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __ofono_error_invalid_args(msg);
dbus_message_iter_get_basic(&iter, &pin);
if (!is_valid_pin(pin))
return __ofono_error_invalid_format(msg);
@ -634,7 +599,6 @@ static DBusMessage *sim_reset_pin(DBusConnection *conn, DBusMessage *msg,
void *data)
{
struct ofono_sim *sim = data;
DBusMessageIter iter;
const char *typestr;
enum ofono_sim_password_type type;
const char *puk;
@ -646,34 +610,20 @@ static DBusMessage *sim_reset_pin(DBusConnection *conn, DBusMessage *msg,
if (sim->pending)
return __ofono_error_busy(msg);
if (!dbus_message_iter_init(msg, &iter))
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &typestr,
DBUS_TYPE_STRING, &puk,
DBUS_TYPE_STRING, &pin,
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __ofono_error_invalid_args(msg);
dbus_message_iter_get_basic(&iter, &typestr);
type = sim_string_to_passwd(typestr);
if (type == OFONO_SIM_PASSWORD_NONE || type != sim->pin_type)
return __ofono_error_invalid_format(msg);
dbus_message_iter_next(&iter);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __ofono_error_invalid_args(msg);
dbus_message_iter_get_basic(&iter, &puk);
if (!is_valid_pin(puk))
return __ofono_error_invalid_format(msg);
dbus_message_iter_next(&iter);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return __ofono_error_invalid_args(msg);
dbus_message_iter_get_basic(&iter, &pin);
if (!is_valid_pin(pin))
return __ofono_error_invalid_format(msg);