RepoInfoBase::label added
authorJán Kupec <jkupec@suse.cz>
Thu, 10 Dec 2009 16:13:14 +0000 (17:13 +0100)
committerJán Kupec <jkupec@suse.cz>
Thu, 10 Dec 2009 16:13:14 +0000 (17:13 +0100)
- should be used in UI messages instead of name() to allow
  apps to choose between alias and name (or other info in the
  future) via ZConfig::repoLabelIsAlias

VERSION.cmake
zypp/ZConfig.cc
zypp/ZConfig.h
zypp/repo/RepoInfoBase.cc
zypp/repo/RepoInfoBase.h

index bb9b3d5..97180f8 100644 (file)
@@ -60,8 +60,8 @@
 #
 SET(LIBZYPP_MAJOR "6")
 SET(LIBZYPP_COMPATMINOR "19")
-SET(LIBZYPP_MINOR "27")
-SET(LIBZYPP_PATCH "1")
+SET(LIBZYPP_MINOR "28")
+SET(LIBZYPP_PATCH "0")
 #
 # LAST RELEASED: 6.27.1 (19)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
index 136a6c1..f39e3ab 100644 (file)
@@ -216,6 +216,7 @@ namespace zypp
         , updateMessagesNotify         ( "single | /usr/lib/zypp/notify-message -p %p" )
         , repo_add_probe               ( false )
         , repo_refresh_delay           ( 10 )
+        , repoLabelIsAlias              ( false )
         , download_use_deltarpm        ( true )
         , download_use_deltarpm_always  ( false )
         , download_media_prefer_download( true )
@@ -461,6 +462,7 @@ namespace zypp
 
     bool repo_add_probe;
     unsigned repo_refresh_delay;
+    bool repoLabelIsAlias;
 
     bool download_use_deltarpm;
     bool download_use_deltarpm_always;
@@ -654,6 +656,12 @@ namespace zypp
     return _pimpl->repo_refresh_delay;
   }
 
+  bool ZConfig::repoLabelIsAlias() const
+  { return _pimpl->repoLabelIsAlias; }
+
+  void ZConfig::repoLabelIsAlias( bool yesno_r )
+  { _pimpl->repoLabelIsAlias = yesno_r; }
+
   bool ZConfig::download_use_deltarpm() const
   { return _pimpl->download_use_deltarpm; }
 
index a222594..b569a18 100644 (file)
@@ -161,6 +161,22 @@ namespace zypp
       unsigned repo_refresh_delay() const;
 
       /**
+       * Whether to use repository alias or name in user messages (progress,
+       * exceptions, ...).
+       * True: use alias, false: use name.
+       */
+      bool repoLabelIsAlias() const;
+
+      /**
+       * Whether to use repository alias or name in user messages (progress,
+       * exceptions, ...). Console applications might prefer to use and display
+       * the shorter alias instead of full repository name.
+       *
+       * Default: false; i.e. repo label is 'name'
+       */
+      void repoLabelIsAlias( bool yesno_r );
+
+      /**
        * Maximum number of concurrent connections for a single transfer
        */
       long download_max_concurrent_connections() const;
index 05e98e0..bac195b 100644 (file)
@@ -11,6 +11,7 @@
  */
 #include <iostream>
 
+#include "zypp/ZConfig.h"
 #include "zypp/repo/RepoVariables.h"
 
 #include "zypp/repo/RepoInfoBase.h"
@@ -135,6 +136,13 @@ namespace zypp
     return replacer(_pimpl->name);
   }
 
+  std::string RepoInfoBase::label() const
+  {
+    if ( ZConfig::instance().repoLabelIsAlias() )
+      return alias();
+    return name();
+  }
+
   Pathname RepoInfoBase::filepath() const
   { return _pimpl->filepath; }
 
index 27b8408..e348b87 100644 (file)
@@ -59,13 +59,19 @@ namespace zypp
       /**
        * \short Repository short label
        *
-       * Short label or description of the repository, to be used on
-       * the user interface.
+       * Short label or description of the repository.
        * ie: "SUSE Linux 10.2 updates"
        */
       std::string name() const;
 
       /**
+       * \short Label for use in messages for the user interface.
+       *
+       * Returns an alias or name, according to ZConfig::repoLabelIsAlias().
+       */
+      std::string label() const;
+
+      /**
        * If enabled is false, then this repository must be ignored as if does
        * not exists, except when checking for duplicate alias.
        */