]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- work on dbus interface
authorArvin Schnell <aschnell@suse.de>
Tue, 17 Jul 2012 09:59:35 +0000 (11:59 +0200)
committerArvin Schnell <aschnell@suse.de>
Tue, 17 Jul 2012 09:59:35 +0000 (11:59 +0200)
client/commands.cc
client/commands.h
client/snapper.cc
server/snapperd.cc

index 99df195e10c5c571a60c17c320f824742b1cd1f5..0583a5e1ff04dd883bb4c76297935ff931f47c3c 100644 (file)
@@ -358,3 +358,19 @@ command_do_xundo_step(DBus::Connection& conn, const string& config_name, unsigne
 
     return ret;
 }
+
+
+vector<string>
+command_xdebug(DBus::Connection& conn)
+{
+    DBus::MessageMethodCall call(SERVICE, OBJECT, INTERFACE, "Debug");
+
+    DBus::Message reply = conn.send_and_reply_and_block(call);
+
+    vector<string> lines;
+
+    DBus::Hihi hihi(reply);
+    hihi >> lines;
+
+    return lines;
+}
index 0a0b75b5968b75bc6d92911ca8ef4d87dc646f72..b73560f0abacc3d3924a599c8e302af7b18d3f8e 100644 (file)
@@ -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<string>
+command_xdebug(DBus::Connection& conn);
index 6b94633a273bd080c48fd7e37c65c3c12c04580d..4c057a8e3eca4cd9459971f8e29c0f5034d5afb9 100644 (file)
@@ -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<string> lines = command_xdebug(conn);
+    for (vector<string>::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' },
index b8f4346cf178298b6587a93439316ab869f72213..d3b3758e34488f068e02a55b18dd17d2a58a2eb4 100644 (file)
@@ -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<Client>::iterator it = clients.begin(); it != clients.end(); ++it)
+    for (list<Client>::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<Snapper*>::iterator it = snappers.begin(); it != snappers.end(); ++it)
+    for (list<Snapper*>::const_iterator it = snappers.begin(); it != snappers.end(); ++it)
     {
        std::ostringstream s;
        s << "    name:'" << (*it)->configName() << "'";