Imported Upstream version 17.12.0
[platform/upstream/libzypp.git] / zypp / target / hal / HalContext.cc
index 8d2ff62..4c21ff8 100644 (file)
  *
  *  \brief Hardware abstaction layer library wrapper implementation.
  */
-#ifndef FAKE_HAL // disables zypp's HAL dependency
-
-#include <zypp/target/hal/HalContext.h>
-#include <zypp/thread/Mutex.h>
-#include <zypp/thread/MutexLock.h>
-#include <zypp/base/NonCopyable.h>
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-#include <zypp/base/Gettext.h>
-
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus-glib.h>
+#include "zypp/base/Gettext.h"
+#include "zypp/target/hal/HalException.h"
+//////////////////////////////////////////////////////////////////////
+namespace zypp
+{ ////////////////////////////////////////////////////////////////////
+  ////////////////////////////////////////////////////////////////////
+  namespace target
+  { //////////////////////////////////////////////////////////////////
+    //////////////////////////////////////////////////////////////////
+    namespace hal
+    { ////////////////////////////////////////////////////////////////
+        HalException::HalException()
+          : zypp::Exception(_("Hal Exception"))
+        {}
+        HalException::HalException(const std::string &msg_r)
+          : zypp::Exception(_("Hal Exception"))
+          , e_name()
+          , e_msg(msg_r)
+        {}
+        HalException::HalException(const std::string &err_name, const std::string &err_msg)
+          : zypp::Exception(_("Hal Exception"))
+          , e_name(err_name)
+          , e_msg(err_msg)
+        {}
+        NoHalException::NoHalException()
+       : Exception(_("Sorry, but this version of libzypp was built without HAL support."))
+      {}
+      ////////////////////////////////////////////////////////////////
+    } // namespace hal
+    //////////////////////////////////////////////////////////////////
+    //////////////////////////////////////////////////////////////////
+  } // namespace target
+  ////////////////////////////////////////////////////////////////////
+  ////////////////////////////////////////////////////////////////////
+} // namespace zypp
+//////////////////////////////////////////////////////////////////////
+
+#ifndef NO_HAL // disables zypp's HAL dependency
+
+#include "zypp/target/hal/HalContext.h"
+#include "zypp/thread/Mutex.h"
+#include "zypp/thread/MutexLock.h"
+#include "zypp/base/NonCopyable.h"
+#include "zypp/base/Logger.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Gettext.h"
+
 #include <hal/libhal.h>
 #include <hal/libhal-storage.h>
 
@@ -1078,9 +1113,9 @@ namespace zypp
   ////////////////////////////////////////////////////////////////////
 } // namespace zypp
 //////////////////////////////////////////////////////////////////////
-#else // FAKE_HAL
-#include <zypp/target/hal/HalContext.h>
-#include <zypp/target/hal/HalException.h>
+#else // NO_HAL
+#include "zypp/target/hal/HalContext.h"
+#include "zypp/target/hal/HalException.h"
 namespace zypp
 { ////////////////////////////////////////////////////////////////////
   ////////////////////////////////////////////////////////////////////
@@ -1104,7 +1139,7 @@ namespace zypp
 
       // --------------------------------------------------------------
       HalContext::HalContext(bool)
-      {}
+      { ZYPP_THROW( NoHalException() ); }
       HalContext::~HalContext()
       {}
       HalContext &
@@ -1144,7 +1179,7 @@ namespace zypp
       { return ""; }
       // --------------------------------------------------------------
       HalDrive::HalDrive()
-      {}
+      { ZYPP_THROW( NoHalException() ); }
       HalDrive::~HalDrive()
       {}
       HalDrive &
@@ -1179,7 +1214,7 @@ namespace zypp
 
       // --------------------------------------------------------------
       HalVolume::HalVolume()
-      {}
+      { ZYPP_THROW( NoHalException() ); }
       HalVolume::~HalVolume()
       {}
       HalVolume &
@@ -1227,7 +1262,7 @@ namespace zypp
   ////////////////////////////////////////////////////////////////////
 } // namespace zypp
 //////////////////////////////////////////////////////////////////////
-#endif // FAKE_HAL
+#endif // NO_HAL
 
 /*
 ** vim: set ts=2 sts=2 sw=2 ai et: