16
|
1 |
#include "HomeView.h"
|
|
2 |
#include "ScreenSize.h"
|
|
3 |
#include "qpushbutton.h"
|
|
4 |
#include "customListwidget.h"
|
|
5 |
#include "GridView.h"
|
|
6 |
#include <qtablewidget.h>
|
|
7 |
|
|
8 |
#include <QMapIterator>
|
|
9 |
#include <smfclient.h>
|
|
10 |
#include <smfprovider.h>
|
|
11 |
#include <QMessageBox>
|
|
12 |
#include <QDebug>
|
|
13 |
#include "ImageDownload.h"
|
|
14 |
|
26
|
15 |
//static int tab = 0;
|
16
|
16 |
|
|
17 |
HomeView::HomeView(QString aHeadName):
|
|
18 |
iHeadName(aHeadName)
|
|
19 |
{
|
|
20 |
//m_providerList = NULL;
|
|
21 |
m_mainWindow = NULL;
|
|
22 |
TabWidget = NULL;
|
|
23 |
iFrndsListWidget = NULL;
|
|
24 |
iPostsListWidget = NULL;
|
|
25 |
iActivityListWidget = NULL;
|
|
26 |
AlbumView = NULL;
|
|
27 |
|
|
28 |
m_contactFetcher = NULL;
|
|
29 |
m_postProvider = NULL;
|
|
30 |
m_gallery = NULL;
|
|
31 |
m_activityFetcher = NULL;
|
|
32 |
m_friendsList = NULL;
|
|
33 |
m_postsList = NULL;
|
|
34 |
m_albumsList = NULL;
|
|
35 |
m_activitiesList = NULL;
|
|
36 |
m_picList = NULL;
|
|
37 |
}
|
|
38 |
|
|
39 |
HomeView::~HomeView()
|
|
40 |
{
|
|
41 |
if(TabWidget)
|
|
42 |
{
|
|
43 |
delete TabWidget;
|
|
44 |
TabWidget = NULL;
|
|
45 |
}
|
|
46 |
if(iFrndsListWidget)
|
|
47 |
{
|
|
48 |
delete iFrndsListWidget;
|
|
49 |
iFrndsListWidget = NULL;
|
|
50 |
}
|
|
51 |
if(iPostsListWidget)
|
|
52 |
{
|
|
53 |
delete iPostsListWidget;
|
|
54 |
iPostsListWidget = NULL;
|
|
55 |
}
|
|
56 |
if(iActivityListWidget)
|
|
57 |
{
|
|
58 |
delete iActivityListWidget;
|
|
59 |
iActivityListWidget = NULL;
|
|
60 |
}
|
|
61 |
if(AlbumView)
|
|
62 |
{
|
|
63 |
delete AlbumView;
|
|
64 |
AlbumView = NULL;
|
|
65 |
}
|
|
66 |
|
|
67 |
if(m_contactFetcher)
|
|
68 |
{
|
|
69 |
delete m_contactFetcher;
|
|
70 |
m_contactFetcher =NULL;
|
|
71 |
}
|
|
72 |
if(m_postProvider)
|
|
73 |
{
|
|
74 |
delete m_postProvider;
|
|
75 |
m_postProvider =NULL;
|
|
76 |
}
|
|
77 |
if(m_gallery)
|
|
78 |
{
|
|
79 |
delete m_gallery;
|
|
80 |
m_gallery =NULL;
|
|
81 |
}
|
|
82 |
if(m_activityFetcher)
|
|
83 |
{
|
|
84 |
delete m_activityFetcher;
|
|
85 |
m_activityFetcher =NULL;
|
|
86 |
}
|
|
87 |
if(m_friendsList)
|
|
88 |
{
|
|
89 |
delete m_friendsList;
|
|
90 |
m_friendsList =NULL;
|
|
91 |
}
|
|
92 |
if(m_postsList)
|
|
93 |
{
|
|
94 |
delete m_postsList;
|
|
95 |
m_postsList =NULL;
|
|
96 |
}
|
|
97 |
if(m_albumsList)
|
|
98 |
{
|
|
99 |
delete m_albumsList;
|
|
100 |
m_albumsList =NULL;
|
|
101 |
}
|
|
102 |
if(m_activitiesList)
|
|
103 |
{
|
|
104 |
delete m_activitiesList;
|
|
105 |
m_activitiesList =NULL;
|
|
106 |
}
|
|
107 |
if(m_picList)
|
|
108 |
{
|
|
109 |
delete m_picList;
|
|
110 |
m_picList =NULL;
|
|
111 |
}
|
|
112 |
}
|
|
113 |
|
|
114 |
|
|
115 |
void HomeView::SetupUI(QMainWindow *Mainwindow)
|
|
116 |
{
|
|
117 |
qDebug()<<"Inside HomeView::SetupUI()";
|
|
118 |
|
|
119 |
m_mainWindow = Mainwindow;
|
|
120 |
|
|
121 |
QPushButton* HomeButton = new QPushButton(m_mainWindow);
|
|
122 |
HomeButton->setText(iHeadName);
|
|
123 |
HomeButton->setGeometry(0,0,ScreenSize::GetScreenRect().width(),KHeadNameHeight);
|
|
124 |
HomeButton->setStyleSheet("background-color: rgb(0,0,0);"
|
|
125 |
"border-width: 2px;"
|
|
126 |
"font: bold 16px;"
|
|
127 |
"min-width: 10em;"
|
|
128 |
"padding: 4px;"
|
|
129 |
"color: white;"
|
|
130 |
);
|
|
131 |
|
|
132 |
HomeButton->setDisabled(true);
|
|
133 |
qDebug()<<"Home button created and setup";
|
|
134 |
|
|
135 |
TabWidget = new QTabWidget(m_mainWindow);
|
|
136 |
connect(TabWidget,SIGNAL(currentChanged(int)),this,SLOT(Navigated2OtherTab(int)));
|
|
137 |
qDebug()<<"Tab widget created";
|
|
138 |
|
|
139 |
iFrndsListWidget = new CustomListWidget();
|
|
140 |
TabWidget->addTab(iFrndsListWidget,"Friends");
|
|
141 |
qDebug()<<"Friends Tab created";
|
|
142 |
|
|
143 |
iPostsListWidget = new CustomListWidget();
|
|
144 |
TabWidget->addTab(iPostsListWidget,"Posts");
|
|
145 |
qDebug()<<"Posts Tab created";
|
|
146 |
|
|
147 |
//AlbumView = new GridView();
|
|
148 |
/*QWidget *widget = new QWidget();
|
|
149 |
TabWidget->addTab(widget,"Album");*/
|
|
150 |
iAlbumWidget = new CustomListWidget();
|
|
151 |
TabWidget->addTab(iAlbumWidget,"Album");
|
|
152 |
|
|
153 |
qDebug()<<"Albums Tab created";
|
|
154 |
|
|
155 |
/*
|
|
156 |
QStringList Iconpathlist;
|
|
157 |
Iconpathlist.append("C:\\data\\AlbumDefault.JPG");
|
|
158 |
Iconpathlist.append("C:\\data\\AlbumDefault.JPG");
|
|
159 |
Iconpathlist.append("C:\\data\\AlbumDefault.JPG");
|
|
160 |
Iconpathlist.append("C:\\data\\AlbumDefault.JPG");
|
|
161 |
|
|
162 |
|
|
163 |
TabWidget->addTab(AlbumView->CreateGridView(Iconpathlist),"Album");
|
|
164 |
qDebug()<<"Albums Tab created";
|
|
165 |
*/
|
|
166 |
|
|
167 |
iActivityListWidget = new CustomListWidget();
|
|
168 |
TabWidget->addTab(iActivityListWidget,"Activity");
|
|
169 |
qDebug()<<"Activity Tab created";
|
|
170 |
|
|
171 |
TabWidget->setGeometry(0,KHeadNameHeight + KWidgetGapFactor,ScreenSize::GetScreenRect().width(),ScreenSize::GetScreenRect().height() - 100);
|
|
172 |
|
|
173 |
//Drawing Tool bar
|
|
174 |
ToolBarwidget = new ToolBar;
|
|
175 |
QStringList actionList;
|
|
176 |
actionList.append("Add Services");
|
|
177 |
//actionList.append("Open");
|
|
178 |
//actionList.append("Reply");
|
|
179 |
ToolBarwidget->GetToolBar(m_mainWindow,actionList);
|
|
180 |
qDebug()<<"Tool bar created";
|
|
181 |
}
|
|
182 |
|
|
183 |
|
|
184 |
void HomeView::getFriends()
|
|
185 |
{
|
|
186 |
qDebug()<<"Inside HomeView::getFriends()";
|
|
187 |
|
|
188 |
// Get the list of providers
|
|
189 |
SmfClient client;
|
|
190 |
QString intfName("org.symbian.smf.plugin.contact.fetcher");
|
|
191 |
|
|
192 |
SmfProviderList *providerList = client.GetServices(intfName);
|
|
193 |
qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
|
|
194 |
|
|
195 |
// flag to check if required plugin is there
|
|
196 |
bool pluginFound = false;
|
|
197 |
foreach(SmfProvider provider, *providerList)
|
|
198 |
{
|
|
199 |
if("Facebook" == provider.serviceName())
|
|
200 |
{
|
|
201 |
qDebug()<<"Plugin for Facebook found";
|
|
202 |
pluginFound = true;
|
|
203 |
m_contactFetcher = new SmfContactFetcher(&provider);
|
|
204 |
bool ret = connect(m_contactFetcher, SIGNAL(friendsListAvailable(SmfContactList*, SmfError , SmfResultPage)),
|
|
205 |
this, SLOT(friendsAvailable(SmfContactList*, SmfError , SmfResultPage)));
|
|
206 |
|
|
207 |
qDebug()<<"Connected ?"<<ret;
|
|
208 |
m_contactFetcher->friends(1,5);
|
|
209 |
}
|
|
210 |
}
|
|
211 |
|
|
212 |
if(!pluginFound)
|
|
213 |
{
|
|
214 |
qDebug()<<"Plugin for Facebook not found!!!";
|
|
215 |
QString smferrString("No Facebook plugin found!!!");
|
|
216 |
QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
|
|
217 |
}
|
|
218 |
}
|
|
219 |
|
|
220 |
|
|
221 |
void HomeView::friendsAvailable(SmfContactList* friendsList, SmfError error, SmfResultPage resultPage)
|
|
222 |
{
|
26
|
223 |
Q_UNUSED(resultPage)
|
16
|
224 |
qDebug()<<"Inside HomeView::friendsAvailable()";
|
|
225 |
|
|
226 |
m_friendsList = friendsList;
|
|
227 |
if(error)
|
|
228 |
{
|
|
229 |
SmfClient client;
|
|
230 |
QString errStr = client.errorString(error);
|
|
231 |
qDebug()<<"Error found, code = "<<error;
|
|
232 |
qDebug()<<"Error string is = "<<errStr;
|
|
233 |
|
|
234 |
QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
|
|
235 |
return;
|
|
236 |
}
|
|
237 |
|
|
238 |
//display friends description
|
|
239 |
qDebug()<<"Number of friends retrieved = "<<friendsList->count();
|
|
240 |
if(friendsList->count() == 0)
|
|
241 |
{
|
|
242 |
QString smferrString("No Friends");
|
|
243 |
QMessageBox::information(m_mainWindow,"No Friends",smferrString,QMessageBox::Ok);
|
|
244 |
return;
|
|
245 |
}
|
|
246 |
|
|
247 |
QMap<QString, QUrl> urlMap;
|
|
248 |
foreach(SmfContact contact, *friendsList)
|
|
249 |
{
|
|
250 |
QString name(contact.value("Name").value<QContactName>().firstName());
|
|
251 |
QString status(contact.value("Presence").value<QContactPresence>().customMessage());
|
|
252 |
if(!status.size())
|
|
253 |
status.append("Not available");
|
|
254 |
QUrl url(contact.value("Avatar").value<QContactAvatar>().imageUrl());
|
|
255 |
|
|
256 |
qDebug()<<"Friends name = "<<contact.value("Name").value<QContactName>().firstName();
|
|
257 |
qDebug()<<"Friends status msg desc = "<<contact.value("Presence").value<QContactPresence>().customMessage();
|
|
258 |
qDebug()<<"Friends profile image URL = "<<contact.value("Avatar").value<QContactAvatar>().imageUrl();
|
|
259 |
urlMap.insert(name, url);
|
|
260 |
}
|
|
261 |
|
|
262 |
// Download Images
|
|
263 |
downloadImages(SmfFriendsFetch, urlMap);
|
|
264 |
|
|
265 |
}
|
|
266 |
|
|
267 |
void HomeView::populateFriendsWidget()
|
|
268 |
{
|
|
269 |
foreach(SmfContact contact, *m_friendsList)
|
|
270 |
{
|
|
271 |
QString name(contact.value("Name").value<QContactName>().firstName());
|
|
272 |
QString status(contact.value("Presence").value<QContactPresence>().customMessage());
|
|
273 |
if(!status.size())
|
|
274 |
status.append("Not available");
|
|
275 |
QString url("C:\\data\\");
|
|
276 |
url.append(name);
|
|
277 |
url.append(".jpg");
|
|
278 |
|
|
279 |
// Add this contact to the list widget
|
|
280 |
iFrndsListWidget->AddListItem(url,name,status);
|
|
281 |
}
|
|
282 |
}
|
|
283 |
|
|
284 |
void HomeView::downloadImages(const SmfItemIdentifier &identifier, const QMap<QString, QUrl> urlMap)
|
|
285 |
{
|
|
286 |
qDebug()<<"Inside HomeView::downloadImages()";
|
|
287 |
QMapIterator<QString, QUrl> iter(urlMap);
|
|
288 |
|
|
289 |
while(iter.hasNext())
|
|
290 |
{
|
|
291 |
iter.next();
|
|
292 |
m_downloader.downloadImage(this, iter.key(), iter.value(), identifier);
|
|
293 |
downloading = true;
|
|
294 |
}
|
|
295 |
}
|
|
296 |
|
|
297 |
void HomeView::Navigated2OtherTab(int tabIndex)
|
|
298 |
{
|
|
299 |
qDebug()<<"Inside HomeView::Navigated2OtherTab() for tab index = "<<tabIndex;
|
|
300 |
|
|
301 |
// Display friends
|
|
302 |
if(tabIndex == 0)
|
|
303 |
{
|
|
304 |
qDebug()<<"Downloading images?? "<<downloading;
|
|
305 |
if(!iFrndsListWidget->count())
|
|
306 |
{
|
|
307 |
if(!downloading)
|
|
308 |
{
|
|
309 |
getFriends();
|
|
310 |
|
|
311 |
/*if (10 == tab)
|
|
312 |
{
|
|
313 |
ToolBarwidget->newAction1->setVisible(false);
|
|
314 |
ToolBarwidget->newAction2->setVisible(false);
|
|
315 |
}*/
|
|
316 |
}
|
|
317 |
}
|
|
318 |
}
|
|
319 |
|
|
320 |
// Display albums
|
|
321 |
else if(tabIndex == 1)
|
|
322 |
{
|
|
323 |
if(!iPostsListWidget->count())
|
|
324 |
{
|
|
325 |
if(!downloading)
|
|
326 |
{
|
|
327 |
getPosts();
|
|
328 |
/*ToolBarwidget->menu->addAction(ToolBarwidget->newAction1);
|
|
329 |
ToolBarwidget->menu->addAction(ToolBarwidget->newAction2);
|
|
330 |
tab = 10;
|
|
331 |
qDebug()<<"Action is visible ?"<<(ToolBarwidget->newAction1->isVisible());
|
|
332 |
if (10 == tab || !(ToolBarwidget->newAction1->isVisible()))
|
|
333 |
{
|
|
334 |
ToolBarwidget->newAction1->setVisible(true);
|
|
335 |
ToolBarwidget->newAction2->setVisible(true);
|
|
336 |
}*/
|
|
337 |
}
|
|
338 |
}
|
|
339 |
}
|
|
340 |
|
|
341 |
// Display albums
|
|
342 |
else if(tabIndex == 2)
|
|
343 |
{
|
|
344 |
if(!m_picList)
|
|
345 |
{
|
|
346 |
if(!downloading)
|
|
347 |
{
|
|
348 |
getPhotos();
|
|
349 |
/*if (ToolBarwidget->newAction1->isVisible())
|
|
350 |
{
|
|
351 |
ToolBarwidget->newAction1->setVisible(false);
|
|
352 |
ToolBarwidget->newAction2->setVisible(false);
|
|
353 |
}*/
|
|
354 |
}
|
|
355 |
}
|
|
356 |
|
|
357 |
}
|
|
358 |
|
|
359 |
// Display activities
|
|
360 |
else if(tabIndex == 3)
|
|
361 |
{
|
|
362 |
if(!iActivityListWidget->count())
|
|
363 |
{
|
|
364 |
getActivities();
|
|
365 |
/*if (ToolBarwidget->newAction1->isVisible())
|
|
366 |
{
|
|
367 |
ToolBarwidget->newAction1->setVisible(false);
|
|
368 |
ToolBarwidget->newAction2->setVisible(false);
|
|
369 |
}*/
|
|
370 |
}
|
|
371 |
}
|
|
372 |
}
|
|
373 |
|
|
374 |
void HomeView::getPosts()
|
|
375 |
{
|
|
376 |
qDebug()<<"Inside HomeView::getPosts()";
|
|
377 |
|
|
378 |
SmfClient client;
|
|
379 |
QString intfName("org.symbian.smf.client.contact.posts");
|
|
380 |
SmfProviderList *providerList = client.GetServices(intfName);
|
|
381 |
bool pluginFound = false;
|
|
382 |
qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
|
|
383 |
foreach(SmfProvider provider, *providerList)
|
|
384 |
{
|
|
385 |
if("Facebook" == provider.serviceName())
|
|
386 |
{
|
|
387 |
qDebug()<<"Plugin for facebook found";
|
|
388 |
pluginFound = true;
|
|
389 |
m_postProvider = new SmfPostProvider(&provider);
|
|
390 |
bool ret = connect(m_postProvider, SIGNAL(postsAvailable(SmfPostList*, SmfError , SmfResultPage)),
|
|
391 |
this, SLOT(postsAvailable(SmfPostList*, SmfError , SmfResultPage)));
|
|
392 |
|
|
393 |
qDebug()<<"Connected ?"<<ret;
|
|
394 |
m_postProvider->posts();
|
|
395 |
}
|
|
396 |
}
|
|
397 |
|
|
398 |
if(!pluginFound)
|
|
399 |
{
|
|
400 |
qDebug()<<"Plugin for facebook not found!!!";
|
|
401 |
QString smferrString("No Facebook plugin found!!!");
|
|
402 |
QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
|
|
403 |
}
|
|
404 |
}
|
|
405 |
|
|
406 |
void HomeView::postsAvailable(SmfPostList* postsList, SmfError error, SmfResultPage page)
|
|
407 |
{
|
|
408 |
Q_UNUSED(page);
|
|
409 |
|
|
410 |
qDebug()<<"Inside HomeView::postsAvailable()";
|
|
411 |
|
|
412 |
m_postsList = postsList;
|
|
413 |
if(error)
|
|
414 |
{
|
|
415 |
SmfClient client;
|
|
416 |
QString errStr = client.errorString(error);
|
|
417 |
qDebug()<<"Error found, code = "<<error;
|
|
418 |
qDebug()<<"Error string is = "<<errStr;
|
|
419 |
|
|
420 |
QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
|
|
421 |
return;
|
|
422 |
}
|
|
423 |
|
|
424 |
//display posts details
|
|
425 |
qDebug()<<"Number of posts retrieved = "<<postsList->count();
|
|
426 |
if(postsList->count() == 0)
|
|
427 |
{
|
|
428 |
QString smferrString("No Posts");
|
|
429 |
QMessageBox::information(m_mainWindow,"No Posts",smferrString,QMessageBox::Ok);
|
|
430 |
return;
|
|
431 |
}
|
|
432 |
QMap<QString, QUrl> urlMap;
|
|
433 |
foreach(SmfPost post, *postsList)
|
|
434 |
{
|
|
435 |
QString name(post.owner().value("Name").value<QContactName>().firstName());
|
|
436 |
QUrl url(post.owner().value("Avatar").value<QContactAvatar>().imageUrl());
|
|
437 |
|
|
438 |
qDebug()<<"Post text = "<<post.description();
|
|
439 |
qDebug()<<"owner = "<<name;
|
|
440 |
qDebug()<<"owner's profile image url = "<<url.toString();
|
|
441 |
|
|
442 |
urlMap.insert(name, url);
|
|
443 |
}
|
|
444 |
|
|
445 |
// Download Images
|
|
446 |
downloadImages(SmfPostsFetch, urlMap);
|
|
447 |
}
|
|
448 |
|
|
449 |
|
|
450 |
void HomeView::populatePostsWidget()
|
|
451 |
{
|
|
452 |
// Add individual items to the widget
|
|
453 |
foreach(SmfPost post, *m_postsList)
|
|
454 |
{
|
|
455 |
QString name(post.owner().value("Name").value<QContactName>().firstName());
|
|
456 |
QString text(post.description());
|
|
457 |
|
|
458 |
QString url("C:\\data\\");
|
|
459 |
url.append(name);
|
|
460 |
url.append(".jpg");
|
|
461 |
|
|
462 |
// Add this contact to the list widget
|
|
463 |
iPostsListWidget->AddListItem(url,name,text);
|
|
464 |
}
|
|
465 |
}
|
|
466 |
|
|
467 |
void HomeView::getAlbums()
|
|
468 |
{
|
|
469 |
qDebug()<<"Inside HomeView::getAlbums()";
|
|
470 |
|
|
471 |
SmfClient client;
|
|
472 |
QString intfName("org.symbian.smf.client.gallery");
|
|
473 |
SmfProviderList *providerList = client.GetServices(intfName);
|
|
474 |
bool pluginFound = false;
|
|
475 |
qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
|
|
476 |
foreach(SmfProvider provider, *providerList)
|
|
477 |
{
|
|
478 |
if("Flickr" == provider.serviceName())
|
|
479 |
{
|
|
480 |
qDebug()<<"Plugin for flickr found";
|
|
481 |
pluginFound = true;
|
|
482 |
m_gallery = new SmfGallery(&provider);
|
|
483 |
bool ret = connect(m_gallery, SIGNAL(albumsAvailable(SmfPictureAlbumList*, SmfError , SmfResultPage)),
|
|
484 |
this, SLOT(albumsAvailable(SmfPictureAlbumList*, SmfError , SmfResultPage)));
|
|
485 |
|
|
486 |
qDebug()<<"Connected ?"<<ret;
|
|
487 |
QStringList names;
|
|
488 |
|
|
489 |
SmfContact user; // current user
|
|
490 |
|
|
491 |
m_gallery->albums(names, &user);
|
|
492 |
}
|
|
493 |
}
|
|
494 |
if(!pluginFound)
|
|
495 |
{
|
|
496 |
qDebug()<<"Plugin for flickr not found!!!";
|
|
497 |
QString smferrString("No flickr plugin found!!!");
|
|
498 |
QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
|
|
499 |
}
|
|
500 |
}
|
|
501 |
|
|
502 |
void HomeView::albumsAvailable(SmfPictureAlbumList* albums, SmfError error, SmfResultPage resultPage)
|
|
503 |
{
|
|
504 |
Q_UNUSED(resultPage);
|
|
505 |
|
|
506 |
qDebug()<<"Inside HomeView::albumsAvailable()";
|
|
507 |
|
|
508 |
m_albumsList = albums;
|
|
509 |
if(error)
|
|
510 |
{
|
|
511 |
SmfClient client;
|
|
512 |
QString errStr = client.errorString(error);
|
|
513 |
qDebug()<<"Error found, code = "<<error;
|
|
514 |
qDebug()<<"Error string is = "<<errStr;
|
|
515 |
|
|
516 |
QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
|
|
517 |
return;
|
|
518 |
}
|
|
519 |
|
|
520 |
//display album details
|
|
521 |
qDebug()<<"Number of albums retrieved = "<<albums->count();
|
|
522 |
if(albums->count() == 0)
|
|
523 |
{
|
|
524 |
QString smferrString("No Albums");
|
|
525 |
QMessageBox::information(m_mainWindow,"No Albums",smferrString,QMessageBox::Ok);
|
|
526 |
return;
|
|
527 |
}
|
|
528 |
|
|
529 |
QStringList albumPicList;
|
|
530 |
QStringList albumNameList;
|
|
531 |
foreach(SmfPictureAlbum album, *m_albumsList)
|
|
532 |
{
|
|
533 |
|
|
534 |
qDebug()<<"Album name = "<<album.title();
|
|
535 |
qDebug()<<"Album description = "<<album.description();
|
|
536 |
qDebug()<<"Album pictureCount = "<<album.pictureCount();
|
|
537 |
qDebug()<<"Album id = "<<album.id();
|
|
538 |
albumNameList.append(album.title());
|
|
539 |
albumPicList.append("C:\\data\\sample.bmp");
|
|
540 |
}
|
|
541 |
|
|
542 |
// Create the grip view
|
|
543 |
AlbumView->CreateGridView(albumPicList, albumNameList);
|
|
544 |
}
|
|
545 |
|
|
546 |
|
|
547 |
void HomeView::getActivities()
|
|
548 |
{
|
|
549 |
qDebug()<<"Inside HomeView::getActivities()";
|
|
550 |
|
|
551 |
// Get the list of providers
|
|
552 |
SmfClient client;
|
|
553 |
QString intfName("org.symbian.smf.client.activity.fetcher");
|
|
554 |
|
|
555 |
SmfProviderList *providerList = client.GetServices(intfName);
|
|
556 |
qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
|
|
557 |
|
|
558 |
// flag to check if required plugin is there
|
|
559 |
bool pluginFound = false;
|
|
560 |
int index = 0;
|
|
561 |
foreach(SmfProvider provider, *providerList)
|
|
562 |
{
|
|
563 |
if("Facebook" == provider.serviceName())
|
|
564 |
{
|
|
565 |
qDebug()<<"Plugin for Facebook found";
|
|
566 |
pluginFound = true;
|
|
567 |
m_activityFetcher = new SmfActivityFetcher(&provider);
|
|
568 |
bool ret = connect(m_activityFetcher, SIGNAL(resultsAvailable(SmfActivityEntryList*, SmfError , SmfResultPage)),
|
|
569 |
this, SLOT(activitiesAvailable(SmfActivityEntryList*, SmfError , SmfResultPage)));
|
|
570 |
|
|
571 |
qDebug()<<"Connected ?"<<ret;
|
|
572 |
m_activityFetcher->selfActivities();
|
|
573 |
}
|
|
574 |
index++;
|
|
575 |
}
|
|
576 |
|
|
577 |
if(!pluginFound)
|
|
578 |
{
|
|
579 |
qDebug()<<"Plugin for Facebook not found!!!";
|
|
580 |
QString smferrString("No Facebook plugin found!!!");
|
|
581 |
QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
|
|
582 |
}
|
|
583 |
}
|
|
584 |
|
|
585 |
|
|
586 |
void HomeView::activitiesAvailable(SmfActivityEntryList* activitiesList, SmfError error, SmfResultPage resultPage)
|
|
587 |
{
|
26
|
588 |
Q_UNUSED(resultPage)
|
16
|
589 |
qDebug()<<"Inside HomeView::activitiesAvailable()";
|
|
590 |
|
|
591 |
m_activitiesList = activitiesList;
|
|
592 |
qDebug()<<"Number of activities retrieved = "<<activitiesList->count();
|
|
593 |
if(error)
|
|
594 |
{
|
|
595 |
SmfClient client;
|
|
596 |
QString errStr = client.errorString(error);
|
|
597 |
qDebug()<<"Error found, code = "<<error;
|
|
598 |
qDebug()<<"Error string is = "<<errStr;
|
|
599 |
|
|
600 |
QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
|
|
601 |
return;
|
|
602 |
}
|
|
603 |
|
|
604 |
//display activity description
|
|
605 |
qDebug()<<"Number of activities retrieved = "<<activitiesList->count();
|
|
606 |
|
|
607 |
if(activitiesList->count() == 0)
|
|
608 |
{
|
|
609 |
QString smferrString("No Recent Activities");
|
|
610 |
QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
|
|
611 |
return;
|
|
612 |
}
|
|
613 |
|
|
614 |
foreach(SmfActivityEntry activity, *activitiesList)
|
|
615 |
{
|
|
616 |
qDebug()<<"Activity author name = "<<activity.author().value("Name").value<QContactName>().firstName();
|
|
617 |
qDebug()<<"Activity title = "<<activity.title().title();
|
|
618 |
qDebug()<<"Activity details = "<<activity.details().description();
|
|
619 |
}
|
|
620 |
|
|
621 |
populateActivitiesWidget();
|
|
622 |
|
|
623 |
}
|
|
624 |
|
|
625 |
void HomeView::populateActivitiesWidget()
|
|
626 |
{
|
|
627 |
qDebug()<<"Inside HomeView::populateActivityWidget()";
|
|
628 |
QString defImagePath("C:\\data\\genericfriendicon.svg");
|
|
629 |
foreach(SmfActivityEntry activity, *m_activitiesList)
|
|
630 |
{
|
|
631 |
QString name(activity.author().value("Name").value<QContactName>().firstName());
|
|
632 |
QString title(activity.title().title());
|
|
633 |
|
|
634 |
|
|
635 |
// Add this contact to the list widget
|
|
636 |
iActivityListWidget->AddListItem(defImagePath, name, title);
|
|
637 |
}
|
|
638 |
}
|
|
639 |
|
|
640 |
|
|
641 |
|
|
642 |
void HomeView::getPhotos()
|
|
643 |
{
|
|
644 |
qDebug()<<"Inside HomeView::getPhotos()";
|
|
645 |
|
|
646 |
// Get the list of providers
|
|
647 |
SmfClient client;
|
|
648 |
QString intfName("org.symbian.smf.client.gallery");
|
|
649 |
|
|
650 |
SmfProviderList *providerList = client.GetServices(intfName);
|
|
651 |
qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
|
|
652 |
|
|
653 |
// flag to check if required plugin is there
|
|
654 |
bool pluginFound = false;
|
|
655 |
int index = 0;
|
|
656 |
foreach(SmfProvider provider, *providerList)
|
|
657 |
{
|
|
658 |
if("Flickr" == provider.serviceName())
|
|
659 |
{
|
|
660 |
qDebug()<<"Plugin for flickr found";
|
|
661 |
pluginFound = true;
|
|
662 |
if(!m_gallery)
|
|
663 |
m_gallery = new SmfGallery(&provider);
|
|
664 |
bool ret = connect(m_gallery, SIGNAL(picturesAvailable(SmfPictureList*, SmfError , SmfResultPage)),
|
|
665 |
this, SLOT(picturesAvailable(SmfPictureList*, SmfError , SmfResultPage)));
|
|
666 |
|
|
667 |
qDebug()<<"Connected ?"<<ret;
|
|
668 |
|
|
669 |
#ifndef IFNOALBUMIDOFTHELOGGEDINUSERISAVAILABLE
|
|
670 |
SmfPictureAlbumList list; // pass empty list to fetch photos which are not part of any set, when albumID is not available
|
|
671 |
#else // If the album id is known use the below piece of code
|
|
672 |
SmfPictureAlbumList list;
|
|
673 |
SmfPictureAlbum album;
|
|
674 |
album.setId("72157623348359220");
|
|
675 |
list.append(album);
|
|
676 |
#endif
|
|
677 |
|
|
678 |
m_gallery->pictures(list);
|
|
679 |
}
|
|
680 |
index++;
|
|
681 |
}
|
|
682 |
|
|
683 |
if(!pluginFound)
|
|
684 |
{
|
|
685 |
qDebug()<<"Plugin for flickr not found!!!";
|
|
686 |
QString smferrString("No Flickr plugin found!!!");
|
|
687 |
QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
|
|
688 |
}
|
|
689 |
}
|
|
690 |
|
|
691 |
|
|
692 |
void HomeView::picturesAvailable(SmfPictureList* picList, SmfError error, SmfResultPage resultPage)
|
|
693 |
{
|
26
|
694 |
Q_UNUSED(resultPage)
|
16
|
695 |
qDebug()<<"Inside HomeView::picturesAvailable()";
|
|
696 |
|
|
697 |
m_picList = picList;
|
|
698 |
if(error)
|
|
699 |
{
|
|
700 |
SmfClient client;
|
|
701 |
QString errStr = client.errorString(error);
|
|
702 |
qDebug()<<"Error found, code = "<<error;
|
|
703 |
qDebug()<<"Error string is = "<<errStr;
|
|
704 |
|
|
705 |
QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
|
|
706 |
return;
|
|
707 |
}
|
|
708 |
|
|
709 |
//display pic description
|
|
710 |
qDebug()<<"Number of pic retrieved = "<<picList->count();
|
|
711 |
|
|
712 |
QMap<QString, QUrl> urlMap;
|
|
713 |
foreach(SmfPicture pic, *picList)
|
|
714 |
{
|
|
715 |
qDebug()<<"Photo title = "<<pic.title();
|
|
716 |
qDebug()<<"Photo posted date = "<<pic.postedDate();
|
|
717 |
qDebug()<<"Photo url = "<<pic.url();
|
|
718 |
qDebug()<<"Photo id = "<<pic.id();
|
|
719 |
|
|
720 |
QString name(pic.title());
|
|
721 |
QUrl url(pic.url());
|
|
722 |
|
|
723 |
urlMap.insert(name, url);
|
|
724 |
}
|
|
725 |
|
|
726 |
// Download Images
|
|
727 |
downloadImages(SmfPhotosFetch, urlMap);
|
|
728 |
}
|
|
729 |
|
|
730 |
|
|
731 |
void HomeView::populatePhotosGridView()
|
|
732 |
{
|
|
733 |
qDebug()<<"Inside HomeView::populatePhotosGridView()";
|
|
734 |
|
|
735 |
QStringList albumPicList;
|
|
736 |
QStringList albumNameList;
|
|
737 |
|
|
738 |
foreach(SmfPicture pic, *m_picList)
|
|
739 |
{
|
|
740 |
QString name(pic.title());
|
|
741 |
|
|
742 |
qDebug()<<"Name :"<<name;
|
|
743 |
QString url("C:\\data\\");
|
|
744 |
url.append(name);
|
|
745 |
url.append(".jpg");
|
|
746 |
|
|
747 |
|
|
748 |
albumNameList.append(name);
|
|
749 |
albumPicList.append(url);
|
|
750 |
}
|
|
751 |
|
|
752 |
// Create the grip view
|
|
753 |
iAlbumWidget->AddListItem(m_mainWindow,albumPicList,albumNameList);
|
|
754 |
// AlbumView->CreateGridView(albumPicList,albumNameList);
|
|
755 |
|
|
756 |
}
|