예제 #1
0
파일: dbus.c 프로젝트: tradej/pacemaker
bool pcmk_dbus_type_check(DBusMessage *msg, DBusMessageIter *field, int expected, const char *function, int line)
{
    int dtype = 0;
    DBusMessageIter lfield;

    if(field == NULL) {
        if(dbus_message_iter_init(msg, &lfield)) {
            field = &lfield;
        }
    }

    if(field == NULL) {
        do_crm_log_alias(LOG_ERR, __FILE__, function, line,
                         "Empty parameter list in reply expecting '%c'", expected);
        return FALSE;
    }

    dtype = dbus_message_iter_get_arg_type(field);

    if(dtype != expected) {
        DBusMessageIter args;
        char *sig;

        dbus_message_iter_init(msg, &args);
        sig = dbus_message_iter_get_signature(&args);
        do_crm_log_alias(LOG_ERR, __FILE__, function, line,
                         "Unexpected DBus type, expected %c in '%s' instead of %c",
                         expected, sig, dtype);
        dbus_free(sig);
        return FALSE;
    }

    return TRUE;
}
예제 #2
0
static DBusHandlerResult
request_navit_zoom(DBusConnection *connection, DBusMessage *message)
{
	int factor;
	struct point p;
	struct navit *navit;
	DBusMessageIter iter;

	navit = object_get_from_message(message, "navit");
	if (! navit)
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

	dbus_message_iter_init(message, &iter);
	dbg(0,"%s\n", dbus_message_iter_get_signature(&iter));
	
	dbus_message_iter_get_basic(&iter, &factor);
	
	if (dbus_message_iter_has_next(&iter))
	{
		dbus_message_iter_next(&iter);
		if (!point_get_from_message(message, &iter, &p))
			return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
	}

	if (factor > 1)
		navit_zoom_in(navit, factor, &p);
	else if (factor < -1)
		navit_zoom_out(navit, 0-factor, &p);

	return empty_reply(connection, message);

}
예제 #3
0
static DBusHandlerResult
request_navit_resize(DBusConnection *connection, DBusMessage *message)
{
	struct navit *navit;
	int w, h;
	DBusMessageIter iter;

	navit = object_get_from_message(message, "navit");
	if (! navit)
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

	dbus_message_iter_init(message, &iter);
	dbg(0,"%s\n", dbus_message_iter_get_signature(&iter));
	
	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32)
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
	dbus_message_iter_get_basic(&iter, &w);
	
	dbus_message_iter_next(&iter);
	
	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32)
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
	dbus_message_iter_get_basic(&iter, &h);

	dbg(0, " w -> %i  h -> %i\n", w, h);
	
	navit_handle_resize(navit, w, h);

	return empty_reply(connection, message);

}
예제 #4
0
static char *
xdbus_message_iter_get_signature(DBusMessageIter *iter)
{
    DBusMessageIter sub;
    dbus_message_iter_recurse(iter, &sub);
    return dbus_message_iter_get_signature(&sub);
}
예제 #5
0
/**
 * Extracts a struct point from a DBus message
 *
 * @param message The DBus message
 * @param iter Sort of pointer that points on that (ii)-object in the message
 * @param p Pointer where the data should get stored
 * @returns Returns 1 when everything went right, otherwise 0
 */
static int
point_get_from_message(DBusMessage *message, DBusMessageIter *iter, struct point *p)
{
	DBusMessageIter iter2;

	dbg(0,"%s\n", dbus_message_iter_get_signature(iter));
	
	dbus_message_iter_recurse(iter, &iter2);

	if (dbus_message_iter_get_arg_type(&iter2) != DBUS_TYPE_INT32)
		return 0;
	dbus_message_iter_get_basic(&iter2, &p->x);
	
	dbus_message_iter_next(&iter2);
	
	if (dbus_message_iter_get_arg_type(&iter2) != DBUS_TYPE_INT32)
		return 0;
	dbus_message_iter_get_basic(&iter2, &p->y);

	dbg(0, " x -> %x  y -> %x\n", p->x, p->y);
	
	dbus_message_iter_next(&iter2);

	if (dbus_message_iter_get_arg_type(&iter2) != DBUS_TYPE_INVALID)
		return 0;
	
	return 1;
}
예제 #6
0
/**
 * Extracts a struct pcoord from a DBus message
 *
 * @param message The DBus message
 * @param iter Sort of pointer that points on that (iii)-object in the message
 * @param pc Pointer where the data should get stored
 * @returns Returns 1 when everything went right, otherwise 0
 */
static int
pcoord_get_from_message(DBusMessage *message, DBusMessageIter *iter, struct pcoord *pc)
{

    if(!strcmp(dbus_message_iter_get_signature(iter), "s")) {
        char *coordstring;

        dbus_message_iter_get_basic(iter, &coordstring);
        if(!pcoord_parse(coordstring, projection_mg, pc))
            return 0;
        
        return 1;
    } else {
        
        DBusMessageIter iter2;
        dbus_message_iter_recurse(iter, &iter2);
        if(!strcmp(dbus_message_iter_get_signature(iter), "(is)")) {
            char *coordstring;
            int projection;
            
            dbus_message_iter_get_basic(&iter2, &projection);

            dbus_message_iter_next(&iter2);
            dbus_message_iter_get_basic(&iter2, &coordstring);

            if(!pcoord_parse(coordstring, projection, pc))
                return 0;

            return 1;
        } else if(!strcmp(dbus_message_iter_get_signature(iter), "(iii)")) {
            
            dbus_message_iter_get_basic(&iter2, &pc->pro);
            
            dbus_message_iter_next(&iter2);
            dbus_message_iter_get_basic(&iter2, &pc->x);
            
            dbus_message_iter_next(&iter2);
            dbus_message_iter_get_basic(&iter2, &pc->y);

            return 1;
        }
    }
    return 0;
    
}
예제 #7
0
static DBusMessage*
handle_set_preference(void            *object,
                      DBusMessage     *message,
                      DBusError       *error)
{
    DBusMessage *reply;
    HippoSettings *settings;
    DBusMessageIter iter;
    DBusMessageIter variant_iter;
    const char *key;
    char *value_signature;
    char *value;
    DBusConnection *dbus_connection;
    
    dbus_connection = object;    
    
    dbus_message_iter_init(message, &iter);

    key = NULL;
    dbus_message_iter_get_basic(&iter, &key);

    dbus_message_iter_next(&iter);

    dbus_message_iter_recurse(&iter, &variant_iter);

    value_signature = dbus_message_iter_get_signature(&variant_iter);

    if (!signature_is_supported(value_signature)) {
        reply = dbus_message_new_error_printf(message,
                                              DBUS_ERROR_INVALID_ARGS,
                                              _("Unable to handle values of type '%s' right now"),
                                              value_signature);
        g_free(value_signature);
        return reply;
    }
    
    value = string_value_from_variant(&variant_iter, value_signature);

    g_free(value_signature);
    
    settings = get_and_ref_settings(dbus_connection);
    
    hippo_settings_set(settings, key, value);

    g_free(value);
    g_object_unref(settings);
    
    /* Just an empty "ack" reply */
    reply = dbus_message_new_method_return(message);

    return reply;
}
예제 #8
0
pa_proplist *pa_dbus_get_proplist_arg(DBusConnection *c, DBusMessage *msg, DBusMessageIter *iter) {
    DBusMessageIter dict_iter;
    DBusMessageIter dict_entry_iter;
    char *signature;
    pa_proplist *proplist = NULL;
    const char *key = NULL;
    const uint8_t *value = NULL;
    int value_length = 0;

    pa_assert(c);
    pa_assert(msg);
    pa_assert(iter);

    pa_assert(signature = dbus_message_iter_get_signature(iter));
    pa_assert_se(pa_streq(signature, "a{say}"));

    dbus_free(signature);

    proplist = pa_proplist_new();

    dbus_message_iter_recurse(iter, &dict_iter);

    while (dbus_message_iter_get_arg_type(&dict_iter) != DBUS_TYPE_INVALID) {
        dbus_message_iter_recurse(&dict_iter, &dict_entry_iter);

        dbus_message_iter_get_basic(&dict_entry_iter, &key);
        dbus_message_iter_next(&dict_entry_iter);

        if (strlen(key) <= 0 || !pa_ascii_valid(key)) {
            pa_dbus_send_error(c, msg, DBUS_ERROR_INVALID_ARGS, "Invalid property list key: '%s'.", key);
            goto fail;
        }

        dbus_message_iter_get_fixed_array(&dict_entry_iter, &value, &value_length);

        pa_assert(value_length >= 0);

        pa_assert_se(pa_proplist_set(proplist, key, value, value_length) >= 0);

        dbus_message_iter_next(&dict_iter);
    }

    dbus_message_iter_next(iter);

    return proplist;

fail:
    if (proplist)
        pa_proplist_free(proplist);

    return NULL;
}
예제 #9
0
int bridge_request_json_params(bridge_request_t *self, DBusMessageIter *it,
			       struct json_object **result, int is_array)
{
	struct json_object *tmp;
	const char *key;
	char *signature;

	*result = 0;

	/* empty array */
	if (is_array && dbus_message_iter_get_arg_type(it) == DBUS_TYPE_INVALID) {
		// empty array of dict entries => empty json object
		// empty array of other types => empty json array
		signature = dbus_message_iter_get_signature(it);
		if(signature && signature[0] == '{') {
			*result = json_object_new_object();
			dbus_free(signature);
		}
		else
			*result = json_object_new_array();
		return 0;
	}

	do {
		bridge_request_json_params_parse(self, it, &tmp, &key);
		if (!tmp) {
			bridge_request_error(self ,
				"unsupported dbus argument type.");
			FCGX_FPrintF(self->request.err, "type: %c\n", dbus_message_iter_get_arg_type(it));
			return EINVAL;
		}

		if (key != 0) {
			if (!*result)
				*result = json_object_new_object();
			json_object_object_add(*result, key, tmp);
		}
		else if (is_array) {
			if (!*result)
				*result = json_object_new_array();
			json_object_array_add(*result, tmp);
		}
		else {
			*result = tmp;
			break;
		}
	} while (dbus_message_iter_next(it));

	return 0;
}
예제 #10
0
static gboolean
iter_get_variant (DBusMessageIter *iter,
                  DataType data_type,
                  gulong attr_type,
                  GckBuilder *builder)
{
	DBusMessageIter variant;
	IterGetFunc func = NULL;
	gboolean ret;
	const gchar *sig = NULL;
	char *signature;

	g_assert (iter != NULL);
	g_assert (builder != NULL);

	g_return_val_if_fail (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_VARIANT, FALSE);
	dbus_message_iter_recurse (iter, &variant);

	switch (data_type) {
	case DATA_TYPE_STRING:
		func = iter_get_string;
		sig = DBUS_TYPE_STRING_AS_STRING;
		break;
	case DATA_TYPE_BOOL:
		func = iter_get_bool;
		sig = DBUS_TYPE_BOOLEAN_AS_STRING;
		break;
	case DATA_TYPE_TIME:
		func = iter_get_time;
		sig = DBUS_TYPE_UINT64_AS_STRING;
		break;
	case DATA_TYPE_FIELDS:
		func = iter_get_fields;
		sig = "a{ss}";
		break;
	default:
		g_assert (FALSE);
		break;
	}

	signature = dbus_message_iter_get_signature (&variant);
	g_return_val_if_fail (signature, FALSE);
	ret = g_str_equal (sig, signature);
	dbus_free (signature);

	if (ret == FALSE)
		return FALSE;

	return (func) (&variant, attr_type, builder);
}
예제 #11
0
/**
 * atspi_table_cell_get_position:
 * @obj: a GObject instance that implements AtspiTableCellIface
 * @row: (out): the row of the given cell.
 * @column: (out): the column of the given cell.
 *
 * Retrieves the tabular position of this cell.
 *
 * Returns: TRUE if successful, FALSE otherwise.
 */
gint
atspi_table_cell_get_position (AtspiTableCell *obj,
                               gint *row,
                               gint *column,
                               GError *error)
{
  DBusMessage *reply;
  DBusMessageIter iter, iter_struct, iter_variant;
  dbus_int32_t d_row = -1, d_column = -1;
  char *iter_sig;

  g_return_val_if_fail (obj != NULL, -1);

  reply = _atspi_dbus_call_partial (obj, "org.freedesktop.DBus.Properties",
                                    "Get", NULL, "ss",
                                    atspi_interface_table_cell, "Position");
	  
  dbus_message_iter_init (reply, &iter);

  /* TODO: Return error here */
  if (dbus_message_iter_get_arg_type (&iter) != 'v')
    return FALSE;

  dbus_message_iter_recurse (&iter, &iter_variant);
  iter_sig = dbus_message_iter_get_signature (&iter_variant);
  /* TODO: Also report error here */
  if (strcmp (iter_sig, "(ii)") != 0)
  {
    dbus_free (iter_sig);
    return FALSE;
  }
  dbus_free (iter_sig);

  dbus_message_iter_recurse (&iter_variant, &iter_struct);
  dbus_message_iter_get_basic (&iter_struct, &d_row);
  if (row)
    *row = d_row;
  dbus_message_iter_next (&iter_struct);
  dbus_message_iter_get_basic (&iter_struct, &d_column);
  if (column)
    *column = d_column;
  dbus_message_unref (reply);
  return TRUE;
}
예제 #12
0
static void iter_append_iter(DBusMessageIter *base, DBusMessageIter *iter)
{
	int type;

	type = dbus_message_iter_get_arg_type(iter);

	if (dbus_type_is_basic(type)) {
		const void *value;

		dbus_message_iter_get_basic(iter, &value);
		dbus_message_iter_append_basic(base, type, &value);
	} else if (dbus_type_is_container(type)) {
		DBusMessageIter iter_sub, base_sub;
		char *sig;

		dbus_message_iter_recurse(iter, &iter_sub);

		switch (type) {
		case DBUS_TYPE_ARRAY:
		case DBUS_TYPE_VARIANT:
			sig = dbus_message_iter_get_signature(&iter_sub);
			break;
		default:
			sig = NULL;
			break;
		}

		dbus_message_iter_open_container(base, type, sig, &base_sub);

		if (sig != NULL)
			dbus_free(sig);

		while (dbus_message_iter_get_arg_type(&iter_sub) !=
							DBUS_TYPE_INVALID) {
			iter_append_iter(&base_sub, &iter_sub);
			dbus_message_iter_next(&iter_sub);
		}

		dbus_message_iter_close_container(base, &base_sub);
	}
}
예제 #13
0
EAPI char *
eldbus_message_iter_signature_get(Eldbus_Message_Iter *iter)
{
   ELDBUS_MESSAGE_ITERATOR_CHECK_RETVAL(iter, NULL);
   return dbus_message_iter_get_signature(&iter->dbus_iterator);
}
예제 #14
0
void cras_bt_transport_update_properties(
	struct cras_bt_transport *transport,
	DBusMessageIter *properties_array_iter,
	DBusMessageIter *invalidated_array_iter)
{
	while (dbus_message_iter_get_arg_type(properties_array_iter) !=
	       DBUS_TYPE_INVALID) {
		DBusMessageIter properties_dict_iter, variant_iter;
		const char *key;
		int type;

		dbus_message_iter_recurse(properties_array_iter,
					  &properties_dict_iter);

		dbus_message_iter_get_basic(&properties_dict_iter, &key);
		dbus_message_iter_next(&properties_dict_iter);

		dbus_message_iter_recurse(&properties_dict_iter, &variant_iter);
		type = dbus_message_iter_get_arg_type(&variant_iter);

		if (type == DBUS_TYPE_STRING) {
			const char *value;

			dbus_message_iter_get_basic(&variant_iter, &value);

			if (strcmp(key, "UUID") == 0) {
				transport->profile =
					cras_bt_device_profile_from_uuid(value);

			} else if (strcmp(key, "State") == 0) {
				enum cras_bt_transport_state old_state =
					transport->state;
				transport->state =
					cras_bt_transport_state_from_string(
						value);
				if (transport->state != old_state)
					cras_bt_transport_state_changed(
						transport);
			}

		} else if (type == DBUS_TYPE_BYTE) {
			int value;

			dbus_message_iter_get_basic(&variant_iter, &value);

			if (strcmp(key, "Codec") == 0)
				transport->codec = value;
		} else if (type == DBUS_TYPE_OBJECT_PATH) {
			const char *obj_path;

			/* Property: object Device [readonly] */
			dbus_message_iter_get_basic(&variant_iter, &obj_path);
			transport->device = cras_bt_device_get(obj_path);
			if (!transport->device) {
				syslog(LOG_ERR, "Device %s not found at update"
				       "transport properties",
				       obj_path);
				transport->device =
					cras_bt_device_create(transport->conn,
							      obj_path);
				cras_bt_transport_update_device(transport);
			}
		} else if (strcmp(
				dbus_message_iter_get_signature(&variant_iter),
				"ay") == 0 &&
			   strcmp(key, "Configuration") == 0) {
			DBusMessageIter value_iter;
			char *value;
			int len;

			dbus_message_iter_recurse(&variant_iter, &value_iter);
			dbus_message_iter_get_fixed_array(&value_iter,
							  &value, &len);

			free(transport->configuration);
			transport->configuration_len = 0;

			transport->configuration = malloc(len);
			if (transport->configuration) {
				memcpy(transport->configuration, value, len);
				transport->configuration_len = len;
			}

		} else if (strcmp(key, "Volume") == 0) {
			uint16_t volume;

			dbus_message_iter_get_basic(&variant_iter, &volume);
			transport->volume = volume;
			cras_bt_transport_update_device(transport);
		}

		dbus_message_iter_next(properties_array_iter);
	}

	while (invalidated_array_iter &&
	       dbus_message_iter_get_arg_type(invalidated_array_iter) !=
	       DBUS_TYPE_INVALID) {
		const char *key;

		dbus_message_iter_get_basic(invalidated_array_iter, &key);

		if (strcmp(key, "Device") == 0) {
			transport->device = NULL;
		} else if (strcmp(key, "UUID") == 0) {
			transport->profile = 0;
		} else if (strcmp(key, "State") == 0) {
			transport->state = CRAS_BT_TRANSPORT_STATE_IDLE;
		} else if (strcmp(key, "Codec") == 0) {
			transport->codec = 0;
		} else if (strcmp(key, "Configuration") == 0) {
			free(transport->configuration);
			transport->configuration = NULL;
			transport->configuration_len = 0;
		}

		dbus_message_iter_next(invalidated_array_iter);
	}
}
예제 #15
0
파일: DBusUtil.cpp 프로젝트: 0xheart0/xbmc
CVariant CDBusUtil::GetAll(const char *destination, const char *object, const char *interface)
{
  CDBusMessage message(destination, object, "org.freedesktop.DBus.Properties", "GetAll");
  CVariant properties;
  message.AppendArgument(interface);
  DBusMessage *reply = message.SendSystem();
  if (reply)
  {
    DBusMessageIter iter;
    if (dbus_message_iter_init(reply, &iter))
    {
      if (!dbus_message_has_signature(reply, "a{sv}"))
        CLog::Log(LOGERROR, "DBus: wrong signature on GetAll - should be \"a{sv}\" but was %s", dbus_message_iter_get_signature(&iter));
      else
      {
        do
        {
          DBusMessageIter sub;
          dbus_message_iter_recurse(&iter, &sub);
          do
          {
            DBusMessageIter dict;
            dbus_message_iter_recurse(&sub, &dict);
            do
            {
              const char * key = NULL;

              dbus_message_iter_get_basic(&dict, &key);
              if (!dbus_message_iter_next(&dict))
                break;

              CVariant value = ParseVariant(&dict);

              if (!value.isNull())
                properties[key] = value;

            } while (dbus_message_iter_next(&dict));

          } while (dbus_message_iter_next(&sub));

        } while (dbus_message_iter_next(&iter));
      }
    }
  }

  return properties;
}
예제 #16
0
파일: DBusUtil.cpp 프로젝트: 0xheart0/xbmc
CVariant CDBusUtil::GetVariant(const char *destination, const char *object, const char *interface, const char *property)
{
//dbus-send --system --print-reply --dest=destination object org.freedesktop.DBus.Properties.Get string:interface string:property
  CDBusMessage message(destination, object, "org.freedesktop.DBus.Properties", "Get");
  CVariant result;

  if (message.AppendArgument(interface) && message.AppendArgument(property))
  {
    DBusMessage *reply = message.SendSystem();

    if (reply)
    {
      DBusMessageIter iter;

      if (dbus_message_iter_init(reply, &iter))
      {
        if (!dbus_message_has_signature(reply, "v"))
          CLog::Log(LOGERROR, "DBus: wrong signature on Get - should be \"v\" but was %s", dbus_message_iter_get_signature(&iter));
        else
          result = ParseVariant(&iter);
      }
    }
  }
  else
    CLog::Log(LOGERROR, "DBus: append arguments failed");

  return result;
}
예제 #17
0
파일: dbus.c 프로젝트: tradej/pacemaker
bool
pcmk_dbus_find_error(const char *method, DBusPendingCall* pending, DBusMessage *reply, DBusError *ret)
{
    DBusError error;

    dbus_error_init(&error);

    if(pending == NULL) {
        error.name = "org.clusterlabs.pacemaker.NoRequest";
        error.message = "No request sent";

    } else if(reply == NULL) {
        error.name = "org.clusterlabs.pacemaker.NoReply";
        error.message = "No reply";

    } else {
        DBusMessageIter args;
        int dtype = dbus_message_get_type(reply);
        char *sig;

        switch(dtype) {
            case DBUS_MESSAGE_TYPE_METHOD_RETURN:
                dbus_message_iter_init(reply, &args);
                sig = dbus_message_iter_get_signature(&args);
                crm_trace("Call to %s returned '%s'", method, sig);
                dbus_free(sig);
                break;
            case DBUS_MESSAGE_TYPE_INVALID:
                error.message = "Invalid reply";
                error.name = "org.clusterlabs.pacemaker.InvalidReply";
                crm_err("Error processing %s response: %s", method, error.message);
                break;
            case DBUS_MESSAGE_TYPE_METHOD_CALL:
                error.message = "Invalid reply (method call)";
                error.name = "org.clusterlabs.pacemaker.InvalidReply.Method";
                crm_err("Error processing %s response: %s", method, error.message);
                break;
            case DBUS_MESSAGE_TYPE_SIGNAL:
                error.message = "Invalid reply (signal)";
                error.name = "org.clusterlabs.pacemaker.InvalidReply.Signal";
                crm_err("Error processing %s response: %s", method, error.message);
                break;

            case DBUS_MESSAGE_TYPE_ERROR:
                dbus_set_error_from_message (&error, reply);
                crm_info("%s error '%s': %s", method, error.name, error.message);
                break;
            default:
                error.message = "Unknown reply type";
                error.name = "org.clusterlabs.pacemaker.InvalidReply.Type";
                crm_err("Error processing %s response: %s (%d)", method, error.message, dtype);
        }
    }

    if(ret && (error.name || error.message)) {
        *ret = error;
        return TRUE;
    }

    return FALSE;
}
예제 #18
0
static QDBusData qFetchParameter(DBusMessageIter *it)
{
    switch (dbus_message_iter_get_arg_type(it)) {
    case DBUS_TYPE_BOOLEAN:
        return QDBusData::fromBool(qIterGet<dbus_bool_t>(it));
    case DBUS_TYPE_BYTE:
        return QDBusData::fromByte(qIterGet<unsigned char>(it));
    case DBUS_TYPE_INT16:
       return QDBusData::fromInt16(qIterGet<dbus_int16_t>(it));
    case DBUS_TYPE_UINT16:
        return QDBusData::fromUInt16(qIterGet<dbus_uint16_t>(it));
    case DBUS_TYPE_INT32:
        return QDBusData::fromInt32(qIterGet<dbus_int32_t>(it));
    case DBUS_TYPE_UINT32:
        return QDBusData::fromUInt32(qIterGet<dbus_uint32_t>(it));
    case DBUS_TYPE_INT64:
        return QDBusData::fromInt64(qIterGet<dbus_int64_t>(it));
    case DBUS_TYPE_UINT64:
        return QDBusData::fromUInt64(qIterGet<dbus_uint64_t>(it));
    case DBUS_TYPE_DOUBLE:
        return QDBusData::fromDouble(qIterGet<double>(it));
    case DBUS_TYPE_STRING:
    case DBUS_TYPE_SIGNATURE:
        return QDBusData::fromString(QString::fromUtf8(qIterGet<char *>(it)));
    case DBUS_TYPE_OBJECT_PATH:
        return QDBusData::fromObjectPath(QDBusObjectPath(qIterGet<char *>(it)));
    case DBUS_TYPE_ARRAY: {
        int arrayType = dbus_message_iter_get_element_type(it);

        char* sig = dbus_message_iter_get_signature(it);
        QCString signature = sig;
        dbus_free(sig);

        QValueList<QDBusData> prototypeList = parseSignature(signature);

        if (arrayType == DBUS_TYPE_DICT_ENTRY) {
            DBusMessageIter sub;
            dbus_message_iter_recurse(it, &sub);

            return qFetchMap(&sub, prototypeList[0]);

//        } else if (arrayType == DBUS_TYPE_BYTE) {
//            DBusMessageIter sub;
//            dbus_message_iter_recurse(it, &sub);
//            int len = dbus_message_iter_get_array_len(&sub);
//            char* data;
//            dbus_message_iter_get_fixed_array(&sub,&data,&len);
//            return QCString(data,len);
//         } else {

        } else {
            QDBusDataList list = prototypeList[0].toList();

            DBusMessageIter arrayIt;
            dbus_message_iter_recurse(it, &arrayIt);

            while (dbus_message_iter_get_arg_type(&arrayIt) != DBUS_TYPE_INVALID) {
                list << qFetchParameter(&arrayIt);

                dbus_message_iter_next(&arrayIt);
            }

            return QDBusData::fromList(list);
        }
    }
    case DBUS_TYPE_VARIANT: {
        QDBusVariant dvariant;
        DBusMessageIter sub;
        dbus_message_iter_recurse(it, &sub);

        char* signature = dbus_message_iter_get_signature(&sub);
        dvariant.signature = QString::fromUtf8(signature);
        dbus_free(signature);

        dvariant.value = qFetchParameter(&sub);

        return QDBusData::fromVariant(dvariant);
    }
    case DBUS_TYPE_STRUCT: {
        QValueList<QDBusData> memberList;

        DBusMessageIter subIt;
        dbus_message_iter_recurse(it, &subIt);

        uint index = 0;
        while (dbus_message_iter_get_arg_type(&subIt) != DBUS_TYPE_INVALID) {
            memberList << qFetchParameter(&subIt);

            dbus_message_iter_next(&subIt);
            ++index;
        }

        return QDBusData::fromStruct(memberList);
    }
#if 0
    case DBUS_TYPE_INVALID:
        // TODO: check if there is better way to detect empty arrays
        return QDBusData();
        break;
#endif
    default:
        qWarning("QDBusMarshall: Don't know how to de-marshall type %d '%c'",
                 dbus_message_iter_get_arg_type(it),
                 dbus_message_iter_get_arg_type(it));
        return QDBusData();
        break;
    }
}
예제 #19
0
static DBusMessage *properties_set(DBusConnection *connection,
					DBusMessage *message, void *user_data)
{
	struct generic_data *data = user_data;
	DBusMessageIter iter, sub;
	struct interface_data *iface;
	const GDBusPropertyTable *property;
	const char *name, *interface;
	struct property_data *propdata;
	gboolean valid_signature;
	char *signature;

	if (!dbus_message_iter_init(message, &iter))
		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
							"No arguments given");

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
					"Invalid argument type: '%c'",
					dbus_message_iter_get_arg_type(&iter));

	dbus_message_iter_get_basic(&iter, &interface);
	dbus_message_iter_next(&iter);

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
					"Invalid argument type: '%c'",
					dbus_message_iter_get_arg_type(&iter));

	dbus_message_iter_get_basic(&iter, &name);
	dbus_message_iter_next(&iter);

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
					"Invalid argument type: '%c'",
					dbus_message_iter_get_arg_type(&iter));

	dbus_message_iter_recurse(&iter, &sub);

	iface = find_interface(data->interfaces, interface);
	if (iface == NULL)
		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
					"No such interface '%s'", interface);

	property = find_property(iface->properties, name);
	if (property == NULL)
		return g_dbus_create_error(message,
						DBUS_ERROR_UNKNOWN_PROPERTY,
						"No such property '%s'", name);

	if (property->set == NULL)
		return g_dbus_create_error(message,
					DBUS_ERROR_PROPERTY_READ_ONLY,
					"Property '%s' is not writable", name);

	if (property->exists != NULL &&
			!property->exists(property, iface->user_data))
		return g_dbus_create_error(message,
						DBUS_ERROR_UNKNOWN_PROPERTY,
						"No such property '%s'", name);

	signature = dbus_message_iter_get_signature(&sub);
	valid_signature = strcmp(signature, property->type) ? FALSE : TRUE;
	dbus_free(signature);
	if (!valid_signature)
		return g_dbus_create_error(message,
					DBUS_ERROR_INVALID_SIGNATURE,
					"Invalid signature for '%s'", name);

	propdata = g_new(struct property_data, 1);
	propdata->id = next_pending_property++;
	propdata->message = dbus_message_ref(message);
	propdata->conn = connection;
	pending_property_set = g_slist_prepend(pending_property_set, propdata);

	property->set(property, &sub, propdata->id, iface->user_data);

	return NULL;
}
예제 #20
0
static DBusHandlerResult
request_navit_set_attr(DBusConnection *connection, DBusMessage *message)
{
    struct navit *navit;
	DBusMessageIter iter, iterattr;
    struct attr attr;
    char *attr_type;

	navit = object_get_from_message(message, "navit");
	if (! navit)
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    dbus_message_iter_init(message, &iter);
    dbus_message_iter_get_basic(&iter, &attr_type);
    attr.type = attr_from_name(attr_type); 
    dbg(0, "attr value: 0x%x string: %s\n", attr.type, attr_type);
    
    if (attr.type == attr_none)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
    
    dbus_message_iter_next(&iter);
    dbus_message_iter_recurse(&iter, &iterattr);
    dbg(0, "seems valid. signature: %s\n", dbus_message_iter_get_signature(&iterattr));
    
    if (attr.type > attr_type_item_begin && attr.type < attr_type_item_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if (attr.type > attr_type_int_begin && attr.type < attr_type_boolean_begin) {
        if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_INT32)
        {
            dbus_message_iter_get_basic(&iterattr, &attr.u.num);
            if (navit_set_attr(navit, &attr))
                return empty_reply(connection, message);
        }
    }
    else if(attr.type > attr_type_boolean_begin && attr.type < attr_type_int_end) {
        if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_BOOLEAN)
        {
            dbus_message_iter_get_basic(&iterattr, &attr.u.num);
            if (navit_set_attr(navit, &attr))
                return empty_reply(connection, message);
        }
    }
#if 0
    else if(attr.type > attr_type_string_begin && attr.type < attr_type_string_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_special_begin && attr.type < attr_type_special_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_double_begin && attr.type < attr_type_double_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_coord_geo_begin && attr.type < attr_type_coord_geo_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_color_begin && attr.type < attr_type_color_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_object_begin && attr.type < attr_type_object_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_coord_begin && attr.type < attr_type_coord_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_pcoord_begin && attr.type < attr_type_pcoord_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

    else if(attr.type > attr_type_callback_begin && attr.type < attr_type_callback_end)
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
#endif
    else {
        dbg(0, "zomg really unhandled111\n");
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
    }
    
    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
예제 #21
0
  EINA_LIST_FOREACH(strings, l, str)
    dbus_message_iter_append_basic(&arr, DBUS_TYPE_STRING, &str);

  dbus_message_iter_close_container(iter, &arr);
}

Eina_List *
e_notify_unmarshal_string_array_as_list(DBusMessageIter *iter, DBusError *err __UNUSED__)
{
  Eina_List *strings;
  char *sig;
  int ret;
  DBusMessageIter arr;

  sig = dbus_message_iter_get_signature(iter);
  ret = !strcmp(sig, "as");
  dbus_free(sig);
  if (!ret) return NULL;

  strings = NULL;

  dbus_message_iter_recurse(iter, &arr);
  while(dbus_message_iter_has_next(&arr))
  {
    const char *str;
    dbus_message_iter_get_basic(&arr, &str);
    strings = eina_list_append(strings, strdup(str)); //XXX use eina_stringshare_instance?
    dbus_message_iter_next(&arr);
  }
  return strings;
예제 #22
0
파일: ibusmessage.c 프로젝트: definite/ibus
gboolean
ibus_message_iter_copy_data (IBusMessageIter *dst,
                             IBusMessageIter *src)
{
    GType type;
    gboolean retval;

    type = ibus_message_iter_get_arg_type (src);

    g_return_val_if_fail (type != G_TYPE_INVALID, FALSE);

    if (gtype_is_basic (type)) {
        gchar data[16];
        ibus_message_iter_get_basic (src, data);
        retval = ibus_message_iter_append (dst, type, data);
        g_return_val_if_fail (retval, FALSE);
        return TRUE;
    }

    if (type == IBUS_TYPE_VARIANT) {
        IBusMessageIter subdst, subsrc;
        gchar *signature;

        retval = ibus_message_iter_recurse (src, IBUS_TYPE_VARIANT, &subsrc);
        g_return_val_if_fail (retval, FALSE);

        signature = dbus_message_iter_get_signature (&subsrc);
        g_return_val_if_fail (signature != NULL, FALSE);
        retval = ibus_message_iter_open_container (dst,
                                                   IBUS_TYPE_VARIANT,
                                                   signature,
                                                   &subdst);
        dbus_free (signature);
        g_return_val_if_fail (retval, FALSE);

        retval = ibus_message_iter_copy_data (&subdst, &subsrc);
        g_return_val_if_fail (retval, FALSE);

        retval = ibus_message_iter_close_container (dst, &subdst);
        g_return_val_if_fail (retval, FALSE);

        return TRUE;
    }
    else if (type == IBUS_TYPE_ARRAY) {
        IBusMessageIter subdst, subsrc;
        gchar *signature;

        retval = ibus_message_iter_recurse (src, IBUS_TYPE_ARRAY, &subsrc);
        g_return_val_if_fail (retval, FALSE);

        signature = dbus_message_iter_get_signature (src);
        g_return_val_if_fail (signature != NULL, FALSE);

        retval = ibus_message_iter_open_container (dst,
                                                   IBUS_TYPE_ARRAY,
                                                   signature + 1,
                                                   &subdst);
        dbus_free (signature);
        g_return_val_if_fail (retval, FALSE);

        while (ibus_message_iter_get_arg_type (&subsrc) != G_TYPE_INVALID) {
            retval = ibus_message_iter_copy_data (&subdst, &subsrc);
            g_return_val_if_fail (retval, FALSE);
            ibus_message_iter_next (&subsrc);
        }

        retval = ibus_message_iter_close_container (dst, &subdst);
        g_return_val_if_fail (retval, FALSE);

        return TRUE;
    }
    else if (type == IBUS_TYPE_STRUCT) {
        IBusMessageIter subdst, subsrc;

        retval = ibus_message_iter_recurse (src, IBUS_TYPE_STRUCT, &subsrc);
        g_return_val_if_fail (retval, FALSE);

        retval = ibus_message_iter_open_container (dst,
                                                   IBUS_TYPE_STRUCT,
                                                   NULL,
                                                   &subdst);
        g_return_val_if_fail (retval, FALSE);

        while (ibus_message_iter_get_arg_type (&subsrc) != G_TYPE_INVALID) {
            retval = ibus_message_iter_copy_data (&subdst, &subsrc);
            ibus_message_iter_next (&subsrc);
            g_return_val_if_fail (retval, FALSE);
        }

        retval = ibus_message_iter_close_container (dst, &subdst);
        g_return_val_if_fail (retval, FALSE);

        return TRUE;
    }
    else if (type == IBUS_TYPE_DICT_ENTRY) {
        IBusMessageIter subdst, subsrc;

        retval = ibus_message_iter_recurse (src, IBUS_TYPE_DICT_ENTRY, &subsrc);
        g_return_val_if_fail (retval, FALSE);

        retval = ibus_message_iter_open_container (dst,
                                                   IBUS_TYPE_DICT_ENTRY,
                                                   NULL,
                                                   &subdst);
        g_return_val_if_fail (retval, FALSE);

        /* copy key */
        retval = ibus_message_iter_copy_data (&subdst, &subsrc);
        g_return_val_if_fail (retval, FALSE);
        ibus_message_iter_next (&subsrc);

        /* copy value */
        retval = ibus_message_iter_copy_data (&subdst, &subsrc);
        g_return_val_if_fail (retval, FALSE);
        ibus_message_iter_next (&subsrc);

        retval = ibus_message_iter_close_container (dst, &subdst);
        g_return_val_if_fail (retval, FALSE);

        return TRUE;
    }

    return FALSE;

}
예제 #23
0
static GVariant *
dconf_dbus_to_gv (DBusMessageIter  *iter,
                  GError          **error)
{
  gint arg_type;

  arg_type = dbus_message_iter_get_arg_type (iter);

  switch (dbus_message_iter_get_arg_type (iter))
    {
     case DBUS_TYPE_BOOLEAN:
      {
        dbus_bool_t value;
        dbus_message_iter_get_basic (iter, &value);
        return g_variant_new_boolean (value);
      }

     case DBUS_TYPE_BYTE:
      {
        guchar value;
        dbus_message_iter_get_basic (iter, &value);
        return g_variant_new_byte (value);
      }

     case DBUS_TYPE_INT16:
      {
        gint16 value;
        dbus_message_iter_get_basic (iter, &value);
        return g_variant_new_int16 (value);
      }

     case DBUS_TYPE_UINT16:
      {
        guint16 value;
        dbus_message_iter_get_basic (iter, &value);
        return g_variant_new_uint16 (value);
      }

     case DBUS_TYPE_INT32:
      {
        gint32 value;
        dbus_message_iter_get_basic (iter, &value);
        return g_variant_new_int32 (value);
      }

     case DBUS_TYPE_UINT32:
      {
        guint32 value;
        dbus_message_iter_get_basic (iter, &value);
        return g_variant_new_uint32 (value);
      }

     case DBUS_TYPE_INT64:
      {
        gint64 value;
        dbus_message_iter_get_basic (iter, &value);
        return g_variant_new_int64 (value);
      }

     case DBUS_TYPE_UINT64:
      {
        guint64 value;
        dbus_message_iter_get_basic (iter, &value);
        return g_variant_new_uint64 (value);
      }

     case DBUS_TYPE_DOUBLE:
      {
        gdouble value;
        dbus_message_iter_get_basic (iter, &value);
        return g_variant_new_double (value);
      }

     case DBUS_TYPE_STRING:
      {
       const gchar *value;
       dbus_message_iter_get_basic (iter, &value);
       return g_variant_new_string (value);
      }

     case DBUS_TYPE_OBJECT_PATH:
      {
       const gchar *value;
       dbus_message_iter_get_basic (iter, &value);
       return g_variant_new_object_path (value);
      }

     case DBUS_TYPE_SIGNATURE:
      {
       const gchar *value;
       dbus_message_iter_get_basic (iter, &value);
       return g_variant_new_signature (value);
      }

     case DBUS_TYPE_VARIANT:
       {
        GVariantBuilder *builder;
        GVariantClass class;
        DBusMessageIter sub;
        char *type;
        GVariant *val;

        dbus_message_iter_recurse (iter, &sub);
        class = dbus_message_iter_get_arg_type (iter);
        type = dbus_message_iter_get_signature (&sub);
        builder = g_variant_builder_new (G_VARIANT_TYPE_VARIANT);
        dbus_free (type);

        while (dbus_message_iter_get_arg_type (&sub))
          {
            val = dconf_dbus_to_gv (&sub, error);
            if (val == NULL)
              {
                g_variant_builder_cancel (builder);
                goto fail;
              }
            g_variant_builder_add_value (builder, val);
            dbus_message_iter_next (&sub);
          }

        return g_variant_builder_end (builder);
       }

     case DBUS_TYPE_ARRAY:
     case DBUS_TYPE_STRUCT:
     case DBUS_TYPE_DICT_ENTRY:
      {
        GVariantBuilder *builder;
        GVariantClass class;
        DBusMessageIter sub;
        char *type;
        GVariant *val;

        dbus_message_iter_recurse (iter, &sub);
        class = dbus_message_iter_get_arg_type (iter);
        type = dbus_message_iter_get_signature (iter);
        builder = g_variant_builder_new (G_VARIANT_TYPE (type));
        dbus_free (type);

        while (dbus_message_iter_get_arg_type (&sub))
          {
            val = dconf_dbus_to_gv (&sub, error);
            if (val == NULL)
              {
                g_variant_builder_cancel (builder);
                goto fail;
              }
            g_variant_builder_add_value (builder, val);
            dbus_message_iter_next (&sub);
          }

        return g_variant_builder_end (builder);
      }

     default:
       g_set_error (error,
                    G_DBUS_ERROR,
                    G_DBUS_ERROR_CONVERSION_FAILED,
                    _("Error serializing D-Bus message to GVariant. Unsupported arg type `%c' (%d)"),
                    arg_type,
                    arg_type);
      goto fail;
    }

  g_assert_not_reached ();

 fail:
  return NULL;
}
예제 #24
0
char* resolve_service(int interface, int protocol, char *name, char *type, char *domain)
{
    DBusMessage* msg;
    DBusMessageIter args;
    DBusConnection* conn;
    DBusError err;
    dbus_error_init(&err);
    DBusPendingCall* pending;
    //dbus_int32_t interface = 2;
    //dbus_int32_t protocol = 1;
    //char *name = "TestService";
    //char *type = "_http._tcp";
    //char *domain = "local";
    dbus_int32_t aprotocol = -1;
    dbus_uint32_t flags = 0;
    printf ("parameter for ResolvesService:%d, %d, %s, %s, %s, %d, %d.\n", interface, protocol, name, type, domain, aprotocol, flags);

   // initialiset the errors
    printf("Calling remote method: %s\n", "org.freedesktop.Avahi");

   // connect to the system bus and check for errors
    conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
    if (dbus_error_is_set(&err)) { 
      fprintf(stderr, "Connection Error (%s)\n", err.message); 
      dbus_error_free(&err);
    }
    if (NULL == conn) { 
      exit(1);
    }

    msg = dbus_message_new_method_call("org.freedesktop.Avahi",// target for the method call
                                        "/", 							// object to call on
                                        "org.freedesktop.Avahi.Server",    // interface to call on
                                        "ResolveService");             // method nameResolveHostName
    if (NULL == msg) 
     { 
      fprintf(stderr, "Message Null\n"); 
      exit(1); 
    }
   // append arguments
    dbus_message_iter_init_append(msg, &args);
    if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &interface))
    {
        fprintf(stderr, "Out Of Memory!\n"); 
        exit(1);
    }
    if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &protocol))
    {
        fprintf(stderr, "Out Of Memory!\n"); 
        exit(1);
    }
    if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &name))
    {
        fprintf(stderr, "Out Of Memory!\n"); 
        exit(1);
    }
    if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &type))
    {
        fprintf(stderr, "Out Of Memory!\n"); 
        exit(1);
    }
    if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &domain))
    {
        fprintf(stderr, "Out Of Memory!\n"); 
        exit(1);
    }
    if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &aprotocol))
    {
        fprintf(stderr, "Out Of Memory!\n"); 
        exit(1);
    }
    if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT32, &flags))
    {
        fprintf(stderr, "Out Of Memory!\n"); 
        exit(1);
    }
      
   // send message and get a handle for a reply
    if (!dbus_connection_send_with_reply (conn, msg, &pending, -1)) { // -1 is default timeout
        fprintf(stderr, "Out Of Memory!\n"); 
        exit(1);
    }
    if (NULL == pending) { 
        fprintf(stderr, "Pending Call Null\n"); 
        exit(1); 
    }
    dbus_connection_flush(conn);
   
    printf("Request Sent\n");

    // free message
    dbus_message_unref(msg);
   
    // block until we recieve a reply
    dbus_pending_call_block(pending);

    // get the reply message
    msg = dbus_pending_call_steal_reply(pending);
    if (NULL == msg) {
        fprintf(stderr, "Reply Null\n"); 
        exit(1); 
    }
    // free the pending message handle
    dbus_pending_call_unref(pending);


    char *address;
    char *host;
    dbus_uint16_t port;//gint16
    GPtrArray *byte_arraies;
    dbus_uint32_t m_flags;
    if (!dbus_message_iter_init(msg, &args))
        g_message("dbus_message_iter_init fail\n");
    else
    { 
//g_message("signature of container args: %s", dbus_message_iter_get_signature(&args));
//g_message("first type: %d", dbus_message_iter_get_arg_type(&args));
//g_message("DBUS_TYPE_INT32: %d", DBUS_TYPE_INT32);
//g_message("DBUS_TYPE_STRING: %d", DBUS_TYPE_STRING);
//char *value;
//dbus_message_iter_get_basic(&args, &value);
//g_message("DBUS_TYPE_STRING: %s", value);

        if (DBUS_TYPE_INT32 != dbus_message_iter_get_arg_type(&args)) 
            g_message( "Argument is not error!\n"); 
        else{
            dbus_message_iter_get_basic(&args, &interface);
            printf("interface : %d\n", interface); 
        }

        if (!dbus_message_iter_next(&args))
            g_message( "Message has too few arguments!\n"); 
        else if (DBUS_TYPE_INT32 != dbus_message_iter_get_arg_type(&args)) 
            g_message("Argument is not error!\n"); 
        else{
            dbus_message_iter_get_basic(&args, &protocol);
            printf("protocol : %d\n", protocol); 
        }

        if (!dbus_message_iter_next(&args))
            g_message("Message has too few arguments!\n"); 
        else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args)) 
            g_message("Argument is not error!\n"); 
        else{
           dbus_message_iter_get_basic(&args, &name);
            printf("name : %s\n", name); 
        }

        if (!dbus_message_iter_next(&args))
            g_message("Message has too few arguments!\n"); 
        else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args)) 
            g_message("Argument is not error!\n"); 
        else{
           dbus_message_iter_get_basic(&args, &type);
            printf("type : %s\n", type); 
        }

        if (!dbus_message_iter_next(&args))
            g_message("Message has too few arguments!\n"); 
        else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args)) 
            g_message("Argument is not error!\n"); 
        else{
            dbus_message_iter_get_basic(&args, &domain);
            printf("domain : %s\n", domain); 
        }

        if (!dbus_message_iter_next(&args))
            g_message("Message has too few arguments!\n"); 
        else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args)) 
            g_message("Argument is not error!\n"); 
        else{
            dbus_message_iter_get_basic(&args, &host);
            printf("host : %s\n", host); 
        }

        if (!dbus_message_iter_next(&args))
            g_message( "Message has too few arguments!\n"); 
        else if (DBUS_TYPE_INT32 != dbus_message_iter_get_arg_type(&args)) 
            g_message("Argument is not error!\n"); 
        else{
            dbus_message_iter_get_basic(&args, &aprotocol);
            printf("aprotocol : %d\n", aprotocol); 
        }

        if (!dbus_message_iter_next(&args))
            g_message("Message has too few arguments!\n"); 
        else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args)) 
            g_message("Argument is not error!\n"); 
        else{
           dbus_message_iter_get_basic(&args, &address);
            printf("address : %s\n", address); 
        }

        if (!dbus_message_iter_next(&args))
            g_message( "Message has too few arguments!\n"); 
        else if (DBUS_TYPE_UINT16 != dbus_message_iter_get_arg_type(&args)) 
            g_message("Argument is not error!\n"); 
        else{
            dbus_message_iter_get_basic(&args, &port);
            printf("port : %d\n", port); 
        }

        if (!dbus_message_iter_next(&args))
            g_message("Message has too few arguments!\n"); 
        else if (strcmp("aay", dbus_message_iter_get_signature(&args))) 
            g_message("Argument is not error!\n"); 
        else{
            DBusMessageIter container_ay, container_y;
            unsigned char *values;int size;
            //dbus_message_iter_get_basic(&args, &flags);
            //dbus_message_iter_open_container(&args, DBUS_TYPE_ARRAY, "ay", &container_ay);
            //dbus_message_iter_open_container(&container_ay, DBUS_TYPE_BYTE, "y", &container_y);

            dbus_message_iter_recurse(&args, &container_ay);

            dbus_message_iter_recurse(&container_ay, &container_y);
            dbus_message_iter_get_fixed_array(&container_y, &values, &size);
            g_message("size: %d, %s", size, values);
/*
g_message("container args: %s", dbus_message_iter_get_signature(&args));
g_message("container_ay: %s", dbus_message_iter_get_signature(&container_ay));
g_message("container_y: %s", dbus_message_iter_get_signature(&container_y));
g_message("type of container_y: %d", dbus_message_iter_get_arg_type(&container_y));
g_message("value of DBUS_TYPE_BYTE: %d", DBUS_TYPE_BYTE);
*/
// && strcmp("ay", dbus_message_iter_get_signature(&container_ay))
            while(dbus_message_iter_next(&container_ay)){
                dbus_message_iter_recurse(&container_ay, &container_y);
                dbus_message_iter_get_fixed_array(&container_y, &values, &size);
                g_message("size: %d, %s", size, values);
            }
        }
        if (!dbus_message_iter_next(&args))
            g_message( "Message has too few arguments!\n"); 
        else if (DBUS_TYPE_UINT32 != dbus_message_iter_get_arg_type(&args)) 
            g_message("Argument is not error!\n"); 
        else{
            dbus_message_iter_get_basic(&args, &m_flags);
            printf("m_flags : %d\n", m_flags); 
        }

/*
dbus_message_iter_next(&args);
g_message("g_message_iter_get_signature: %s", dbus_message_iter_get_signature(&args));
*/
/*
        if (!dbus_message_iter_next(&args))
            g_message("Message has too few arguments!\n"); 
        else if (DBUS_TYPE_UINT32 != dbus_message_iter_get_arg_type(&args)) 
            g_message("Argument is not error!\n"); 
        else
            dbus_message_iter_get_basic(&args, &flags);
*/
  //      printf("discovered:%d, %d, %s, %s, %s, %d.\n", interface, protocol, name, type, domain, flags);
    }
    dbus_message_unref(msg);  
}