source: SMSSender/frontend/business/contactimporter/oauth2_p.h @ 405:f056fa7fe8b4

Last change on this file since 405:f056fa7fe8b4 was 405:f056fa7fe8b4, checked in by Sämy Zehnder <saemy.zehnder@…>, 6 years ago
  • Switches to OAuth2 authentication for importing contacts from Google.
File size: 2.4 KB
Line 
1/*
2 smssender - A frontend for fast and easy SMS sending over different gateways.
3 Copyright (C) 2007-2014, gorrión. See http://smssender.gorrion.ch
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (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, see <http://www.gnu.org/licenses/>.
17 */
18#define FRONTEND_CONTACTIMPORTER_OAUTH2_P_H
19
20#include <QScopedPointer>
21#include <QString>
22#include <QTcpServer>
23
24#include "common/network/snetworkhelper.h"
25#include "frontend/business/contactimporter/oauth2.h"
26
27namespace OAuth2 {
28
29class RequestAccessTokenHandler : public QObject {
30    Q_OBJECT
31
32public:
33    RequestAccessTokenHandler(
34            const QString &clientId, const QString &clientSecret,
35            const QString &accountId, const QSet<QString> &scopes,
36            const AuthorizationFlow::UrlToUserCallback &callback);
37    void request();
38
39signals:
40    void tokenReply(const QSet<QString> &scopes, const QString &reply);
41
42private slots:
43    void onNewTcpConnection();
44    void onRequestTokenFinished();
45
46private:
47    void emitError(const QString &error);
48    void writeReply(QTcpSocket &socket, const QString &message) const;
49
50    const QString m_clientId;
51    const QString m_clientSecret;
52    const QString m_accountId;
53    const QSet<QString> m_scopes;
54    const AuthorizationFlow::UrlToUserCallback m_callback;
55
56    QScopedPointer<SNetworkHelper> m_http;
57    QScopedPointer<QTcpServer> m_tcpServer;
58};
59
60class RefreshAccessTokenHandler : public QObject {
61    Q_OBJECT
62
63public:
64    RefreshAccessTokenHandler(const QString &clientId,
65                              const QString &clientSecret,
66                              const QString &refreshToken);
67    void refresh();
68
69signals:
70    void tokenReply(const QString &reply);
71
72private slots:
73    void onRefreshTokenFinished();
74
75private:
76    const QString m_clientId;
77    const QString m_clientSecret;
78    const QString m_refreshToken;
79
80    QScopedPointer<SNetworkHelper> m_http;
81};
82
83} // namespce OAuth2
84
85#endif // FRONTEND_CONTACTIMPORTER_OAUTH2_P_H
Note: See TracBrowser for help on using the repository browser.