From: Arvin Schnell Date: Mon, 6 Aug 2012 11:46:24 +0000 (+0200) Subject: - work on dbus interface X-Git-Tag: v0.1.3~165 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=cfd4a5132145e91314f239be88a45daee47d331a;p=thirdparty%2Fsnapper.git - work on dbus interface --- diff --git a/client/commands.cc b/client/commands.cc index 20173267..174abe58 100644 --- a/client/commands.cc +++ b/client/commands.cc @@ -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) diff --git a/client/commands.h b/client/commands.h index b73560f0..ad5b55c6 100644 --- a/client/commands.h +++ b/client/commands.h @@ -75,7 +75,7 @@ void command_delete_xsnapshots(DBus::Connection& conn, const string& config_name, list 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); diff --git a/server/Client.cc b/server/Client.cc index 3d5f4805..2c28ac8d 100644 --- a/server/Client.cc +++ b/server/Client.cc @@ -234,6 +234,11 @@ Client::introspect(DBus::Connection& conn, DBus::Message& msg) " \n" " \n" + " \n" + " \n" + " \n" + " \n" + " \n" " \n" " \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::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 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")) diff --git a/server/Client.h b/server/Client.h index 143627c2..2a9cc6fc 100644 --- a/server/Client.h +++ b/server/Client.h @@ -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);