]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
Use libclient
authorMartin Vidner <mvidner@suse.cz>
Wed, 30 Oct 2019 12:30:04 +0000 (13:30 +0100)
committerMartin Vidner <mvidner@suse.cz>
Thu, 12 Dec 2019 12:44:52 +0000 (13:44 +0100)
zypp-plugin/Makefile.am
zypp-plugin/snapper_zypp_plugin.cc

index 974ae407baf7d00208d91221d2105a6763e87f70..7f8eb3cc97d16e945798b096c3ffdb457b31b065 100644 (file)
@@ -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
index 733498e4c300b410368aefaea708f116d5e9fd15..9147522f59f51fb327ee6f3576facf70d7bb46a3 100644 (file)
@@ -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<string, string>& 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<string, string>& 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<string, string>& 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<unsigned int>& 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<unsigned int> 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) {