dbus: Share the same function for type to type-as-string conversion

This commit is contained in:
Jouni Malinen 2010-01-02 10:45:03 +02:00
parent c221499782
commit 97d3f8c3a9
3 changed files with 6 additions and 35 deletions

View File

@ -69,7 +69,7 @@ dbus_bool_t wpa_dbus_dict_close_write(DBusMessageIter *iter,
}
static const char * _wpa_get_type_as_string_from_type(const int type)
const char * wpa_dbus_type_as_string(const int type)
{
switch(type) {
case DBUS_TYPE_BYTE:
@ -143,7 +143,7 @@ static dbus_bool_t _wpa_dbus_add_dict_entry_basic(DBusMessageIter *iter_dict,
if (key == NULL)
return FALSE;
type_as_string = _wpa_get_type_as_string_from_type(value_type);
type_as_string = wpa_dbus_type_as_string(value_type);
if (!type_as_string)
return FALSE;

View File

@ -25,6 +25,8 @@ dbus_bool_t wpa_dbus_dict_open_write(DBusMessageIter *iter,
dbus_bool_t wpa_dbus_dict_close_write(DBusMessageIter *iter,
DBusMessageIter *iter_dict);
const char * wpa_dbus_type_as_string(const int type);
dbus_bool_t wpa_dbus_dict_append_string(DBusMessageIter *iter_dict,
const char *key, const char *value);

View File

@ -314,37 +314,6 @@ static DBusMessage * set_network_properties(DBusMessage *message,
}
static const char * _get_dbus_type_as_string(const int type)
{
switch(type) {
case DBUS_TYPE_BYTE:
return DBUS_TYPE_BYTE_AS_STRING;
case DBUS_TYPE_BOOLEAN:
return DBUS_TYPE_BOOLEAN_AS_STRING;
case DBUS_TYPE_INT16:
return DBUS_TYPE_INT16_AS_STRING;
case DBUS_TYPE_UINT16:
return DBUS_TYPE_UINT16_AS_STRING;
case DBUS_TYPE_INT32:
return DBUS_TYPE_INT32_AS_STRING;
case DBUS_TYPE_UINT32:
return DBUS_TYPE_UINT32_AS_STRING;
case DBUS_TYPE_INT64:
return DBUS_TYPE_INT64_AS_STRING;
case DBUS_TYPE_UINT64:
return DBUS_TYPE_UINT64_AS_STRING;
case DBUS_TYPE_DOUBLE:
return DBUS_TYPE_DOUBLE_AS_STRING;
case DBUS_TYPE_STRING:
return DBUS_TYPE_STRING_AS_STRING;
case DBUS_TYPE_OBJECT_PATH:
return DBUS_TYPE_OBJECT_PATH_AS_STRING;
default:
return NULL;
}
}
/**
* wpas_dbus_simple_property_getter - Get basic type property
* @message: Pointer to incoming dbus message
@ -376,7 +345,7 @@ DBusMessage * wpas_dbus_simple_property_getter(DBusMessage *message,
dbus_message_iter_init_append(reply, &iter);
if (!dbus_message_iter_open_container(
&iter, DBUS_TYPE_VARIANT,
_get_dbus_type_as_string(type), &variant_iter) ||
wpa_dbus_type_as_string(type), &variant_iter) ||
!dbus_message_iter_append_basic(&variant_iter, type,
val) ||
!dbus_message_iter_close_container(&iter, &variant_iter)) {
@ -474,7 +443,7 @@ DBusMessage * wpas_dbus_simple_array_property_getter(DBusMessage *message,
return wpas_dbus_error_unknown_error(message, NULL);
}
sub_type_str = _get_dbus_type_as_string(type);
sub_type_str = wpa_dbus_type_as_string(type);
type_str[1] = sub_type_str[0];
if (message == NULL)