[yast-commit] r55174 - in /branches/tmp/lslezak/core/dbus/namespace_service: DBusModulesServer.cc DBusModulesServer.h modules_dbus_server.cc
Author: lslezak
Date: Fri Jan 30 18:33:51 2009
New Revision: 55174
URL: http://svn.opensuse.org/viewcvs/yast?rev=55174&view=rev
Log:
- handle multiple namespaces in the service
Modified:
branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc
branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.h
branches/tmp/lslezak/core/dbus/namespace_service/modules_dbus_server.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=55174&r1=55173&r2=55174&view=diff
==============================================================================
--- branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc (original)
+++ branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc Fri Jan 30 18:33:51 2009
@@ -36,23 +36,31 @@
}
}
-DBusModulesServer::DBusModulesServer(const std::string &name_space) : e(this), wfm(NULL)
+DBusModulesServer::DBusModulesServer(const NameSpaceList &name_spaces) : e(this), wfm(NULL)
{
init_wfm();
- Import import(name_space); // has an iternal static cache
+ for (NameSpaceList::const_iterator it = name_spaces.begin();
+ it != name_spaces.end();
+ ++it)
+ {
+ Import import(*it); // has an iternal static cache
- ns = import.nameSpace();
+ Y2Namespace *ns = import.nameSpace();
- if (ns == NULL)
- {
- y2error("Import name space %s failed", name_space.c_str());
- }
- else
- {
- ns->initialize();
- y2milestone("Imported name space: %s", name_space.c_str());
+ if (ns == NULL)
+ {
+ y2error("Import name space %s failed", it->c_str());
+ }
+ else
+ {
+ ns->initialize();
+ y2milestone("Imported name space: %s", it->c_str());
+
+ nsmap[*it] = ns;
+ }
}
+
}
DBusModulesServer::~DBusModulesServer()
@@ -67,6 +75,12 @@
void DBusModulesServer::registerFunctions(const std::string &interface_prefix)
{
+ for (NameSpaceMap::const_iterator it = nsmap.begin();
+ it != nsmap.end();
+ ++it)
+ {
+ Y2Namespace *ns = it->second;
+
if (ns)
{
unsigned symbols = ns->symbolCount();
@@ -136,6 +150,7 @@
index++;
}
}
+ }
}
std::string DBusModulesServer::Y2Dtype(constTypePtr type) const
@@ -176,8 +191,10 @@
return ret;
}
-constTypePtr DBusModulesServer::searchFuncType(const std::string &fname) const
+constTypePtr DBusModulesServer::searchFuncType(const std::string &objname, const std::string &fname) const
{
+ Y2Namespace *ns = nsmap.find(objname)->second;
+
if (ns)
{
unsigned symbols = ns->symbolCount();
@@ -221,8 +238,17 @@
DBusMsg reply;
std::string method = request.method();
+ std::string object = request.path();
- constTypePtr t = searchFuncType(method);
+ // remove the leading slash from the object name
+ if (!object.empty() && object[0] == '/')
+ {
+ object.erase(object.begin());
+ }
+
+ y2debug("Requested object: %s, method: %s", object.c_str(), method.c_str());
+
+ constTypePtr t = searchFuncType(object, method);
if (t)
{
@@ -231,28 +257,34 @@
if (request.arguments() == reqarg)
{
- // create function call
- Y2Function *y2func = ns->createFunctionCall(method.c_str(), t);
+ // TODO improve it, Y2Namespace was already found in searchFuncType()
+ Y2Namespace *ns = nsmap[object];
- if (y2func)
+ if (ns)
{
- int index = 0;
+ // create function call
+ Y2Function *y2func = ns->createFunctionCall(method.c_str(), t);
- while(index < reqarg)
+ if (y2func)
{
- YCPValue arg = request.getYCPValue(index);
- y2func->appendParameter(arg);
- index ++;
- }
+ int index = 0;
- if (y2func->finishParameters())
- {
- // call the function
- ret = y2func->evaluateCall();
- }
- else
- {
- y2error("Wrong parameters to function %s", method.c_str());
+ while(index < reqarg)
+ {
+ YCPValue arg = request.getYCPValue(index);
+ y2func->appendParameter(arg);
+ index ++;
+ }
+
+ if (y2func->finishParameters())
+ {
+ // call the function
+ ret = y2func->evaluateCall();
+ }
+ else
+ {
+ y2error("Wrong parameters to function %s", method.c_str());
+ }
}
}
}
Modified: branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.h?rev=55174&r1=55173&r2=55174&view=diff
==============================================================================
--- branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.h (original)
+++ branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.h Fri Jan 30 18:33:51 2009
@@ -15,6 +15,7 @@
#include
participants (1)
-
lslezak@svn.opensuse.org