1 /* pinentrydialog.h - A secure KDE dialog for PIN entry.
2  * Copyright (C) 2002 Klarälvdalens Datakonsult AB
3  * Written by Steffen Hansen <steffen@klaralvdalens-datakonsult.se>.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, see <https://www.gnu.org/licenses/>.
17  * SPDX-License-Identifier: GPL-2.0+
18  */
19 
20 #ifndef __PINENTRYDIALOG_H__
21 #define __PINENTRYDIALOG_H__
22 
23 #include <ntqdialog.h>
24 #include "pinentry.h"
25 
26 class TQLabel;
27 class TQPushButton;
28 class TQProgressBar;
29 class SecTQLineEdit;
30 class SecTQString;
31 
32 class PinEntryDialog : public TQDialog {
33   TQ_OBJECT
34 
35   TQ_PROPERTY( TQString description READ description WRITE setDescription )
36   TQ_PROPERTY( TQString error READ error WRITE setError )
37     //  TQ_PROPERTY( SecTQString text READ text WRITE setText )
38   TQ_PROPERTY( TQString prompt READ prompt WRITE setPrompt )
39 public:
40   friend class PinEntryController; // TODO: remove when assuan lets me use TQt eventloop.
41   PinEntryDialog( TQWidget* parent = 0, const char* name = 0,
42                   bool modal = false, bool enable_quality_bar = false );
43 
44   void setDescription( const TQString& );
45   TQString description() const;
46 
47   void setError( const TQString& );
48   TQString error() const;
49 
50   void setText( const SecTQString& );
51   SecTQString text() const;
52 
53   void setPrompt( const TQString& );
54   TQString prompt() const;
55 
56   void setOkText( const TQString& );
57   void setCancelText( const TQString& );
58 
59   void setQualityBar( const TQString& );
60   void setQualityBarTT( const TQString& );
61 
62   void setPinentryInfo (pinentry_t);
63 
64 public slots:
65   void updateQuality(const SecTQString &);
66   void onBackspace();
67 
68 signals:
69   void accepted();
70   void rejected();
71 
72 protected:
73   virtual void keyPressEvent( TQKeyEvent *e );
74   virtual void hideEvent( TQHideEvent* );
75   virtual void paintEvent( TQPaintEvent* );
76 
77 private:
78   TQLabel*    _icon;
79   TQLabel*    _desc;
80   TQLabel*    _error;
81   TQLabel*    _prompt;
82   TQLabel*    _quality_bar_label;
83   TQProgressBar* _quality_bar;
84   SecTQLineEdit* _edit;
85   TQPushButton* _ok;
86   TQPushButton* _cancel;
87   bool       _grabbed;
88   bool       _have_quality_bar;
89   pinentry_t _pinentry_info;
90   bool       _disable_echo_allowed;
91 };
92 
93 
94 #endif // __PINENTRYDIALOG_H__
95