]> vaikene.ee Git - evaf/blob - src/apps/PswGen/Generator/generator.h
3c3096fcd5a8f8d8ad438416df17bd7ac5789812
[evaf] / src / apps / PswGen / Generator / generator.h
1 /**
2 * @file PswGen/Generator/generator.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_GENERATOR_H
21 # define __PSWGEN_GENERATOR_GENERATOR_H
22
23 #include "igenerator.h"
24
25 #include <Plugins/iPlugin>
26
27 #include <QObject>
28
29 namespace eVaf {
30 namespace PswGen {
31
32 /// Module that generates strong passwords using cryptographic methods
33 namespace Generator {
34
35 /// Internal implementation of the Generator module
36 namespace Internal {
37
38 /**
39 * iGenerator interface implementation.
40 *
41 * Implements the iGenerator interface using MD5 cryptographic hashes.
42 */
43
44 class GeneratorImpl : public iGenerator
45 {
46 Q_OBJECT
47
48 public:
49
50 GeneratorImpl();
51
52 virtual ~GeneratorImpl();
53
54 bool init();
55
56 void done();
57
58 virtual QString generatePassword(char const * const name, char const * const masterPassword, int length = iGenerator::DEFAULT_LENGTH, uint flags = 0);
59
60 virtual int maxLength() const { return 24; }
61
62 };
63
64 } // namespace eVaf::PswGen::Generator::Internal
65
66 /**
67 * Module implementing the iGenerator interface.
68 */
69 class Module : public Plugins::iPlugin
70 {
71 Q_OBJECT
72
73 public:
74
75 Module();
76
77 virtual ~Module();
78
79 virtual bool init(const QString & args);
80
81 virtual void done();
82
83 virtual bool isReady() const { return mReady; }
84
85
86 private: // Members
87
88 /// Flag indicating that the module is ready
89 bool mReady;
90
91 /// iGenerator interface instance
92 Internal::GeneratorImpl * mGenerator;
93
94 };
95
96
97 } // namespace eVaf::PswGen::Generator
98 } // namespace eVaf::PswGen
99 } // namespace eVaf
100
101 #endif // generator.h