Author: lslezak
Date: Thu Feb 12 09:11:01 2009
New Revision: 55451
URL: http://svn.opensuse.org/viewcvs/yast?rev=55451&view=rev
Log:
- DBus service - use #DEFINEs instead of hardcoded strings
Added:
branches/tmp/lslezak/core/dbus/namespace_service/Yast_dbus_names.h.in
Modified:
branches/tmp/lslezak/core/configure.in.in
branches/tmp/lslezak/core/dbus/namespace_service/ (props changed)
branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc
branches/tmp/lslezak/core/dbus/namespace_service/Makefile.am
branches/tmp/lslezak/core/liby2dbus/src/DBusCaller.cc
branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.cc
Modified: branches/tmp/lslezak/core/configure.in.in
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/configure.in.in?rev=55451&r1=55450&r2=55451&view=diff
==============================================================================
--- branches/tmp/lslezak/core/configure.in.in (original)
+++ branches/tmp/lslezak/core/configure.in.in Thu Feb 12 09:11:01 2009
@@ -129,9 +129,13 @@
AC_SUBST(HAVE_POLKIT)
AM_CONDITIONAL([HAVE_POLKIT], [test "x$HAVE_POLKIT" = x1])
+YAST_DBUS_SERVICE=org.opensuse.yast.modules
+AC_SUBST(YAST_DBUS_SERVICE)
+
## and generate the output
AC_CONFIG_FILES([
scr/doc/SCR.html
scr/doc/intro_to_scr.html
+ dbus/namespace_service/Yast_dbus_names.h
])
@YAST2-OUTPUT@
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=55451&r1=55450&r2=55451&view=diff
==============================================================================
--- branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc (original)
+++ branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc Thu Feb 12 09:11:01 2009
@@ -8,8 +8,6 @@
#include "DBusModulesServer.h"
#include "DBusMsg.h"
-#include
-#include
#include
#include
#include
@@ -18,12 +16,13 @@
#include
#include
-#include
#include <functional>
#include
+#include "Yast_dbus_names.h"
+
void DBusModulesServer::init_wfm()
{
if (Y2WFMComponent::instance() == NULL)
@@ -136,11 +135,11 @@
{
sig_raw.params = p_raw;
// register the function: register_function(object, interface, method, signature, handler)
- register_method(nspace, "org.opensuse.yast.modules.Values", fname, sig_raw, e);
+ register_method(nspace, YAST_DBUS_RAW_INTERFACE, fname, sig_raw, e);
}
sig_marshalled.params = p_marshalled;
- register_method(nspace, "org.opensuse.yast.modules.YCPValues", fname, sig_marshalled, e);
+ register_method(nspace, YAST_DBUS_YCP_INTERFACE, fname, sig_marshalled, e);
return true;
}
@@ -222,12 +221,12 @@
sig.params = p;
// register the manager object: register_function(object, interface, method, signature, handler)
- register_method("", "org.opensuse.yast.modules.ModuleManager", "Import", sig, manager_callback);
+ register_method("", YAST_DBUS_MGR_INTERFACE, YAST_DBUS_MANAGER_IMPORT_METHOD, sig, manager_callback);
DBusSignature void_sig;
// register the manager object: register_function(object, interface, method, signature, handler)
- register_method("", "org.opensuse.yast.modules.ModuleManager", "Unlock", void_sig, manager_callback);
- register_method("", "org.opensuse.yast.modules.ModuleManager", "Lock", void_sig, manager_callback);
+ register_method("", YAST_DBUS_MGR_INTERFACE, YAST_DBUS_MANAGER_UNLOCK_METHOD, void_sig, manager_callback);
+ register_method("", YAST_DBUS_MGR_INTERFACE, YAST_DBUS_MANAGER_LOCK_METHOD, void_sig, manager_callback);
}
std::string DBusModulesServer::Y2Dtype(constTypePtr type) const
@@ -295,7 +294,7 @@
bool DBusModulesServer::connect()
{
registerManager();
- return DBusServerBase::connect(SYSTEM, "org.opensuse.yast.modules");
+ return DBusServerBase::connect(SYSTEM, YAST_DBUS_SERVICE_NAME);
}
/*
@@ -424,7 +423,7 @@
if (argtype->matchvalue(arg) < 0)
{
- if (interface == "org.opensuse.yast.modules.Values")
+ if (interface == YAST_DBUS_RAW_INTERFACE)
{
// try converting DBus types to YCPValues in the raw interface
YCPValue casted = AutoCast(arg, argtype);
@@ -496,7 +495,7 @@
// return empty message for void functions
if (!ret->isVoid())
{
- if (interface == "org.opensuse.yast.modules.Values")
+ if (interface == YAST_DBUS_RAW_INTERFACE)
{
reply.addValue(ret);
}
@@ -529,9 +528,9 @@
if (object == "/")
{
- if (interface == "org.opensuse.yast.modules.ModuleManager")
+ if (interface == YAST_DBUS_MGR_INTERFACE)
{
- if (method == "Import")
+ if (method == YAST_DBUS_MANAGER_IMPORT_METHOD)
{
if (request.arguments() == 1)
{
@@ -571,11 +570,11 @@
y2error("ModuleManager function %s got %d parameters instead of 1", method.c_str(), request.arguments());
}
}
- else if (method == "Unlock")
+ else if (method == YAST_DBUS_MANAGER_UNLOCK_METHOD)
{
unregister_client(request.sender());
}
- else if (method == "Lock")
+ else if (method == YAST_DBUS_MANAGER_LOCK_METHOD)
{
register_client(request.sender());
}
@@ -596,8 +595,8 @@
std::string DBusModulesServer::createActionId(const DBusMsg &msg)
{
// actionId: <prefix>.<namespace>.<method>
- std::string ret(msg.interface() == "org.opensuse.yast.modules.ModuleManager"
- ? "org.opensuse.yast.module_manager" : "org.opensuse.yast.modules");
+ std::string ret(msg.interface() == YAST_DBUS_MGR_INTERFACE
+ ? YAST_POLKIT_PREFIX_MANAGER : YAST_POLKIT_PREFIX_MODULES);
std::string obj(msg.path());
Modified: branches/tmp/lslezak/core/dbus/namespace_service/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/dbus/namespace_service/Makefile.am?rev=55451&r1=55450&r2=55451&view=diff
==============================================================================
--- branches/tmp/lslezak/core/dbus/namespace_service/Makefile.am (original)
+++ branches/tmp/lslezak/core/dbus/namespace_service/Makefile.am Thu Feb 12 09:11:01 2009
@@ -2,7 +2,8 @@
# Makefile.am for dbus/service
#
-EXTRA_DIST=org.opensuse.yast.modules.service.in org.opensuse.yast.modules.conf.in org.opensuse.yast.modules.policy
+EXTRA_DIST=org.opensuse.yast.modules.service.in org.opensuse.yast.modules.conf.in org.opensuse.yast.modules.policy \
+ Yast_dbus_names.h.in
AM_CXXFLAGS = -DY2LOG=\"DBus-service\" -DSUSEVERSION=\"${SUSEVERSION}\"
Added: branches/tmp/lslezak/core/dbus/namespace_service/Yast_dbus_names.h.in
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/dbus/namespace_service/Yast_dbus_names.h.in?rev=55451&view=auto
==============================================================================
--- branches/tmp/lslezak/core/dbus/namespace_service/Yast_dbus_names.h.in (added)
+++ branches/tmp/lslezak/core/dbus/namespace_service/Yast_dbus_names.h.in Thu Feb 12 09:11:01 2009
@@ -0,0 +1,24 @@
+/*
+ * Yast_dbus_names.h - generated from Yast_dbus_names.h.in
+ *
+ */
+
+#ifndef YAST_DBUS_NAMES_H
+#define YAST_DBUS_NAMES_H
+
+// name of the Yast DBus service
+#define YAST_DBUS_SERVICE_NAME "@YAST_DBUS_SERVICE@"
+
+// interface name for marshalled YCPValues - using (bsv) DBus structure
+#define YAST_DBUS_YCP_INTERFACE "org.opensuse.yast.modules.YCPValues"
+// interface name for raw (direct) DBus values
+#define YAST_DBUS_RAW_INTERFACE "org.opensuse.yast.modules.Values"
+// interface name for management functions (Import, Lock...)
+#define YAST_DBUS_MGR_INTERFACE "org.opensuse.yast.modules.ModuleManager"
+
+// prefix for PolicyKit action IDs - namespace calls
+#define YAST_POLKIT_PREFIX_MODULES "org.opensuse.yast.modules"
+// prefix for PolicyKit action IDs - manager calls
+#define YAST_POLKIT_PREFIX_MANAGER "org.opensuse.yast.module_manager"
+
+#endif
Modified: branches/tmp/lslezak/core/liby2dbus/src/DBusCaller.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2dbus/src/DBusCaller.cc?rev=55451&r1=55450&r2=55451&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2dbus/src/DBusCaller.cc (original)
+++ branches/tmp/lslezak/core/liby2dbus/src/DBusCaller.cc Thu Feb 12 09:11:01 2009
@@ -25,8 +25,8 @@
DBusMsg query;
// ask the DBus server for the PID of the caller
- query.createCall("org.freedesktop.DBus", "/org/freedesktop/DBus/Bus",
- "org.freedesktop.DBus", "GetConnectionUnixProcessID");
+ query.createCall(DBUS_SERVICE_DBUS, DBUS_PATH_DBUS"/Bus",
+ DBUS_INTERFACE_DBUS, "GetConnectionUnixProcessID");
query.addString(busid);
Modified: branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.cc?rev=55451&r1=55450&r2=55451&view=diff
==============================================================================
--- branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.cc (original)
+++ branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.cc Thu Feb 12 09:11:01 2009
@@ -173,7 +173,7 @@
// introcpection data for the root node
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
"\n<node>\n"
- " <interface name='org.freedesktop.DBus.Introspectable'>\n"
+ " <interface name='"DBUS_INTERFACE_INTROSPECTABLE"'>\n"
" <method name='Introspect'>\n"
" <arg name='xml_data' type='s' direction='out'/>\n"
" </method>\n"
@@ -206,7 +206,7 @@
// introcpection data for the root node
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
"\n<node>\n"
- " <interface name='org.freedesktop.DBus.Introspectable'>\n"
+ " <interface name='"DBUS_INTERFACE_INTROSPECTABLE"'>\n"
" <method name='Introspect'>\n"
" <arg name='xml_data' type='s' direction='out'/>\n"
" </method>\n"
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org