]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- added function to call dbus quota methods 229/head
authorArvin Schnell <aschnell@suse.de>
Wed, 30 Mar 2016 14:14:14 +0000 (16:14 +0200)
committerArvin Schnell <aschnell@suse.de>
Wed, 30 Mar 2016 14:14:14 +0000 (16:14 +0200)
client/commands.cc
client/commands.h
client/errors.cc
client/types.cc
client/types.h

index 908e44f006e890c2db2f9ef3dc443764b43864e5..6a8ab8b94e358b190f57fc882987b0c74a42efa9 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) [2012-2015] Novell, Inc.
+ * Copyright (c) 2016 SUSE LLC
  *
  * All Rights Reserved.
  *
@@ -401,6 +402,37 @@ command_get_xfiles(DBus::Connection& conn, const string& config_name, unsigned i
 }
 
 
+void
+command_prepare_quota(DBus::Connection& conn, const string& config_name)
+{
+    DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "PrepareQuota");
+
+    DBus::Hoho hoho(call);
+    hoho << config_name;
+
+    conn.send_with_reply_and_block(call);
+}
+
+
+XQuotaData
+command_query_quota(DBus::Connection& conn, const string& config_name)
+{
+    DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "QueryQuota");
+
+    DBus::Hoho hoho(call);
+    hoho << config_name;
+
+    DBus::Message reply = conn.send_with_reply_and_block(call);
+
+    XQuotaData quota_data;
+
+    DBus::Hihi hihi(reply);
+    hihi >> quota_data;
+
+    return quota_data;
+}
+
+
 void
 command_xsync(DBus::Connection& conn, const string& config_name)
 {
index 7b1c188e3814119c5fa6c9021e712bcede801905..55207b586365de378ffcb8b2f74112000cb35506 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) [2012-2015] Novell, Inc.
+ * Copyright (c) 2016 SUSE LLC
  *
  * All Rights Reserved.
  *
@@ -115,6 +116,12 @@ list<XFile>
 command_get_xfiles(DBus::Connection& conn, const string& config_name, unsigned int number1,
                   unsigned int number2);
 
+void
+command_prepare_quota(DBus::Connection& conn, const string& config_name);
+
+XQuotaData
+command_query_quota(DBus::Connection& conn, const string& config_name);
+
 void
 command_xsync(DBus::Connection& conn, const string& config_name);
 
index 4670badca2cb520f2bb6b7fda837291cd3ecc5c7..f2dc43e4fa065deefa1daac5c1dd022fa78acf1c 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) [2011-2014] Novell, Inc.
+ * Copyright (c) [2016] SUSE LLC
  *
  * All Rights Reserved.
  *
@@ -84,5 +85,8 @@ error_description(const DBus::ErrorException& e)
     if (name == "error.acl_error")
        return _("ACL error.");
 
+    if (name == "error.quota")
+       return sformat(_("Quota failure (%s)."), e.message());
+
     return sformat(_("Failure (%s)."), name.c_str());
 }
index bbd75f1ca9050207dc7bc07267b25f314a49bb12..17152f8f5caf303d680285e2f122ab04ca4c529c 100644 (file)
@@ -118,6 +118,16 @@ namespace DBus
     }
 
 
+    Hihi&
+    operator>>(Hihi& hihi, XQuotaData& data)
+    {
+       hihi.open_recurse();
+       hihi >> data.size >> data.used;
+       hihi.close_recurse();
+       return hihi;
+    }
+
+
     Hoho&
     operator<<(Hoho& hoho, SnapshotType data)
     {
index d06325e474a44f79d13fe16290f2f799df78ade1..856a6e6da9dd518336538218dfb933e91e0faaba 100644 (file)
@@ -98,6 +98,13 @@ struct XFile
 };
 
 
+struct XQuotaData
+{
+    uint64_t size;
+    uint64_t used;
+};
+
+
 namespace DBus
 {
 
@@ -114,4 +121,6 @@ namespace DBus
 
     Hihi& operator>>(Hihi& hihi, XFile& data);
 
+    Hihi& operator>>(Hihi& hihi, XQuotaData& data);
+
 }