File indexing completed on 2023-10-03 07:22:43

0001 /* ============================================================
0002  *
0003  * This file is a part of KDE project
0004  *
0005  *
0006  * Date        : 2008-12-26
0007  * Description : a kipi plugin to export images to Facebook web service
0008  *
0009  * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
0010  * Copyright (C) 2008-2018 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  * Copyright (C) 2008-2009 by Luka Renko <lure at kubuntu dot org>
0012  *
0013  * This program is free software; you can redistribute it
0014  * and/or modify it under the terms of the GNU General
0015  * Public License as published by the Free Software Foundation;
0016  * either version 2, or (at your option) any later version.
0017  *
0018  * This program is distributed in the hope that it will be useful,
0019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0021  * GNU General Public License for more details.
0022  *
0023  * ============================================================ */
0024 
0025 #ifndef FBWINDOW_H
0026 #define FBWINDOW_H
0027 
0028 // Qt includes
0029 
0030 #include <QList>
0031 
0032 // Libkipi includes
0033 
0034 #include <KIPI/Interface>
0035 
0036 // Local includes
0037 
0038 #include "kptooldialog.h"
0039 
0040 class QCloseEvent;
0041 
0042 class QUrl;
0043 
0044 namespace KIPI
0045 {
0046     class Interface;
0047 }
0048 
0049 namespace KIPIPlugins
0050 {
0051     class KPAboutData;
0052 }
0053 
0054 using namespace KIPI;
0055 using namespace KIPIPlugins;
0056 
0057 namespace KIPIFacebookPlugin
0058 {
0059 
0060 class FbTalker;
0061 class FbWidget;
0062 class FbNewAlbum;
0063 class FbUser;
0064 class FbAlbum;
0065 class FbPhoto;
0066 
0067 class FbWindow : public KPToolDialog
0068 {
0069     Q_OBJECT
0070 
0071 public:
0072 
0073     FbWindow(const QString& tmpFolder, QWidget* const parent);
0074     ~FbWindow();
0075 
0076     /**
0077      * Use this method to (re-)activate the dialog after it has been created
0078      * to display it. This also loads the currently selected images.
0079      */
0080     void reactivate();
0081 
0082 private Q_SLOTS:
0083 
0084     void slotBusy(bool val);
0085     void slotLoginProgress(int step, int maxStep, const QString& label);
0086     void slotLoginDone(int errCode, const QString& errMsg);
0087     void slotAddPhotoDone(int errCode, const QString& errMsg);
0088     void slotCreateAlbumDone(int errCode, const QString& errMsg,
0089                              const QString &newAlbumID);
0090     void slotListAlbumsDone(int errCode, const QString& errMsg,
0091                             const QList<FbAlbum>& albumsList);
0092 
0093     void slotUserChangeRequest();
0094     void slotReloadAlbumsRequest(long long userID);
0095     void slotNewAlbumRequest();
0096     void slotStartTransfer();
0097     void slotImageListChanged();
0098     void slotStopAndCloseProgressBar();
0099 
0100     void slotFinished();
0101     void slotCancelClicked();
0102 
0103 private:
0104 
0105     void    setProfileAID(long long userID);
0106     QString getImageCaption(const QString& fileName);
0107     bool    prepareImageForUpload(const QString& imgPath, QString& caption);
0108 
0109     void    uploadNextPhoto();
0110 
0111     void    readSettings();
0112     void    writeSettings();
0113 
0114     void    authenticate();
0115 
0116     void    buttonStateChange(bool state);
0117 
0118     void    closeEvent(QCloseEvent*) override;
0119 
0120 private:
0121 
0122     unsigned int m_imagesCount;
0123     unsigned int m_imagesTotal;
0124     QString      m_tmpDir;
0125     QString      m_tmpPath;
0126 
0127     QString      m_profileAID;
0128     QString      m_currentAlbumID;
0129 
0130     // the next two entries are only used to upgrade to the new authentication scheme
0131     QString      m_sessionKey;             // old world session key
0132     QString      m_sessionSecret;          // old world session secret
0133     unsigned int m_sessionExpires;
0134     QString      m_accessToken;            // OAuth access token
0135 
0136     QList<QUrl>  m_transferQueue;
0137 
0138     FbTalker*    m_talker;
0139     FbNewAlbum*  m_albumDlg;
0140 
0141 private:
0142 
0143     class Private;
0144     Private* const d;
0145 };
0146 
0147 } // namespace KIPIFacebookPlugin
0148 
0149 #endif /* FBWINDOW_H */