~ubuntu-branches/ubuntu/precise/p7zip/precise-updates

« back to all changes in this revision

Viewing changes to CPP/7zip/UI/Console/UserInputUtils.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mohammed Adnène Trojette
  • Date: 2009-02-14 20:12:27 UTC
  • mfrom: (1.1.11 upstream) (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090214201227-go63qxm9ozfdma60
Tags: 4.65~dfsg.1-1
* New upstream release.
* Remove wx2.8 Build-Depends added by mistakes (7zG is not yet
  intended to be built).
* Use dh_clean without -k.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#ifdef HAVE_GETPASS
19
19
#include <pwd.h>
20
20
#include <unistd.h>
 
21
#include "Common/MyException.h"
21
22
#endif
22
23
#endif
23
24
 
25
26
static const char kNo = 'N';
26
27
static const char kYesAll = 'A';
27
28
static const char kNoAll = 'S';
28
 
static const char kAutoRename = 'U';
 
29
static const char kAutoRenameAll = 'U';
29
30
static const char kQuit = 'Q';
30
31
 
31
32
static const char *kFirstQuestionMessage = "?\n";
32
 
static const char *kHelpQuestionMessage = 
33
 
  "(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename / (Q)uit? ";
 
33
static const char *kHelpQuestionMessage =
 
34
  "(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? ";
34
35
 
35
36
// return true if pressed Quite;
36
 
// in: anAll
37
 
// out: anAll, anYes;
38
37
 
39
38
NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
40
39
{
55
54
          return NUserAnswerMode::kYesAll;
56
55
        case kNoAll:
57
56
          return NUserAnswerMode::kNoAll;
58
 
        case kAutoRename:
59
 
          return NUserAnswerMode::kAutoRename;
 
57
        case kAutoRenameAll:
 
58
          return NUserAnswerMode::kAutoRenameAll;
60
59
        case kQuit:
61
60
          return NUserAnswerMode::kQuit;
62
61
      }
63
62
  }
64
63
}
65
64
 
66
 
UString GetPassword(CStdOutStream *outStream)
 
65
UString GetPassword(CStdOutStream *outStream,bool verify)
67
66
{
68
67
#ifdef USE_FLTK 
69
68
  const char *r = fl_password("Enter password", 0);
74
73
  (*outStream) << "\nEnter password (will not be echoed) :";
75
74
  outStream->Flush();
76
75
  AString oemPassword = getpass("");
 
76
  if (verify)
 
77
  {
 
78
    (*outStream) << "Verify password (will not be echoed) :";
 
79
    outStream->Flush();
 
80
    AString oemPassword2 = getpass("");
 
81
    if (oemPassword != oemPassword2) throw "password verification failed";
 
82
  }
77
83
#else
78
84
  (*outStream) << "\nEnter password:";
79
85
  outStream->Flush();
80
86
  AString oemPassword = g_StdIn.ScanStringUntilNewLine();
81
87
#endif
82
88
#endif /* USE_FLTK */
83
 
  return MultiByteToUnicodeString(oemPassword, CP_OEMCP); 
 
89
  return MultiByteToUnicodeString(oemPassword, CP_OEMCP);
84
90
}