fbApi.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * From: https://github.com/netogallo/FrameBook/
  3. * heavily modified for Project PhotoBunny
  4. *
  5. * 2014 Gwilyn Saunders
  6. */
  7. #ifndef FBAPI_H
  8. #define FBAPI_H
  9. #include <QString>
  10. #include <QSettings>
  11. #include <QUrl>
  12. #include <QNetworkRequest>
  13. #include <QNetworkAccessManager>
  14. #include <QNetworkReply>
  15. #include <QFile>
  16. //#include <qjson/parser.h>
  17. #include <QWebPage>
  18. #include "common.h"
  19. enum LoginStatus {
  20. BAD_PERM,
  21. BAD_PASS,
  22. SUCCESS
  23. };
  24. class FbApi
  25. : public QObject {
  26. Q_OBJECT
  27. QSettings *st;
  28. QString token;
  29. QString appID;
  30. QStringList picList;
  31. QStringList albumIDs;
  32. QList<QVariantMap> albumList;
  33. bool loginStatus;
  34. int imgCount;
  35. QString tmpPath;
  36. public:
  37. FbApi(const char* appID, QObject *parent = 0);
  38. ~FbApi();
  39. bool highRes;
  40. bool caching;
  41. QWebPage *page;
  42. QUrl getLoginUrl();
  43. void loadAlbums();
  44. void loadPictures();
  45. void authenticate(QString userName, QString password);
  46. //access methods
  47. QString user();
  48. bool loggedIn();
  49. void selectAlbums(QStringList ids);
  50. QList<QVariantMap> allAlbums();
  51. QStringList pictures();
  52. QString getTempPath();
  53. private:
  54. QString *userName;
  55. QString *password;
  56. QNetworkAccessManager *net;
  57. QNetworkReply *resp;
  58. QNetworkReply *picResp;
  59. //QJson::Parser parser;
  60. QFile *pic;
  61. signals:
  62. void loginResult(LoginStatus status);
  63. void albumsLoaded();
  64. void picsLoaded();
  65. void picLoaded(QString pic);
  66. void error(QString msg);
  67. public slots:
  68. void nextPicture();
  69. private slots:
  70. void loadPicList();
  71. void loadAlbumList();
  72. void setPicture();
  73. void doAuthentication(bool stat);
  74. void acceptPermissions();
  75. };
  76. #endif // FBAPI_H