From: Arvin Schnell Date: Wed, 11 Jul 2012 10:49:46 +0000 (+0200) Subject: - work on dbus interface X-Git-Tag: v0.1.3~211 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=223298d0e35b442cbcbe42d7fde0540ed12de3e0;p=thirdparty%2Fsnapper.git - work on dbus interface --- diff --git a/client/snapper.cc b/client/snapper.cc index 3d3bdaee..2163cf92 100644 --- a/client/snapper.cc +++ b/client/snapper.cc @@ -1019,38 +1019,6 @@ help() } -struct CompareCallbackImpl : public CompareCallback -{ - void start() { cout << _("comparing snapshots...") << flush; } - void stop() { cout << " " << _("done") << endl; } -}; - -CompareCallbackImpl compare_callback_impl; - - -struct UndoCallbackImpl : public UndoCallback -{ - void start() { cout << _("undoing change...") << endl; } - void stop() { cout << _("undoing change done") << endl; } - - void createInfo(const string& name) - { if (verbose) cout << sformat(_("creating %s"), name.c_str()) << endl; } - void modifyInfo(const string& name) - { if (verbose) cout << sformat(_("modifying %s"), name.c_str()) << endl; } - void deleteInfo(const string& name) - { if (verbose) cout << sformat(_("deleting %s"), name.c_str()) << endl; } - - void createError(const string& name) - { cerr << sformat(_("failed to create %s"), name.c_str()) << endl; } - void modifyError(const string& name) - { cerr << sformat(_("failed to modify %s"), name.c_str()) << endl; } - void deleteError(const string& name) - { cerr << sformat(_("failed to delete %s"), name.c_str()) << endl; } -}; - -UndoCallbackImpl undo_callback_impl; - - int main(int argc, char** argv) { diff --git a/dbus/DBusMessage.h b/dbus/DBusMessage.h index 0d865218..c5aa0792 100644 --- a/dbus/DBusMessage.h +++ b/dbus/DBusMessage.h @@ -113,7 +113,7 @@ namespace DBus public: MessageMethodCall(const char* service, const char* object, const char* interface, - const char* method) + const char* method) : Message(dbus_message_new_method_call(service, object, interface, method)) { } diff --git a/snapper/File.cc b/snapper/File.cc index bd8317b5..b841c3fe 100644 --- a/snapper/File.cc +++ b/snapper/File.cc @@ -118,7 +118,7 @@ namespace snapper comparison->getSnapshot2()->getNum()); if (getSnapper()->getCompareCallback()) - getSnapper()->getCompareCallback()->start(); + getSnapper()->getCompareCallback()->start(comparison); if (!comparison->getSnapshot1()->isCurrent()) comparison->getSnapshot1()->mountFilesystemSnapshot(); @@ -137,7 +137,7 @@ namespace snapper sort(entries.begin(), entries.end()); if (getSnapper()->getCompareCallback()) - getSnapper()->getCompareCallback()->stop(); + getSnapper()->getCompareCallback()->stop(comparison); y2mil("found " << entries.size() << " lines"); } @@ -686,9 +686,9 @@ namespace snapper { switch (getAction()) { - case CREATE: getSnapper()->getUndoCallback()->createInfo(name); break; - case MODIFY: getSnapper()->getUndoCallback()->modifyInfo(name); break; - case DELETE: getSnapper()->getUndoCallback()->deleteInfo(name); break; + case CREATE: getSnapper()->getUndoCallback()->createInfo(comparison, name); break; + case MODIFY: getSnapper()->getUndoCallback()->modifyInfo(comparison, name); break; + case DELETE: getSnapper()->getUndoCallback()->deleteInfo(comparison, name); break; } } @@ -716,9 +716,9 @@ namespace snapper { switch (getAction()) { - case CREATE: getSnapper()->getUndoCallback()->createError(name); break; - case MODIFY: getSnapper()->getUndoCallback()->modifyError(name); break; - case DELETE: getSnapper()->getUndoCallback()->deleteError(name); break; + case CREATE: getSnapper()->getUndoCallback()->createError(comparison, name); break; + case MODIFY: getSnapper()->getUndoCallback()->modifyError(comparison, name); break; + case DELETE: getSnapper()->getUndoCallback()->deleteError(comparison, name); break; } } diff --git a/snapper/Snapper.h b/snapper/Snapper.h index 346d2e33..3083a304 100644 --- a/snapper/Snapper.h +++ b/snapper/Snapper.h @@ -37,6 +37,7 @@ namespace snapper class SysconfigFile; class Filesystem; + class Comparison; struct CompareCallback @@ -44,8 +45,8 @@ namespace snapper CompareCallback() {} virtual ~CompareCallback() {} - virtual void start() = 0; - virtual void stop() = 0; + virtual void start(const Comparison* comparison) = 0; + virtual void stop(const Comparison* comparison) = 0; }; @@ -57,13 +58,13 @@ namespace snapper virtual void start() = 0; virtual void stop() = 0; - virtual void createInfo(const string& name) = 0; - virtual void modifyInfo(const string& name) = 0; - virtual void deleteInfo(const string& name) = 0; + virtual void createInfo(const Comparison* comparison, const string& name) = 0; + virtual void modifyInfo(const Comparison* comparison, const string& name) = 0; + virtual void deleteInfo(const Comparison* comparison, const string& name) = 0; - virtual void createError(const string& name) = 0; - virtual void modifyError(const string& name) = 0; - virtual void deleteError(const string& name) = 0; + virtual void createError(const Comparison* comparison, const string& name) = 0; + virtual void modifyError(const Comparison* comparison, const string& name) = 0; + virtual void deleteError(const Comparison* comparison, const string& name) = 0; }; diff --git a/testsuite-real/common.cc b/testsuite-real/common.cc index a422defd..1792cf6f 100644 --- a/testsuite-real/common.cc +++ b/testsuite-real/common.cc @@ -32,8 +32,8 @@ unsigned int numCreateErrors, numModifyErrors, numDeleteErrors; struct CompareCallbackImpl : public CompareCallback { - void start() { cout << "comparing snapshots..." << flush; } - void stop() { cout << " done" << endl; } + void start(const Comparison* comparison) { cout << "comparing snapshots..." << flush; } + void stop(const Comparison* comparison) { cout << " done" << endl; } }; CompareCallbackImpl compare_callback_impl; @@ -44,13 +44,19 @@ struct UndoCallbackImpl : public UndoCallback void start() { cout << "undoing..." << endl; } void stop() { cout << "undoing done" << endl; } - void createInfo(const string& name) { cout << "creating " << name << endl; } - void modifyInfo(const string& name) { cout << "modifying " << name << endl; } - void deleteInfo(const string& name) { cout << "deleting " << name << endl; } - - void createError(const string& name) { cout << "failed to create " << name << endl; numCreateErrors++; } - void modifyError(const string& name) { cout << "failed to modify " << name << endl; numModifyErrors++; } - void deleteError(const string& name) { cout << "failed to delete " << name << endl; numDeleteErrors++; } + void createInfo(const Comparison* comparison, const string& name) + { cout << "creating " << name << endl; } + void modifyInfo(const Comparison* comparison, const string& name) + { cout << "modifying " << name << endl; } + void deleteInfo(const Comparison* comparison, const string& name) + { cout << "deleting " << name << endl; } + + void createError(const Comparison* comparison, const string& name) + { cout << "failed to create " << name << endl; numCreateErrors++; } + void modifyError(const Comparison* comparison, const string& name) + { cout << "failed to modify " << name << endl; numModifyErrors++; } + void deleteError(const Comparison* comparison, const string& name) + { cout << "failed to delete " << name << endl; numDeleteErrors++; } }; UndoCallbackImpl undo_callback_impl;