ref: refs/heads/master
commit 6e873bea145ba7a6db6b42e56462332483115db7
Author: Ján Kupec
Date: Thu Dec 10 17:13:14 2009 +0100
RepoInfoBase::label added
- 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 | 4 ++--
zypp/ZConfig.cc | 8 ++++++++
zypp/ZConfig.h | 16 ++++++++++++++++
zypp/repo/RepoInfoBase.cc | 8 ++++++++
zypp/repo/RepoInfoBase.h | 10 ++++++++--
5 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/VERSION.cmake b/VERSION.cmake
index bb9b3d5..97180f8 100644
--- a/VERSION.cmake
+++ b/VERSION.cmake
@@ -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)
diff --git a/zypp/ZConfig.cc b/zypp/ZConfig.cc
index 136a6c1..f39e3ab 100644
--- a/zypp/ZConfig.cc
+++ b/zypp/ZConfig.cc
@@ -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; }
diff --git a/zypp/ZConfig.h b/zypp/ZConfig.h
index a222594..b569a18 100644
--- a/zypp/ZConfig.h
+++ b/zypp/ZConfig.h
@@ -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;
diff --git a/zypp/repo/RepoInfoBase.cc b/zypp/repo/RepoInfoBase.cc
index 05e98e0..bac195b 100644
--- a/zypp/repo/RepoInfoBase.cc
+++ b/zypp/repo/RepoInfoBase.cc
@@ -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; }
diff --git a/zypp/repo/RepoInfoBase.h b/zypp/repo/RepoInfoBase.h
index 27b8408..e348b87 100644
--- a/zypp/repo/RepoInfoBase.h
+++ b/zypp/repo/RepoInfoBase.h
@@ -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.
*/
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org