forked from GMaxera/QtFacebook
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathqfacebook_desktop.cpp
More file actions
executable file
·147 lines (123 loc) · 4.76 KB
/
qfacebook_desktop.cpp
File metadata and controls
executable file
·147 lines (123 loc) · 4.76 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* ************************************************************************
* Copyright (c) 2014 GMaxera <gmaxera@gmail.com> *
* *
* This file is part of QtFacebook *
* *
* QtFacebook is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* ********************************************************************** */
#include "qfacebook.h"
#include <QString>
#include <QDebug>
#include <QByteArray>
#include <QBuffer>
class QFacebookPlatformData {
public:
QString jClassName;
// this avoid to create the QFacebook from native method
// when the Qt Application is not loaded yet
static bool initialized;
// init state and permission got from Facebook SDK before
// the Qt Application loading
static int stateAtStart;
static QStringList grantedPermissionAtStart;
};
bool QFacebookPlatformData::initialized = false;
int QFacebookPlatformData::stateAtStart = -1;
QStringList QFacebookPlatformData::grantedPermissionAtStart = QStringList();
void QFacebook::initPlatformData() {
displayName = "Not used on Android";
data = new QFacebookPlatformData();
data->jClassName = "org/gmaxera/qtfacebook/QFacebookBinding";
// Get the default application ID
appID = "dummy";
data->initialized = true;
qDebug() << "QFacebook Initialization:" << appID;
if ( QFacebookPlatformData::stateAtStart != -1 ) {
qDebug() << "Sync with state and permission loaded at start";
onFacebookStateChanged( QFacebookPlatformData::stateAtStart,
QFacebookPlatformData::grantedPermissionAtStart );
qDebug() << state << grantedPermissions;
}
}
void QFacebook::login() {
// Directly calling slot
onFacebookStateChanged(SessionOpen, QStringList());
}
bool QFacebook::autoLogin() {
// NOT IMPLEMENTED YET
return false;
}
void QFacebook::close() {
// Directly calling slot
onFacebookStateChanged(SessionClosed, QStringList());
}
void QFacebook::requestMe() {
qDebug() << "Request Me";
}
void QFacebook::requestPublishPermissions() {
// Directly calling slot
onFacebookStateChanged(SessionOpenTokenExtended, QStringList());
}
void QFacebook::publishPhoto(QString photoUrl, QString message)
{
Q_UNUSED(message)
qDebug() << "Publish Photo" << photoUrl << message;
}
void QFacebook::publishPhoto( QPixmap photo, QString message ) {
Q_UNUSED(message)
qDebug() << "Publish Photo" << photo.size() << message;
}
void QFacebook::publishPhotosViaShareDialog(QVariantList photos)
{
qDebug() << "Publish Photos" << photos.size();
}
void QFacebook::publishPhotoViaShareDialog(QString photo_url, QString caption){}
void QFacebook::publishLinkViaShareDialog( QString linkName, QString link, QString imageUrl, QString caption, QString description ) {
qDebug() << "Publish link" << link << linkName << imageUrl;
}
void QFacebook::requestMyFriends() {
// NOT IMPLEMENTED YET
QVariantMap dataMap;
dataMap["friends"] = QStringList();
emit operationDone( "requestMyFriends", dataMap );
}
void QFacebook::inviteFriends(QString appId,QString imgUrl){}
void QFacebook::setAppID( QString appID ) {
Q_UNUSED(appID)
}
void QFacebook::setDisplayName( QString displayName ) {
Q_UNUSED(displayName)
// NOT USED
}
void QFacebook::setRequestPermissions( QStringList requestPermissions ) {
this->requestPermissions = requestPermissions;
emit requestPermissionsChanged( this->requestPermissions );
}
void QFacebook::addRequestPermission( QString requestPermission ) {
if ( !requestPermissions.contains(requestPermission) ) {
// add the permission
requestPermissions.append( requestPermission );
emit requestPermissionsChanged(requestPermissions);
}
}
QString QFacebook::getAccessToken() {
return QString();
}
QString QFacebook::getExpirationDate() {
return QString();
}
void QFacebook::onApplicationStateChanged(Qt::ApplicationState state) {
Q_UNUSED(state);
// NOT USED
}