Tests/DemoGUI/HomeView.cpp
changeset 26 83d6a149c755
equal deleted inserted replaced
25:a180113055cb 26:83d6a149c755
       
     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 #include "ToolBar.h"
       
     8 #include <QMapIterator>
       
     9 #include <smfclient.h>
       
    10 #include <smfprovider.h>
       
    11 #include <QMessageBox>
       
    12 #include <QDebug>
       
    13 #include <qsettings.h>
       
    14 #include "ImageDownload.h"
       
    15 
       
    16 HomeView::HomeView(QString aHeadName):
       
    17         iHeadName(aHeadName)
       
    18 	{
       
    19 	//m_providerList = NULL;
       
    20 	m_mainWindow = NULL;
       
    21 	TabWidget = NULL;
       
    22 	iFrndsListWidget = NULL;
       
    23 	iPostsListWidget = NULL;
       
    24 	iActivityListWidget = NULL;
       
    25 	AlbumView = NULL;
       
    26 	
       
    27 	m_contactFetcher = NULL;
       
    28 	m_postProvider = NULL;
       
    29 	m_gallery = NULL;
       
    30 	m_activityFetcher = NULL;
       
    31 	m_friendsList = NULL;
       
    32 	m_postsList = NULL;
       
    33 	m_albumsList = NULL;
       
    34 	m_activitiesList = NULL;
       
    35 	m_picList = NULL;
       
    36 	}
       
    37 
       
    38 HomeView::~HomeView()
       
    39 	{
       
    40 	if(TabWidget)
       
    41 		{
       
    42 		delete TabWidget;
       
    43 		TabWidget = NULL;
       
    44 		}
       
    45 	if(iFrndsListWidget)
       
    46 		{
       
    47 		delete iFrndsListWidget;
       
    48 		iFrndsListWidget = NULL;
       
    49 		}
       
    50 	if(iPostsListWidget)
       
    51 		{
       
    52 		delete iPostsListWidget;
       
    53 		iPostsListWidget = NULL;
       
    54 		}
       
    55 	if(iActivityListWidget)
       
    56 		{
       
    57 		delete iActivityListWidget;
       
    58 		iActivityListWidget = NULL;
       
    59 		}
       
    60 	if(AlbumView)
       
    61 		{
       
    62 		delete AlbumView;
       
    63 		AlbumView = NULL;
       
    64 		}
       
    65 	
       
    66 	if(m_contactFetcher)
       
    67 		{
       
    68 		delete m_contactFetcher;
       
    69 		m_contactFetcher =NULL;
       
    70 		}
       
    71 	if(m_postProvider)
       
    72 		{
       
    73 		delete m_postProvider;
       
    74 		m_postProvider =NULL;
       
    75 		}
       
    76 	if(m_gallery)
       
    77 		{
       
    78 		delete m_gallery;
       
    79 		m_gallery =NULL;
       
    80 		}
       
    81 	if(m_activityFetcher)
       
    82 		{
       
    83 		delete m_activityFetcher;
       
    84 		m_activityFetcher =NULL;
       
    85 		}
       
    86 	if(m_friendsList)
       
    87 		{
       
    88 		delete m_friendsList;
       
    89 		m_friendsList =NULL;
       
    90 		}
       
    91 	if(m_postsList)
       
    92 		{
       
    93 		delete m_postsList;
       
    94 		m_postsList =NULL;
       
    95 		}
       
    96 	if(m_albumsList)
       
    97 		{
       
    98 		delete m_albumsList;
       
    99 		m_albumsList =NULL;
       
   100 		}
       
   101 	if(m_activitiesList)
       
   102 		{
       
   103 		delete m_activitiesList;
       
   104 		m_activitiesList =NULL;
       
   105 		}
       
   106 	if(m_picList)
       
   107 		{
       
   108 		delete m_picList;
       
   109 		m_picList =NULL;
       
   110 		}
       
   111 	}
       
   112 
       
   113 
       
   114 void HomeView::SetupUI(QMainWindow *Mainwindow)
       
   115 	{
       
   116 	qDebug()<<"Inside HomeView::SetupUI()";
       
   117 	
       
   118 	m_mainWindow = Mainwindow;
       
   119 	
       
   120     QPushButton* HomeButton = new QPushButton(m_mainWindow);
       
   121     HomeButton->setText(iHeadName);
       
   122     HomeButton->setGeometry(0,0,ScreenSize::GetScreenRect().width(),KHeadNameHeight);
       
   123     HomeButton->setStyleSheet("background-color: rgb(0,0,0);"
       
   124                              "border-width: 2px;"
       
   125                              "font: bold 16px;"
       
   126                              "min-width: 10em;"
       
   127                              "padding: 4px;"
       
   128 							 "color: white;"
       
   129                             );
       
   130 
       
   131     HomeButton->setDisabled(true);
       
   132     qDebug()<<"Home button created and setup";
       
   133     
       
   134     TabWidget = new QTabWidget(m_mainWindow);
       
   135     connect(TabWidget,SIGNAL(currentChanged(int)),this,SLOT(Navigated2OtherTab(int)));
       
   136     qDebug()<<"Tab widget created";
       
   137     
       
   138     iFrndsListWidget = new CustomListWidget();
       
   139     TabWidget->addTab(iFrndsListWidget,"Friends New");
       
   140     qDebug()<<"Friends Tab created";
       
   141     
       
   142     iPostsListWidget = new CustomListWidget();
       
   143     TabWidget->addTab(iPostsListWidget,"Posts");
       
   144     qDebug()<<"Posts Tab created";
       
   145 
       
   146     //AlbumView = new GridView();
       
   147     /*QWidget *widget = new QWidget();
       
   148     TabWidget->addTab(widget,"Album");*/
       
   149     iAlbumWidget = new CustomListWidget();
       
   150     TabWidget->addTab(iAlbumWidget,"Album");
       
   151     
       
   152     qDebug()<<"Albums Tab created";
       
   153     
       
   154  
       
   155         
       
   156     
       
   157 /*
       
   158     QStringList Iconpathlist;
       
   159     Iconpathlist.append("C:\\data\\AlbumDefault.JPG");
       
   160     Iconpathlist.append("C:\\data\\AlbumDefault.JPG");
       
   161     Iconpathlist.append("C:\\data\\AlbumDefault.JPG");
       
   162     Iconpathlist.append("C:\\data\\AlbumDefault.JPG");
       
   163 
       
   164     
       
   165     TabWidget->addTab(AlbumView->CreateGridView(Iconpathlist),"Album");
       
   166     qDebug()<<"Albums Tab created";
       
   167 */
       
   168 
       
   169     iActivityListWidget = new CustomListWidget();
       
   170     TabWidget->addTab(iActivityListWidget,"Activity");
       
   171     qDebug()<<"Activity Tab created";
       
   172 
       
   173     
       
   174     iPlaylistWidget = new CustomListWidget();
       
   175     TabWidget->addTab(iPlaylistWidget,"PlayList");
       
   176     qDebug()<<"Music Tab created";
       
   177     
       
   178     iEventslistWidget = new CustomListWidget();
       
   179     TabWidget->addTab(iEventslistWidget,"EventsList");
       
   180     qDebug()<<"Events Tab created";
       
   181     
       
   182     iMusicSearchListWidget=new CustomListWidget();
       
   183     TabWidget->addTab(iMusicSearchListWidget,"SearchList");
       
   184     qDebug()<<"Search Tab created";
       
   185    
       
   186     TabWidget->setGeometry(0,KHeadNameHeight + KWidgetGapFactor,ScreenSize::GetScreenRect().width(),ScreenSize::GetScreenRect().height() - 100);
       
   187 
       
   188     //Drawing Tool bar
       
   189     ToolBar* ToolBarwidget = new ToolBar;
       
   190     QStringList actionList;
       
   191     actionList.append("Open");
       
   192     actionList.append("Reply");
       
   193     actionList.append("Add Services");
       
   194     ToolBarwidget->GetToolBar(m_mainWindow,actionList);
       
   195     qDebug()<<"Tool bar created";
       
   196     }
       
   197 
       
   198 
       
   199 void HomeView::getFriends()
       
   200 	{
       
   201 	qDebug()<<"Inside HomeView::getFriends()";
       
   202 	
       
   203 	// Get the list of providers
       
   204 	SmfClient client;
       
   205 	QString intfName("org.symbian.smf.plugin.contact.fetcher");
       
   206 	
       
   207 	SmfProviderList *providerList = client.GetServices(intfName);
       
   208 	qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
       
   209 	
       
   210 	// flag to check if required plugin is there
       
   211 	bool pluginFound = false;
       
   212 	foreach(SmfProvider provider, *providerList)
       
   213 		{
       
   214 		if("Facebook" == provider.serviceName())
       
   215 			{
       
   216 			qDebug()<<"Plugin for Facebook found";
       
   217 			pluginFound = true;
       
   218 			m_contactFetcher = new SmfContactFetcher(&provider);
       
   219 			bool ret = connect(m_contactFetcher, SIGNAL(friendsListAvailable(SmfContactList*, SmfError , SmfResultPage)),
       
   220 					this, SLOT(friendsAvailable(SmfContactList*, SmfError , SmfResultPage)));
       
   221 			
       
   222 			qDebug()<<"Connected ?"<<ret;
       
   223 			m_contactFetcher->friends(1,5);
       
   224 			}
       
   225 		}
       
   226 	
       
   227 	if(!pluginFound)
       
   228 		{
       
   229 		qDebug()<<"Plugin for Facebook not found!!!";
       
   230 		QString smferrString("No Facebook plugin found!!!");
       
   231 		QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
       
   232 		}
       
   233 	}
       
   234 
       
   235 
       
   236 void HomeView::friendsAvailable(SmfContactList* friendsList, SmfError error, SmfResultPage resultPage)
       
   237 	{
       
   238 	qDebug()<<"Inside HomeView::friendsAvailable()";
       
   239 	
       
   240 	m_friendsList = friendsList;
       
   241 	if(error)
       
   242 		{
       
   243 		SmfClient client;
       
   244 		QString errStr = client.errorString(error);
       
   245 		qDebug()<<"Error found, code = "<<error;
       
   246 		qDebug()<<"Error string is = "<<errStr;
       
   247 		
       
   248 		QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
       
   249 		return;
       
   250 		}
       
   251 	
       
   252 	//display friends description
       
   253 	int count = 0;
       
   254 	qDebug()<<"Number of friends retrieved = "<<friendsList->count();
       
   255 	if(friendsList->count() == 0)
       
   256 		{
       
   257 		QString smferrString("No Friends");
       
   258 		QMessageBox::information(m_mainWindow,"No Friends",smferrString,QMessageBox::Ok);
       
   259 		return;
       
   260 		}
       
   261 		
       
   262 	QMap<QString, QUrl> urlMap;
       
   263 	foreach(SmfContact contact, *friendsList)
       
   264 		{
       
   265 		QString name(contact.value("Name").value<QContactName>().firstName());
       
   266 		QString status(contact.value("Presence").value<QContactPresence>().customMessage());
       
   267 		if(!status.size())
       
   268 			status.append("Not available");
       
   269 		QUrl url(contact.value("Avatar").value<QContactAvatar>().imageUrl());
       
   270 
       
   271 		qDebug()<<"Friends name = "<<contact.value("Name").value<QContactName>().firstName();
       
   272 		qDebug()<<"Friends status msg desc = "<<contact.value("Presence").value<QContactPresence>().customMessage();
       
   273 		qDebug()<<"Friends profile image URL = "<<contact.value("Avatar").value<QContactAvatar>().imageUrl();
       
   274 		urlMap.insert(name, url);
       
   275 		}
       
   276 
       
   277 	// Download Images
       
   278 	downloadImages(SmfFriendsFetch, urlMap);
       
   279 		
       
   280 	}
       
   281 
       
   282 void HomeView::populateFriendsWidget()
       
   283 	{
       
   284 	foreach(SmfContact contact, *m_friendsList)
       
   285 		{
       
   286 		QString name(contact.value("Name").value<QContactName>().firstName());
       
   287 		QString status(contact.value("Presence").value<QContactPresence>().customMessage());
       
   288 		if(!status.size())
       
   289 			status.append("Not available");
       
   290 		QString url("C:\\data\\");
       
   291 		url.append(name);
       
   292 		url.append(".jpg");
       
   293 		
       
   294 		// Add this contact to the list widget
       
   295 		iFrndsListWidget->AddListItem(url,name,status);
       
   296 		}
       
   297 	}
       
   298 
       
   299 void HomeView::downloadImages(const SmfItemIdentifier &identifier, const QMap<QString, QUrl> urlMap)
       
   300 	{
       
   301 	qDebug()<<"Inside HomeView::downloadImages()";
       
   302 	QMapIterator<QString, QUrl> iter(urlMap);
       
   303 	
       
   304 	while(iter.hasNext())
       
   305 		{
       
   306 		iter.next();
       
   307 		m_downloader.downloadImage(this, iter.key(), iter.value(), identifier);
       
   308 		downloading = true;
       
   309 		}
       
   310 	}
       
   311 
       
   312 
       
   313 void HomeView::Navigated2OtherTab(int tabIndex)
       
   314 	{
       
   315 	qDebug()<<"Inside HomeView::Navigated2OtherTab() for tab index = "<<tabIndex;
       
   316 	
       
   317 	// Display friends
       
   318     if(tabIndex == 0)
       
   319     	{
       
   320 		qDebug()<<"Downloading images?? "<<downloading;
       
   321         if(!iFrndsListWidget->count())
       
   322         	{
       
   323 			//if(!downloading)
       
   324 				//getPlayList();
       
   325 				//getFriends();
       
   326         	}
       
   327     	}
       
   328     
       
   329     // Display albums
       
   330     else if(tabIndex == 1)
       
   331     	{
       
   332 		if(!iPostsListWidget->count())
       
   333 			{
       
   334 			if(!downloading)
       
   335 				getPosts();
       
   336 			}
       
   337     	}
       
   338     
       
   339     // Display albums
       
   340     else if(tabIndex == 2)
       
   341     	{
       
   342 		if(!m_picList)
       
   343 			{
       
   344 			if(!downloading)
       
   345 				getPhotos();
       
   346 			}
       
   347     	}
       
   348     	
       
   349     // Display activities
       
   350     else if(tabIndex == 3)
       
   351     	{
       
   352 		if(!iActivityListWidget->count())
       
   353 			getActivities();
       
   354     	}
       
   355     else if(tabIndex == 4)
       
   356     	{	
       
   357           qDebug()<<"MUSICCCCCCccc? ";
       
   358           if(!iPlaylistWidget->count())
       
   359           	{
       
   360   	
       
   361   				getPlayList();
       
   362   
       
   363           	}
       
   364     	}
       
   365     else if(tabIndex == 5)
       
   366         	{	
       
   367               qDebug()<<"MUSICCCCCCccc Events? ";
       
   368               if(!iEventslistWidget->count())
       
   369               	{
       
   370       	           getEvents();
       
   371       			 }
       
   372         	}
       
   373     else if(tabIndex ==6 )
       
   374             	{	
       
   375                   qDebug()<<"MUSICC Search? ";
       
   376                   if(!iMusicSearchListWidget->count())
       
   377                   	{
       
   378                         getRecommendationList();
       
   379           			 }
       
   380             	}
       
   381 
       
   382 	}
       
   383 
       
   384 void HomeView::getPosts()
       
   385 	{
       
   386 	qDebug()<<"Inside HomeView::getPosts()";
       
   387 		
       
   388 	SmfClient client;
       
   389 	QString intfName("org.symbian.smf.client.contact.posts");
       
   390 	SmfProviderList *providerList = client.GetServices(intfName);
       
   391 	bool pluginFound = false;
       
   392 	qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
       
   393 	foreach(SmfProvider provider, *providerList)
       
   394 		{
       
   395 		if("Facebook" == provider.serviceName())
       
   396 			{
       
   397 			qDebug()<<"Plugin for facebook found";
       
   398 			pluginFound = true;
       
   399 			m_postProvider = new SmfPostProvider(&provider);
       
   400 			bool ret = connect(m_postProvider, SIGNAL(postsAvailable(SmfPostList*, SmfError , SmfResultPage)),
       
   401 					this, SLOT(postsAvailable(SmfPostList*, SmfError , SmfResultPage)));
       
   402 			
       
   403 			qDebug()<<"Connected ?"<<ret;
       
   404 			m_postProvider->posts();
       
   405 			}
       
   406 		}
       
   407 
       
   408 	if(!pluginFound)
       
   409 		{
       
   410 		qDebug()<<"Plugin for facebook not found!!!";
       
   411 		QString smferrString("No Facebook plugin found!!!");
       
   412 		QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
       
   413 		}
       
   414 	}
       
   415 
       
   416 void HomeView::postsAvailable(SmfPostList* postsList, SmfError error, SmfResultPage page)
       
   417 	{
       
   418 	Q_UNUSED(page);
       
   419 			
       
   420 	qDebug()<<"Inside HomeView::postsAvailable()";
       
   421 	
       
   422 	m_postsList = postsList;
       
   423 	if(error)
       
   424 		{
       
   425 		SmfClient client;
       
   426 		QString errStr = client.errorString(error);
       
   427 		qDebug()<<"Error found, code = "<<error;
       
   428 		qDebug()<<"Error string is = "<<errStr;
       
   429 		
       
   430 		QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
       
   431 		return;
       
   432 		}
       
   433 	
       
   434 	//display posts details
       
   435 	int count = 0;
       
   436 	qDebug()<<"Number of posts retrieved = "<<postsList->count();
       
   437 	if(postsList->count() == 0)
       
   438 		{
       
   439 		QString smferrString("No Posts");
       
   440 		QMessageBox::information(m_mainWindow,"No Posts",smferrString,QMessageBox::Ok);
       
   441 		return;
       
   442 		}
       
   443 	QMap<QString, QUrl> urlMap;
       
   444 	foreach(SmfPost post, *postsList)
       
   445 		{
       
   446 		QString name(post.owner().value("Name").value<QContactName>().firstName());
       
   447 		QUrl url(post.owner().value("Avatar").value<QContactAvatar>().imageUrl());
       
   448 
       
   449 		qDebug()<<"Post text = "<<post.description();
       
   450 		qDebug()<<"owner = "<<name;
       
   451 		qDebug()<<"owner's profile image url = "<<url.toString();
       
   452 		
       
   453 		urlMap.insert(name, url);
       
   454 		}
       
   455 	
       
   456 	// Download Images
       
   457 	downloadImages(SmfPostsFetch, urlMap);
       
   458 	}
       
   459 
       
   460 
       
   461 void HomeView::populatePostsWidget()
       
   462 	{
       
   463 	// Add individual items to the widget
       
   464 	foreach(SmfPost post, *m_postsList)
       
   465 		{
       
   466 		QString name(post.owner().value("Name").value<QContactName>().firstName());
       
   467 		QString text(post.description());
       
   468 
       
   469 		QString url("C:\\data\\");
       
   470 		url.append(name);
       
   471 		url.append(".jpg");
       
   472 		
       
   473 		// Add this contact to the list widget
       
   474 		iPostsListWidget->AddListItem(url,name,text);
       
   475 		}
       
   476 	}
       
   477 
       
   478 void HomeView::getAlbums()
       
   479 	{
       
   480 	qDebug()<<"Inside HomeView::getAlbums()";
       
   481 		
       
   482 	SmfClient client;
       
   483 	QString intfName("org.symbian.smf.client.gallery");
       
   484 	SmfProviderList *providerList = client.GetServices(intfName);
       
   485 	bool pluginFound = false;
       
   486 	qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
       
   487 	foreach(SmfProvider provider, *providerList)
       
   488 		{
       
   489 		if("Flickr" == provider.serviceName())
       
   490 			{
       
   491 			qDebug()<<"Plugin for flickr found";
       
   492 			pluginFound = true;
       
   493 			m_gallery = new SmfGallery(&provider);
       
   494 			bool ret = connect(m_gallery, SIGNAL(albumsAvailable(SmfPictureAlbumList*, SmfError , SmfResultPage)),
       
   495 					this, SLOT(albumsAvailable(SmfPictureAlbumList*, SmfError , SmfResultPage)));
       
   496 			
       
   497 			qDebug()<<"Connected ?"<<ret;
       
   498 			QStringList names;
       
   499 			
       
   500 			SmfContact user; // current user
       
   501 			
       
   502 			m_gallery->albums(names, &user);
       
   503 			}
       
   504 		}
       
   505 	if(!pluginFound)
       
   506 		{
       
   507 		qDebug()<<"Plugin for flickr not found!!!";
       
   508 		QString smferrString("No flickr plugin found!!!");
       
   509 		QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
       
   510 		}
       
   511 	}
       
   512 
       
   513 void HomeView::albumsAvailable(SmfPictureAlbumList* albums, SmfError error, SmfResultPage resultPage)
       
   514 	{
       
   515 	Q_UNUSED(resultPage);
       
   516 			
       
   517 	qDebug()<<"Inside HomeView::albumsAvailable()";
       
   518 	
       
   519 	m_albumsList = albums;
       
   520 	if(error)
       
   521 		{
       
   522 		SmfClient client;
       
   523 		QString errStr = client.errorString(error);
       
   524 		qDebug()<<"Error found, code = "<<error;
       
   525 		qDebug()<<"Error string is = "<<errStr;
       
   526 		
       
   527 		QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
       
   528 		return;
       
   529 		}
       
   530 	
       
   531 	//display album details
       
   532 	int count = 0;
       
   533 	qDebug()<<"Number of albums retrieved = "<<albums->count();
       
   534 	if(albums->count() == 0)
       
   535 		{
       
   536 		QString smferrString("No Albums");
       
   537 		QMessageBox::information(m_mainWindow,"No Albums",smferrString,QMessageBox::Ok);
       
   538 		return;
       
   539 		}
       
   540 	
       
   541 	QStringList albumPicList;
       
   542 	QStringList albumNameList;
       
   543 	foreach(SmfPictureAlbum album, *m_albumsList)
       
   544 		{
       
   545 		
       
   546 		qDebug()<<"Album name = "<<album.title();
       
   547 		qDebug()<<"Album description = "<<album.description();
       
   548 		qDebug()<<"Album pictureCount = "<<album.pictureCount();
       
   549 		qDebug()<<"Album id = "<<album.id();
       
   550 		albumNameList.append(album.title());
       
   551 		albumPicList.append("C:\\data\\sample.bmp");
       
   552 		}
       
   553 	
       
   554 	// Create the grip view
       
   555 	AlbumView->CreateGridView(albumPicList, albumNameList);
       
   556 	}
       
   557 
       
   558 
       
   559 void HomeView::getActivities()
       
   560 	{
       
   561 	qDebug()<<"Inside HomeView::getActivities()";
       
   562 	
       
   563 	// Get the list of providers
       
   564 	SmfClient client;
       
   565 	QString intfName("org.symbian.smf.client.activity.fetcher");
       
   566 	
       
   567 	SmfProviderList *providerList = client.GetServices(intfName);
       
   568 	qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
       
   569 	
       
   570 	// flag to check if required plugin is there
       
   571 	bool pluginFound = false;
       
   572 	int index = 0;
       
   573 	foreach(SmfProvider provider, *providerList)
       
   574 		{
       
   575 		if("Facebook" == provider.serviceName())
       
   576 			{
       
   577 			qDebug()<<"Plugin for Facebook found";
       
   578 			pluginFound = true;
       
   579 			m_activityFetcher = new SmfActivityFetcher(&provider);
       
   580 			bool ret = connect(m_activityFetcher, SIGNAL(resultsAvailable(SmfActivityEntryList*, SmfError , SmfResultPage)),
       
   581 					this, SLOT(activitiesAvailable(SmfActivityEntryList*, SmfError , SmfResultPage)));
       
   582 			
       
   583 			qDebug()<<"Connected ?"<<ret;
       
   584 			m_activityFetcher->selfActivities();
       
   585 			}
       
   586 		index++;
       
   587 		}
       
   588 	
       
   589 	if(!pluginFound)
       
   590 		{
       
   591 		qDebug()<<"Plugin for Facebook not found!!!";
       
   592 		QString smferrString("No Facebook plugin found!!!");
       
   593 		QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
       
   594 		}
       
   595 	}
       
   596 
       
   597 
       
   598 void HomeView::activitiesAvailable(SmfActivityEntryList* activitiesList, SmfError error, SmfResultPage resultPage)
       
   599 	{
       
   600 	qDebug()<<"Inside HomeView::activitiesAvailable()";
       
   601 	
       
   602 	m_activitiesList = activitiesList;
       
   603 	qDebug()<<"Number of activities retrieved = "<<activitiesList->count();
       
   604 	if(error)
       
   605 		{
       
   606 		SmfClient client;
       
   607 		QString errStr = client.errorString(error);
       
   608 		qDebug()<<"Error found, code = "<<error;
       
   609 		qDebug()<<"Error string is = "<<errStr;
       
   610 		
       
   611 		QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
       
   612 		return;
       
   613 		}
       
   614 	
       
   615 	//display activity description
       
   616 	int count = 0;
       
   617 	qDebug()<<"Number of activities retrieved = "<<activitiesList->count();
       
   618 	
       
   619 	if(activitiesList->count() == 0)
       
   620 		{
       
   621 		QString smferrString("No Recent Activities");
       
   622 		QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
       
   623 		return;
       
   624 		}
       
   625 	
       
   626 	foreach(SmfActivityEntry activity, *activitiesList)
       
   627 		{
       
   628 		qDebug()<<"Activity author name = "<<activity.author().value("Name").value<QContactName>().firstName();
       
   629 		qDebug()<<"Activity title = "<<activity.title().title();
       
   630 		qDebug()<<"Activity details = "<<activity.details().description();
       
   631 		}
       
   632 
       
   633 	populateActivitiesWidget();
       
   634 		
       
   635 	}
       
   636 
       
   637 void HomeView::populateActivitiesWidget()
       
   638 	{
       
   639 	qDebug()<<"Inside HomeView::populateActivityWidget()";
       
   640 	QString defImagePath("C:\\data\\sample.bmp");
       
   641 	foreach(SmfActivityEntry activity, *m_activitiesList)
       
   642 		{
       
   643 		QString name(activity.author().value("Name").value<QContactName>().firstName());
       
   644 		QString title(activity.title().title());
       
   645 
       
   646 		
       
   647 		// Add this contact to the list widget
       
   648 		iActivityListWidget->AddListItem(defImagePath, name, title);
       
   649 		}
       
   650 	}
       
   651 
       
   652 
       
   653 
       
   654 void HomeView::getPhotos()
       
   655 	{
       
   656 	qDebug()<<"Inside HomeView::getPhotos()";
       
   657 	
       
   658 	// Get the list of providers
       
   659 	SmfClient client;
       
   660 	QString intfName("org.symbian.smf.client.gallery");
       
   661 	
       
   662 	SmfProviderList *providerList = client.GetServices(intfName);
       
   663 	qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
       
   664 	
       
   665 	// flag to check if required plugin is there
       
   666 	bool pluginFound = false;
       
   667 	int index = 0;
       
   668 	foreach(SmfProvider provider, *providerList)
       
   669 		{
       
   670 		if("Flickr" == provider.serviceName())
       
   671 			{
       
   672 			qDebug()<<"Plugin for flickr found";
       
   673 			pluginFound = true;
       
   674 			if(!m_gallery)
       
   675 				m_gallery = new SmfGallery(&provider);
       
   676 			bool ret = connect(m_gallery, SIGNAL(picturesAvailable(SmfPictureList*, SmfError , SmfResultPage)),
       
   677 					this, SLOT(picturesAvailable(SmfPictureList*, SmfError , SmfResultPage)));
       
   678 			
       
   679 			qDebug()<<"Connected ?"<<ret;
       
   680 			
       
   681 #ifndef IFNOALBUMIDOFTHELOGGEDINUSERISAVAILABLE
       
   682 			SmfPictureAlbumList list; // pass empty list to fetch photos which are not part of any set, when albumID is not available
       
   683 #else		// If the album id is known use the below piece of code
       
   684 			SmfPictureAlbumList list;
       
   685 			SmfPictureAlbum album;
       
   686 			album.setId("72157623348359220");
       
   687 			list.append(album);
       
   688 #endif
       
   689 					
       
   690 			m_gallery->pictures(list);
       
   691 			}
       
   692 		index++;
       
   693 		}
       
   694 	
       
   695 	if(!pluginFound)
       
   696 		{
       
   697 		qDebug()<<"Plugin for flickr not found!!!";
       
   698 		QString smferrString("No Flickr plugin found!!!");
       
   699 		QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
       
   700 		}
       
   701 	}
       
   702 
       
   703 
       
   704 void HomeView::picturesAvailable(SmfPictureList* picList, SmfError error, SmfResultPage resultPage)
       
   705 	{
       
   706 	qDebug()<<"Inside HomeView::picturesAvailable()";
       
   707 	
       
   708 	m_picList = picList;
       
   709 	if(error)
       
   710 		{
       
   711 		SmfClient client;
       
   712 		QString errStr = client.errorString(error);
       
   713 		qDebug()<<"Error found, code = "<<error;
       
   714 		qDebug()<<"Error string is = "<<errStr;
       
   715 		
       
   716 		QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
       
   717 		return;
       
   718 		}
       
   719 	
       
   720 	//display pic description
       
   721 	int count = 0;
       
   722 	qDebug()<<"Number of pic retrieved = "<<picList->count();
       
   723 	
       
   724 	QMap<QString, QUrl> urlMap;
       
   725 	foreach(SmfPicture pic, *picList)
       
   726 		{
       
   727 		qDebug()<<"Photo title = "<<pic.title();
       
   728 		qDebug()<<"Photo posted date = "<<pic.postedDate();
       
   729 		qDebug()<<"Photo url = "<<pic.url();
       
   730 		qDebug()<<"Photo id = "<<pic.id();
       
   731 		
       
   732 		QString name(pic.title());
       
   733 		QUrl url(pic.url());
       
   734 
       
   735 		urlMap.insert(name, url);
       
   736 		}
       
   737 
       
   738 	// Download Images
       
   739 	downloadImages(SmfPhotosFetch, urlMap);
       
   740 	}
       
   741 
       
   742 
       
   743 void HomeView::populatePhotosGridView()
       
   744 	{
       
   745 	qDebug()<<"Inside HomeView::populatePhotosGridView()";
       
   746 	
       
   747 	QStringList albumPicList;
       
   748 	QStringList albumNameList;
       
   749 	
       
   750 	foreach(SmfPicture pic, *m_picList)
       
   751 		{
       
   752 		QString name(pic.title());
       
   753 		
       
   754 		qDebug()<<"Name  :"<<name;
       
   755 		QString url("C:\\data\\");
       
   756 		url.append(name);
       
   757 		url.append(".jpg");
       
   758 		
       
   759 		
       
   760 		albumNameList.append(name);
       
   761 		albumPicList.append(url);
       
   762 		}
       
   763 	
       
   764 	// Create the grip view
       
   765 	iAlbumWidget->AddListItem(m_mainWindow,albumPicList,albumNameList);
       
   766 //	AlbumView->CreateGridView(albumPicList,albumNameList);
       
   767 	
       
   768 	}
       
   769 
       
   770 void HomeView::getPlayList()
       
   771 	{
       
   772 	qDebug()<<"Inside HomeView::getPlayList()";
       
   773 	
       
   774 	// Get the list of providers
       
   775 	SmfClient client;
       
   776 	QString intfName("org.symbian.smf.plugin.music.playlist");
       
   777 	
       
   778 	SmfProviderList *providerList = client.GetServices(intfName);
       
   779 	qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
       
   780 	
       
   781 	// flag to check if required plugin is there
       
   782 	bool pluginFound = false;
       
   783 	foreach(SmfProvider provider, *providerList)
       
   784 		{
       
   785 		if("Last.fm" == provider.serviceName())
       
   786 			{
       
   787 			qDebug()<<"Plugin for Last.fm found";
       
   788 			pluginFound = true;
       
   789 			m_playlistService = new SmfPlaylistService(&provider);
       
   790 			bool ret = connect(m_playlistService, SIGNAL(playlistsListAvailable(SmfPlaylistList*, SmfError , SmfResultPage)),
       
   791 					this, SLOT( playListAvailable(SmfPlaylistList*, SmfError, SmfResultPage)));
       
   792 			
       
   793 			qDebug()<<"Connected ?"<<ret;
       
   794 			m_playlistService->playlists(1,5);
       
   795 			}
       
   796 		}
       
   797 	
       
   798 	if(!pluginFound)
       
   799 		{
       
   800 		qDebug()<<"Plugin for last.fm not found!!!";
       
   801 		QString smferrString("No last.fm plugin found!!!");
       
   802 		QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
       
   803 		}
       
   804 	}
       
   805 
       
   806 void HomeView::playListAvailable(SmfPlaylistList* playList, SmfError error, SmfResultPage resultPage)
       
   807 	{
       
   808 	  qDebug()<<"Inside slot : playlist availaible";
       
   809 	
       
   810 	  m_playlist = playList;
       
   811 		if(error)
       
   812 			{
       
   813 			SmfClient client;
       
   814 			QString errStr = client.errorString(error);
       
   815 			qDebug()<<"Error found, code = "<<error;
       
   816 			qDebug()<<"Error string is = "<<errStr;
       
   817 			
       
   818 			QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
       
   819 			return;
       
   820 			}
       
   821 		
       
   822 		//display friends description
       
   823 		int count = 0;
       
   824 		qDebug()<<"Number of playlist  retrieved = "<<playList->count();
       
   825 		if(playList->count() == 0)
       
   826 			{
       
   827 			QString smferrString("No playlist");
       
   828 			QMessageBox::information(m_mainWindow,"No Playlist",smferrString,QMessageBox::Ok);
       
   829 			return;
       
   830 			}
       
   831 			
       
   832 		
       
   833 		foreach(SmfPlaylist playlist, *playList)
       
   834 			{
       
   835 			 QString title(playlist.playListTitle());
       
   836 		     qDebug()<<"playlists title = "<<title;
       
   837 			
       
   838 			}
       
   839 		populatePlaylistWidget();
       
   840 	}
       
   841 
       
   842 void HomeView::populatePlaylistWidget()
       
   843 	{
       
   844 	 qDebug()<<"playst Widget = ";
       
   845 	foreach(SmfPlaylist playlist, *m_playlist)
       
   846 		{
       
   847 		QString title(playlist.playListTitle());
       
   848 		
       
   849 		qDebug()<<" Widget = "<<title;
       
   850 		//Add this contact to the list widget
       
   851 		iPlaylistWidget->AddListItem(title);
       
   852 		}
       
   853 	}
       
   854 //For getting the events
       
   855 void HomeView::getEvents()
       
   856 	{
       
   857 	qDebug()<<"Inside HomeView::getEvents()";
       
   858 		
       
   859 		// Get the list of providers
       
   860 		SmfClient client;
       
   861 		QString intfName("org.symbian.smf.plugin.music.events");
       
   862 		
       
   863 		SmfProviderList *providerList = client.GetServices(intfName);
       
   864 		qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
       
   865 		
       
   866 		// flag to check if required plugin is there
       
   867 		bool pluginFound = false;
       
   868 		foreach(SmfProvider provider, *providerList)
       
   869 			{
       
   870 			if("Last.fm" == provider.serviceName())
       
   871 				{
       
   872 				qDebug()<<"Plugin for Last.fm found";
       
   873 				pluginFound = true;
       
   874 		/*		m_musicEvents = new SmfMusicEvents(&provider);
       
   875 				bool ret = connect(m_musicEvents, SIGNAL(eventsAvailable(SmfEventList*, SmfError , SmfResultPage)),
       
   876 						this, SLOT( EventListAvailable(SmfEventList*, SmfError, SmfResultPage)));
       
   877 				SmfLocation location;
       
   878 				qDebug()<<"Connected ?"<<ret;
       
   879 				m_musicEvents->events(location,1,5);*/
       
   880 				}
       
   881 			}
       
   882 		
       
   883 		if(!pluginFound)
       
   884 			{
       
   885 			qDebug()<<"Plugin for last.fm not found!!!";
       
   886 			QString smferrString("No last.fm plugin found!!!");
       
   887 			QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
       
   888 			}
       
   889 	
       
   890 	}
       
   891 void HomeView::EventListAvailable(SmfEventList* eventsList,SmfError error, SmfResultPage resultPage)
       
   892 	{
       
   893 	 qDebug()<<"Inside slot : eventlist availaible";
       
   894 		
       
   895 	 m_eventList = eventsList;
       
   896 	  if(error)
       
   897 	  {
       
   898 		SmfClient client;
       
   899 		QString errStr = client.errorString(error);
       
   900 		qDebug()<<"Error found, code = "<<error;
       
   901 		qDebug()<<"Error string is = "<<errStr;
       
   902 				
       
   903 		QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
       
   904 		return;
       
   905 	  }
       
   906 	  int count = 0;
       
   907 	  qDebug()<<"Number of events  retrieved = "<<eventsList->count();
       
   908 	  if(eventsList->count() == 0)
       
   909 	  {
       
   910 		 QString smferrString("No events");
       
   911 		 QMessageBox::information(m_mainWindow,"No events",smferrString,QMessageBox::Ok);
       
   912 		 return;
       
   913 	   }
       
   914 				
       
   915 	   foreach(SmfEvent smfEvent, *eventsList)
       
   916 	   {
       
   917 		  QString title(smfEvent.title());
       
   918 		  qDebug()<<"events title= "<<title;
       
   919 				
       
   920 	   }
       
   921 	   populateEventlistWidget();
       
   922 	
       
   923 	}
       
   924 void HomeView::populateEventlistWidget()
       
   925 	{
       
   926 	  foreach(SmfEvent smfEvent, *m_eventList)
       
   927 	   {
       
   928 		  QString title(smfEvent.title());
       
   929 		  qDebug()<<"events title= "<<title;
       
   930 		  iEventslistWidget->AddListItem(title);
       
   931 		  qDebug()<<"events title= last"<<title;
       
   932 	    }
       
   933 	}
       
   934 void HomeView::getRecommendationList()
       
   935 	{
       
   936 	qDebug()<<"Inside HomeView::getRecommendations()";
       
   937 			
       
   938 			// Get the list of providers
       
   939 			SmfClient client;
       
   940 			QString intfName("org.symbian.smf.plugin.music.search");
       
   941 			
       
   942 			SmfProviderList *providerList = client.GetServices(intfName);
       
   943 			qDebug()<<"client.GetServices returned a list with count = "<<providerList->count();
       
   944 			
       
   945 			// flag to check if required plugin is there
       
   946 			bool pluginFound = false;
       
   947 			foreach(SmfProvider provider, *providerList)
       
   948 				{
       
   949 				if("Last.fm" == provider.serviceName())
       
   950 					{
       
   951 					qDebug()<<"Plugin for Last.fm found";
       
   952 					pluginFound = true;
       
   953 					m_musicSearch = new SmfMusicSearch(&provider);
       
   954 					bool ret = connect(m_musicSearch, SIGNAL(trackSearchAvailable(SmfTrackInfoList*, SmfError , SmfResultPage)),
       
   955 							this, SLOT( RecommendationListAvailable(SmfTrackInfoList*, SmfError, SmfResultPage)));
       
   956 					SmfTrackInfo track;
       
   957 					qDebug()<<"Connected ?"<<ret;
       
   958 					//m_musicSearch->tracks(track,1,5);
       
   959 					}
       
   960 				}
       
   961 			
       
   962 			if(!pluginFound)
       
   963 				{
       
   964 				qDebug()<<"Plugin for last.fm not found!!!";
       
   965 				QString smferrString("No last.fm plugin found!!!");
       
   966 				QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok);
       
   967 				}
       
   968 	}
       
   969 void HomeView::RecommendationListAvailable(SmfTrackInfoList* trackInfoList,SmfError error, SmfResultPage resultPage)
       
   970 	{
       
   971 	 qDebug()<<"Inside slot : Recommendationlist availaible";
       
   972 		
       
   973 	 m_TrackinfoList = trackInfoList;
       
   974 	  if(error)
       
   975 	  {
       
   976 		SmfClient client;
       
   977 		QString errStr = client.errorString(error);
       
   978 		qDebug()<<"Error found, code = "<<error;
       
   979 		qDebug()<<"Error string is = "<<errStr;
       
   980 				
       
   981 		QMessageBox::information(m_mainWindow,"Error",errStr,QMessageBox::Ok);
       
   982 		return;
       
   983 	  }
       
   984 	  int count = 0;
       
   985 	  qDebug()<<"Number of track  retrieved = "<<trackInfoList->count();
       
   986 	/*  if(trackInfoList->count() == 0)
       
   987 	  {
       
   988 		 QString smferrString("No trach");
       
   989 		 QMessageBox::information(m_mainWindow,"No track",smferrString,QMessageBox::Ok);
       
   990 		 return;
       
   991 	   }
       
   992 				
       
   993 	   foreach(SmfTrackInfo smfTrack, *trackInfoList)
       
   994 	   {
       
   995 		  //QString title(smfTrack.title());
       
   996 	
       
   997 				
       
   998 	   }
       
   999 	   populateRecommendationListWidget();*/
       
  1000 	
       
  1001 	}
       
  1002 void HomeView::populateRecommendationListWidget()
       
  1003 	{
       
  1004 	  foreach(SmfTrackInfo smfTrack, *m_TrackinfoList)
       
  1005 	   {
       
  1006 		  //QString title(smfEvent.title());
       
  1007 		  //qDebug()<<"events title= "<<title;
       
  1008 		  //iEventslistWidget->AddListItem(title);
       
  1009 	//	  qDebug()<<"events title= last"<<title;
       
  1010 	    }
       
  1011 	}