]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- work on dbus interface
authorArvin Schnell <aschnell@suse.de>
Tue, 5 Jun 2012 14:11:12 +0000 (16:11 +0200)
committerArvin Schnell <aschnell@suse.de>
Tue, 5 Jun 2012 14:11:12 +0000 (16:11 +0200)
client/snapper.cc
dbus/DBusConnection.cc
dbus/DBusMessage.h

index 8bb981bc15adfccde40e3962ce4cb2bab355dce2..b5a324ef63513de30500fe4a7261ba38d8f3e744 100644 (file)
@@ -1212,9 +1212,23 @@ main(int argc, char** argv)
        exit(EXIT_FAILURE);
     }
 
-    DBus::Connection conn(DBUS_BUS_SYSTEM);
+    try
+    {
+       DBus::Connection conn(DBUS_BUS_SYSTEM);
 
-    (*cmd->second)(conn);
+       (*cmd->second)(conn);
+    }
+    catch (const DBus::ErrorException& e)
+    {
+       if (strcmp(e.name(), "error.no_permissions") == 0)
+           cerr << "failed (no permissions)" << endl;
+       else
+           cerr << "failed (" << e.what() << ")" << endl;
+    }
+    catch (const DBus::FatalException& e)
+    {
+       cerr << "failed (" << e.what() << ")" << endl;
+    }
 
     exit(EXIT_SUCCESS);
 }
index bcf4359aa8da1d34b1f0d1257496c837940355fc..ef492eca0043695136ef0b523cb733a86cd35fe9 100644 (file)
@@ -102,8 +102,7 @@ namespace DBus
                                                                     0x7fffffff, &err);
        if (dbus_error_is_set(&err))
        {
-           dbus_error_free(&err);
-           throw FatalException();
+           throw ErrorException(err);
        }
 
        Message reply(tmp);
index e5a40c08d9a2e70be1b71def71634e165b0cb230..b8f3ea48f48c5bf17047a13add562fab66cb3a45 100644 (file)
@@ -47,6 +47,17 @@ namespace DBus
     };
 
 
+    struct ErrorException : public Exception
+    {
+       explicit ErrorException(const DBusError err) throw() : err(err) {}
+       ~ErrorException() throw() { dbus_error_free(&err); }
+       virtual const char* what() const throw() { return "dbus error exception"; }
+       virtual const char* name() const throw() { return err.name; }
+       virtual const char* message() const throw() { return err.message; }
+       DBusError err;
+    };
+
+
     struct MarshallingException : public Exception
     {
        explicit MarshallingException() throw() {}