1 /* ============================================================ 2 * 3 * This file is a part of KDE project 4 * 5 * 6 * Date : 2008-12-26 7 * Description : a kipi plugin to export images to Facebook web service 8 * 9 * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com> 10 * Copyright (C) 2008-2018 by Gilles Caulier <caulier dot gilles at gmail dot com> 11 * Copyright (C) 2008-2009 by Luka Renko <lure at kubuntu dot org> 12 * 13 * This program is free software; you can redistribute it 14 * and/or modify it under the terms of the GNU General 15 * Public License as published by the Free Software Foundation; 16 * either version 2, or (at your option) any later version. 17 * 18 * This program is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU General Public License for more details. 22 * 23 * ============================================================ */ 24 25 #ifndef FBWINDOW_H 26 #define FBWINDOW_H 27 28 // Qt includes 29 30 #include <QList> 31 32 // Libkipi includes 33 34 #include <KIPI/Interface> 35 36 // Local includes 37 38 #include "kptooldialog.h" 39 40 class QCloseEvent; 41 42 class QUrl; 43 44 namespace KIPI 45 { 46 class Interface; 47 } 48 49 namespace KIPIPlugins 50 { 51 class KPAboutData; 52 } 53 54 using namespace KIPI; 55 using namespace KIPIPlugins; 56 57 namespace KIPIFacebookPlugin 58 { 59 60 class FbTalker; 61 class FbWidget; 62 class FbNewAlbum; 63 class FbUser; 64 class FbAlbum; 65 class FbPhoto; 66 67 class FbWindow : public KPToolDialog 68 { 69 Q_OBJECT 70 71 public: 72 73 FbWindow(const QString& tmpFolder, QWidget* const parent); 74 ~FbWindow(); 75 76 /** 77 * Use this method to (re-)activate the dialog after it has been created 78 * to display it. This also loads the currently selected images. 79 */ 80 void reactivate(); 81 82 private Q_SLOTS: 83 84 void slotBusy(bool val); 85 void slotLoginProgress(int step, int maxStep, const QString& label); 86 void slotLoginDone(int errCode, const QString& errMsg); 87 void slotAddPhotoDone(int errCode, const QString& errMsg); 88 void slotCreateAlbumDone(int errCode, const QString& errMsg, 89 const QString &newAlbumID); 90 void slotListAlbumsDone(int errCode, const QString& errMsg, 91 const QList<FbAlbum>& albumsList); 92 93 void slotUserChangeRequest(); 94 void slotReloadAlbumsRequest(long long userID); 95 void slotNewAlbumRequest(); 96 void slotStartTransfer(); 97 void slotImageListChanged(); 98 void slotStopAndCloseProgressBar(); 99 100 void slotFinished(); 101 void slotCancelClicked(); 102 103 private: 104 105 void setProfileAID(long long userID); 106 QString getImageCaption(const QString& fileName); 107 bool prepareImageForUpload(const QString& imgPath, QString& caption); 108 109 void uploadNextPhoto(); 110 111 void readSettings(); 112 void writeSettings(); 113 114 void authenticate(); 115 116 void buttonStateChange(bool state); 117 118 void closeEvent(QCloseEvent*) override; 119 120 private: 121 122 unsigned int m_imagesCount; 123 unsigned int m_imagesTotal; 124 QString m_tmpDir; 125 QString m_tmpPath; 126 127 QString m_profileAID; 128 QString m_currentAlbumID; 129 130 // the next two entries are only used to upgrade to the new authentication scheme 131 QString m_sessionKey; // old world session key 132 QString m_sessionSecret; // old world session secret 133 unsigned int m_sessionExpires; 134 QString m_accessToken; // OAuth access token 135 136 QList<QUrl> m_transferQueue; 137 138 FbTalker* m_talker; 139 FbNewAlbum* m_albumDlg; 140 141 private: 142 143 class Private; 144 Private* const d; 145 }; 146 147 } // namespace KIPIFacebookPlugin 148 149 #endif /* FBWINDOW_H */ 150