]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- added ListSnapshotsAtTime method (for samba)
authorArvin Schnell <aschnell@suse.de>
Tue, 9 Oct 2012 12:37:22 +0000 (14:37 +0200)
committerArvin Schnell <aschnell@suse.de>
Tue, 9 Oct 2012 12:37:22 +0000 (14:37 +0200)
server/Client.cc
server/Client.h

index 1384c5408ff9245a22831f9c018c6e96e6dc2910..12bbf71c333fb35e484420c17927f71dc5f20f1b 100644 (file)
@@ -186,6 +186,13 @@ Client::introspect(DBus::Connection& conn, DBus::Message& msg)
        "      <arg name='snapshots' type='v' direction='out'/>\n"
        "    </method>\n"
 
+       "    <method name='ListSnapshotsAtTime'>\n"
+       "      <arg name='config-name' type='s' direction='in'/>\n"
+       "      <arg name='begin' type='t' direction='in'/>\n"
+       "      <arg name='end' type='t' direction='in'/>\n"
+       "      <arg name='snapshots' type='v' direction='out'/>\n"
+       "    </method>\n"
+
        "    <method name='GetSnapshot'>\n"
        "      <arg name='config-name' type='s' direction='in'/>\n"
        "      <arg name='number' type='u' direction='in'/>\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<boost::shared_mutex> 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<Snapshot>::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"))
index 6715a1d32d05029ce495520b35a04865ebd381e4..3c1054b907ebd6e80f5dfa2002cd9952e48be2de 100644 (file)
@@ -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);