1 /*
2 Copyright (C) 2011-2013 Yubico AB.  All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are
6 met:
7 
8    1. Redistributions of source code must retain the above copyright
9       notice, this list of conditions and the following disclaimer.
10 
11    2. Redistributions in binary form must reproduce the above
12       copyright notice, this list of conditions and the following
13       disclaimer in the documentation and/or other materials provided
14       with the distribution.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #include "ui/helpbox.h"
30 #include "ui_helpbox.h"
31 
32 #include "common.h"
33 #include "help.h"
34 #include "yubikeylogger.h"
35 
HelpBox(QWidget * parent)36 HelpBox::HelpBox(QWidget *parent) :
37         QDialog(parent),
38         ui(new Ui::HelpBox)
39 {
40     ui->setupUi(this);
41 }
42 
~HelpBox()43 HelpBox::~HelpBox() {
44     delete ui;
45 }
46 
setHelpIndex(Help helpIndex)47 void HelpBox::setHelpIndex(Help helpIndex) {
48     QString title;
49     QString helpMsg;
50 
51     switch(helpIndex) {
52     case Help_ConfigurationSlot:
53         title = tr("Configuration Slots");
54         helpMsg = tr(HELP_CONFIG_SLOT);
55         break;
56     case Help_PublicID:
57         title = tr("Public Identity");
58         helpMsg = tr(HELP_PUBLIC_ID);
59         break;
60     case Help_PrivateID:
61         title = tr("Private Identity");
62         helpMsg = tr(HELP_PRIVATE_ID);
63         break;
64     case Help_SecretKey:
65         title = tr("Secret Key");
66         helpMsg = tr(HELP_SECRET_KEY);
67         break;
68     case Help_ParameterGeneration:
69         title = tr("Parameter Generation Scheme");
70         helpMsg = tr(HELP_PARAM_GENERATION);
71         break;
72     case Help_ConfigurationProtection:
73         title = tr("Configuration Protection");
74         helpMsg = tr(HELP_CONFIG_PROTECTION);
75         break;
76     case Help_OutputFormat:
77         title = tr("Output Format");
78         helpMsg = tr(HELP_OUTPUT_FORMAT);
79         break;
80     case Help_OutputSpeed:
81         title = tr("Output Speed Throttling");
82         helpMsg = tr(HELP_OUTPUT_SPEED);
83         break;
84     case Help_SrNoVisibility:
85         title = tr("Serial # Visibility");
86         helpMsg = tr(HELP_SR_NO_VISIBILITY);
87         break;
88     case Help_OathPublicID:
89         title = tr("OATH Token Identifier");
90         helpMsg = tr(HELP_OATH_PUBLIC_ID);
91         break;
92     case Help_HotpLen:
93         title = tr("HOTP Length");
94         helpMsg = tr(HELP_HOTP_LEN);
95         break;
96     case Help_HotpParam:
97         title = tr("HOTP Moving Factor Seed");
98         helpMsg = tr(HELP_HOTP_PARAM);
99         break;
100     case Help_StaticScanCode:
101         title = tr("Static Password Scan Code Mode");
102         helpMsg = tr(HELP_STATIC_SCAN_CODE);
103         break;
104     case Help_ChalRespYubico:
105         title = tr("Challenge-Response Yubico OTP Mode");
106         helpMsg = tr(HELP_CHALRESP_YUBICO);
107         break;
108     case Help_ChalRespHmac:
109         title = tr("Challenge-Response HMAC-SHA1 Mode");
110         helpMsg = tr(HELP_CHALRESP_HMAC);
111         break;
112     case Help_ChalRespOption:
113         title = tr("Challenge-Response Options");
114         helpMsg = tr(HELP_CHALRESP_OPTION);
115         break;
116     case Help_AllowUpdate:
117         title = tr("Allow Update");
118         helpMsg = tr(HELP_ALLOW_UPDATE_OPTION);
119         break;
120     case Help_Swap:
121         title = tr("Swap");
122         helpMsg = tr(HELP_SWAP_OPTION);
123         break;
124     case Help_ManUpdate:
125         title = tr("Manual Update");
126         helpMsg = tr(HELP_MAN_UPDATE_OPTION);
127         break;
128     case Help_LogFormat:
129         {
130             title = tr("Flexible Log Format");
131             helpMsg = tr(HELP_LOG_FORMAT);
132             QStringList names = YubiKeyLogger::getLogNames();
133             helpMsg.append(names.join(", "));
134             helpMsg.append("</p>");
135         }
136         break;
137 
138     default:
139         helpMsg = tr("");
140     }
141 
142     this->setWindowTitle(tr("Help: %1").arg(title));
143     ui->helpTxtBrowser->setText(helpMsg);
144 }
145