[yast-commit] r55239 - in /branches/tmp/lslezak/core: dbus/namespace_service/DBusModulesServer.cc liby2dbus/src/DBusMsg.cc
Author: lslezak Date: Wed Feb 4 14:00:13 2009 New Revision: 55239 URL: http://svn.opensuse.org/viewcvs/yast?rev=55239&view=rev Log: - fixed list and map fucntion signatures - fixed conversion YCPList -> DBus message Modified: branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc Modified: branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc?rev=55239&r1=55238&r2=55239&view=diff ============================================================================== --- branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc (original) +++ branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc Wed Feb 4 14:00:13 2009 @@ -182,8 +182,10 @@ case(YT_STRING) : ret = DBUS_TYPE_STRING_AS_STRING; break; case(YT_PATH) : ret = DBUS_TYPE_STRING_AS_STRING; break; case(YT_SYMBOL) : ret = DBUS_TYPE_STRING_AS_STRING; break; - case(YT_LIST) : ret = DBUS_TYPE_ARRAY_AS_STRING; break; - case(YT_MAP) : ret = DBUS_TYPE_ARRAY_AS_STRING; break; + case(YT_LIST) : ret = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_VARIANT_AS_STRING; break; /* av */ + case(YT_MAP) : ret = DBUS_TYPE_ARRAY_AS_STRING + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_VARIANT_AS_STRING + DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING; break; /* a{vv} */ case(YT_TERM) : ret = DBUS_TYPE_STRING_AS_STRING; break; case(YT_CODE) : ret = DBUS_TYPE_STRING_AS_STRING; break; Modified: branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc?rev=55239&r1=55238&r2=55239&view=diff ============================================================================== --- branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc (original) +++ branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc Wed Feb 4 14:00:13 2009 @@ -280,23 +280,42 @@ int sz = lst->size(); int index = 0; + // use string as fallback for empty map + std::string list_type(sz ? typeStr(lst->value(0)) : DBUS_TYPE_STRING_AS_STRING); + + // dbus allows only basic complete types in a list + const std::string valid_list_types(DBUS_TYPE_INT64_AS_STRING DBUS_TYPE_DOUBLE_AS_STRING + DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_BOOLEAN_AS_STRING); + + if (valid_list_types.find(list_type) == std::string::npos) + { + y2error("Invalid type of list item (non-basic type): %s, ignoring the list", list_type.c_str()); + return false; + } + DBusMessageIter array_it; // open array container y2debug("Opening array container"); - dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "v", &array_it); + + dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, list_type.c_str(), &array_it); while(index < sz) { y2debug("Adding YCP value at index %d", index); - // add VARIANT container - DBusMessageIter var_it; - dbus_message_iter_open_container(&array_it, DBUS_TYPE_VARIANT, typeStr(lst->value(index)), &var_it); - // add the raw YCP value - addValueAt(lst->value(index), &array_it); + YCPValue list_item = lst->value(index); - y2debug("Closing VARIANT container"); - dbus_message_iter_close_container(&array_it, &var_it); + if (typeStr(list_item) != list_type) + { + y2error("Found different type in list: %s (expected %s) - ignoring item %s", + typeStr(list_item), list_type.c_str(), + list_item->toString().c_str()); + } + else + { + // add the raw YCP value + addValueAt(lst->value(index), &array_it); + } index++; } @@ -313,7 +332,7 @@ YCPMapIterator mit = map.begin(); // use string as fallback for empty map - std::string key_type(mit == map.end() ? "s" : typeStr(mit.key())); + std::string key_type(mit == map.end() ? DBUS_TYPE_STRING_AS_STRING : typeStr(mit.key())); // dbus allows only basic types as key type in a map const std::string valid_key_types(DBUS_TYPE_INT64_AS_STRING DBUS_TYPE_DOUBLE_AS_STRING -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
lslezak@svn.opensuse.org