Author: lslezak Date: Tue Jul 15 15:08:03 2008 New Revision: 49098 URL: http://svn.opensuse.org/viewcvs/yast?rev=49098&view=rev Log: - pass YCPTerm as list [name [arguments] Modified: branches/tmp/lslezak/workshop/core/scr/src/DBusMsg.cc Modified: branches/tmp/lslezak/workshop/core/scr/src/DBusMsg.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/core/scr/src/DBusMsg.cc?rev=49098&r1=49097&r2=49098&view=diff ============================================================================== --- branches/tmp/lslezak/workshop/core/scr/src/DBusMsg.cc (original) +++ branches/tmp/lslezak/workshop/core/scr/src/DBusMsg.cc Tue Jul 15 15:08:03 2008 @@ -245,14 +245,49 @@ dbus_bool_t b = val->asBoolean()->value(); addValue(type, &b, i); } - // add term, path and symbol as string - else if (val->isTerm() || val->isPath() || val->isSymbol()) + // add path and symbol as string + else if (val->isPath() || val->isSymbol()) { std::string val_str = val->toString(); const char *str = val_str.c_str(); // add path as a string addValue(type, &str, i); } + else if (val->isTerm()) + { + // send YCPTerm as a list: [ name [args] ] + YCPTerm t = val->asTerm(); + y2internal("Sending TERM size: %d", t->size()); + y2internal("Sending TERM name: %s, list: %s", t->name().c_str(), t->args()->toString().c_str()); + + YCPString term_name(t->name()); + YCPList term_list(t->args()); + + int sz = term_list->size(); + int index = 0; + + DBusMessageIter array_it; + + // open array container + y2milestone("Opening array container"); + dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "(bsv)", &array_it); + + // add the name + addYCPValue(term_name, &array_it); + + while(index < sz) + { + y2milestone("Adding YCP value at index %d", index); + // add an item + addYCPValue(term_list->value(index), &array_it); + + index++; + } + + // close array container + y2milestone("Closing array container"); + dbus_message_iter_close_container(i, &array_it); + } else if (val->isList()) { YCPList lst = val->asList(); @@ -421,8 +456,6 @@ // use ycp_type to return the correct type if (ycp_type == "symbol") ret = YCPSymbol(s); - if (ycp_type == "term") - ret = YCPTerm(s); if (ycp_type == "path") ret = YCPPath(s); else @@ -437,7 +470,7 @@ // DBUS_TYPE_ARRAY is used for YCPList and YCPMap if (ycp_type == "list") { - y2milestone("Found YCPList container"); + y2milestone("Found an YCPList container"); YCPList lst; while (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_INVALID) @@ -452,7 +485,7 @@ } else if (ycp_type == "map") { - y2milestone("Found YCPMap container"); + y2milestone("Found an YCPMap container"); YCPMap map; while (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_INVALID) @@ -479,6 +512,44 @@ ret = map; } + else if (ycp_type == "term") + { + y2milestone("Found an YCPTerm container"); + + YCPList term_list; + std::string term_name; + + int index = 0; + while (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_INVALID) + { + YCPValue list_val = getYCPValue(&sub); + + if (index == 0) + { + if (!list_val.isNull() && list_val->isString()) + { + term_name = list_val->asString()->value(); + } + else + { + y2error("Expecting string (term name) in the list"); + return YCPVoid(); + } + } + else + { + term_list->add(list_val); + } + + dbus_message_iter_next(&sub); + index++; + } + + y2milestone("Received TERM: name: %s, list: %s", term_name.c_str(), term_list->toString().c_str()); + + YCPTerm term(term_name, term_list); + ret = term; + } else { y2error("Unknown container type for DBUS_TYPE_ARRAY: %s", ycp_type.c_str()); @@ -665,6 +736,10 @@ { return DBUS_TYPE_STRING; } + else if (val->isTerm()) + { + return DBUS_TYPE_ARRAY; + } else if (val->isBoolean()) { return DBUS_TYPE_BOOLEAN; @@ -698,10 +773,14 @@ { return DBUS_TYPE_DOUBLE_AS_STRING; } - else if (val->isString() || val->isTerm() || val->isPath() || val->isSymbol()) + else if (val->isString() || val->isPath() || val->isSymbol()) { return DBUS_TYPE_STRING_AS_STRING; } + else if (val->isTerm()) + { + return "a(bsv)"; + } else if (val->isBoolean()) { return DBUS_TYPE_BOOLEAN_AS_STRING; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org