QXmpp  Version:0.9.1
QXmppPasswordChecker.h
1 /*
2  * Copyright (C) 2008-2014 The QXmpp developers
3  *
4  * Author:
5  * Jeremy LainĂ©
6  *
7  * Source:
8  * https://github.com/qxmpp-project/qxmpp
9  *
10  * This file is a part of QXmpp library.
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  */
23 
24 #ifndef QXMPPPASSWORDCHECKER_H
25 #define QXMPPPASSWORDCHECKER_H
26 
27 #include <QObject>
28 
29 #include "QXmppGlobal.h"
30 
33 class QXMPP_EXPORT QXmppPasswordRequest
34 {
35 public:
37  enum Type {
38  CheckPassword = 0
39  };
40 
41  QString domain() const;
42  void setDomain(const QString &domain);
43 
44  QString password() const;
45  void setPassword(const QString &password);
46 
47  QString username() const;
48  void setUsername(const QString &username);
49 
50 private:
51  QString m_domain;
52  QString m_password;
53  QString m_username;
54 };
55 
58 class QXMPP_EXPORT QXmppPasswordReply : public QObject
59 {
60  Q_OBJECT
61 
62 public:
64  enum Error {
65  NoError = 0,
66  AuthorizationError,
67  TemporaryError
68  };
69 
70  QXmppPasswordReply(QObject *parent = 0);
71 
72  QByteArray digest() const;
73  void setDigest(const QByteArray &digest);
74 
75  QString password() const;
76  void setPassword(const QString &password);
77 
78  QXmppPasswordReply::Error error() const;
79  void setError(QXmppPasswordReply::Error error);
80 
81  bool isFinished() const;
82 
83 public slots:
84  void finish();
85  void finishLater();
86 
87 signals:
89  void finished();
90 
91 private:
92  QByteArray m_digest;
93  QString m_password;
95  bool m_isFinished;
96 };
97 
100 
101 class QXMPP_EXPORT QXmppPasswordChecker
102 {
103 public:
104  virtual QXmppPasswordReply *checkPassword(const QXmppPasswordRequest &request);
105  virtual QXmppPasswordReply *getDigest(const QXmppPasswordRequest &request);
106  virtual bool hasGetPassword() const;
107 
108 protected:
109  virtual QXmppPasswordReply::Error getPassword(const QXmppPasswordRequest &request, QString &password);
110 };
111 
112 #endif
The QXmppPasswordChecker class represents an abstract password checker.
Definition: QXmppPasswordChecker.h:101
Error
This enum is used to describe authentication errors.
Definition: QXmppPasswordChecker.h:64
The QXmppPasswordReply class represents a password reply.
Definition: QXmppPasswordChecker.h:58
The QXmppPasswordRequest class represents a password request.
Definition: QXmppPasswordChecker.h:33
Type
This enum is used to describe request types.
Definition: QXmppPasswordChecker.h:37