]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- work on dbus interface
authorArvin Schnell <aschnell@suse.de>
Mon, 6 Aug 2012 11:46:24 +0000 (13:46 +0200)
committerArvin Schnell <aschnell@suse.de>
Mon, 6 Aug 2012 11:46:24 +0000 (13:46 +0200)
client/commands.cc
client/commands.h
server/Client.cc
server/Client.h

index 20173267f9b7dd8b7e3c8788d4a53b20c22537db..174abe583ea47ef062adada8cc62cf128b6eda22 100644 (file)
@@ -215,7 +215,7 @@ command_delete_xsnapshots(DBus::Connection& conn, const string& config_name,
 }
 
 
-void
+string
 command_mount_xsnapshots(DBus::Connection& conn, const string& config_name,
                         unsigned int num)
 {
@@ -224,7 +224,14 @@ command_mount_xsnapshots(DBus::Connection& conn, const string& config_name,
     DBus::Hoho hoho(call);
     hoho << config_name << num;
 
-    conn.send_with_reply_and_block(call);
+    DBus::Message reply = conn.send_with_reply_and_block(call);
+
+    string mount_point;
+
+    DBus::Hihi hihi(reply);
+    hihi >> mount_point;
+
+    return mount_point;
 }
 
 
@@ -241,6 +248,26 @@ command_umount_xsnapshots(DBus::Connection& conn, const string& config_name,
 }
 
 
+string
+command_get_xmount_point(DBus::Connection& conn, const string& config_name,
+                        unsigned int num)
+{
+    DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "GetMountPoint");
+
+    DBus::Hoho hoho(call);
+    hoho << config_name << num;
+
+    DBus::Message reply = conn.send_with_reply_and_block(call);
+
+    string mount_point;
+
+    DBus::Hihi hihi(reply);
+    hihi >> mount_point;
+
+    return mount_point;
+}
+
+
 void
 command_create_xcomparison(DBus::Connection& conn, const string& config_name, unsigned int number1,
                           unsigned int number2)
index b73560f0abacc3d3924a599c8e302af7b18d3f8e..ad5b55c62aa448462a6ff01582d21f912b97c03f 100644 (file)
@@ -75,7 +75,7 @@ void
 command_delete_xsnapshots(DBus::Connection& conn, const string& config_name,
                          list<unsigned int> nums);
 
-void
+string
 command_mount_xsnapshots(DBus::Connection& conn, const string& config_name,
                         unsigned int num);
 
@@ -83,6 +83,10 @@ void
 command_umount_xsnapshots(DBus::Connection& conn, const string& config_name,
                          unsigned int num);
 
+string
+command_get_xmount_point(DBus::Connection& conn, const string& config_name,
+                        unsigned int num);
+
 void
 command_create_xcomparison(DBus::Connection& conn, const string& config_name, unsigned int number1,
                           unsigned int number2);
index 3d5f4805aa745f99487080682570c628e621e0a7..2c28ac8d5609181d7c38cfd1527ec2e7c840487f 100644 (file)
@@ -234,6 +234,11 @@ Client::introspect(DBus::Connection& conn, DBus::Message& msg)
        "      <arg name='number' type='u' direction='in'/>\n"
        "    </method>\n"
 
+       "    <method name='GetMountPoint'>\n"
+       "      <arg name='config-name' type='s' direction='in'/>\n"
+       "      <arg name='number' type='u' direction='in'/>\n"
+       "    </method>\n"
+
        "    <method name='CreateComparison'>\n"
        "      <arg name='config-name' type='s' direction='in'/>\n"
        "      <arg name='number1' type='u' direction='in'/>\n"
@@ -622,7 +627,6 @@ Client::get_snapshot(DBus::Connection& conn, DBus::Message& msg)
     check_permission(conn, msg, *it);
 
     Snapper* snapper = it->getSnapper();
-
     Snapshots& snapshots = snapper->getSnapshots();
 
     Snapshots::iterator snap = snapshots.find(num);
@@ -657,7 +661,6 @@ Client::set_snapshot(DBus::Connection& conn, DBus::Message& msg)
     check_permission(conn, msg, *it);
 
     Snapper* snapper = it->getSnapper();
-
     Snapshots& snapshots = snapper->getSnapshots();
 
     Snapshots::iterator snap = snapshots.find(num);
@@ -771,7 +774,6 @@ Client::create_post_snapshot(DBus::Connection& conn, DBus::Message& msg)
     check_permission(conn, msg, *it);
 
     Snapper* snapper = it->getSnapper();
-
     Snapshots& snapshots = snapper->getSnapshots();
 
     Snapshots::iterator snap1 = snapshots.find(pre_num);
@@ -814,7 +816,6 @@ Client::delete_snapshots(DBus::Connection& conn, DBus::Message& msg)
     check_in_use(*it);
 
     Snapper* snapper = it->getSnapper();
-
     Snapshots& snapshots = snapper->getSnapshots();
 
     for (list<unsigned int>::const_iterator it = nums.begin(); it != nums.end(); ++it)
@@ -850,15 +851,19 @@ Client::mount_snapshot(DBus::Connection& conn, DBus::Message& msg)
     check_permission(conn, msg, *it);
 
     Snapper* snapper = it->getSnapper();
-
     Snapshots& snapshots = snapper->getSnapshots();
 
     Snapshots::iterator snap = snapshots.find(num);
 
     snap->mountFilesystemSnapshot();
 
+    string mount_point = snap->snapshotDir();
+
     DBus::MessageMethodReturn reply(msg);
 
+    DBus::Hoho hoho(reply);
+    hoho << mount_point;
+
     conn.send(reply);
 }
 
@@ -881,7 +886,6 @@ Client::umount_snapshot(DBus::Connection& conn, DBus::Message& msg)
     check_permission(conn, msg, *it);
 
     Snapper* snapper = it->getSnapper();
-
     Snapshots& snapshots = snapper->getSnapshots();
 
     Snapshots::iterator snap = snapshots.find(num);
@@ -894,6 +898,38 @@ Client::umount_snapshot(DBus::Connection& conn, DBus::Message& msg)
 }
 
 
+void
+Client::get_mount_point(DBus::Connection& conn, DBus::Message& msg)
+{
+    string config_name;
+    dbus_uint32_t num;
+
+    DBus::Hihi hihi(msg);
+    hihi >> config_name >> num;
+
+    y2deb("GetMountPoint config_name:" << config_name << " num:" << num);
+
+    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();
+    Snapshots::iterator snap = snapshots.find(num);
+
+    string mount_point = snap->snapshotDir();
+
+    DBus::MessageMethodReturn reply(msg);
+
+    DBus::Hoho hoho(reply);
+    hoho << mount_point;
+
+    conn.send(reply);
+}
+
+
 void
 Client::create_comparison(DBus::Connection& conn, DBus::Message& msg)
 {
@@ -1258,6 +1294,8 @@ Client::dispatch(DBus::Connection& conn, DBus::Message& msg)
            mount_snapshot(conn, msg);
        else if (msg.is_method_call(INTERFACE, "UmountSnapshot"))
            umount_snapshot(conn, msg);
+       else if (msg.is_method_call(INTERFACE, "GetMountPoint"))
+           get_mount_point(conn, msg);
        else if (msg.is_method_call(INTERFACE, "CreateComparison"))
            create_comparison(conn, msg);
        else if (msg.is_method_call(INTERFACE, "DeleteComparison"))
index 143627c294155aaaced0ec571c6b15f2323385c4..2a9cc6fcb4611adecb25153d6828d19e156c2f56 100644 (file)
@@ -94,6 +94,7 @@ public:
     void delete_snapshots(DBus::Connection& conn, DBus::Message& msg);
     void mount_snapshot(DBus::Connection& conn, DBus::Message& msg);
     void umount_snapshot(DBus::Connection& conn, DBus::Message& msg);
+    void get_mount_point(DBus::Connection& conn, DBus::Message& msg);
     void create_comparison(DBus::Connection& conn, DBus::Message& msg);
     void delete_comparison(DBus::Connection& conn, DBus::Message& msg);
     void get_files(DBus::Connection& conn, DBus::Message& msg);