source: SMSSender/frontend/business/contactimporter/oauth2_p.h @ 406:f628b34f038d

Last change on this file since 406:f628b34f038d was 406:f628b34f038d, checked in by Sämy Zehnder <saemy.zehnder@…>, 6 years ago
  • Adds missing line in include guard.
File size: 2.5 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#ifndef FRONTEND_CONTACTIMPORTER_OAUTH2_P_H
19#define FRONTEND_CONTACTIMPORTER_OAUTH2_P_H
20
21#include <QScopedPointer>
22#include <QString>
23#include <QTcpServer>
24
25#include "common/network/snetworkhelper.h"
26#include "frontend/business/contactimporter/oauth2.h"
27
28namespace OAuth2 {
29
30class RequestAccessTokenHandler : public QObject {
31    Q_OBJECT
32
33public:
34    RequestAccessTokenHandler(
35            const QString &clientId, const QString &clientSecret,
36            const QString &accountId, const QSet<QString> &scopes,
37            const AuthorizationFlow::UrlToUserCallback &callback);
38    void request();
39
40signals:
41    void tokenReply(const QSet<QString> &scopes, const QString &reply);
42
43private slots:
44    void onNewTcpConnection();
45    void onRequestTokenFinished();
46
47private:
48    void emitError(const QString &error);
49    void writeReply(QTcpSocket &socket, const QString &message) const;
50
51    const QString m_clientId;
52    const QString m_clientSecret;
53    const QString m_accountId;
54    const QSet<QString> m_scopes;
55    const AuthorizationFlow::UrlToUserCallback m_callback;
56
57    QScopedPointer<SNetworkHelper> m_http;
58    QScopedPointer<QTcpServer> m_tcpServer;
59};
60
61class RefreshAccessTokenHandler : public QObject {
62    Q_OBJECT
63
64public:
65    RefreshAccessTokenHandler(const QString &clientId,
66                              const QString &clientSecret,
67                              const QString &refreshToken);
68    void refresh();
69
70signals:
71    void tokenReply(const QString &reply);
72
73private slots:
74    void onRefreshTokenFinished();
75
76private:
77    const QString m_clientId;
78    const QString m_clientSecret;
79    const QString m_refreshToken;
80
81    QScopedPointer<SNetworkHelper> m_http;
82};
83
84} // namespce OAuth2
85
86#endif // FRONTEND_CONTACTIMPORTER_OAUTH2_P_H
Note: See TracBrowser for help on using the repository browser.