From 1d34e764ca9f21afecb63ef31515081c945bc88d Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Wed, 30 Mar 2016 16:14:14 +0200 Subject: [PATCH] - added function to call dbus quota methods --- client/commands.cc | 32 ++++++++++++++++++++++++++++++++ client/commands.h | 7 +++++++ client/errors.cc | 4 ++++ client/types.cc | 10 ++++++++++ client/types.h | 9 +++++++++ 5 files changed, 62 insertions(+) diff --git a/client/commands.cc b/client/commands.cc index 908e44f0..6a8ab8b9 100644 --- a/client/commands.cc +++ b/client/commands.cc @@ -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) { diff --git a/client/commands.h b/client/commands.h index 7b1c188e..55207b58 100644 --- a/client/commands.h +++ b/client/commands.h @@ -1,5 +1,6 @@ /* * Copyright (c) [2012-2015] Novell, Inc. + * Copyright (c) 2016 SUSE LLC * * All Rights Reserved. * @@ -115,6 +116,12 @@ list 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); diff --git a/client/errors.cc b/client/errors.cc index 4670badc..f2dc43e4 100644 --- a/client/errors.cc +++ b/client/errors.cc @@ -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()); } diff --git a/client/types.cc b/client/types.cc index bbd75f1c..17152f8f 100644 --- a/client/types.cc +++ b/client/types.cc @@ -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) { diff --git a/client/types.h b/client/types.h index d06325e4..856a6e6d 100644 --- a/client/types.h +++ b/client/types.h @@ -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); + } -- 2.47.3