1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/***************************************************************************
* *
* copyright (C) 2003, 2004 by Michael Buesch *
* email: mbuesch@freenet.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
/***************************************************************************
* copyright (C) 2004 by Ulf Schenk
* This file is originaly based on version 1.0.1 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#ifndef __PWMDOCUI_H
#define __PWMDOCUI_H
#include <qwidget.h>
#include <klocale.h>
/** string to display, if the pw-entry
* is locked, in place of the password.
*/
#define LOCKED_STRING PwMDocUi::string_locked()
/** The name of the "default" category */
#define DEFAULT_CATEGORY PwMDocUi::string_defaultCategory()
/** deep-lock message to display in main-view, if it's locked */
#define IS_DEEPLOCKED_SHORTMSG PwMDocUi::string_deepLockedShort()
#define IS_DEEPLOCKED_MSG PwMDocUi::string_deepLockedLong()
/** default title. Display if the doc has no title, yet */
#define DEFAULT_TITLE PwMDocUi::string_defaultTitle()
class PwMKeyCard;
class PwMDoc;
/** User-interface layer for PwMDoc.
* This class handles for example all Master-password related things (asking
* the user for the password od the chipcard) and some
* other UI-things, that PwMDoc is not allowed to
* handle. (PwMDoc is _NOT_ allowed to handle anything
* UI related.)
*/
class PwMDocUi : public QObject
{
Q_OBJECT
public:
PwMDocUi(QObject* parent = 0, const char *name = 0);
~PwMDocUi();
/** when a new view is activated, call this to
* inform the Master-password-layer about this.
*/
void setCurrentView(QWidget *view)
{ currentView = view; }
/** return the currentView pointer */
QWidget* getCurrentView()
{ return currentView; }
/** set pointer to the keycard-access object */
void setPwMKeyCard(PwMKeyCard *_keyCard)
{ keyCard = _keyCard; }
/** saves the document (with user dialog) */
bool saveDocUi(PwMDoc *doc);
/** save as (with user dialog) */
bool saveAsDocUi(PwMDoc *doc);
/** opens a new document (with user dialog) */
bool openDocUi(PwMDoc *doc,
QString filename = QString::null,
bool openDeepLocked = false);
static QString string_defaultCategory();
static QString string_locked();
static QString string_deepLockedShort();
static QString string_deepLockedLong();
static QString string_defaultTitle();
protected:
/** request the user to enter the master-password or
* to insert his chipcard.
* If forcePw is true, it will always ask for a pw
* and never for a chipcard.
*/
QString requestMpw(bool chipcard);
/** request the user to enter a new master-password of
* to create a new chipcard.
* It "chipcard" is a NULL pointer, chipcards will not be
* allowed.
*/
QString requestNewMpw(bool *chipcard);
/** request a master-pw change.(or chipcard change).
* This function asks the user and requests the pw
*/
QString requestMpwChange(const QString *currentPw, bool *chipcard);
/** informs the user, that he entered the wrong mpw.
* It opens a message-box
*/
void wrongMpwMsgBox(bool chipcard,
QString prefix = "",
QString postfix = "");
/** informs the user, that the mpw is needed, but he
* didn't enter one
*/
void noMpwMsgBox(bool chipcard,
QString prefix = "",
QString postfix = "");
/** display "feature not availavle while UID 0" msg box */
void rootAlertMsgBox();
/** display "can't deeplock, because not saved yet" msg box */
void cantDeeplock_notSavedMsgBox();
/** gpasman-export password length error */
void gpmPwLenErrMsgBox();
/** ask for saving */
int dirtyAskSave(const QString &docTitle);
private:
/** the currently active view */
QWidget *currentView;
/** pointer to the keycard-access object */
PwMKeyCard *keyCard;
};
#endif
|