Author: lslezak
Date: Wed Jul 16 12:54:29 2008
New Revision: 49148
URL: http://svn.opensuse.org/viewcvs/yast?rev=49148&view=rev
Log:
- added support for YCPCode type (returnewd by .target.yast2 or
.target.ycp agent)
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=49148&r1=49147&r2=49148&view=diff
==============================================================================
--- branches/tmp/lslezak/workshop/core/scr/src/DBusMsg.cc (original)
+++ branches/tmp/lslezak/workshop/core/scr/src/DBusMsg.cc Wed Jul 16 12:54:29 2008
@@ -7,6 +7,7 @@
#include "DBusMsg.h"
#include "YCP.h"
+#include
#include
DBusMsg::DBusMsg() : msg(NULL)
@@ -343,6 +344,12 @@
// close array container
dbus_message_iter_close_container(i, &array_it);
}
+ else if (val->isCode())
+ {
+ // add the block as string
+ const char *str = val->toString().c_str();
+ addValue(type, &str, i);
+ }
else
{
y2error("Unsupported type %s, value: %s", Type::vt2type(val->valuetype())->toString().c_str(),
@@ -452,14 +459,49 @@
const char *s;
dbus_message_iter_get_basic(it, &s);
+ static const char* block_prefix = "block ";
+ static const int block_prefix_len = ::strlen(block_prefix);
+
// use ycp_type to return the correct type
- if (ycp_type == "symbol")
+ if (ycp_type.empty() || ycp_type == "string")
+ ret = YCPString(s);
+ else if (ycp_type == "symbol")
ret = YCPSymbol(s);
- if (ycp_type == "path")
+ else if (ycp_type == "path")
ret = YCPPath(s);
+ else if (std::string(ycp_type, 0, block_prefix_len) == block_prefix)
+ {
+ y2internal("Found YCP block");
+ // parse the string, recreate the YCPBlock again
+ Parser parser(s);
+ parser.setBuffered();
+ YCodePtr p = parser.parse();
+ YCPValue contents = YCPNull ();
+
+ if (!p)
+ {
+ y2error("Parse error in YCP code: %s", s);
+ }
+ else
+ {
+ if (p->isBlock ())
+ {
+ contents = YCPCode (p);
+ }
+ else
+ {
+ contents = p->evaluate (true);
+ }
+ }
+
+ ret = !contents.isNull() ? contents : YCPVoid();
+ }
else
+ {
+ y2warning("Unknown STRING data, returning as YCPString");
// default is YCPString
ret = YCPString(s);
+ }
}
else if (type == DBUS_TYPE_ARRAY)
{
@@ -732,7 +774,7 @@
{
return DBUS_TYPE_DOUBLE;
}
- else if (val->isString() || val->isTerm() || val->isPath() || val->isSymbol())
+ else if (val->isString() || val->isTerm() || val->isPath() || val->isSymbol() || val->isCode())
{
return DBUS_TYPE_STRING;
}
@@ -789,6 +831,10 @@
{
return "a(bsv)";
}
+ else if (val->isCode())
+ {
+ return DBUS_TYPE_STRING_AS_STRING;
+ }
else if (val->isMap())
{
YCPMap map = val->asMap();
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org