From: Arvin Schnell Date: Tue, 17 Jul 2012 09:59:35 +0000 (+0200) Subject: - work on dbus interface X-Git-Tag: v0.1.3~208 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=fdb15b67643aa866b910f17155d31c984657dc65;p=thirdparty%2Fsnapper.git - work on dbus interface --- diff --git a/client/commands.cc b/client/commands.cc index 99df195e..0583a5e1 100644 --- a/client/commands.cc +++ b/client/commands.cc @@ -358,3 +358,19 @@ command_do_xundo_step(DBus::Connection& conn, const string& config_name, unsigne return ret; } + + +vector +command_xdebug(DBus::Connection& conn) +{ + DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "Debug"); + + DBus::Message reply = conn.send_and_reply_and_block(call); + + vector lines; + + DBus::Hihi hihi(reply); + hihi >> lines; + + return lines; +} diff --git a/client/commands.h b/client/commands.h index 0a0b75b5..b73560f0 100644 --- a/client/commands.h +++ b/client/commands.h @@ -110,3 +110,6 @@ command_get_xundo_steps(DBus::Connection& conn, const string& config_name, unsig bool command_do_xundo_step(DBus::Connection& conn, const string& config_name, unsigned int number1, unsigned int number2, const XUndoStep& undo_step); + +vector +command_xdebug(DBus::Connection& conn); diff --git a/client/snapper.cc b/client/snapper.cc index 6b94633a..4c057a8e 100644 --- a/client/snapper.cc +++ b/client/snapper.cc @@ -1031,6 +1031,22 @@ command_cleanup(DBus::Connection& conn) } +void +command_debug(DBus::Connection& conn) +{ + getopts.parse("debug", GetOpts::no_options); + if (getopts.hasArgs()) + { + cerr << _("Command 'debug' does not take arguments.") << endl; + exit(EXIT_FAILURE); + } + + vector lines = command_xdebug(conn); + for (vector::const_iterator it = lines.begin(); it != lines.end(); ++it) + cout << *it << endl; +} + + void help() { @@ -1088,6 +1104,7 @@ main(int argc, char** argv) cmds["diff"] = command_diff; cmds["undochange"] = command_undo; cmds["cleanup"] = command_cleanup; + cmds["debug"] = command_debug; const struct option options[] = { { "quiet", no_argument, 0, 'q' }, diff --git a/server/snapperd.cc b/server/snapperd.cc index b8f4346c..d3b3758e 100644 --- a/server/snapperd.cc +++ b/server/snapperd.cc @@ -1102,7 +1102,7 @@ Undoing::done() void reply_to_command_debug(DBus::Connection& conn, DBus::Message& msg) { - // check_permission(conn, msg); + check_permission(conn, msg); DBus::MessageMethodReturn reply(msg); @@ -1111,7 +1111,7 @@ reply_to_command_debug(DBus::Connection& conn, DBus::Message& msg) hoho.open_array("s"); hoho << "clients:"; - for (list::iterator it = clients.begin(); it != clients.end(); ++it) + for (list::const_iterator it = clients.begin(); it != clients.end(); ++it) { std::ostringstream s; s << " name:'" << it->name << "'"; @@ -1126,7 +1126,7 @@ reply_to_command_debug(DBus::Connection& conn, DBus::Message& msg) } hoho << "snappers:"; - for (list::iterator it = snappers.begin(); it != snappers.end(); ++it) + for (list::const_iterator it = snappers.begin(); it != snappers.end(); ++it) { std::ostringstream s; s << " name:'" << (*it)->configName() << "'";