~renatofilho/buteo-sync-plugins-contacts/solve-eds-conflict

« back to all changes in this revision

Viewing changes to google/GTransport.h

  • Committer: CI Train Bot
  • Author(s): Renato Araujo Oliveira Filho
  • Date: 2015-09-24 17:50:44 UTC
  • mfrom: (1.3.53 initial-vr)
  • Revision ID: ci-train-bot@canonical.com-20150924175044-rp0akjs0h1xwxmpj
Implemented buteo contacts sync plugin for google, heavily based on:
  - https://github.com/nemomobile-graveyard/buteo-sync-plugins-google
  - https://github.com/nemomobile/buteo-sync-plugins-social
Approved by: Michael Sheldon

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of buteo-gcontact-plugin package
 
3
 *
 
4
 * Copyright (C) 2013 Jolla Ltd. and/or its subsidiary(-ies).
 
5
 *               2015 Canonical Ltd.
 
6
 *
 
7
 * Contributors: Sateesh Kavuri <sateesh.kavuri@gmail.com>
 
8
 *               Renato Araujo Oliveira Filho <renato.filho@canonical.com>
 
9
 *
 
10
 * This library is free software; you can redistribute it and/or
 
11
 * modify it under the terms of the GNU Lesser General Public License
 
12
 * version 2.1 as published by the Free Software Foundation.
 
13
 *
 
14
 * This library is distributed in the hope that it will be useful, but
 
15
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
17
 * Lesser General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU Lesser General Public
 
20
 * License along with this library; if not, write to the Free Software
 
21
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 
22
 * 02110-1301 USA
 
23
 *
 
24
 */
 
25
 
 
26
#ifndef GTRANSPORT_H
 
27
#define GTRANSPORT_H
 
28
 
 
29
#include <QObject>
 
30
#include <QList>
 
31
#include <QDateTime>
 
32
#include <QPair>
 
33
#include <QUrl>
 
34
#include <QNetworkAccessManager>
 
35
#include <QNetworkRequest>
 
36
#include <QNetworkReply>
 
37
 
 
38
class GTransportPrivate;
 
39
class GTransport : public QObject
 
40
{
 
41
    Q_OBJECT
 
42
    Q_DECLARE_PRIVATE(GTransport)
 
43
public:
 
44
 
 
45
    typedef enum {
 
46
        GET,
 
47
        POST,
 
48
        DELETE,
 
49
        PUT,
 
50
        HEAD
 
51
    } HTTP_REQUEST_TYPE;
 
52
 
 
53
    explicit GTransport(QObject *parent = 0);
 
54
    GTransport (QUrl url, QList<QPair<QByteArray, QByteArray> > headers);
 
55
    GTransport (QUrl url, QList<QPair<QByteArray, QByteArray> > headers, QByteArray data);
 
56
 
 
57
    virtual ~GTransport();
 
58
 
 
59
    void setUrl(const QString &url);
 
60
    void setData(QByteArray data);
 
61
    void setHeaders();
 
62
    void addHeader(const QByteArray first, const QByteArray second);
 
63
    void setAuthToken(const QString token);
 
64
    void setGDataVersionHeader();
 
65
    void setProxy(QString proxyHost, QString proxyPort);
 
66
    void request(const HTTP_REQUEST_TYPE type);
 
67
    bool hasReply() const;
 
68
    const QByteArray replyBody() const;
 
69
    void setUpdatedMin(const QDateTime datetime);
 
70
    void setMaxResults(unsigned int limit);
 
71
    void setShowDeleted();
 
72
    void setGroupFilter(const QString &account, const QString &groupId);
 
73
    bool showDeleted() const;
 
74
    void setStartIndex(const int index);
 
75
    HTTP_REQUEST_TYPE requestType();
 
76
    void reset();
 
77
 
 
78
    typedef enum
 
79
    {
 
80
        HTTP_OK = 200,
 
81
        HTTP_CONTACT_CREATED = 201,
 
82
        HTTP_PRECONDITION_FAILED = 412
 
83
    } RESPONSE_CODE;
 
84
 
 
85
    static const QString GDATA_VERSION_HEADER;
 
86
 
 
87
signals:
 
88
    void finishedRequest();
 
89
    void error(int errorCode);
 
90
 
 
91
    // used by tests
 
92
    void requested(const QUrl &url, QByteArray *result);
 
93
 
 
94
private slots:
 
95
    virtual void finishedSlot(QNetworkReply* reply);
 
96
    virtual void readyRead();
 
97
 
 
98
private:
 
99
    QScopedPointer<GTransportPrivate> d_ptr;
 
100
 
 
101
};
 
102
 
 
103
#endif // GTRANSPORT_H