aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-07-14 08:12:47 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-07-14 03:35:25 +0100
commit8a4a6b294bbf57e5ea37a5735085fb9a54d212a3 (patch)
treee7288483489bdf1af72eb93c06de9bdb193a0d7a
parentc0b1927d236cd0aa2dfe9d69d2129af17f2c821d (diff)
downloadpaludis-8a4a6b294bbf57e5ea37a5735085fb9a54d212a3.tar.gz
paludis-8a4a6b294bbf57e5ea37a5735085fb9a54d212a3.tar.xz
Show notifications for inquisitio
-rw-r--r--src/clients/inquisitio/do_search.cc46
-rw-r--r--src/clients/inquisitio/do_search.hh4
2 files changed, 47 insertions, 3 deletions
diff --git a/src/clients/inquisitio/do_search.cc b/src/clients/inquisitio/do_search.cc
index f9bc679..47b7d2a 100644
--- a/src/clients/inquisitio/do_search.cc
+++ b/src/clients/inquisitio/do_search.cc
@@ -30,6 +30,7 @@
#include <paludis/action.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/notifier_callback.hh>
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/make_shared_ptr.hh>
@@ -49,6 +50,43 @@ using namespace inquisitio;
namespace
{
+ struct DisplayCallback
+ {
+ mutable Mutex mutex;
+ mutable bool done_header;
+
+ DisplayCallback() :
+ done_header(false)
+ {
+ }
+
+ void operator() (const NotifierCallbackEvent & event) const
+ {
+ event.accept(*this);
+ }
+
+ void visit(const NotifierCallbackGeneratingMetadataEvent &) const
+ {
+ Lock lock(mutex);
+ if (! done_header)
+ {
+ std::cout << "Generating metadata (no cache available): ";
+ done_header = true;
+ }
+ std::cout << "*" << std::flush;
+ }
+
+ void visit(const NotifierCallbackResolverStepEvent &) const
+ {
+ }
+
+ void done()
+ {
+ if (done_header)
+ std::cout << std::endl;
+ }
+ };
+
struct Eligible
{
typedef bool result;
@@ -188,10 +226,13 @@ namespace
}
int
-do_search(const Environment & env)
+do_search(Environment & env)
{
using namespace std::tr1::placeholders;
+ DisplayCallback display_callback;
+ ScopedNotifierCallback display_callback_holder(&env, NotifierCallbackFunction(std::tr1::cref(display_callback)));
+
if (CommandLine::get_instance()->a_repository.specified() &&
! CommandLine::get_instance()->a_kind.specified())
CommandLine::get_instance()->a_kind.set_argument("all");
@@ -302,6 +343,9 @@ do_search(const Environment & env)
CommandLine::get_instance()->a_not.specified()),
n_threads, 10);
+ display_callback_holder.remove_now();
+ display_callback.done();
+
bool any(false);
InquisitioQueryTask task(&env);
for (std::map<QualifiedPackageName, std::tr1::shared_ptr<const PackageID> >::const_iterator
diff --git a/src/clients/inquisitio/do_search.hh b/src/clients/inquisitio/do_search.hh
index 08bf075..f2c6631 100644
--- a/src/clients/inquisitio/do_search.hh
+++ b/src/clients/inquisitio/do_search.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -25,6 +25,6 @@ namespace paludis
class Environment;
}
-int do_search(const paludis::Environment & env);
+int do_search(paludis::Environment & env);
#endif