[yast-commit] r57982 - in /branches/tmp/mvidner/core-dbus-values: dbus/SCR_service/ dbus/namespace_service/src/ dbus/namespace_service/testsuite/ libscr/src/ liby2dbus/src/
![](https://seccdn.libravatar.org/avatar/6988c1d101434edca30549af3bc31040.jpg?s=120&d=mm&r=g)
Author: mvidner
Date: Thu Jul 9 17:49:19 2009
New Revision: 57982
URL: http://svn.opensuse.org/viewcvs/yast?rev=57982&view=rev
Log:
getYCPValue can now throw DBusException. Catch it in the callers.
Convert it to DBus Error where applicable.
Throw it on BSV bad type name or type mismatch (bnc#520616).
More throws will come once tests are written.
Enabled t4.
Modified:
branches/tmp/mvidner/core-dbus-values/dbus/SCR_service/DBusServer.cc
branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/src/DBusModulesServer.cc
branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/test_all
branches/tmp/mvidner/core-dbus-values/libscr/src/SCR.cc
branches/tmp/mvidner/core-dbus-values/liby2dbus/src/DBusMsg.cc
Modified: branches/tmp/mvidner/core-dbus-values/dbus/SCR_service/DBusServer.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/core-dbus-values/dbus/SCR_service/DBusServer.cc?rev=57982&r1=57981&r2=57982&view=diff
==============================================================================
--- branches/tmp/mvidner/core-dbus-values/dbus/SCR_service/DBusServer.cc (original)
+++ branches/tmp/mvidner/core-dbus-values/dbus/SCR_service/DBusServer.cc Thu Jul 9 17:49:19 2009
@@ -94,6 +94,8 @@
&& request.interface() == YAST_SCR_INTERFACE
&& request.path() == SCR_OBJECT_PATH)
{
+ try
+ {
std::string method(request.method());
YCPValue arg0;
@@ -188,6 +190,13 @@
else
reply.addYCPValue(YCPVoid());
}
+ }
+ catch (const DBusException& de)
+ {
+ y2error ("Caught: %s", de.message().c_str());
+ y2error ("Returning %s", de.name().c_str());
+ reply.createError(request, de.message(), de.name());
+ }
}
y2milestone("Finishing the callback");
@@ -205,30 +214,39 @@
ret.push_back(action_id);
- YCPValue path = msg.getYCPValue(0, Type::Path);
- YCPValue arg = msg.getYCPValue(1, Type::Unspec);
- YCPValue opt = msg.getYCPValue(2, Type::Unspec);
+ try
+ {
+ YCPValue path = msg.getYCPValue(0, Type::Path);
+ YCPValue arg = msg.getYCPValue(1, Type::Unspec);
+ YCPValue opt = msg.getYCPValue(2, Type::Unspec);
- std::string path_str, arg_str, opt_str;
+ std::string path_str, arg_str, opt_str;
- if (!path.isNull())
- {
- path_str = path->toString();
- }
-
- if (!arg.isNull() && arg->isString())
- {
- arg_str = arg->asString()->value();
- }
+ if (!path.isNull())
+ {
+ path_str = path->toString();
+ }
- if (!opt.isNull() && opt->isString())
+ if (!arg.isNull() && arg->isString())
+ {
+ arg_str = arg->asString()->value();
+ }
+
+ if (!opt.isNull() && opt->isString())
+ {
+ opt_str = opt->asString()->value();
+ }
+
+ action_id = PolKit::createActionId(POLKIT_PREFIX, path_str, msg.method(), arg_str, opt_str);
+
+ ret.push_back(action_id);
+ }
+ catch (const DBusException& de)
{
- opt_str = opt->asString()->value();
+ y2error ("Caught: %s", de.message().c_str());
+ y2error ("While trying to create action ID.");
}
- action_id = PolKit::createActionId(POLKIT_PREFIX, path_str, msg.method(), arg_str, opt_str);
-
- ret.push_back(action_id);
#endif
return ret;
Modified: branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/src/DBusModulesServer.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/src/DBusModulesServer.cc?rev=57982&r1=57981&r2=57982&view=diff
==============================================================================
--- branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/src/DBusModulesServer.cc (original)
+++ branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/src/DBusModulesServer.cc Thu Jul 9 17:49:19 2009
@@ -407,6 +407,8 @@
bool found = false;
if (t)
{
+ try
+ {
constFunctionTypePtr fptr(t);
if (fptr)
@@ -500,6 +502,14 @@
y2error("Function %s::%s got %d parameters instead of %d", object.c_str(), method.c_str(), request.arguments(), fptr->parameterCount());
}
}
+ }
+ catch (const DBusException& de)
+ {
+ y2error ("Caught: %s", de.message().c_str());
+ y2error ("Returning %s", de.name().c_str());
+ reply.createError(request, de.message(), de.name());
+ return reply;
+ }
}
if (!found)
@@ -555,8 +565,6 @@
y2milestone("ModuleManager request: object: %s, method: %s, interface: %s",
object.c_str(), method.c_str(), interface.c_str());
- reply.createReply(request);
-
if (object == YAST_DBUS_OBJ_PREFIX)
{
if (interface == YAST_DBUS_MGR_INTERFACE)
@@ -565,6 +573,8 @@
{
if (request.arguments() == 1)
{
+ try
+ {
YCPValue arg = request.getYCPValue(0, Type::String);
if (arg.isNull())
@@ -589,6 +599,7 @@
}
y2milestone("Result: %s", ret ? "true" : "false");
+ reply.createReply(request);
reply.addBoolean(ret);
}
else
@@ -596,20 +607,29 @@
y2error("Expecting 'string' parameter, got '%s'", Type::vt2type(arg->valuetype())->toString().c_str());
}
}
-
+ }
+ catch (const DBusException& de)
+ {
+ y2error ("Caught: %s", de.message().c_str());
+ y2error ("Returning %s", de.name().c_str());
+ reply.createError(request, de.message(), de.name());
+ }
}
else
{
y2error("ModuleManager function %s got %d parameters instead of 1", method.c_str(), request.arguments());
+ reply.createError(request, "Invalid number of parameters", DBUS_ERROR_INVALID_ARGS);
}
}
else if (method == YAST_DBUS_MANAGER_UNLOCK_METHOD)
{
unregister_client(request.sender());
+ reply.createReply(request);
}
else if (method == YAST_DBUS_MANAGER_LOCK_METHOD)
{
register_client(request.sender());
+ reply.createReply(request);
}
}
}
Modified: branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/test_all
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/test_all?rev=57982&r1=57981&r2=57982&view=diff
==============================================================================
--- branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/test_all (original)
+++ branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/test_all Thu Jul 9 17:49:19 2009
@@ -3,7 +3,7 @@
# $0 [-a: all, even failing]
# $0 ./a_single_testcase
if [ "$1" = "" ]; then
- : ${CASES:=./t[1235]*}
+ : ${CASES:=./t[12345]*}
elif [ "$1" = "-a" ]; then
: ${CASES:=./t? ./t*-*}
else
Modified: branches/tmp/mvidner/core-dbus-values/libscr/src/SCR.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/core-dbus-values/libscr/src/SCR.cc?rev=57982&r1=57981&r2=57982&view=diff
==============================================================================
--- branches/tmp/mvidner/core-dbus-values/libscr/src/SCR.cc (original)
+++ branches/tmp/mvidner/core-dbus-values/libscr/src/SCR.cc Thu Jul 9 17:49:19 2009
@@ -83,7 +83,15 @@
y2debug("Received reply type: %d", reply.type());
// return the first argument from the reply
- YCPValue ret = reply.getYCPValue(0, Type::Unspec);
+ YCPValue ret;
+ try
+ {
+ ret = reply.getYCPValue(0, Type::Unspec);
+ }
+ catch (const DBusException& de)
+ {
+ y2error ("Caught: %s: %s", de.name().c_str(), de.message().c_str());
+ }
// validate the reply (check for exceptions)
if (reply.type() != DBUS_MESSAGE_TYPE_METHOD_RETURN)
Modified: branches/tmp/mvidner/core-dbus-values/liby2dbus/src/DBusMsg.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/core-dbus-values/liby2dbus/src/DBusMsg.cc?rev=57982&r1=57981&r2=57982&view=diff
==============================================================================
--- branches/tmp/mvidner/core-dbus-values/liby2dbus/src/DBusMsg.cc (original)
+++ branches/tmp/mvidner/core-dbus-values/liby2dbus/src/DBusMsg.cc Thu Jul 9 17:49:19 2009
@@ -8,6 +8,8 @@
#include "YCP.h"
#include
participants (1)
-
mvidner@svn.opensuse.org