example/DemoGUI/HomeView.cpp
changeset 16 b78fa4cdbf2b
child 26 83d6a149c755
equal deleted inserted replaced
15:9b00ca3cc206 16:b78fa4cdbf2b
       
     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 
       
    15 static int tab = 0;
       
    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 	{
       
   223 	qDebug()<<"Inside HomeView::friendsAvailable()";
       
   224 	
       
   225 	m_friendsList = friendsList;
       
   226 	if(error)
       
   227 		{
       
   228 		SmfClient client;
       
   229 		QString errStr = client.errorString(error);
       
   230 		qDebug()<<"Error found, code = "<<error;
       
   231 		qDebug()<<"Error string is = "<<errStr;
       
   232 		
       
   233 		QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
       
   234 		return;
       
   235 		}
       
   236 	
       
   237 	//display friends description
       
   238 	int count = 0;
       
   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 	int count = 0;
       
   426 	qDebug()<<"Number of posts retrieved = "<<postsList->count();
       
   427 	if(postsList->count() == 0)
       
   428 		{
       
   429 		QString smferrString("No Posts");
       
   430 		QMessageBox::information(m_mainWindow,"No Posts",smferrString,QMessageBox::Ok);
       
   431 		return;
       
   432 		}
       
   433 	QMap<QString, QUrl> urlMap;
       
   434 	foreach(SmfPost post, *postsList)
       
   435 		{
       
   436 		QString name(post.owner().value("Name").value<QContactName>().firstName());
       
   437 		QUrl url(post.owner().value("Avatar").value<QContactAvatar>().imageUrl());
       
   438 
       
   439 		qDebug()<<"Post text = "<<post.description();
       
   440 		qDebug()<<"owner = "<<name;
       
   441 		qDebug()<<"owner's profile image url = "<<url.toString();
       
   442 		
       
   443 		urlMap.insert(name, url);
       
   444 		}
       
   445 	
       
   446 	// Download Images
       
   447 	downloadImages(SmfPostsFetch, urlMap);
       
   448 	}
       
   449 
       
   450 
       
   451 void HomeView::populatePostsWidget()
       
   452 	{
       
   453 	// Add individual items to the widget
       
   454 	foreach(SmfPost post, *m_postsList)
       
   455 		{
       
   456 		QString name(post.owner().value("Name").value<QContactName>().firstName());
       
   457 		QString text(post.description());
       
   458 
       
   459 		QString url("C:\\data\\");
       
   460 		url.append(name);
       
   461 		url.append(".jpg");
       
   462 		
       
   463 		// Add this contact to the list widget
       
   464 		iPostsListWidget->AddListItem(url,name,text);
       
   465 		}
       
   466 	}
       
   467 
       
   468 void HomeView::getAlbums()
       
   469 	{
       
   470 	qDebug()<<"Inside HomeView::getAlbums()";
       
   471 		
       
   472 	SmfClient client;
       
   473 	QString intfName("org.symbian.smf.client.gallery");
       
   474 	SmfProviderList *providerList = client.GetServices(intfName);
       
   475 	bool pluginFound = false;
       
   476 	qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
       
   477 	foreach(SmfProvider provider, *providerList)
       
   478 		{
       
   479 		if("Flickr" == provider.serviceName())
       
   480 			{
       
   481 			qDebug()<<"Plugin for flickr found";
       
   482 			pluginFound = true;
       
   483 			m_gallery = new SmfGallery(&provider);
       
   484 			bool ret = connect(m_gallery, SIGNAL(albumsAvailable(SmfPictureAlbumList*, SmfError , SmfResultPage)),
       
   485 					this, SLOT(albumsAvailable(SmfPictureAlbumList*, SmfError , SmfResultPage)));
       
   486 			
       
   487 			qDebug()<<"Connected ?"<<ret;
       
   488 			QStringList names;
       
   489 			
       
   490 			SmfContact user; // current user
       
   491 			
       
   492 			m_gallery->albums(names, &user);
       
   493 			}
       
   494 		}
       
   495 	if(!pluginFound)
       
   496 		{
       
   497 		qDebug()<<"Plugin for flickr not found!!!";
       
   498 		QString smferrString("No flickr plugin found!!!");
       
   499 		QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
       
   500 		}
       
   501 	}
       
   502 
       
   503 void HomeView::albumsAvailable(SmfPictureAlbumList* albums, SmfError error, SmfResultPage resultPage)
       
   504 	{
       
   505 	Q_UNUSED(resultPage);
       
   506 			
       
   507 	qDebug()<<"Inside HomeView::albumsAvailable()";
       
   508 	
       
   509 	m_albumsList = albums;
       
   510 	if(error)
       
   511 		{
       
   512 		SmfClient client;
       
   513 		QString errStr = client.errorString(error);
       
   514 		qDebug()<<"Error found, code = "<<error;
       
   515 		qDebug()<<"Error string is = "<<errStr;
       
   516 		
       
   517 		QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
       
   518 		return;
       
   519 		}
       
   520 	
       
   521 	//display album details
       
   522 	int count = 0;
       
   523 	qDebug()<<"Number of albums retrieved = "<<albums->count();
       
   524 	if(albums->count() == 0)
       
   525 		{
       
   526 		QString smferrString("No Albums");
       
   527 		QMessageBox::information(m_mainWindow,"No Albums",smferrString,QMessageBox::Ok);
       
   528 		return;
       
   529 		}
       
   530 	
       
   531 	QStringList albumPicList;
       
   532 	QStringList albumNameList;
       
   533 	foreach(SmfPictureAlbum album, *m_albumsList)
       
   534 		{
       
   535 		
       
   536 		qDebug()<<"Album name = "<<album.title();
       
   537 		qDebug()<<"Album description = "<<album.description();
       
   538 		qDebug()<<"Album pictureCount = "<<album.pictureCount();
       
   539 		qDebug()<<"Album id = "<<album.id();
       
   540 		albumNameList.append(album.title());
       
   541 		albumPicList.append("C:\\data\\sample.bmp");
       
   542 		}
       
   543 	
       
   544 	// Create the grip view
       
   545 	AlbumView->CreateGridView(albumPicList, albumNameList);
       
   546 	}
       
   547 
       
   548 
       
   549 void HomeView::getActivities()
       
   550 	{
       
   551 	qDebug()<<"Inside HomeView::getActivities()";
       
   552 	
       
   553 	// Get the list of providers
       
   554 	SmfClient client;
       
   555 	QString intfName("org.symbian.smf.client.activity.fetcher");
       
   556 	
       
   557 	SmfProviderList *providerList = client.GetServices(intfName);
       
   558 	qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
       
   559 	
       
   560 	// flag to check if required plugin is there
       
   561 	bool pluginFound = false;
       
   562 	int index = 0;
       
   563 	foreach(SmfProvider provider, *providerList)
       
   564 		{
       
   565 		if("Facebook" == provider.serviceName())
       
   566 			{
       
   567 			qDebug()<<"Plugin for Facebook found";
       
   568 			pluginFound = true;
       
   569 			m_activityFetcher = new SmfActivityFetcher(&provider);
       
   570 			bool ret = connect(m_activityFetcher, SIGNAL(resultsAvailable(SmfActivityEntryList*, SmfError , SmfResultPage)),
       
   571 					this, SLOT(activitiesAvailable(SmfActivityEntryList*, SmfError , SmfResultPage)));
       
   572 			
       
   573 			qDebug()<<"Connected ?"<<ret;
       
   574 			m_activityFetcher->selfActivities();
       
   575 			}
       
   576 		index++;
       
   577 		}
       
   578 	
       
   579 	if(!pluginFound)
       
   580 		{
       
   581 		qDebug()<<"Plugin for Facebook not found!!!";
       
   582 		QString smferrString("No Facebook plugin found!!!");
       
   583 		QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
       
   584 		}
       
   585 	}
       
   586 
       
   587 
       
   588 void HomeView::activitiesAvailable(SmfActivityEntryList* activitiesList, SmfError error, SmfResultPage resultPage)
       
   589 	{
       
   590 	qDebug()<<"Inside HomeView::activitiesAvailable()";
       
   591 	
       
   592 	m_activitiesList = activitiesList;
       
   593 	qDebug()<<"Number of activities retrieved = "<<activitiesList->count();
       
   594 	if(error)
       
   595 		{
       
   596 		SmfClient client;
       
   597 		QString errStr = client.errorString(error);
       
   598 		qDebug()<<"Error found, code = "<<error;
       
   599 		qDebug()<<"Error string is = "<<errStr;
       
   600 		
       
   601 		QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
       
   602 		return;
       
   603 		}
       
   604 	
       
   605 	//display activity description
       
   606 	int count = 0;
       
   607 	qDebug()<<"Number of activities retrieved = "<<activitiesList->count();
       
   608 	
       
   609 	if(activitiesList->count() == 0)
       
   610 		{
       
   611 		QString smferrString("No Recent Activities");
       
   612 		QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
       
   613 		return;
       
   614 		}
       
   615 	
       
   616 	foreach(SmfActivityEntry activity, *activitiesList)
       
   617 		{
       
   618 		qDebug()<<"Activity author name = "<<activity.author().value("Name").value<QContactName>().firstName();
       
   619 		qDebug()<<"Activity title = "<<activity.title().title();
       
   620 		qDebug()<<"Activity details = "<<activity.details().description();
       
   621 		}
       
   622 
       
   623 	populateActivitiesWidget();
       
   624 		
       
   625 	}
       
   626 
       
   627 void HomeView::populateActivitiesWidget()
       
   628 	{
       
   629 	qDebug()<<"Inside HomeView::populateActivityWidget()";
       
   630 	QString defImagePath("C:\\data\\genericfriendicon.svg");
       
   631 	foreach(SmfActivityEntry activity, *m_activitiesList)
       
   632 		{
       
   633 		QString name(activity.author().value("Name").value<QContactName>().firstName());
       
   634 		QString title(activity.title().title());
       
   635 
       
   636 		
       
   637 		// Add this contact to the list widget
       
   638 		iActivityListWidget->AddListItem(defImagePath, name, title);
       
   639 		}
       
   640 	}
       
   641 
       
   642 
       
   643 
       
   644 void HomeView::getPhotos()
       
   645 	{
       
   646 	qDebug()<<"Inside HomeView::getPhotos()";
       
   647 	
       
   648 	// Get the list of providers
       
   649 	SmfClient client;
       
   650 	QString intfName("org.symbian.smf.client.gallery");
       
   651 	
       
   652 	SmfProviderList *providerList = client.GetServices(intfName);
       
   653 	qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
       
   654 	
       
   655 	// flag to check if required plugin is there
       
   656 	bool pluginFound = false;
       
   657 	int index = 0;
       
   658 	foreach(SmfProvider provider, *providerList)
       
   659 		{
       
   660 		if("Flickr" == provider.serviceName())
       
   661 			{
       
   662 			qDebug()<<"Plugin for flickr found";
       
   663 			pluginFound = true;
       
   664 			if(!m_gallery)
       
   665 				m_gallery = new SmfGallery(&provider);
       
   666 			bool ret = connect(m_gallery, SIGNAL(picturesAvailable(SmfPictureList*, SmfError , SmfResultPage)),
       
   667 					this, SLOT(picturesAvailable(SmfPictureList*, SmfError , SmfResultPage)));
       
   668 			
       
   669 			qDebug()<<"Connected ?"<<ret;
       
   670 			
       
   671 #ifndef IFNOALBUMIDOFTHELOGGEDINUSERISAVAILABLE
       
   672 			SmfPictureAlbumList list; // pass empty list to fetch photos which are not part of any set, when albumID is not available
       
   673 #else		// If the album id is known use the below piece of code
       
   674 			SmfPictureAlbumList list;
       
   675 			SmfPictureAlbum album;
       
   676 			album.setId("72157623348359220");
       
   677 			list.append(album);
       
   678 #endif
       
   679 					
       
   680 			m_gallery->pictures(list);
       
   681 			}
       
   682 		index++;
       
   683 		}
       
   684 	
       
   685 	if(!pluginFound)
       
   686 		{
       
   687 		qDebug()<<"Plugin for flickr not found!!!";
       
   688 		QString smferrString("No Flickr plugin found!!!");
       
   689 		QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
       
   690 		}
       
   691 	}
       
   692 
       
   693 
       
   694 void HomeView::picturesAvailable(SmfPictureList* picList, SmfError error, SmfResultPage resultPage)
       
   695 	{
       
   696 	qDebug()<<"Inside HomeView::picturesAvailable()";
       
   697 	
       
   698 	m_picList = picList;
       
   699 	if(error)
       
   700 		{
       
   701 		SmfClient client;
       
   702 		QString errStr = client.errorString(error);
       
   703 		qDebug()<<"Error found, code = "<<error;
       
   704 		qDebug()<<"Error string is = "<<errStr;
       
   705 		
       
   706 		QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
       
   707 		return;
       
   708 		}
       
   709 	
       
   710 	//display pic description
       
   711 	int count = 0;
       
   712 	qDebug()<<"Number of pic retrieved = "<<picList->count();
       
   713 	
       
   714 	QMap<QString, QUrl> urlMap;
       
   715 	foreach(SmfPicture pic, *picList)
       
   716 		{
       
   717 		qDebug()<<"Photo title = "<<pic.title();
       
   718 		qDebug()<<"Photo posted date = "<<pic.postedDate();
       
   719 		qDebug()<<"Photo url = "<<pic.url();
       
   720 		qDebug()<<"Photo id = "<<pic.id();
       
   721 		
       
   722 		QString name(pic.title());
       
   723 		QUrl url(pic.url());
       
   724 
       
   725 		urlMap.insert(name, url);
       
   726 		}
       
   727 
       
   728 	// Download Images
       
   729 	downloadImages(SmfPhotosFetch, urlMap);
       
   730 	}
       
   731 
       
   732 
       
   733 void HomeView::populatePhotosGridView()
       
   734 	{
       
   735 	qDebug()<<"Inside HomeView::populatePhotosGridView()";
       
   736 	
       
   737 	QStringList albumPicList;
       
   738 	QStringList albumNameList;
       
   739 	
       
   740 	foreach(SmfPicture pic, *m_picList)
       
   741 		{
       
   742 		QString name(pic.title());
       
   743 		
       
   744 		qDebug()<<"Name  :"<<name;
       
   745 		QString url("C:\\data\\");
       
   746 		url.append(name);
       
   747 		url.append(".jpg");
       
   748 		
       
   749 		
       
   750 		albumNameList.append(name);
       
   751 		albumPicList.append(url);
       
   752 		}
       
   753 	
       
   754 	// Create the grip view
       
   755 	iAlbumWidget->AddListItem(m_mainWindow,albumPicList,albumNameList);
       
   756 //	AlbumView->CreateGridView(albumPicList,albumNameList);
       
   757 	
       
   758 	}