Adding project to GIT
[froff-onlinedoc] / googledocumentservice.h
1 /*
2  *  Copyright (c) 2010 Mani Chandrasekar <maninc@gmail.com>
3  *                     Kaushal M <kshlmster@gmail.com>
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 2 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, write to the Free Software
17  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef GOOGLEDOCUMENTSERVICE_H
21 #define GOOGLEDOCUMENTSERVICE_H
22
23 #include <QObject>
24 #include <QXmlInputSource>
25 #include <QNetworkAccessManager>
26 #include <QList>
27 //#include "documentlistwindow.h"
28
29 class GoogleDocumentList;
30 class GoogleDocument;
31 class GoogleContentHandler;
32 //class DocumentListWindow;
33
34 class GoogleDocumentService : public QObject
35 {
36     Q_OBJECT
37
38 public:
39     GoogleDocumentService();
40     void clientLogin(const QString & username, const QString & password);
41     void listDocuments();
42     void prepareLists();
43     void uploadDocument(QString *filename, QString *title);
44     void downloadDocument(GoogleDocument *, QString *saveFileName);
45     bool alreadyAuthenticated() {
46         return loggedin;
47     }
48
49     QList<GoogleDocument *> documentList;
50     QList<GoogleDocument *> presentationList;
51     QList<GoogleDocument *> spreadsheetList;
52     QList<GoogleDocument *> othersList;
53
54 signals:
55     void userAuthenticated(bool success);
56     void listDone(bool);
57     void downloadDone(bool);
58     void uploadDone(bool);
59     void downloadProgress(qint64 bytesSent, qint64 bytesTotal);
60     void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
61
62 private slots:
63     void handleNetworkData(QNetworkReply *networkReply);
64
65 private:
66     QXmlSimpleReader xmlReader;
67     QXmlInputSource  xmlInput;
68     bool newInformation;
69     bool waitingForDoc;
70     bool uploadingDoc;
71     bool loggedin;
72     bool haveDocAuthToken;
73     GoogleContentHandler *gHandler;
74     QString authToken;
75     QString docAuthToken;
76     QString spreadAuthToken;
77     QString *saveFileName;
78     QString username;
79     QString password;
80     QNetworkAccessManager networkManager;
81
82     static const QString GOOGLE_DOCUMENT_URL;
83     static const QString GOOGLE_SPREADSHEET_URL;
84 };
85
86 #endif // GOOGLEDOCUMENTSERVICE_H