26
|
1 |
#include "Mainwindow.h"
|
|
2 |
#include <QUrl>
|
|
3 |
#include <QDebug>
|
|
4 |
#include <QImage>
|
|
5 |
#include <QVariant>
|
|
6 |
#include <QtGui>
|
|
7 |
#include <QDataStream>
|
|
8 |
#include <smfprovider.h>
|
|
9 |
#include <qcontactguid.h>
|
|
10 |
|
|
11 |
|
|
12 |
/*#ifndef TEST_FLICKR
|
|
13 |
#define TEST_FLICKR
|
|
14 |
#define PROVIDER_NAME "Flickr"
|
|
15 |
*/
|
|
16 |
//Test Cases
|
|
17 |
/*
|
|
18 |
#define TEST_CASE_FLCRAlbums
|
|
19 |
#define TEST_CASE_FLCRUpload*/
|
|
20 |
//#define TEST_CASE_FLCRPictures
|
|
21 |
|
|
22 |
//#define TEST_CASE_FLCRMultiUpload
|
|
23 |
//#define TEST_CASE_FLCRDescription
|
|
24 |
//#define TEST_CASE_FLCRPostComment
|
|
25 |
//#endif
|
|
26 |
/*
|
|
27 |
*/
|
|
28 |
#ifndef TEST_FACEBOOK
|
|
29 |
#define TEST_FACEBOOK
|
|
30 |
#define PROVIDER_NAME "Facebook"
|
|
31 |
|
|
32 |
#define TEST_CASE_FBFrndActvities
|
|
33 |
#endif
|
|
34 |
/*
|
|
35 |
#ifndef TEST_LastFm
|
|
36 |
#define TEST_LastFm
|
|
37 |
#define PROVIDER_NAME "last.fm"
|
|
38 |
#endif
|
|
39 |
|
|
40 |
|
|
41 |
#ifndef TEST_LyricsFly
|
|
42 |
#define TEST_LyricsFly
|
|
43 |
#define PROVIDER_NAME "Last.fm"
|
|
44 |
#endif
|
|
45 |
*/
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
MainWindow::MainWindow(QWidget *parent):QWidget(parent)
|
|
52 |
{
|
|
53 |
pB = new QPushButton("Start Test Application",this);
|
|
54 |
QObject::connect(pB,SIGNAL(clicked()),this,SLOT(StartTesting()));
|
|
55 |
|
|
56 |
}
|
|
57 |
MainWindow::~MainWindow()
|
|
58 |
{
|
|
59 |
}
|
|
60 |
void MainWindow::StartTesting()
|
|
61 |
{
|
|
62 |
/*#ifdef TEST_FLICKR
|
|
63 |
TestFlickrAPIS();
|
|
64 |
#endif
|
|
65 |
*/
|
|
66 |
|
|
67 |
#ifdef TEST_FACEBOOK
|
|
68 |
TestFaceBookAPIS();
|
|
69 |
#endif
|
|
70 |
|
|
71 |
}
|
|
72 |
|
|
73 |
void MainWindow::TestFlickrAPIS()
|
|
74 |
{
|
|
75 |
SmfClient m_smf;
|
|
76 |
QList<SmfProvider> *providerList = m_smf.GetServices("org.symbian.smf.client.gallery");
|
|
77 |
qDebug() <<"SmfGallery::get services "<<providerList->length() ;
|
|
78 |
qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
|
|
79 |
|
|
80 |
SmfError error =(SmfError) 100;
|
|
81 |
QString str = m_smf.errorString(error);
|
|
82 |
|
|
83 |
qDebug() << "SmfClient::error string returned " << str;
|
|
84 |
foreach(SmfProvider provider, *providerList)
|
|
85 |
{
|
|
86 |
if(PROVIDER_NAME == provider.serviceName())
|
|
87 |
{
|
|
88 |
qDebug()<<"Plugin for flickr found";
|
|
89 |
|
|
90 |
pSmfGallery = new SmfGallery(&provider);
|
|
91 |
#ifdef TEST_CASE_FLCRUpload
|
|
92 |
|
|
93 |
TEST_CASE_FLCRUpload_func(pSmfGallery);
|
|
94 |
|
|
95 |
#endif
|
|
96 |
|
|
97 |
#ifdef TEST_CASE_FLCRMultiUpload
|
|
98 |
TEST_CASE_FLCRMultiUpload_func(pSmfGallery);
|
|
99 |
#endif
|
|
100 |
|
|
101 |
#ifdef TEST_CASE_FLCRDescription
|
|
102 |
TEST_CASE_FLCRGetDescription_func(pSmfGallery);
|
|
103 |
|
|
104 |
#endif
|
|
105 |
|
|
106 |
#ifdef TEST_CASE_FLCRPostComment
|
|
107 |
TEST_CASE_FLCRPostComment_func(pSmfGallery);
|
|
108 |
|
|
109 |
#endif
|
|
110 |
#ifdef TEST_CASE_FLCRPictures
|
|
111 |
TEST_CASE_FLCRGetPictures_func(pSmfGallery);
|
|
112 |
|
|
113 |
#endif
|
|
114 |
#ifdef TEST_CASE_FLCRAlbums
|
|
115 |
TEST_CASE_FLCRGetAlbums_func(pSmfGallery);
|
|
116 |
|
|
117 |
#endif
|
|
118 |
}
|
|
119 |
}
|
|
120 |
}
|
|
121 |
void MainWindow::TestFaceBookAPIS()
|
|
122 |
{
|
|
123 |
SmfClient m_smf;
|
|
124 |
QList <SmfProvider> *services = m_smf.GetServices("org.symbian.smf.plugin.activity.fetcher");
|
|
125 |
qDebug() << "SmfClient::GetServices returned " << services->length() << " services.";
|
|
126 |
|
|
127 |
foreach(SmfProvider provider, *services)
|
|
128 |
{
|
|
129 |
if(PROVIDER_NAME == provider.serviceName())
|
|
130 |
{
|
|
131 |
qDebug()<<"Plugin for Facebook found";
|
|
132 |
activityFetcher = new SmfActivityFetcher(&provider);
|
|
133 |
|
|
134 |
#ifdef TEST_CASE_FBFrndActvities
|
|
135 |
|
|
136 |
TEST_CASE_FBFriendsActivities_func(activityFetcher);
|
|
137 |
|
|
138 |
#endif
|
|
139 |
}
|
|
140 |
}
|
|
141 |
}
|
|
142 |
void MainWindow::TEST_CASE_FLCRUpload_func(SmfGallery *pSmfGallery)
|
|
143 |
{
|
|
144 |
SmfPictureAlbum smfPictureAlbum;
|
|
145 |
SmfPicture smfImage;
|
|
146 |
smfImage.setPicture(QImage("C:\\data\\4.jpg","JPG"));
|
|
147 |
bool ret = connect(pSmfGallery,SIGNAL(uploadFinished(QList<SmfError> )),
|
|
148 |
this,SLOT(uploadFinishedSlot(QList<SmfError> )));
|
|
149 |
pSmfGallery->upload(&smfImage,&smfPictureAlbum);
|
|
150 |
qDebug()<<"SmfGallery::upload picture ";
|
|
151 |
}
|
|
152 |
|
|
153 |
void MainWindow::TEST_CASE_FLCRMultiUpload_func(SmfGallery *pSmfGallery)
|
|
154 |
{
|
|
155 |
|
|
156 |
SmfPictureAlbum smfPictureAlbum;
|
|
157 |
smfPictureAlbum.setId("72157624246208730");
|
|
158 |
SmfPicture smfPicture1,smfPicture2;
|
|
159 |
smfPicture1.setPicture(QImage("C:\\data\\Cyber_towers.jpg","jpg"));
|
|
160 |
smfPicture2.setPicture(QImage("C:\\data\\test.jpg","jpg"));
|
|
161 |
QList<SmfPicture> smfPicList;
|
|
162 |
smfPicList.append(smfPicture1);
|
|
163 |
smfPicList.append(smfPicture2);
|
|
164 |
bool ret = connect(pSmfGallery,SIGNAL(uploadFinished(QList<SmfError> )),
|
|
165 |
this,SLOT(uploadFinishedSlot(QList<SmfError> )));
|
|
166 |
pSmfGallery->upload(&smfPicList,&smfPictureAlbum);
|
|
167 |
qDebug()<<"SmfGallery::upload picture List ";
|
|
168 |
}
|
|
169 |
void MainWindow::TEST_CASE_FLCRGetDescription_func(SmfGallery *pSmfGallery)
|
|
170 |
{
|
|
171 |
SmfPicture smfImage;
|
|
172 |
smfImage.setId("5058988107");
|
|
173 |
SmfError err = pSmfGallery->description(smfImage);
|
|
174 |
bool ret = QObject::connect(pSmfGallery,SIGNAL(descriptionAvailable(QString,SmfError)),
|
|
175 |
this,SLOT(descSlot(QString,SmfError )));
|
|
176 |
qDebug()<<"SmfGallery::get description ";
|
|
177 |
}
|
|
178 |
void MainWindow::TEST_CASE_FLCRPostComment_func(SmfGallery *pSmfGallery)
|
|
179 |
{
|
|
180 |
SmfPicture smfImage;
|
|
181 |
smfImage.setId("5058988107");
|
|
182 |
SmfComment smfComment;
|
|
183 |
smfComment.setText("Hello Symbian");
|
|
184 |
SmfError err = pSmfGallery->postComment(smfImage,smfComment);
|
|
185 |
|
|
186 |
bool ret = QObject::connect(pSmfGallery,SIGNAL(uploadFinished(QList<SmfError> )),
|
|
187 |
this,SLOT(uploadFinishedSlot(QList<SmfError> )));
|
|
188 |
qDebug()<<"SmfGallery::Post a Comment ";
|
|
189 |
}
|
|
190 |
void MainWindow::TEST_CASE_FLCRGetPictures_func(SmfGallery *pSmfGallery)
|
|
191 |
{
|
|
192 |
QList<SmfPictureAlbum> smfAlbumList;
|
|
193 |
SmfPictureAlbum smfPictureAlbum;
|
|
194 |
smfPictureAlbum.setId("72157624966587095");
|
|
195 |
smfAlbumList.append(smfPictureAlbum);
|
|
196 |
int pageNum = 0, perPage = 0;
|
|
197 |
SmfError err = pSmfGallery->pictures(smfAlbumList,pageNum , perPage);
|
|
198 |
bool ret = connect(pSmfGallery,SIGNAL(picturesAvailable(SmfPictureList*, SmfError , SmfResultPage)),
|
|
199 |
this, SLOT(picturesAvailableSlot(SmfPictureList*, SmfError , SmfResultPage)));
|
|
200 |
qDebug()<<"SmfGallery::Get picture ";
|
|
201 |
}
|
|
202 |
void MainWindow::TEST_CASE_FLCRGetAlbums_func(SmfGallery *pSmfGallery)
|
|
203 |
{
|
|
204 |
SmfPictureAlbum smfPictureAlbum;
|
|
205 |
SmfPicture smfImage;
|
|
206 |
smfImage.setPicture(QImage("C:\\data\\4.jpg","JPG"));
|
|
207 |
bool ret = connect(pSmfGallery,SIGNAL(albumsAvailable(SmfPictureAlbumList*, SmfError , SmfResultPage)),
|
|
208 |
this, SLOT(albumsAvailableSlot(SmfPictureAlbumList*, SmfError , SmfResultPage)));
|
|
209 |
QStringList names;
|
|
210 |
SmfContact user;
|
|
211 |
pSmfGallery->albums(names, &user,1,2);
|
|
212 |
qDebug()<<"SmfGallery::upload picture ";
|
|
213 |
}
|
|
214 |
void MainWindow::TEST_CASE_FBFriendsActivities_func(SmfActivityFetcher *actvityFetcher)
|
|
215 |
{
|
|
216 |
|
|
217 |
SmfContact m_contact;
|
|
218 |
QContactGuid guid;
|
|
219 |
guid.setGuid("100001376714970");
|
|
220 |
QVariant contactId = QVariant::fromValue<QContactGuid>(guid);
|
|
221 |
m_contact.setValue("Guid",contactId);
|
|
222 |
actvityFetcher->friendsActivities(m_contact,1,1);
|
|
223 |
bool ret = connect(actvityFetcher, SIGNAL(resultsAvailable(SmfActivityEntryList*, SmfError , SmfResultPage)),
|
|
224 |
this, SLOT(activitiesAvailableSlot(SmfActivityEntryList*, SmfError , SmfResultPage)));
|
|
225 |
qDebug()<<"connected"<<ret;
|
|
226 |
|
|
227 |
}
|
|
228 |
void MainWindow::albumsAvailableSlot(SmfPictureAlbumList* albums, SmfError error, SmfResultPage resultPage)
|
|
229 |
{
|
|
230 |
Q_UNUSED(resultPage);
|
|
231 |
|
|
232 |
qDebug()<<"Inside HomeView::albumsAvailable()";
|
|
233 |
|
|
234 |
m_albumsList = albums;
|
|
235 |
if(error)
|
|
236 |
{
|
|
237 |
SmfClient client;
|
|
238 |
QString errStr = client.errorString(error);
|
|
239 |
qDebug()<<"Error found, code = "<<error;
|
|
240 |
qDebug()<<"Error string is = "<<errStr;
|
|
241 |
return;
|
|
242 |
}
|
|
243 |
|
|
244 |
//display album details
|
|
245 |
qDebug()<<"Number of albums retrieved = "<<albums->count();
|
|
246 |
if(albums->count() == 0)
|
|
247 |
{
|
|
248 |
QString smferrString("No Albums");
|
|
249 |
return;
|
|
250 |
}
|
|
251 |
|
|
252 |
QStringList albumPicList;
|
|
253 |
QStringList albumNameList;
|
|
254 |
foreach(SmfPictureAlbum album, *m_albumsList)
|
|
255 |
{
|
|
256 |
|
|
257 |
qDebug()<<"Album name = "<<album.title();
|
|
258 |
qDebug()<<"Album description = "<<album.description();
|
|
259 |
qDebug()<<"Album pictureCount = "<<album.pictureCount();
|
|
260 |
qDebug()<<"Album id = "<<album.id();
|
|
261 |
}
|
|
262 |
|
|
263 |
|
|
264 |
}
|
|
265 |
|
|
266 |
void MainWindow::picturesAvailableSlot(SmfPictureList* picList, SmfError error, SmfResultPage resultPage)
|
|
267 |
{
|
|
268 |
Q_UNUSED(resultPage)
|
|
269 |
qDebug()<<"Inside HomeView::picturesAvailable()";
|
|
270 |
|
|
271 |
m_picList = picList;
|
|
272 |
if(error)
|
|
273 |
{
|
|
274 |
SmfClient client;
|
|
275 |
QString errStr = client.errorString(error);
|
|
276 |
qDebug()<<"Error found, code = "<<error;
|
|
277 |
qDebug()<<"Error string is = "<<errStr;
|
|
278 |
return;
|
|
279 |
}
|
|
280 |
|
|
281 |
//display pic description
|
|
282 |
qDebug()<<"Number of pic retrieved = "<<picList->count();
|
|
283 |
|
|
284 |
QMap<QString, QUrl> urlMap;
|
|
285 |
foreach(SmfPicture pic, *picList)
|
|
286 |
{
|
|
287 |
qDebug()<<"Photo title = "<<pic.title();
|
|
288 |
qDebug()<<"Photo posted date = "<<pic.postedDate();
|
|
289 |
qDebug()<<"Photo url = "<<pic.url();
|
|
290 |
qDebug()<<"Photo id = "<<pic.id();
|
|
291 |
}
|
|
292 |
|
|
293 |
|
|
294 |
}
|
|
295 |
|
|
296 |
void MainWindow::uploadFinishedSlot( QList<SmfError> error )
|
|
297 |
{
|
|
298 |
SmfClient m_smf;
|
|
299 |
QString str = m_smf.errorString(error.at(0));
|
|
300 |
qDebug()<<"upload finished";
|
|
301 |
qDebug()<<" SMF Error Code"<<str;
|
|
302 |
}
|
|
303 |
|
|
304 |
void MainWindow::descSlot(QString str,SmfError err )
|
|
305 |
{
|
|
306 |
SmfClient m_smf;
|
|
307 |
QString errstr = m_smf.errorString(err);
|
|
308 |
qDebug()<<"description string"<<str;
|
|
309 |
qDebug()<<" SMF Error Code"<<errstr;
|
|
310 |
}
|
|
311 |
void MainWindow::activitiesAvailableSlot(SmfActivityEntryList* activitiesList, SmfError error, SmfResultPage resultPage)
|
|
312 |
{
|
|
313 |
Q_UNUSED(resultPage)
|
|
314 |
qDebug()<<"Inside HomeView::activitiesAvailable()";
|
|
315 |
|
|
316 |
|
|
317 |
qDebug()<<"Number of activities retrieved = "<<activitiesList->count();
|
|
318 |
|
|
319 |
SmfClient client;
|
|
320 |
QString errStr = client.errorString(error);
|
|
321 |
qDebug()<<"Error found, code = "<<error;
|
|
322 |
qDebug()<<"Error string is = "<<errStr;
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
//display activity description
|
|
327 |
qDebug()<<"Number of activities retrieved = "<<activitiesList->count();
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
foreach(SmfActivityEntry activity, *activitiesList)
|
|
332 |
{
|
|
333 |
qDebug()<<"Activity author name = "<<activity.author().value("Name").value<QContactName>().firstName();
|
|
334 |
qDebug()<<"Activity title = "<<activity.title().title();
|
|
335 |
qDebug()<<"Activity details = "<<activity.details().description();
|
|
336 |
}
|
|
337 |
|
|
338 |
|
|
339 |
}
|