From: Martin Vidner Date: Wed, 30 Oct 2019 12:30:04 +0000 (+0100) Subject: Use libclient X-Git-Tag: v0.8.7^2~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f506dec2470f2ef03157b8cf1128c36dce363721;p=thirdparty%2Fsnapper.git Use libclient --- diff --git a/zypp-plugin/Makefile.am b/zypp-plugin/Makefile.am index 974ae407..7f8eb3cc 100644 --- a/zypp-plugin/Makefile.am +++ b/zypp-plugin/Makefile.am @@ -7,4 +7,8 @@ snapper_zypp_plugin_SOURCES = \ snapper_zypp_plugin.cc \ zypp_commit_plugin.cc zypp_commit_plugin.h \ zypp_plugin.cc zypp_plugin.h -snapper_zypp_plugin_LDFLAGS = ../snapper/libsnapper.la ../dbus/libdbus.la -lboost_regex +snapper_zypp_plugin_LDFLAGS = \ + ../client/libclient.la \ + ../snapper/libsnapper.la \ + ../dbus/libdbus.la \ + -lboost_regex diff --git a/zypp-plugin/snapper_zypp_plugin.cc b/zypp-plugin/snapper_zypp_plugin.cc index 733498e4..9147522f 100644 --- a/zypp-plugin/snapper_zypp_plugin.cc +++ b/zypp-plugin/snapper_zypp_plugin.cc @@ -16,80 +16,10 @@ using namespace std; #include "snapper/Exception.h" using snapper::Exception; using snapper::CodeLocation; +#include "client/commands.h" #include "zypp_commit_plugin.h" -// this is copied from command.cc, not part of any library now - -#define SERVICE "org.opensuse.Snapper" -#define OBJECT "/org/opensuse/Snapper" -#define INTERFACE "org.opensuse.Snapper" - -unsigned int -command_create_pre_snapshot(DBus::Connection& conn, const string& config_name, - const string& description, const string& cleanup, - const map& userdata) -{ - DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "CreatePreSnapshot"); - - DBus::Hoho hoho(call); - hoho << config_name << description << cleanup << userdata; - - DBus::Message reply = conn.send_with_reply_and_block(call); - - unsigned int number; - - DBus::Hihi hihi(reply); - hihi >> number; - - return number; -} - -unsigned int -command_create_post_snapshot(DBus::Connection& conn, const string& config_name, - unsigned int prenum, const string& description, - const string& cleanup, const map& userdata) -{ - DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "CreatePostSnapshot"); - - DBus::Hoho hoho(call); - hoho << config_name << prenum << description << cleanup << userdata; - - DBus::Message reply = conn.send_with_reply_and_block(call); - - unsigned int number; - - DBus::Hihi hihi(reply); - hihi >> number; - - return number; -} - -void -command_set_snapshot(DBus::Connection& conn, const string& config_name, unsigned int num, - const string& description, const string& cleanup, - const map& userdata) -{ - DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "SetSnapshot"); - - DBus::Hoho hoho(call); - hoho << config_name << num << description << cleanup << userdata; - - conn.send_with_reply_and_block(call); -} - -void -command_delete_snapshots(DBus::Connection& conn, const string& config_name, - const vector& nums) -{ - DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "DeleteSnapshots"); - - DBus::Hoho hoho(call); - hoho << config_name << nums; - - conn.send_with_reply_and_block(call); -} - class Logging { public: void debug(const string& s) { cerr << s << endl; } @@ -160,8 +90,11 @@ public: userdata["important"] = important ? "yes" : "no"; try { - command_set_snapshot(dbus_conn, "root", pre_snapshot_num, snapshot_description, cleanup_algorithm, - userdata); + snapper::SMD modification_data; + modification_data.description = snapshot_description; + modification_data.cleanup = cleanup_algorithm; + modification_data.userdata = userdata; + command_set_snapshot(dbus_conn, "root", pre_snapshot_num, modification_data); } catch (const Exception& ex) { logging.error("setting snapshot data failed:"); @@ -184,7 +117,8 @@ public: try { logging.info("deleting pre snapshot"); vector nums{ pre_snapshot_num }; - command_delete_snapshots(dbus_conn, "root", nums); + bool verbose = false; + command_delete_snapshots(dbus_conn, "root", nums, verbose); logging.debug(str(format("deleted pre snapshot %u") % pre_snapshot_num)); } catch (const Exception& ex) {