]> vaikene.ee Git - evaf/blob - src/apps/PswGen/Generator/module.h
Modified the PswGen application to follow the tutorial.
[evaf] / src / apps / PswGen / Generator / module.h
1 /**
2 * @file PswGen/Generator/module.h
3 * @brief Implementation of the iGenerator interface
4 * @author Enar Vaikene
5 *
6 * Copyright (c) 2011 Enar Vaikene
7 *
8 * This file is part of the eVaf C++ cross-platform application development framework.
9 *
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
15 *
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
18 */
19
20 #ifndef __PSWGEN_GENERATOR_MODULE_H
21 # define __PSWGEN_GENERATOR_MODULE_H
22
23 #include "igenerator.h"
24
25 #include <Plugins/iPlugin>
26
27 #include <QObject>
28 #include <QString>
29
30 namespace eVaf {
31 namespace PswGen {
32
33 /// Module that generates strong passwords using cryptographic methods
34 namespace Generator {
35
36 /// Internal implementation of the Generator module
37 namespace Internal {
38 class GeneratorImpl;
39 } // namespace eVaf::PswGen::Generator::Internal
40
41 /**
42 * Module implementing the iGenerator interface.
43 */
44 class Module : public Plugins::iPlugin
45 {
46 Q_OBJECT
47
48 public:
49
50 Module();
51
52 virtual ~Module();
53
54 virtual bool init(QString const & args);
55
56 virtual void done();
57
58 virtual bool isReady() const { return true; }
59
60
61 private: // Members
62
63 /// iGenerator interface instance
64 Internal::GeneratorImpl * mGenerator;
65
66 };
67
68
69 namespace Internal {
70
71 /**
72 * iGenerator interface implementation.
73 *
74 * Implements the iGenerator interface using MD5 cryptographic hashes.
75 */
76
77 class GeneratorImpl : public iGenerator
78 {
79 Q_OBJECT
80
81 public:
82
83 GeneratorImpl();
84
85 virtual ~GeneratorImpl();
86
87 virtual QString generatePassword(QString const & name, QString const & masterPassword, int length, uint flags = 0) const;
88
89 virtual int maxLength() const { return 24; }
90
91 };
92
93 } // namespace eVaf::PswGen::Generator::Internal
94
95
96 } // namespace eVaf::PswGen::Generator
97 } // namespace eVaf::PswGen
98 } // namespace eVaf
99
100 #endif // module.h