blob: 002d858f9a909875bcdf06dc042992bad8eea96a [file] [log] [blame]
/*
*
* Connection Manager
*
* Copyright (C) 2012 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <dbus/dbus.h>
#include "dbus.h"
void dbus_property_append_basic(DBusMessageIter *iter,
const char *key, int type, void *val)
{
DBusMessageIter value;
const char *signature;
dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &key);
switch (type) {
case DBUS_TYPE_BOOLEAN:
signature = DBUS_TYPE_BOOLEAN_AS_STRING;
break;
case DBUS_TYPE_STRING:
signature = DBUS_TYPE_STRING_AS_STRING;
break;
case DBUS_TYPE_BYTE:
signature = DBUS_TYPE_BYTE_AS_STRING;
break;
case DBUS_TYPE_UINT16:
signature = DBUS_TYPE_UINT16_AS_STRING;
break;
case DBUS_TYPE_INT16:
signature = DBUS_TYPE_INT16_AS_STRING;
break;
case DBUS_TYPE_UINT32:
signature = DBUS_TYPE_UINT32_AS_STRING;
break;
case DBUS_TYPE_INT32:
signature = DBUS_TYPE_INT32_AS_STRING;
break;
case DBUS_TYPE_UINT64:
signature = DBUS_TYPE_UINT64_AS_STRING;
break;
case DBUS_TYPE_INT64:
signature = DBUS_TYPE_INT64_AS_STRING;
break;
case DBUS_TYPE_OBJECT_PATH:
signature = DBUS_TYPE_OBJECT_PATH_AS_STRING;
break;
default:
signature = DBUS_TYPE_VARIANT_AS_STRING;
break;
}
dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
signature, &value);
dbus_message_iter_append_basic(&value, type, val);
dbus_message_iter_close_container(iter, &value);
}