]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- work on dbus interface
authorArvin Schnell <aschnell@suse.de>
Fri, 1 Jun 2012 14:29:06 +0000 (16:29 +0200)
committerArvin Schnell <aschnell@suse.de>
Fri, 1 Jun 2012 14:29:06 +0000 (16:29 +0200)
client/cleanup.cc
client/snapper.cc
client/types.cc
client/types.h

index d23f295a39c46036f3d728789cd8d62a350b422d..c44684b070c1dbea13eb48dc07800d0511b98640 100644 (file)
@@ -58,7 +58,7 @@ filter2(const XSnapshots& snapshots, list<XSnapshots::const_iterator>& tmp)
 
     for (list<XSnapshots::const_iterator>::const_iterator it1 = tmp.begin(); it1 != tmp.end(); ++it1)
     {
-       if ((*it1)->getType() == XPRE)
+       if ((*it1)->getType() == PRE)
        {
            XSnapshots::const_iterator it2 = snapshots.findPost(*it1);
            if (it2 != snapshots.end())
@@ -68,7 +68,7 @@ filter2(const XSnapshots& snapshots, list<XSnapshots::const_iterator>& tmp)
            }
        }
 
-       if ((*it1)->getType() == XPOST)
+       if ((*it1)->getType() == POST)
        {
            XSnapshots::const_iterator it2 = snapshots.findPre(*it1);
            if (it2 != snapshots.end())
@@ -307,7 +307,7 @@ do_cleanup_empty_pre_post(DBus::Connection& conn, const string& config_name)
 
     for (XSnapshots::const_iterator it1 = snapshots.begin(); it1 != snapshots.end(); ++it1)
     {
-       if (it1->getType() == XPRE)
+       if (it1->getType() == PRE)
        {
            XSnapshots::const_iterator it2 = snapshots.findPost(it1);
 
index 87c25fc46264d2a5aa8d5ecaba75066aa626b2c1..8bb981bc15adfccde40e3962ce4cb2bab355dce2 100644 (file)
@@ -380,9 +380,9 @@ command_list(DBus::Connection& conn)
            for (XSnapshots::const_iterator it1 = snapshots.begin(); it1 != snapshots.end(); ++it1)
            {
                TableRow row;
-               row.add(/*toString(*/ decString((int)(it1->getType())));
+               row.add(toString(it1->getType()));
                row.add(decString(it1->getNum()));
-               row.add(it1->getType() == XPOST ? decString(it1->getPreNum()) : "");
+               row.add(it1->getType() == POST ? decString(it1->getPreNum()) : "");
                row.add(it1->isCurrent() ? "" : datetime(it1->getDate(), false, false));
                row.add(it1->getCleanup());
                row.add(it1->getDescription());
@@ -404,7 +404,7 @@ command_list(DBus::Connection& conn)
            XSnapshots snapshots = command_list_xsnapshots(conn, config_name);
            for (XSnapshots::const_iterator it1 = snapshots.begin(); it1 != snapshots.end(); ++it1)
            {
-               if (it1->getType() != XSINGLE)
+               if (it1->getType() != SINGLE)
                    continue;
 
                TableRow row;
@@ -431,7 +431,7 @@ command_list(DBus::Connection& conn)
            XSnapshots snapshots = command_list_xsnapshots(conn, config_name);
            for (XSnapshots::const_iterator it1 = snapshots.begin(); it1 != snapshots.end(); ++it1)
            {
-               if (it1->getType() != XPRE)
+               if (it1->getType() != PRE)
                    continue;
 
                XSnapshots::const_iterator it2 = snapshots.findPost(it1);
index ae110280c981b5b98976ddd04ec106b7dcaafcda..4fbce685cbf22b9696bffada95955eb32441bfa5 100644 (file)
  */
 
 
+#include "snapper/SnapperTmpl.h"
+
 #include "types.h"
 
 
+using namespace snapper;
+
+
 XSnapshots::const_iterator
 XSnapshots::findPre(const_iterator post) const
 {
-    if (post == entries.end() || post->isCurrent() || post->getType() != XPOST)
+    if (post == entries.end() || post->isCurrent() || post->getType() != POST)
        throw;
 
     for (const_iterator it = begin(); it != end(); ++it)
     {
-       if (it->getType() == XPRE && it->getNum() == post->getPreNum())
+       if (it->getType() == PRE && it->getNum() == post->getPreNum())
            return it;
     }
 
@@ -42,12 +47,12 @@ XSnapshots::findPre(const_iterator post) const
 XSnapshots::const_iterator
 XSnapshots::findPost(const_iterator pre) const
 {
-    if (pre == entries.end() || pre->isCurrent() || pre->getType() != XPRE)
+    if (pre == entries.end() || pre->isCurrent() || pre->getType() != PRE)
        throw;
 
     for (const_iterator it = begin(); it != end(); ++it)
     {
-       if (it->getType() == XPOST && it->getPreNum() == pre->getNum())
+       if (it->getType() == POST && it->getPreNum() == pre->getNum())
            return it;
     }
 
@@ -81,11 +86,11 @@ namespace DBus
 
 
     Hihi&
-    operator>>(Hihi& hihi, XSnapshotType& data)
+    operator>>(Hihi& hihi, SnapshotType& data)
     {
        dbus_uint16_t tmp;
        hihi >> tmp;
-       data = static_cast<XSnapshotType>(tmp);
+       data = static_cast<SnapshotType>(tmp);
        return hihi;
     }
 
@@ -112,7 +117,7 @@ namespace DBus
 
 
     Hoho&
-    operator<<(Hoho& hoho, XSnapshotType data)
+    operator<<(Hoho& hoho, SnapshotType data)
     {
        hoho << static_cast<dbus_uint16_t>(data);
        return hoho;
index 80956af9a85efaa331a89378c08c09671d94e5f0..6bf931f3b5d00f1196ffe3e9bbcb4adcbc7b05b2 100644 (file)
@@ -31,6 +31,10 @@ using std::map;
 #include "dbus/DBusConnection.h"
 #include "dbus/DBusMessage.h"
 
+#include "snapper/Snapshot.h"
+
+using namespace snapper;
+
 
 struct XConfigInfo
 {
@@ -39,12 +43,9 @@ struct XConfigInfo
 };
 
 
-enum XSnapshotType { XSINGLE, XPRE, XPOST };
-
-
 struct XSnapshot
 {
-    XSnapshotType getType() const { return type; }
+    SnapshotType getType() const { return type; }
 
     unsigned int getNum() const { return num; }
     bool isCurrent() const { return num == 0; }
@@ -59,7 +60,7 @@ struct XSnapshot
 
     map<string, string> getUserdata() const { return userdata; }
 
-    XSnapshotType type;
+    SnapshotType type;
     unsigned int num;
     time_t date;
     unsigned int pre_num;
@@ -118,11 +119,14 @@ namespace DBus
     template <> struct TypeInfo<XUndo> { static const char* signature; };
 
     Hihi& operator>>(Hihi& hihi, XConfigInfo& data);
-    Hihi& operator>>(Hihi& hihi, XSnapshotType& data);
+
+    Hihi& operator>>(Hihi& hihi, SnapshotType& data);
+    Hoho& operator<<(Hoho& hoho, SnapshotType data);
+
     Hihi& operator>>(Hihi& hihi, XSnapshot& data);
+
     Hihi& operator>>(Hihi& hihi, XFile& data);
 
-    Hoho& operator<<(Hoho& hoho, XSnapshotType data);
     Hoho& operator<<(Hoho& hoho, const XUndo& data);
 
 };