From: Arvin Schnell Date: Fri, 1 Jun 2012 14:29:06 +0000 (+0200) Subject: - work on dbus interface X-Git-Tag: v0.1.3~225 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=29c998f396b5ff701d7c7c7fc9488279ca7d602d;p=thirdparty%2Fsnapper.git - work on dbus interface --- diff --git a/client/cleanup.cc b/client/cleanup.cc index d23f295a..c44684b0 100644 --- a/client/cleanup.cc +++ b/client/cleanup.cc @@ -58,7 +58,7 @@ filter2(const XSnapshots& snapshots, list& tmp) for (list::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& 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); diff --git a/client/snapper.cc b/client/snapper.cc index 87c25fc4..8bb981bc 100644 --- a/client/snapper.cc +++ b/client/snapper.cc @@ -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); diff --git a/client/types.cc b/client/types.cc index ae110280..4fbce685 100644 --- a/client/types.cc +++ b/client/types.cc @@ -20,18 +20,23 @@ */ +#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(tmp); + data = static_cast(tmp); return hihi; } @@ -112,7 +117,7 @@ namespace DBus Hoho& - operator<<(Hoho& hoho, XSnapshotType data) + operator<<(Hoho& hoho, SnapshotType data) { hoho << static_cast(data); return hoho; diff --git a/client/types.h b/client/types.h index 80956af9..6bf931f3 100644 --- a/client/types.h +++ b/client/types.h @@ -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 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 { 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); };