summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/plugins/facebook/facebookconnectwidget.h
blob: ebaded04b4571d678ce436541c2c331df95b053f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// SPDX-License-Identifier: GPL-2.0
#ifndef FACEBOOKCONNECTWIDGET_H
#define FACEBOOKCONNECTWIDGET_H

#include <QDialog>
#include <QUrl>
#ifdef USE_WEBENGINE
class QWebEngineView;
#else
class QWebView;
#endif
class QNetworkReply;
class QNetworkAccessManager;

namespace Ui {
	class FacebookConnectWidget;
	class SocialnetworksDialog;
}

struct FacebookInfo {
	enum Size {SMALL, MEDIUM, BIG};

	QString bodyText;
	QString albumId;
	QString albumName;
	Size profileSize;
	QPixmap profileData;
};

class FacebookManager : public QObject
{
	Q_OBJECT
public:
	static FacebookManager *instance();
	void requestAlbumId();
	void requestUserId();
	QUrl connectUrl();
	QUrl albumListUrl();
	bool loggedIn();
	QPixmap grabProfilePixmap();

signals:
	void justLoggedIn(bool triggererd);
	void justLoggedOut(bool triggered);
	void albumIdReceived(const QString& albumId);
	void sendDiveFinished();
	void sendMessage(const QString& message);

public slots:
	void tryLogin(const QUrl& loginResponse);
	void logout();
	void sendDiveInit();
	void sendDiveToAlbum(const QString& album);

	void uploadFinished();
	void albumListReceived();
	void userIdReceived();
	void createFacebookAlbum();
	void facebookAlbumCreated();
private:
	explicit FacebookManager(QObject *parent = 0);
	FacebookInfo fbInfo;
	QNetworkAccessManager *manager;
};


class FacebookConnectWidget : public QDialog {
	Q_OBJECT
public:
	explicit FacebookConnectWidget(QWidget* parent = 0);
	void facebookLoggedIn();
	void facebookDisconnect();
	void showEvent(QShowEvent *event);
private:
	Ui::FacebookConnectWidget *ui;
#ifdef USE_WEBENGINE
	QWebEngineView *facebookWebView;
#else
	QWebView *facebookWebView;
#endif
};

class SocialNetworkDialog : public QDialog {
	Q_OBJECT
public:

	SocialNetworkDialog(QWidget *parent = 0);
	QString text() const;
	QString album() const;
	FacebookInfo::Size profileSize() const;

public slots:
	void selectionChanged();
	void albumChanged();
private:
	Ui::SocialnetworksDialog *ui;
};

#endif