eVaf
module.h
Go to the documentation of this file.
1 
20 #ifndef __PSWGEN_STORAGE_MODULE_H
21 # define __PSWGEN_STORAGE_MODULE_H
22 
23 #include "istorage.h"
24 #include "version.h"
25 
26 #include <Plugins/iPlugin>
27 
28 #include <QObject>
29 #include <QString>
30 #include <QAbstractListModel>
31 #include <QMap>
32 #include <QtSql/QSqlDatabase>
33 
34 
35 namespace eVaf {
36 namespace PswGen {
37 
39 namespace Storage {
40 
42 namespace Internal {
43  class StorageImpl;
44 } // namespace eVaf::PswGen::Storage::Internal
45 
49 class Module : public Plugins::iPlugin
50 {
51  Q_OBJECT
52  Q_INTERFACES(eVaf::Plugins::iPlugin)
53  Q_PLUGIN_METADATA(IID VER_MODULE_NAME_STR)
54 
55 public:
56 
57  Module();
58 
59  virtual ~Module();
60 
61  virtual bool init(QString const & args);
62 
63  virtual void done();
64 
65  virtual bool isReady() const { return mReady; }
66 
67 
68 private: // Members
69 
71  bool mReady;
72 
74  Internal::StorageImpl * mStorage;
75 
76 };
77 
78 
79 namespace Internal {
80 
87 class StorageImpl : public QAbstractListModel, public iStorage
88 {
89  Q_OBJECT
90  Q_INTERFACES(eVaf::PswGen::iStorage)
91 
92 public:
93 
94  StorageImpl();
95 
96  virtual ~StorageImpl();
97 
98  bool init();
99 
100  void done();
101 
102  /*
103  iStorage interface
104  */
105 
106  virtual bool save(QString const & name, QExplicitlySharedDataPointer<Storage::Data> data);
107 
108  virtual QExplicitlySharedDataPointer<Storage::Data> query(QString const & name) const;
109 
110  virtual QAbstractItemModel * autoCompletionModel() { return this; }
111 
112  /*
113  QAbstractListModel methods
114  */
115 
116  virtual int rowCount(QModelIndex const & parent) const { return mData.count(); }
117 
118  virtual QVariant data(QModelIndex const & index, int role = Qt::DisplayRole) const;
119 
120 
121 private: // Members
122 
124  static char const * const DbConnectionName;
125 
127  static char const * const DbName;
128 
130  QSqlDatabase mDb;
131 
133  QMap<QString, QExplicitlySharedDataPointer<Storage::Data> > mData;
134 
135 
136 private: // Methods
137 
142  bool createTables();
143 
152  bool upgradeTables();
153 
158  bool loadData();
159 
160 };
161 
162 } // namespace eVaf::PswGen::Storage::Internal
163 
164 
165 } // namespace eVaf::PswGen::Storage
166 } // namespace eVaf::PswGen
167 } // namespace eVaf
168 
169 #endif // module.h
iStorage interface implementation.
Definition: module.h:87
Version information for eVaf modules.
bool COMMON_EXPORT init()
eVaf common library initialized
#define VER_MODULE_NAME_STR
Module/library name (shall end with \0)
Definition: version.h:38
Module implementing the iStorage interface.
Definition: module.h:49
Global eVaf namespace.
Definition: engine.h:37
Common interface for all the eVaf modules.
Definition: iplugin.h:38
Password storage interface.
Definition: istorage.h:117
Interface for password storage modules.