Author: aschnell
Date: Fri Jan 23 16:37:39 2009
New Revision: 54950
URL: http://svn.opensuse.org/viewcvs/yast?rev=54950&view=rev
Log:
- added hal agent (needed for bnc #464453)
Added:
branches/SuSE-Code-11-Branch/core/agent-hal/
branches/SuSE-Code-11-Branch/core/agent-hal/Makefile.am
branches/SuSE-Code-11-Branch/core/agent-hal/conf/
branches/SuSE-Code-11-Branch/core/agent-hal/conf/Makefile.am
branches/SuSE-Code-11-Branch/core/agent-hal/conf/hal.scr
branches/SuSE-Code-11-Branch/core/agent-hal/doc/
branches/SuSE-Code-11-Branch/core/agent-hal/doc/Makefile.am
branches/SuSE-Code-11-Branch/core/agent-hal/src/
branches/SuSE-Code-11-Branch/core/agent-hal/src/HalAgent.cc
branches/SuSE-Code-11-Branch/core/agent-hal/src/HalAgent.h
branches/SuSE-Code-11-Branch/core/agent-hal/src/Makefile.am
branches/SuSE-Code-11-Branch/core/agent-hal/src/Y2CCHalAgent.cc
Modified:
branches/SuSE-Code-11-Branch/core/SUBDIRS
branches/SuSE-Code-11-Branch/core/VERSION
branches/SuSE-Code-11-Branch/core/package/yast2-core.changes
branches/SuSE-Code-11-Branch/core/yast2-core.spec.in
Modified: branches/SuSE-Code-11-Branch/core/SUBDIRS
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/SUBDIRS?rev=54950&r1=54949&r2=54950&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/SUBDIRS (original)
+++ branches/SuSE-Code-11-Branch/core/SUBDIRS Fri Jan 23 16:37:39 2009
@@ -1 +1 @@
-liby2util-r liby2 libycp liby2dbus libscr agent-dummy scr agent-system agent-any agent-ini agent-modules agent-resolver agents-non-y2 agents-perl wfm agent-process base autodocs dbus
+liby2util-r liby2 libycp liby2dbus libscr agent-dummy scr agent-system agent-hal agent-any agent-ini agent-modules agent-resolver agents-non-y2 agents-perl wfm agent-process base autodocs dbus
Modified: branches/SuSE-Code-11-Branch/core/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/VERSION?rev=54950&r1=54949&r2=54950&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/VERSION (original)
+++ branches/SuSE-Code-11-Branch/core/VERSION Fri Jan 23 16:37:39 2009
@@ -1 +1 @@
-2.17.26
+2.17.27
Added: branches/SuSE-Code-11-Branch/core/agent-hal/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-hal/Makefile.am?rev=54950&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-hal/Makefile.am (added)
+++ branches/SuSE-Code-11-Branch/core/agent-hal/Makefile.am Fri Jan 23 16:37:39 2009
@@ -0,0 +1,5 @@
+#
+# Makefile.am for core/agent-hal
+#
+
+SUBDIRS = conf doc src
Added: branches/SuSE-Code-11-Branch/core/agent-hal/conf/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-hal/conf/Makefile.am?rev=54950&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-hal/conf/Makefile.am (added)
+++ branches/SuSE-Code-11-Branch/core/agent-hal/conf/Makefile.am Fri Jan 23 16:37:39 2009
@@ -0,0 +1,7 @@
+#
+# Makefile.am for core/agent-hal/conf
+#
+
+scrconf_DATA = hal.scr
+
+EXTRA_DIST = $(scrconf_DATA)
Added: branches/SuSE-Code-11-Branch/core/agent-hal/conf/hal.scr
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-hal/conf/hal.scr?rev=54950&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-hal/conf/hal.scr (added)
+++ branches/SuSE-Code-11-Branch/core/agent-hal/conf/hal.scr Fri Jan 23 16:37:39 2009
@@ -0,0 +1,7 @@
+/**
+ * File: hal.scr
+ * Authors: Arvin Schnell
+ */
+.hal
+
+`ag_hal ()
Added: branches/SuSE-Code-11-Branch/core/agent-hal/doc/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-hal/doc/Makefile.am?rev=54950&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-hal/doc/Makefile.am (added)
+++ branches/SuSE-Code-11-Branch/core/agent-hal/doc/Makefile.am Fri Jan 23 16:37:39 2009
@@ -0,0 +1,16 @@
+#
+# Makefile.am for core/agent-hal/doc
+#
+
+SUBDIRS =
+
+builtin = $(srcdir)/../src/HalAgent.cc
+hbuiltin = ag_hal.html
+$(hbuiltin): $(builtin)
+ `pkg-config --variable=ybindir yast2-devtools`/makebuiltindocs -t "SCR Hal agent functions" -a $(builtin) > $@.new
+ mv $@.new $@
+
+compdir = $(yastdocdir)/components
+comp_DATA = $(hbuiltin)
+
+CLEANFILES = $(hbuiltin)
Added: branches/SuSE-Code-11-Branch/core/agent-hal/src/HalAgent.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-hal/src/HalAgent.cc?rev=54950&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-hal/src/HalAgent.cc (added)
+++ branches/SuSE-Code-11-Branch/core/agent-hal/src/HalAgent.cc Fri Jan 23 16:37:39 2009
@@ -0,0 +1,196 @@
+/*
+ * HalAgent.cc
+ *
+ * An agent for some hal commands.
+ *
+ * Authors: Arvin Schnell
+ */
+
+#include "config.h"
+
+#include
+#include
+
+#include "HalAgent.h"
+
+
+HalAgent::HalAgent()
+ : hal_ctx(NULL),
+ initialised(false)
+{
+ hal_ctx = libhal_ctx_new();
+ if (hal_ctx == NULL)
+ {
+ y2error("libhal_ctx_new failed");
+ return;
+ }
+
+ DBusError error;
+ dbus_error_init(&error);
+
+ DBusConnection* connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL)
+ {
+ y2error("dbus_bus_get failed: %s: %s", error.name, error.message);
+ LIBHAL_FREE_DBUS_ERROR(&error);
+ return;
+ }
+
+ if (!libhal_ctx_set_dbus_connection(hal_ctx, connection))
+ {
+ y2error("libhal_ctx_set_dbus_connection failed");
+ return;
+ }
+
+ if (!libhal_ctx_init(hal_ctx, &error))
+ {
+ if (dbus_error_is_set(&error))
+ {
+ y2error("libhal_ctx_init failed: %s: %s\n", error.name, error.message);
+ dbus_error_free(&error);
+ }
+ y2error("could not initialise connection to hald.");
+ return;
+ }
+
+ initialised = true;
+}
+
+
+HalAgent::~HalAgent ()
+{
+ if (hal_ctx)
+ {
+ DBusError error;
+ dbus_error_init(&error);
+
+ libhal_ctx_shutdown (hal_ctx, &error);
+ if (dbus_error_is_set(&error))
+ {
+ y2error("libhal_ctx_shutdown failed: %s: %s\n", error.name, error.message);
+ dbus_error_free(&error);
+ }
+
+ libhal_ctx_free(hal_ctx);
+ }
+}
+
+
+bool
+HalAgent::acquire_global_interface_lock(const string& interface, bool exclusive)
+{
+ if (!initialised)
+ return false;
+
+ DBusError error;
+ dbus_error_init(&error);
+
+ bool ret = libhal_acquire_global_interface_lock(hal_ctx, interface.c_str(), exclusive, &error);
+ if (dbus_error_is_set(&error))
+ {
+ y2error("libhal_acquire_global_interface_lock failed: %s: %s:", error.name, error.message);
+ dbus_error_free (&error);
+ }
+
+ return ret;
+}
+
+
+bool
+HalAgent::release_global_interface_lock(const string& interface)
+{
+ if (!initialised)
+ return false;
+
+ DBusError error;
+ dbus_error_init(&error);
+
+ bool ret = libhal_release_global_interface_lock(hal_ctx, interface.c_str(), &error);
+ if (dbus_error_is_set(&error))
+ {
+ y2error("libhal_release_global_interface_lock failed: %s: %s:", error.name, error.message);
+ dbus_error_free (&error);
+ }
+
+ return ret;
+}
+
+
+YCPValue
+HalAgent::Read(const YCPPath& path, const YCPValue& arg, const YCPValue&)
+{
+ y2debug("Read(%s)", path->toString().c_str());
+
+ if (path->isRoot())
+ {
+ ycp2error("Read() called without sub-path");
+ return YCPNull();
+ }
+
+ const string cmd = path->component_str(0); // just a shortcut
+
+ return YCPError(string("Undefined subpath for Read(") + path->toString() + ")");
+}
+
+
+YCPBoolean
+HalAgent::Write(const YCPPath& path, const YCPValue& value, const YCPValue& arg)
+{
+ y2debug("Write(%s)", path->toString().c_str());
+
+ if (path->isRoot())
+ {
+ ycp2error("Write() called without sub-path");
+ return YCPBoolean(false);
+ }
+
+ const string cmd = path->component_str(0); // just a shortcut
+
+ ycp2error("Undefined subpath for Write(%s)", path->toString().c_str());
+ return YCPBoolean (false);
+}
+
+
+YCPValue
+HalAgent::Execute(const YCPPath& path, const YCPValue& value, const YCPValue& arg)
+{
+ y2debug ("Execute (%s)", path->toString().c_str());
+
+ if (path->isRoot())
+ {
+ return YCPError("Execute() called without sub-path");
+ }
+
+ if (value.isNull())
+ {
+ return YCPError(string("Execute(")+path->toString()+") without argument.");
+ }
+
+ const string cmd = path->component_str(0); // just a shortcut
+
+ if (cmd == "acquire_global_interface_lock")
+ {
+ if (value.isNull() || !value->isString())
+ return YCPError("Bad interface in Execute(.hal.acquire_global_interface_lock, "
+ "string interface, boolean exclusive)", YCPBoolean(false));
+ string interface = value->asString()->value();
+
+ if (arg.isNull() || !arg->isBoolean())
+ return YCPError("Bad exclusive in Execute(.hal.acquire_global_interface_lock, "
+ "string interface, boolean exclusive)", YCPBoolean(false));
+ bool exclusive = arg->asBoolean()->value();
+
+ return YCPBoolean(acquire_global_interface_lock(interface, exclusive));
+ }
+ else if (cmd == "release_global_interface_lock")
+ {
+ if (value.isNull() || !value->isString())
+ return YCPError("Bad interface in Execute(.hal.release_global_interface_lock, "
+ "string interface)", YCPBoolean(false));
+ string interface = value->asString()->value();
+
+ return YCPBoolean(release_global_interface_lock(interface));
+ }
+
+ return YCPError(string("Undefined subpath for Execute(") + path->toString() + ")");
+}
Added: branches/SuSE-Code-11-Branch/core/agent-hal/src/HalAgent.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-hal/src/HalAgent.h?rev=54950&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-hal/src/HalAgent.h (added)
+++ branches/SuSE-Code-11-Branch/core/agent-hal/src/HalAgent.h Fri Jan 23 16:37:39 2009
@@ -0,0 +1,65 @@
+/*
+ * HalAgent.h
+ *
+ * An agent for some hal commands.
+ *
+ * Authors: Arvin Schnell
+ */
+
+#ifndef HalAgent_h
+#define HalAgent_h
+
+
+#include
+
+#include
+#include
+
+
+/**
+ * @short SCR Agent for some hal commands.
+ */
+class HalAgent : public SCRAgent
+{
+
+public:
+
+ HalAgent();
+ ~HalAgent();
+
+ /**
+ * Read data
+ */
+ virtual YCPValue Read(const YCPPath& path, const YCPValue& arg = YCPNull(),
+ const YCPValue& opt = YCPNull ());
+
+ /**
+ * Write data
+ */
+ virtual YCPBoolean Write(const YCPPath& path, const YCPValue& value,
+ const YCPValue& arg = YCPNull());
+
+ /**
+ * Execute a command
+ */
+ virtual YCPValue Execute(const YCPPath& path, const YCPValue& value = YCPNull(),
+ const YCPValue& arg = YCPNull());
+
+ /**
+ * Get a list of all subtrees
+ */
+ virtual YCPList Dir(const YCPPath& path) { return YCPList(); }
+
+private:
+
+ LibHalContext* hal_ctx;
+
+ bool initialised;
+
+ bool acquire_global_interface_lock(const string& interface, bool exclusive);
+ bool release_global_interface_lock(const string& interface);
+
+};
+
+
+#endif // HalAgent_h
Added: branches/SuSE-Code-11-Branch/core/agent-hal/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-hal/src/Makefile.am?rev=54950&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-hal/src/Makefile.am (added)
+++ branches/SuSE-Code-11-Branch/core/agent-hal/src/Makefile.am Fri Jan 23 16:37:39 2009
@@ -0,0 +1,18 @@
+#
+# Makefile.am for core/agent-hal/src
+#
+
+AM_CXXFLAGS = -DY2LOG=\"agent-hal\"
+
+plugin_LTLIBRARIES = libpy2ag_hal.la
+
+libpy2ag_hal_la_SOURCES = \
+ Y2CCHalAgent.cc \
+ HalAgent.cc HalAgent.h
+
+libpy2ag_hal_la_LDFLAGS = -version-info 2:0 \
+ `pkg-config --libs hal dbus-glib-1`
+libpy2ag_hal_la_LIBADD = @AGENT_LIBADD@
+
+INCLUDES = @AGENT_INCLUDES@ \
+ `pkg-config --cflags hal dbus-glib-1`
Added: branches/SuSE-Code-11-Branch/core/agent-hal/src/Y2CCHalAgent.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-hal/src/Y2CCHalAgent.cc?rev=54950&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-hal/src/Y2CCHalAgent.cc (added)
+++ branches/SuSE-Code-11-Branch/core/agent-hal/src/Y2CCHalAgent.cc Fri Jan 23 16:37:39 2009
@@ -0,0 +1,17 @@
+
+
+/*
+ * Author: Arvin Schnell
+ */
+
+
+#include
+#include
+
+#include "HalAgent.h"
+
+
+typedef Y2AgentComp <HalAgent> Y2HalAgentComp;
+
+Y2CCAgentComp <Y2HalAgentComp> g_y2ccag_hal ("ag_hal");
+
Modified: branches/SuSE-Code-11-Branch/core/package/yast2-core.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/package/yast2-core.changes?rev=54950&r1=54949&r2=54950&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/package/yast2-core.changes (original)
+++ branches/SuSE-Code-11-Branch/core/package/yast2-core.changes Fri Jan 23 16:37:39 2009
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Fri Jan 23 15:15:05 CET 2009 - aschnell@suse.de
+
+- added hal agent (needed for bnc #464453)
+- 2.17.27
+
+-------------------------------------------------------------------
Mon Dec 22 13:16:02 CET 2008 - mvidner@suse.cz
- Reverted r50800 which, in an attempt to fix another bug, encoded to
Modified: branches/SuSE-Code-11-Branch/core/yast2-core.spec.in
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/yast2-core.spec.in?rev=54950&r1=54949&r2=54950&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/yast2-core.spec.in (original)
+++ branches/SuSE-Code-11-Branch/core/yast2-core.spec.in Fri Jan 23 16:37:39 2009
@@ -21,7 +21,8 @@
BuildRequires: libblocxx-devel
# libycp includes crypto built-ins
BuildRequires: libxcrypt-devel
-
+# agent-hal
+BuildRequires: hal-devel dbus-1-devel
# for SCR DBus service
BuildRequires: dbus-1-devel PolicyKit-devel
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org