Author: jkupec
Date: Mon Jul 16 17:41:49 2007
New Revision: 6031
URL: http://svn.opensuse.org/viewcvs/zypp?rev=6031&view=rev
Log:
readBoolAnswer() moved from zypper-misc to zypper-callbacks
Modified:
trunk/zypper/src/zypper-callbacks.cc
trunk/zypper/src/zypper-callbacks.h
trunk/zypper/src/zypper-keyring-callbacks.h
trunk/zypper/src/zypper-misc.cc
trunk/zypper/src/zypper-misc.h
Modified: trunk/zypper/src/zypper-callbacks.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-callbacks.cc?rev=6031&r1=6030&r2=6031&view=diff
==============================================================================
--- trunk/zypper/src/zypper-callbacks.cc (original)
+++ trunk/zypper/src/zypper-callbacks.cc Mon Jul 16 17:41:49 2007
@@ -20,6 +20,8 @@
cout_v << flush;
}
+// ----------------------------------------------------------------------------
+
void display_tick (const string& s) {
static AliveCursor cursor;
@@ -27,6 +29,8 @@
cout_v << flush;
}
+// ----------------------------------------------------------------------------
+
void display_done (const string& s) {
static AliveCursor cursor;
@@ -34,10 +38,14 @@
cout_v << flush;
}
+// ----------------------------------------------------------------------------
+
void display_done () {
cout_v << endl;
}
+// ----------------------------------------------------------------------------
+
//template<typename Action>
//Action ...
int read_action_ari (int default_action) {
@@ -82,6 +90,36 @@
return default_action;
}
+// ----------------------------------------------------------------------------
+
+// return the default value on input failure
+// TODO make this locale dependent?
+bool read_bool_with_default (bool defval) {
+ istream & stm = cin;
+
+ string c = "";
+ while (stm.good () && c != "y" && c != "Y" && c != "N" && c != "n")
+ c = zypp::str::getline (stm, zypp::str::TRIM);
+
+ if (c == "y" || c == "Y")
+ return true;
+ else if (c == "n" || c == "N")
+ return false;
+ else
+ return defval;
+}
+
+// ----------------------------------------------------------------------------
+
+// Read an answer (ynYN)
+// Defaults to 'false'
+bool readBoolAnswer()
+{
+ return read_bool_with_default (false);
+}
+
+// ----------------------------------------------------------------------------
+
string to_string (zypp::Resolvable::constPtr resolvable) {
ostringstream ss;
ss << *resolvable;
Modified: trunk/zypper/src/zypper-callbacks.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-callbacks.h?rev=6031&r1=6030&r2=6031&view=diff
==============================================================================
--- trunk/zypper/src/zypper-callbacks.h (original)
+++ trunk/zypper/src/zypper-callbacks.h Mon Jul 16 17:41:49 2007
@@ -48,5 +48,15 @@
* is ignored.
*/
int read_action_ari (int default_action = -1);
+
+/**
+ * Prompt for Yes/No answer from stdin.
+ *
+ * \todo work with default
+ * \todo non-interactive mode
+ * \todo make this localized
+ */
+bool readBoolAnswer();
+
std::string to_string (zypp::Resolvable::constPtr resolvable);
#endif
Modified: trunk/zypper/src/zypper-keyring-callbacks.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-keyring-callbacks.h?rev=6031&r1=6030&r2=6031&view=diff
==============================================================================
--- trunk/zypper/src/zypper-keyring-callbacks.h (original)
+++ trunk/zypper/src/zypper-keyring-callbacks.h Mon Jul 16 17:41:49 2007
@@ -20,7 +20,7 @@
#include
#include "AliveCursor.h"
-#include "zypper-misc.h"
+#include "zypper-callbacks.h"
///////////////////////////////////////////////////////////////////
namespace zypp {
@@ -37,7 +37,6 @@
return readBoolAnswer();
}
-#ifndef LIBZYPP_1xx
virtual bool askUserToImportKey( const PublicKey &key )
{
if ( geteuid() != 0 )
@@ -46,36 +45,25 @@
cout << CLEARLN << _("Import key ") << key.id() << _(" to trusted keyring?") << " [y/n]: " << flush;
return readBoolAnswer();
}
-#endif
-#ifdef LIBZYPP_1xx
- virtual bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id, const std::string &/*keyname*/, const std::string &/*fingerprint*/ )
-#else
virtual bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id )
-#endif
{
cout << CLEARLN << file << _(" is signed with an unknown key id: ") << id << ", " << _("continue?") << " [y/n]: " << flush;
return readBoolAnswer();
}
-#ifdef LIBZYPP_1xx
- virtual bool askUserToTrustKey( const std::string &keyid, const std::string &keyname, const std::string &fingerprint) {
-#else
- virtual bool askUserToTrustKey( const PublicKey &key ) {
+ virtual bool askUserToTrustKey( const PublicKey &key )
+ {
const std::string& keyid = key.id(), keyname = key.name(),
fingerprint = key.fingerprint();
-#endif
cout << CLEARLN << _("Do you want to trust key id ") << keyid << " " << keyname << _(" fingerprint:") << fingerprint << " ? [y/n]: " << flush;
return readBoolAnswer();
}
-#ifdef LIBZYPP_1xx
- virtual bool askUserToAcceptVerificationFailed( const std::string &file, const std::string &keyid, const std::string &keyname, const std::string &fingerprint ) {
-#else
- virtual bool askUserToAcceptVerificationFailed( const std::string &file,const PublicKey &key ) {
+ virtual bool askUserToAcceptVerificationFailed( const std::string &file,const PublicKey &key )
+ {
const std::string& keyid = key.id(), keyname = key.name(),
fingerprint = key.fingerprint();
-#endif
cout << file << _("Signature verification for ") << file
<< _(" with public key id ") << keyid << " " << keyname << _(" fingerprint:") << fingerprint << _(" failed, THIS IS RISKY!") << ". " << _("continue?") << " [y/n]: " << endl;
return readBoolAnswer(); // TODO do this with format()
Modified: trunk/zypper/src/zypper-misc.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.cc?rev=6031&r1=6030&r2=6031&view=diff
==============================================================================
--- trunk/zypper/src/zypper-misc.cc (original)
+++ trunk/zypper/src/zypper-misc.cc Mon Jul 16 17:41:49 2007
@@ -1,8 +1,6 @@
#include <fstream>
#include <sstream>
#include
-#include "zypper.h"
-#include "zypper-misc.h"
#include
#include
@@ -12,6 +10,10 @@
#include
#include
+#include "zypper.h"
+#include "zypper-misc.h"
+#include "zypper-callbacks.h"
+
using namespace zypp::detail;
using namespace std;
@@ -33,30 +35,6 @@
}
}
-// return the default value on input failure
-// TODO make this locale dependent?
-bool read_bool_with_default (bool defval) {
- istream & stm = cin;
-
- string c = "";
- while (stm.good () && c != "y" && c != "Y" && c != "N" && c != "n")
- c = zypp::str::getline (stm, zypp::str::TRIM);
-
- if (c == "y" || c == "Y")
- return true;
- else if (c == "n" || c == "N")
- return false;
- else
- return defval;
-}
-
-// Read an answer (ynYN)
-// Defaults to 'false'
-bool readBoolAnswer()
-{
- return read_bool_with_default (false);
-}
-
// converts a user-supplied kind to a zypp kind object
// returns an empty one if not recognized
ResObject::Kind string_to_kind (const string &skind)
Modified: trunk/zypper/src/zypper-misc.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.h?rev=6031&r1=6030&r2=6031&view=diff
==============================================================================
--- trunk/zypper/src/zypper-misc.h (original)
+++ trunk/zypper/src/zypper-misc.h Mon Jul 16 17:41:49 2007
@@ -21,7 +21,6 @@
*/
void cond_init_target();
-bool readBoolAnswer();
zypp::ResObject::Kind string_to_kind (const std::string &skind);
void mark_for_install( const zypp::ResObject::Kind &kind,
const std::string &name );
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org