source: SMSSender/frontend/business/contactimporter/googlecontactimporter_base.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.0 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_GOOGLECONTACTIMPORTER_BASE_H
19#define FRONTEND_CONTACTIMPORTER_GOOGLECONTACTIMPORTER_BASE_H
20
21#include <QScopedPointer>
22
23#include "common/business/icontactimporter.h"
24#include "common/network/snetworkhelper.h"
25#include "frontend/business/contactimporter/oauth2.h"
26
27class BaseGoogleContactImporter : public IContactImporter {
28    Q_INTERFACES(IContactImporter)
29
30public:
31    explicit BaseGoogleContactImporter(const OAuth2::AccessToken &accessToken);
32
33public: /* IContactImporter */
34    void importContacts(QSet<SContact*> *contacts);
35
36    class Builder : public IContactImporter::Builder {
37    public:
38        QString description() const;
39        bool isApplicable() const;
40
41        void init();
42        void createImporters(QSet<IContactImporter *> *importers);
43
44    protected:
45        OAuth2::AccessToken m_accessToken;
46    };
47
48protected:
49    virtual void parseEntry(const QString &entry, SContact *contact);
50    SNetworkHelper *httpHelper();
51
52private:
53    void requestAuthToken();
54    void parseContactsFeed(const QString &feed, QSet<SContact *> *contacts);
55
56private:
57    OAuth2::AccessToken m_accessToken;
58    SNetworkHelper m_httpHelper;
59};
60
61#endif /* FRONTEND_CONTACTIMPORTER_GOOGLECONTACTIMPORTER_BASE_H */
Note: See TracBrowser for help on using the repository browser.