1 /*
2  * Copyright (C) 2011 Daniele E. Domenichelli <daniele.domenichelli@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18 
19 #ifndef X_TELEPATHY_PASSWORD_AUTH_OPERATION_H
20 #define X_TELEPATHY_PASSWORD_AUTH_OPERATION_H
21 
22 #include <TelepathyQt/PendingOperation>
23 #include <TelepathyQt/Types>
24 #include "x-telepathy-password-prompt.h"
25 
26 #include <KConfigGroup>
27 #include <KSharedConfig>
28 
29 class XTelepathyPasswordAuthOperation : public Tp::PendingOperation
30 {
31     Q_OBJECT
32     Q_DISABLE_COPY(XTelepathyPasswordAuthOperation)
33 
34 public:
35     explicit XTelepathyPasswordAuthOperation(
36             const Tp::AccountPtr &account,
37             int accountStorageId,
38             Tp::Client::ChannelInterfaceSASLAuthenticationInterface *saslIface,
39             bool canTryAgain);
40     ~XTelepathyPasswordAuthOperation();
41 
42 private Q_SLOTS:
43     void onSASLStatusChanged(uint status, const QString &reason, const QVariantMap &details);
44     void onDialogFinished(int result);
45 
46 private:
47     void promptUser();
48     void storeCredentials(const QString &secret);
49 
50     Tp::AccountPtr m_account;
51     Tp::Client::ChannelInterfaceSASLAuthenticationInterface *m_saslIface;
52     KSharedConfigPtr m_config;
53     KConfigGroup m_lastLoginFailedConfig;
54     int m_accountStorageId;
55     bool m_canTryAgain;
56     bool m_canFinish;
57     QPointer<XTelepathyPasswordPrompt> m_dialog;
58 
59     friend class SaslAuthOp;
60 };
61 
62 
63 #endif // X_TELEPATHY_PASSWORD_AUTH_OPERATION_H
64