QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscredentials.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscredentials.h - interface for requesting credentials
3  ----------------------
4  begin : Feburary 2010
5  copyright : (C) 2010 by Juergen E. Fischer
6  email : jef at norbit dot de
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 
17 #ifndef QGSCREDENTIALS_H
18 #define QGSCREDENTIALS_H
19 
20 #include <QString>
21 #include <QObject>
22 #include <QPair>
23 #include <QMap>
24 #include <QMutex>
25 
37 class CORE_EXPORT QgsCredentials
38 {
39  public:
41  virtual ~QgsCredentials();
42 
43  bool get( QString realm, QString &username, QString &password, QString message = QString::null );
44  void put( QString realm, QString username, QString password );
45 
47  static QgsCredentials *instance();
48 
55  void lock();
56 
61  void unlock();
62 
67  QMutex *mutex() { return &mMutex; }
68 
69  protected:
71 
73  virtual bool request( QString realm, QString &username, QString &password, QString message = QString::null ) = 0;
74 
76  void setInstance( QgsCredentials *theInstance );
77 
78  private:
79  Q_DISABLE_COPY( QgsCredentials )
80 
81 
82  QMap< QString, QPair<QString, QString> > mCredentialCache;
83 
85  static QgsCredentials *smInstance;
86 
87  QMutex mMutex;
88 };
89 
90 
98 class CORE_EXPORT QgsCredentialsConsole : public QObject, public QgsCredentials
99 {
100  Q_OBJECT
101 
102  public:
104 
105  signals:
107  void destroyed();
108 
109  protected:
110  virtual bool request( QString realm, QString &username, QString &password, QString message = QString::null );
111 };
112 
113 #endif