From: Arvin Schnell Date: Tue, 9 Oct 2012 12:37:22 +0000 (+0200) Subject: - added ListSnapshotsAtTime method (for samba) X-Git-Tag: v0.1.3~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d436dd40c96daa6d161a87ba4fa66f292b6a4400;p=thirdparty%2Fsnapper.git - added ListSnapshotsAtTime method (for samba) --- diff --git a/server/Client.cc b/server/Client.cc index 1384c540..12bbf71c 100644 --- a/server/Client.cc +++ b/server/Client.cc @@ -186,6 +186,13 @@ Client::introspect(DBus::Connection& conn, DBus::Message& msg) " \n" " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" " \n" " \n" @@ -581,11 +588,49 @@ Client::list_snapshots(DBus::Connection& conn, DBus::Message& msg) check_permission(conn, msg, *it); Snapper* snapper = it->getSnapper(); + Snapshots& snapshots = snapper->getSnapshots(); DBus::MessageMethodReturn reply(msg); DBus::Hoho hoho(reply); - hoho << snapper->getSnapshots(); + hoho << snapshots; + + conn.send(reply); +} + + +void +Client::list_snapshots_at_time(DBus::Connection& conn, DBus::Message& msg) +{ + string config_name; + time_t begin, end; + + DBus::Hihi hihi(msg); + hihi >> config_name >> begin >> end; + + y2deb("ListSnapshotsAtTime config_name:" << config_name << " begin:" << begin << + " end:" << end); + + boost::unique_lock lock(big_mutex); + + MetaSnappers::iterator it = meta_snappers.find(config_name); + + check_permission(conn, msg, *it); + + Snapper* snapper = it->getSnapper(); + Snapshots& snapshots = snapper->getSnapshots(); + + DBus::MessageMethodReturn reply(msg); + + DBus::Hoho hoho(reply); + + hoho.open_array(DBus::TypeInfo::signature); + for (Snapshots::const_iterator it = snapshots.begin(); it != snapshots.end(); ++it) + { + if (it->getDate() >= begin && it->getDate() <= end) + hoho << *it; + } + hoho.close_array(); conn.send(reply); } @@ -1107,6 +1152,8 @@ Client::dispatch(DBus::Connection& conn, DBus::Message& msg) unlock_config(conn, msg); else if (msg.is_method_call(INTERFACE, "ListSnapshots")) list_snapshots(conn, msg); + else if (msg.is_method_call(INTERFACE, "ListSnapshotsAtTime")) + list_snapshots_at_time(conn, msg); else if (msg.is_method_call(INTERFACE, "GetSnapshot")) get_snapshot(conn, msg); else if (msg.is_method_call(INTERFACE, "SetSnapshot")) diff --git a/server/Client.h b/server/Client.h index 6715a1d3..3c1054b9 100644 --- a/server/Client.h +++ b/server/Client.h @@ -87,6 +87,7 @@ public: void lock_config(DBus::Connection& conn, DBus::Message& msg); void unlock_config(DBus::Connection& conn, DBus::Message& msg); void list_snapshots(DBus::Connection& conn, DBus::Message& msg); + void list_snapshots_at_time(DBus::Connection& conn, DBus::Message& msg); void get_snapshot(DBus::Connection& conn, DBus::Message& msg); void set_snapshot(DBus::Connection& conn, DBus::Message& msg); void create_single_snapshot(DBus::Connection& conn, DBus::Message& msg);