passwordscfg.h
1 //------------------------------------------------------------------------------
2 // passwordscfg.h
3 //------------------------------------------------------------------------------
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
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU 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, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301, USA.
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2013 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef id1E18D75F_28FA_48A1_9CACE55638B41394
24 #define id1E18D75F_28FA_48A1_9CACE55638B41394
25 
26 #include "dptr.h"
27 
28 #include <QList>
29 #include <QSettings>
30 #include <QString>
31 #include <QStringList>
32 
33 class Ini;
34 class Server;
35 class ServerPassword;
37 
39 {
40  public:
41  static void initIni(const QString& path);
42 
43  PasswordsCfg();
44  ~PasswordsCfg();
45 
46  bool isHidingPasswords() const;
47  bool isRememberingConnectPhrase() const;
48  int maxNumberOfServersPerPassword() const;
49  void removeServerPhrase(const QString& phrase);
60  void saveServerPhrase(const QString& phrase, const Server* server,
61  const QString &type);
62  QList<ServerPassword> serverPasswords() const;
63  QStringList serverPhrases() const;
64  void setHidePasswords(bool val);
65  void setMaxNumberOfServersPerPassword(int val);
66  void setRememberConnectPhrase(bool val);
67  void setServerPasswords(const QList<ServerPassword>& val);
76  ServerPassword suggestPassword(const Server* server, const QString &type);
77 
78  private:
79  static bool serverDateDescending(ServerPasswordSummary& s1, ServerPasswordSummary& s2);
80 
81  static Ini* ini;
82  static QSettings* settings;
83 
85 
86  void cutServers(QList<ServerPassword>& passwords) const;
87  void cutStoredServers();
88  void storeServerPasswords(const QList<ServerPassword>& val);
89 };
90 
91 #endif
A representation of a server for a given game.
Definition: server.h:93
Configuration handler.
Definition: ini.h:69
void saveServerPhrase(const QString &phrase, const Server *server, const QString &type)
Stores server phrase in persistence along its use case.
ServerPassword suggestPassword(const Server *server, const QString &type)
Suggests best password basing on several criteria.