source: extensions/digikam_export/piwigoexport/piwigotalker.h @ 16931

Last change on this file since 16931 was 4874, checked in by fcoiffie, 15 years ago

[digikam_export] Removal of all useless and commented code

  • Temporary files are removed
  • Warnings correction
  • Selected 'thumbnail size' is stored in the configuration file
File size: 3.9 KB
Line 
1/* ============================================================
2*
3* This file is a part of kipi-plugins project
4* http://www.kipi-plugins.org
5*
6* Date        : 2010-01-07
7* Description : a plugin to export to a remote Piwigo server.
8*
9* Copyright (C) 2003-2005 by Renchi Raju <renchi dot raju at gmail dot com>
10* Copyright (C) 2006 by Colin Guthrie <kde@colin.guthr.ie>
11* Copyright (C) 2006-2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
12* Copyright (C) 2008 by Andrea Diamantini <adjam7 at gmail dot com>
13* Copyright (C) 2010 by Frederic Coiffier <frederic dot coiffier at free dot com>
14*
15* This program is free software; you can redistribute it
16* and/or modify it under the terms of the GNU General
17* Public License as published by the Free Software Foundation;
18* either version 2, or (at your option) any later version.
19*
20* This program is distributed in the hope that it will be useful,
21* but WITHOUT ANY WARRANTY; without even the implied warranty of
22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23* GNU General Public License for more details.
24*
25* ============================================================ */
26
27#ifndef PIWIGOTALKER_H
28#define PIWIGOTALKER_H
29
30// Qt includes
31
32#include <QObject>
33#include <QList>
34#include <QDateTime>
35// Debug
36#include <QTextStream>
37#include <QFile>
38
39// KDE includes
40
41#include <KUrl>
42#include <kio/job.h>
43
44namespace KIO
45{
46class Job;
47}
48
49class KUrl;
50template <class T> class QList;
51
52namespace KIPIPiwigoExportPlugin
53{
54
55class GAlbum;
56class GPhoto;
57
58class PiwigoTalker : public QObject
59{
60    Q_OBJECT
61
62public:
63
64    enum State {
65        GE_LOGIN = 0,
66        GE_LISTALBUMS,
67        GE_CHECKPHOTOEXIST,
68        GE_ADDPHOTO,
69        GE_ADDTHUMB,
70        GE_ADDPHOTOSUMMARY
71    };
72
73public:
74
75    PiwigoTalker(QWidget* parent);
76    ~PiwigoTalker();
77
78    static QString getAuthToken() {
79        return s_authToken;
80    };
81
82    bool loggedIn() const;
83
84    void login(const KUrl& url, const QString& name, const QString& passwd);
85    void listAlbums();
86    void listPhotos(const QString& albumName);
87
88    void createAlbum(const QString& parentAlbumName,
89                     const QString& albumName,
90                     const QString& albumTitle,
91                     const QString& albumCaption);
92
93    bool addPhoto(int albumId,
94                  const QString& photoPath,
95                  const QString& caption = QString(),
96                  bool  captionIsTitle = true, bool captionIsDescription = false,
97                  bool rescale = false, int maxDim = 600, int thumbDim = 128);
98
99    void cancel();
100
101Q_SIGNALS:
102
103    void signalError(const QString& msg);
104    void signalLoginFailed(const QString& msg);
105    void signalBusy(bool val);
106    void signalAlbums(const QList<GAlbum>& albumList);
107    void signalAddPhotoSucceeded();
108    void signalAddPhotoFailed(const QString& msg);
109
110private:
111
112    void parseResponseLogin(const QByteArray& data);
113    void parseResponseListAlbums(const QByteArray& data);
114    void parseResponseDoesPhotoExist(const QByteArray& data);
115    void parseResponseAddPhoto(const QByteArray& data);
116    void parseResponseAddThumbnail(const QByteArray& data);
117    void parseResponseAddPhotoSummary(const QByteArray& data);
118
119    QByteArray computeMD5Sum(const QString &filepath);
120
121private Q_SLOTS:
122
123    void slotTalkerData(KIO::Job *job, const QByteArray& data);
124    void slotResult(KJob *job);
125
126private:
127
128    QWidget*          m_parent;
129    State             m_state;
130    QString           m_cookie;
131    KUrl              m_url;
132    KIO::TransferJob* m_job;
133    bool              m_loggedIn;
134    QByteArray        m_talker_buffer;
135
136    QByteArray        m_md5sum;
137    QString           m_path;
138    int               m_albumId;
139    QString           m_thumbpath;
140    QString           m_comment;
141    QString           m_name;
142    QDateTime         m_date;
143
144    static QString    s_authToken;
145};
146
147} // namespace KIPIPiwigoExportPlugin
148
149#endif /* PIWIGOTALKER_H */
Note: See TracBrowser for help on using the repository browser.