From c09766a08866278fcd960e7e8ae64d60b6f9751f Mon Sep 17 00:00:00 2001
From: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
Date: Fri, 21 Aug 2015 10:25:15 -0400
Subject: [PATCH] dbus: add dbus error handler interface

The default implementation of this interface throws an exception,
as before, but the clients now have the option to implement an
alternative way to handle dbus errors.

Issue: #79654
Change-Id: I9e929e97b84e78432151d285199ccf09d90e4c01
---
 CMakeLists.txt                     |  3 +++
 src/dbus/callmanager.cpp           | 28 +++++++++++++--------
 src/dbus/configurationmanager.cpp  | 31 +++++++++++++++---------
 src/dbus/instancemanager.cpp       | 39 +++++++++++++++++++-----------
 src/dbus/presencemanager.cpp       | 31 +++++++++++++++---------
 src/dbus/videomanager.cpp          | 28 ++++++++++++++-------
 src/dbuserrorhandlerdefault.cpp    | 36 +++++++++++++++++++++++++++
 src/dbuserrorhandlerdefault.h      | 35 +++++++++++++++++++++++++++
 src/globalinstances.cpp            | 37 ++++++++++++++++++++++------
 src/globalinstances.h              |  5 ++++
 src/interfaces/dbuserrorhandleri.h | 35 +++++++++++++++++++++++++++
 11 files changed, 245 insertions(+), 63 deletions(-)
 create mode 100644 src/dbuserrorhandlerdefault.cpp
 create mode 100644 src/dbuserrorhandlerdefault.h
 create mode 100644 src/interfaces/dbuserrorhandleri.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9326894b..aa88fe04 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -295,6 +295,7 @@ SET( libringclient_LIB_SRCS
   src/pixmapmanipulatordefault.cpp
   src/profilepersisterdefault.cpp
   src/shortcutcreatordefault.cpp
+  src/dbuserrorhandlerdefault.cpp
 
   #Other
   src/categorizedcompositenode.cpp
@@ -400,6 +401,7 @@ SET( libringclient_LIB_HDRS
   src/pixmapmanipulatordefault.h
   src/profilepersisterdefault.h
   src/shortcutcreatordefault.h
+  src/dbuserrorhandlerdefault.h
 )
 
 SET(libringclient_video_LIB_HDRS
@@ -450,6 +452,7 @@ SET(libringclient_interface_LIB_HDRS
   src/interfaces/pixmapmanipulatori.h
   src/interfaces/profilepersisteri.h
   src/interfaces/shortcutcreatori.h
+  src/interfaces/dbuserrorhandleri.h
 )
 
 SET( libringclient_extra_LIB_HDRS
diff --git a/src/dbus/callmanager.cpp b/src/dbus/callmanager.cpp
index 8a061082..dfd4ac69 100644
--- a/src/dbus/callmanager.cpp
+++ b/src/dbus/callmanager.cpp
@@ -1,5 +1,5 @@
 /****************************************************************************
- *   Copyright (C) 2009-2014 by Savoir-Faire Linux                          *
+ *   Copyright (C) 2009-2015 by Savoir-faire Linux                          *
  *   Author : Jérémy Quentin <jeremy.quentin@savoirfairelinux.com>          *
  *            Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
  *                                                                          *
@@ -18,21 +18,29 @@
  ***************************************************************************/
 #include "callmanager.h"
 
+#include "../globalinstances.h"
+#include "../interfaces/dbuserrorhandleri.h"
+
 CallManagerInterface * DBus::CallManager::interface = nullptr;
 
 CallManagerInterface & DBus::CallManager::instance(){
 
 #ifdef ENABLE_LIBWRAP
-   if (!interface)
+    if (!interface)
         interface = new CallManagerInterface();
 #else
-   if (!dbus_metaTypeInit) registerCommTypes();
-   if (!interface)
-      interface = new CallManagerInterface( "cx.ring.Ring", "/cx/ring/Ring/CallManager", QDBusConnection::sessionBus());
-   if(!interface->connection().isConnected())
-      throw "Error : dring not connected. Service " + interface->service() + " not connected. From call manager interface.";
-   if (!interface->isValid())
-      throw "Dring daemon not available, be sure it running";
+    if (!dbus_metaTypeInit) registerCommTypes();
+    if (!interface)
+        interface = new CallManagerInterface( "cx.ring.Ring", "/cx/ring/Ring/CallManager", QDBusConnection::sessionBus());
+    if(!interface->connection().isConnected()) {
+        GlobalInstances::dBusErrorHandler().connectionError(
+            "Error : dring not connected. Service " + interface->service() + " not connected. From call manager interface."
+        );
+    } if (!interface->isValid()) {
+        GlobalInstances::dBusErrorHandler().invalidInterfaceError(
+            "Error : dring is not available, make sure it is running"
+        );
+    }
 #endif
-   return *interface;
+    return *interface;
 }
diff --git a/src/dbus/configurationmanager.cpp b/src/dbus/configurationmanager.cpp
index 348321f5..ec7dc25b 100644
--- a/src/dbus/configurationmanager.cpp
+++ b/src/dbus/configurationmanager.cpp
@@ -1,5 +1,5 @@
 /****************************************************************************
- *   Copyright (C) 2009-2014 by Savoir-Faire Linux                          *
+ *   Copyright (C) 2009-2015 by Savoir-faire Linux                          *
  *   Author : Jérémy Quentin <jeremy.quentin@savoirfairelinux.com>          *
  *            Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
  *                                                                          *
@@ -18,24 +18,31 @@
  ***************************************************************************/
 #include "configurationmanager.h"
 
+#include "../globalinstances.h"
+#include "../interfaces/dbuserrorhandleri.h"
+
 ConfigurationManagerInterface* DBus::ConfigurationManager::interface = nullptr;
 
 ConfigurationManagerInterface& DBus::ConfigurationManager::instance()
 {
 #ifdef ENABLE_LIBWRAP
-   if (!interface) {
+    if (!interface) {
         interface = new ConfigurationManagerInterface();
     }
 #else
-   if (!dbus_metaTypeInit) registerCommTypes();
-   if (!interface)
-      interface = new ConfigurationManagerInterface("cx.ring.Ring", "/cx/ring/Ring/ConfigurationManager", QDBusConnection::sessionBus());
-   if(!interface->connection().isConnected()) {
-      qDebug() << "Error : dring not connected. Service " << interface->service() << " not connected. From configuration manager interface.";
-      throw "Error : dring not connected. Service " + interface->service() + " not connected. From configuration manager interface.";
-   }
-   if (!interface->isValid())
-      throw "DRing daemon not available, be sure it running";
+    if (!dbus_metaTypeInit) registerCommTypes();
+    if (!interface)
+        interface = new ConfigurationManagerInterface("cx.ring.Ring", "/cx/ring/Ring/ConfigurationManager", QDBusConnection::sessionBus());
+    if(!interface->connection().isConnected()) {
+        GlobalInstances::dBusErrorHandler().connectionError(
+            "Error : dring not connected. Service " + interface->service() + " not connected. From configuration manager interface."
+        );
+    }
+    if (!interface->isValid()) {
+        GlobalInstances::dBusErrorHandler().invalidInterfaceError(
+            "Error : dring is not available, make sure it is running"
+        );
+    }
 #endif
-   return *interface;
+    return *interface;
 }
diff --git a/src/dbus/instancemanager.cpp b/src/dbus/instancemanager.cpp
index 8f50b31d..88f30eb3 100644
--- a/src/dbus/instancemanager.cpp
+++ b/src/dbus/instancemanager.cpp
@@ -1,5 +1,5 @@
 /****************************************************************************
- *   Copyright (C) 2009-2014 by Savoir-Faire Linux                          *
+ *   Copyright (C) 2009-2015 by Savoir-faire Linux                          *
  *   Author : Jérémy Quentin <jeremy.quentin@savoirfairelinux.com>          *
  *            Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
  *                                                                          *
@@ -18,8 +18,12 @@
  ***************************************************************************/
 
 #include "instancemanager.h"
+
 #include <unistd.h>
 
+#include "../globalinstances.h"
+#include "../interfaces/dbuserrorhandleri.h"
+
 InstanceInterface* DBus::InstanceManager::interface = nullptr;
 
 InstanceInterface& DBus::InstanceManager::instance()
@@ -28,18 +32,25 @@ InstanceInterface& DBus::InstanceManager::instance()
     if (!interface)
         interface = new InstanceInterface();
 #else
-   if (!dbus_metaTypeInit) registerCommTypes();
-   if (!interface)
-      interface = new InstanceInterface("cx.ring.Ring", "/cx/ring/Ring/Instance", QDBusConnection::sessionBus());
-   if(!interface->connection().isConnected()) {
-      throw "Error : dring not connected. Service " + interface->service() + " not connected. From instance interface.";
-   }
-   static bool registered = false;
-   if (!registered) {
-      QDBusPendingReply<QString> reply = interface->Register(getpid(), "");
-      registered = true;
-      reply.waitForFinished();
-   }
+    if (!dbus_metaTypeInit) registerCommTypes();
+    if (!interface)
+        interface = new InstanceInterface("cx.ring.Ring", "/cx/ring/Ring/Instance", QDBusConnection::sessionBus());
+    if (!interface->connection().isConnected()) {
+        GlobalInstances::dBusErrorHandler().connectionError(
+            "Error : dring not connected. Service " + interface->service() + " not connected. From instance interface."
+        );
+    }
+    static bool registered = false;
+    if (!registered) {
+        QDBusPendingReply<QString> reply = interface->Register(getpid(), "");
+        registered = true;
+        reply.waitForFinished();
+    }
+    if (!interface->isValid()) {
+        GlobalInstances::dBusErrorHandler().invalidInterfaceError(
+            "Error : dring is not available, make sure it is running"
+        );
+    }
 #endif
-   return *interface;
+    return *interface;
 }
diff --git a/src/dbus/presencemanager.cpp b/src/dbus/presencemanager.cpp
index 77a0c3f2..94e6743e 100644
--- a/src/dbus/presencemanager.cpp
+++ b/src/dbus/presencemanager.cpp
@@ -1,5 +1,5 @@
 /****************************************************************************
- *   Copyright (C) 2013-2014 by Savoir-Faire Linux                          *
+ *   Copyright (C) 2013-2015 by Savoir-faire Linux                          *
  *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
  *                                                                          *
  *   This library is free software; you can redistribute it and/or          *
@@ -17,21 +17,30 @@
  ***************************************************************************/
 #include "presencemanager.h"
 
+#include "../globalinstances.h"
+#include "../interfaces/dbuserrorhandleri.h"
+
 PresenceManagerInterface* DBus::PresenceManager::interface = nullptr;
 
 PresenceManagerInterface& DBus::PresenceManager::instance()
 {
 #ifdef ENABLE_LIBWRAP
-   if (!interface)
-      interface = new PresenceManagerInterface();
+    if (!interface)
+        interface = new PresenceManagerInterface();
 #else
-   if (!dbus_metaTypeInit) registerCommTypes();
-   if (!interface)
-      interface = new PresenceManagerInterface("cx.ring.Ring", "/cx/ring/Ring/PresenceManager", QDBusConnection::sessionBus());
-
-   if(!interface->connection().isConnected()) {
-      throw "Error : dring not connected. Service " + interface->service() + " not connected. From instance interface.";
-   }
+    if (!dbus_metaTypeInit) registerCommTypes();
+    if (!interface)
+        interface = new PresenceManagerInterface("cx.ring.Ring", "/cx/ring/Ring/PresenceManager", QDBusConnection::sessionBus());
+    if (!interface->connection().isConnected()) {
+        GlobalInstances::dBusErrorHandler().connectionError(
+            "Error : dring not connected. Service " + interface->service() + " not connected. From presence interface."
+        );
+    }
+    if (!interface->isValid()) {
+        GlobalInstances::dBusErrorHandler().invalidInterfaceError(
+            "Error : dring is not available, make sure it is running"
+        );
+    }
 #endif
-   return *interface;
+    return *interface;
 }
diff --git a/src/dbus/videomanager.cpp b/src/dbus/videomanager.cpp
index 03d770f6..713f085c 100644
--- a/src/dbus/videomanager.cpp
+++ b/src/dbus/videomanager.cpp
@@ -1,5 +1,5 @@
 /****************************************************************************
- *   Copyright (C) 2012-2014 by Savoir-Faire Linux                          *
+ *   Copyright (C) 2012-2015 by Savoir-faire Linux                          *
  *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
  *                                                                          *
  *   This library is free software; you can redistribute it and/or          *
@@ -17,20 +17,30 @@
  ***************************************************************************/
 #include "videomanager.h"
 
+#include "../globalinstances.h"
+#include "../interfaces/dbuserrorhandleri.h"
+
 VideoManagerInterface* DBus::VideoManager::interface = nullptr;
 
 VideoManagerInterface& DBus::VideoManager::instance()
 {
 #ifdef ENABLE_LIBWRAP
-   if (!interface)
-      interface = new VideoManagerInterface();
+    if (!interface)
+        interface = new VideoManagerInterface();
 #else
-   if (!dbus_metaTypeInit) registerCommTypes();
-   if (!interface)
-      interface = new VideoManagerInterface("cx.ring.Ring", "/cx/ring/Ring/VideoManager", QDBusConnection::sessionBus());
-   if(!interface->connection().isConnected()) {
-      throw "Error : dring not connected. Service " + interface->service() + " not connected. From instance interface.";
-   }
+    if (!dbus_metaTypeInit) registerCommTypes();
+    if (!interface)
+        interface = new VideoManagerInterface("cx.ring.Ring", "/cx/ring/Ring/VideoManager", QDBusConnection::sessionBus());
+    if (!interface->connection().isConnected()) {
+        GlobalInstances::dBusErrorHandler().connectionError(
+            "Error : dring not connected. Service " + interface->service() + " not connected. From video manager interface."
+        );
+    }
+    if (!interface->isValid()) {
+        GlobalInstances::dBusErrorHandler().invalidInterfaceError(
+            "Error : dring is not available, make sure it is running"
+        );
+    }
 #endif
    return *interface;
 }
diff --git a/src/dbuserrorhandlerdefault.cpp b/src/dbuserrorhandlerdefault.cpp
new file mode 100644
index 00000000..4fe3781b
--- /dev/null
+++ b/src/dbuserrorhandlerdefault.cpp
@@ -0,0 +1,36 @@
+/****************************************************************************
+ *   Copyright (C) 2015 by Savoir-faire Linux                               *
+ *   Author : Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>*
+ *                                                                          *
+ *   This library is free software; you can redistribute it and/or          *
+ *   modify it under the terms of the GNU Lesser General Public             *
+ *   License as published by the Free Software Foundation; either           *
+ *   version 2.1 of the License, or (at your option) any later version.     *
+ *                                                                          *
+ *   This library is distributed in the hope that it will be useful,        *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      *
+ *   Lesser General Public License for more details.                        *
+ *                                                                          *
+ *   You should have received a copy of the GNU General Public License      *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
+ ***************************************************************************/
+#include "dbuserrorhandlerdefault.h"
+
+namespace Interfaces {
+
+void
+DBusErrorHandlerDefault::connectionError(const QString& error)
+{
+    qDebug() << error;
+    throw error.toLatin1().constData();
+}
+
+void
+DBusErrorHandlerDefault::invalidInterfaceError(const QString& error)
+{
+    qDebug() << error;
+    throw error.toLatin1().constData();
+}
+
+} // namespace Interfaces
diff --git a/src/dbuserrorhandlerdefault.h b/src/dbuserrorhandlerdefault.h
new file mode 100644
index 00000000..aca17b58
--- /dev/null
+++ b/src/dbuserrorhandlerdefault.h
@@ -0,0 +1,35 @@
+/****************************************************************************
+ *   Copyright (C) 2015 by Savoir-faire Linux                               *
+ *   Author : Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>*
+ *                                                                          *
+ *   This library is free software; you can redistribute it and/or          *
+ *   modify it under the terms of the GNU Lesser General Public             *
+ *   License as published by the Free Software Foundation; either           *
+ *   version 2.1 of the License, or (at your option) any later version.     *
+ *                                                                          *
+ *   This library is distributed in the hope that it will be useful,        *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      *
+ *   Lesser General Public License for more details.                        *
+ *                                                                          *
+ *   You should have received a copy of the GNU General Public License      *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
+ ***************************************************************************/
+#pragma once
+
+#include <typedefs.h>
+
+#include "interfaces/dbuserrorhandleri.h"
+
+namespace Interfaces {
+
+/**
+ * This implementation of the DBusErrorHandler interface throws an exception with the given message.
+ */
+class LIB_EXPORT DBusErrorHandlerDefault : public DBusErrorHandlerI {
+public:
+    [[noreturn]] void connectionError(const QString& error) override;
+    [[noreturn]] void invalidInterfaceError(const QString& error) override;
+};
+
+} // namespace Interfaces
diff --git a/src/globalinstances.cpp b/src/globalinstances.cpp
index 9a073ced..ce99c507 100644
--- a/src/globalinstances.cpp
+++ b/src/globalinstances.cpp
@@ -21,6 +21,7 @@
 
 #include "interfaces/accountlistcolorizeri.h"
 #include "interfaces/contactmethodselectori.h"
+#include "interfaces/dbuserrorhandleri.h"
 #include "interfaces/itemmodelstateserializeri.h"
 #include "interfaces/pixmapmanipulatori.h"
 #include "interfaces/presenceserializeri.h"
@@ -28,6 +29,7 @@
 #include "interfaces/shortcutcreatori.h"
 
 #include "accountlistcolorizerdefault.h"
+#include "dbuserrorhandlerdefault.h"
 #include "pixmapmanipulatordefault.h"
 #include "presenceserializerdefault.h"
 #include "shortcutcreatordefault.h"
@@ -36,13 +38,14 @@ namespace GlobalInstances {
 
 struct InstanceManager
 {
-   std::unique_ptr<Interfaces::AccountListColorizerI>     m_accountListColorizer;
-   std::unique_ptr<Interfaces::ContactMethodSelectorI>    m_contactMethodSelector;
-   std::unique_ptr<Interfaces::ItemModelStateSerializerI> m_itemModelStateSerializer;
-   std::unique_ptr<Interfaces::PixmapManipulatorI>        m_pixmapManipulator;
-   std::unique_ptr<Interfaces::PresenceSerializerI>       m_presenceSerializer;
-   std::unique_ptr<Interfaces::ProfilePersisterI>         m_profilePersister;
-   std::unique_ptr<Interfaces::ShortcutCreatorI>          m_shortcutCreator;
+    std::unique_ptr<Interfaces::AccountListColorizerI>     m_accountListColorizer;
+    std::unique_ptr<Interfaces::ContactMethodSelectorI>    m_contactMethodSelector;
+    std::unique_ptr<Interfaces::DBusErrorHandlerI>         m_dBusErrorHandler;
+    std::unique_ptr<Interfaces::ItemModelStateSerializerI> m_itemModelStateSerializer;
+    std::unique_ptr<Interfaces::PixmapManipulatorI>        m_pixmapManipulator;
+    std::unique_ptr<Interfaces::PresenceSerializerI>       m_presenceSerializer;
+    std::unique_ptr<Interfaces::ProfilePersisterI>         m_profilePersister;
+    std::unique_ptr<Interfaces::ShortcutCreatorI>          m_shortcutCreator;
 };
 
 static InstanceManager&
@@ -94,6 +97,25 @@ setContactMethodSelector(std::unique_ptr<Interfaces::ContactMethodSelectorI> ins
     instanceManager().m_contactMethodSelector = std::move(instance);
 }
 
+Interfaces::DBusErrorHandlerI&
+dBusErrorHandler()
+{
+    if (!instanceManager().m_dBusErrorHandler)
+        instanceManager().m_dBusErrorHandler.reset(new Interfaces::DBusErrorHandlerDefault);
+    return *instanceManager().m_dBusErrorHandler;
+}
+
+void
+setDBusErrorHandler(std::unique_ptr<Interfaces::DBusErrorHandlerI> instance)
+{
+    // do not allow empty pointers
+    if (!instance) {
+        qWarning() << "ignoring empty unique_ptr";
+        return;
+    }
+    instanceManager().m_dBusErrorHandler = std::move(instance);
+}
+
 /**
  * LRC does not provide a default implementation of this interface, thus an exception will be thrown
  * if this getter is called without an instance being set by the client
@@ -221,6 +243,7 @@ void setInterfaceInternal(I* i)\
 
 REGISTER_INTERFACE(Interfaces::AccountListColorizerI    , m_accountListColorizer    )
 REGISTER_INTERFACE(Interfaces::ContactMethodSelectorI   , m_contactMethodSelector   )
+REGISTER_INTERFACE(Interfaces::DBusErrorHandlerI        , m_dBusErrorHandler        )
 REGISTER_INTERFACE(Interfaces::ItemModelStateSerializerI, m_itemModelStateSerializer)
 REGISTER_INTERFACE(Interfaces::PixmapManipulatorI       , m_pixmapManipulator       )
 REGISTER_INTERFACE(Interfaces::PresenceSerializerI      , m_presenceSerializer      )
diff --git a/src/globalinstances.h b/src/globalinstances.h
index c173df8a..2a88772a 100644
--- a/src/globalinstances.h
+++ b/src/globalinstances.h
@@ -24,6 +24,7 @@
 namespace Interfaces {
 class AccountListColorizerI;
 class ContactMethodSelectorI;
+class DBusErrorHandlerI;
 class ItemModelStateSerializerI;
 class PixmapManipulatorI;
 class PresenceSerializerI;
@@ -51,6 +52,9 @@ void setAccountListColorizer(std::unique_ptr<Interfaces::AccountListColorizerI>
 Interfaces::ContactMethodSelectorI& contactMethodSelector();
 void setContactMethodSelector(std::unique_ptr<Interfaces::ContactMethodSelectorI> instance);
 
+Interfaces::DBusErrorHandlerI& dBusErrorHandler();
+void setDBusErrorHandler(std::unique_ptr<Interfaces::DBusErrorHandlerI> instance);
+
 /**
  * LRC does not provide a default implementation of this interface, thus an exception will be thrown
  * if this getter is called without an instance being set by the client
@@ -79,6 +83,7 @@ void setShortcutCreatorI(std::unique_ptr<Interfaces::ShortcutCreatorI> instance)
 //Private use only
 void setInterfaceInternal(Interfaces::AccountListColorizerI    *);
 void setInterfaceInternal(Interfaces::ContactMethodSelectorI   *);
+void setInterfaceInternal(Interfaces::DBusErrorHandlerI        *);
 void setInterfaceInternal(Interfaces::ItemModelStateSerializerI*);
 void setInterfaceInternal(Interfaces::PixmapManipulatorI       *);
 void setInterfaceInternal(Interfaces::PresenceSerializerI      *);
diff --git a/src/interfaces/dbuserrorhandleri.h b/src/interfaces/dbuserrorhandleri.h
new file mode 100644
index 00000000..8426ae86
--- /dev/null
+++ b/src/interfaces/dbuserrorhandleri.h
@@ -0,0 +1,35 @@
+/****************************************************************************
+ *   Copyright (C) 2015 by Savoir-faire Linux                               *
+ *   Author : Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>*
+ *                                                                          *
+ *   This library is free software; you can redistribute it and/or          *
+ *   modify it under the terms of the GNU Lesser General Public             *
+ *   License as published by the Free Software Foundation; either           *
+ *   version 2.1 of the License, or (at your option) any later version.     *
+ *                                                                          *
+ *   This library is distributed in the hope that it will be useful,        *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      *
+ *   Lesser General Public License for more details.                        *
+ *                                                                          *
+ *   You should have received a copy of the GNU General Public License      *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
+ ***************************************************************************/
+#pragma once
+
+#include <typedefs.h>
+
+namespace Interfaces {
+
+/**
+ * Some clients may not have a nice way to generally handle exceptions event wide (ie: handle any
+ * exception which may occur during an itteration or an event on the main loop). This interface
+ * gives them the option to implement various ways to handle dbus errors.
+ */
+class DBusErrorHandlerI {
+public:
+    virtual void connectionError(const QString& error) = 0;
+    virtual void invalidInterfaceError(const QString& error) = 0;
+};
+
+} // namespace Interfaces
-- 
GitLab