- fix status of patters/patches/products
authorJan Kupec <jkupec@suse.cz>
Mon, 28 Apr 2008 14:12:49 +0000 (14:12 +0000)
committerJan Kupec <jkupec@suse.cz>
Mon, 28 Apr 2008 14:12:49 +0000 (14:12 +0000)
src/zypper-info.cc
src/zypper-search.cc
src/zypper.cc

index 23e5d73..488233a 100644 (file)
@@ -15,6 +15,8 @@
 #include "zypper-tabulator.h"
 #include "zypper-info.h"
 #include "zypper-richtext.h"
+#include "zypper-search.h"
+
 
 using namespace std;
 using namespace zypp;
@@ -205,14 +207,9 @@ atom: xv = 3.10a-1091.2
 void printPatchInfo(const Zypper & zypper, const ui::Selectable & s )
 {
   const PoolItem & pool_item = s.theObj();
-  const PoolItem & ins_pool_item = s.installedObj();
   printNVA(pool_item.resolvable());
 
-  cout << _("Status: "); // TODO debug
-  bool i = bool(ins_pool_item);
-  if (pool_item.isBroken ())
-    cout << (i ? _("broken"): _("satisfied"));
-  cout << endl;
+  cout << _("Status: ") << string_ppp_status(pool_item) << endl;
 
   Patch::constPtr patch = asKind<Patch>(pool_item.resolvable());
   cout << _("Category: ") << patch->category() << endl;
@@ -274,7 +271,6 @@ This pattern provides a graphical application and a command line tool for keepin
 void printPatternInfo(const Zypper & zypper, const ui::Selectable & s)
 {
   const PoolItem & pool_item = s.theObj();
-  const PoolItem & ins_pool_item = s.installedObj();
 
   cout << (zypper.globalOpts().is_rug_compatible ? _("Catalog: ") : _("Repository: "))
        << pool_item.resolvable()->repository().info().name() << endl;
@@ -336,8 +332,7 @@ Description:
  */
 void printProductInfo(const Zypper & zypper, const ui::Selectable & s)
 {
-  const PoolItem & pool_item = s.theObj();
-  const PoolItem & ins_pool_item = s.installedObj();
+  const PoolItem & pool_item = s.theObj(); // should be the only one
 
   cout << (zypper.globalOpts().is_rug_compatible ? _("Catalog: ") : _("Repository: "))
        << pool_item.resolvable()->repository().info().name() << endl;
@@ -346,7 +341,7 @@ void printProductInfo(const Zypper & zypper, const ui::Selectable & s)
 
   Product::constPtr product = asKind<Product>(pool_item.resolvable());
   cout << _("Category: ") << product->type() << endl;
-  cout << _("Installed: ") << (!ins_pool_item ? "No" : "Yes") << endl;
+  cout << _("Installed: ") << (pool_item.status().isSatisfied() ? "Yes" : "No") << endl;
   cout << _("Short Name: ") << product->shortName() << endl;
   cout << _("Long Name: ") << product->longName() << endl;
 
index 477d696..84a4f16 100644 (file)
@@ -42,17 +42,21 @@ string selectable_search_repo_str(const ui::Selectable & s)
 
 string string_ppp_status(const PoolItem & pi)
 {
+  // make sure this will not happen
+  if (pi.isUndetermined())
+    return _("Unknown");
+
   if (pi.isRelevant())
   {
     if (pi.isSatisfied())
-      return _("Installed");
+      return _("Installed"); //! \todo make this "Applied" instead?
     if (pi.isBroken())
       return _("Needed");
     // can this ever happen?
     return "";
   }
 
-  return _("Not Applicable");
+  return _("Not Applicable"); //! \todo make this "Not Needed" after 11.0
 }
 
 
index 11507b7..c5961fb 100644 (file)
@@ -2954,7 +2954,8 @@ void Zypper::doCommand()
     if (exitCode() != ZYPPER_EXIT_OK)
       return;
     load_resolvables(*this);
-    resolve(*this); // needed to compute status of PPP?
+    // needed to compute status of PPP
+    resolve(*this);
 
     printInfo(*this, kind);