diff -r a180113055cb -r 83d6a149c755 Tests/DemoGUI/HomeView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/DemoGUI/HomeView.cpp Mon Oct 11 21:59:54 2010 +0530 @@ -0,0 +1,1011 @@ +#include "HomeView.h" +#include "ScreenSize.h" +#include "qpushbutton.h" +#include "customListwidget.h" +#include "GridView.h" +#include +#include "ToolBar.h" +#include +#include +#include +#include +#include +#include +#include "ImageDownload.h" + +HomeView::HomeView(QString aHeadName): + iHeadName(aHeadName) + { + //m_providerList = NULL; + m_mainWindow = NULL; + TabWidget = NULL; + iFrndsListWidget = NULL; + iPostsListWidget = NULL; + iActivityListWidget = NULL; + AlbumView = NULL; + + m_contactFetcher = NULL; + m_postProvider = NULL; + m_gallery = NULL; + m_activityFetcher = NULL; + m_friendsList = NULL; + m_postsList = NULL; + m_albumsList = NULL; + m_activitiesList = NULL; + m_picList = NULL; + } + +HomeView::~HomeView() + { + if(TabWidget) + { + delete TabWidget; + TabWidget = NULL; + } + if(iFrndsListWidget) + { + delete iFrndsListWidget; + iFrndsListWidget = NULL; + } + if(iPostsListWidget) + { + delete iPostsListWidget; + iPostsListWidget = NULL; + } + if(iActivityListWidget) + { + delete iActivityListWidget; + iActivityListWidget = NULL; + } + if(AlbumView) + { + delete AlbumView; + AlbumView = NULL; + } + + if(m_contactFetcher) + { + delete m_contactFetcher; + m_contactFetcher =NULL; + } + if(m_postProvider) + { + delete m_postProvider; + m_postProvider =NULL; + } + if(m_gallery) + { + delete m_gallery; + m_gallery =NULL; + } + if(m_activityFetcher) + { + delete m_activityFetcher; + m_activityFetcher =NULL; + } + if(m_friendsList) + { + delete m_friendsList; + m_friendsList =NULL; + } + if(m_postsList) + { + delete m_postsList; + m_postsList =NULL; + } + if(m_albumsList) + { + delete m_albumsList; + m_albumsList =NULL; + } + if(m_activitiesList) + { + delete m_activitiesList; + m_activitiesList =NULL; + } + if(m_picList) + { + delete m_picList; + m_picList =NULL; + } + } + + +void HomeView::SetupUI(QMainWindow *Mainwindow) + { + qDebug()<<"Inside HomeView::SetupUI()"; + + m_mainWindow = Mainwindow; + + QPushButton* HomeButton = new QPushButton(m_mainWindow); + HomeButton->setText(iHeadName); + HomeButton->setGeometry(0,0,ScreenSize::GetScreenRect().width(),KHeadNameHeight); + HomeButton->setStyleSheet("background-color: rgb(0,0,0);" + "border-width: 2px;" + "font: bold 16px;" + "min-width: 10em;" + "padding: 4px;" + "color: white;" + ); + + HomeButton->setDisabled(true); + qDebug()<<"Home button created and setup"; + + TabWidget = new QTabWidget(m_mainWindow); + connect(TabWidget,SIGNAL(currentChanged(int)),this,SLOT(Navigated2OtherTab(int))); + qDebug()<<"Tab widget created"; + + iFrndsListWidget = new CustomListWidget(); + TabWidget->addTab(iFrndsListWidget,"Friends New"); + qDebug()<<"Friends Tab created"; + + iPostsListWidget = new CustomListWidget(); + TabWidget->addTab(iPostsListWidget,"Posts"); + qDebug()<<"Posts Tab created"; + + //AlbumView = new GridView(); + /*QWidget *widget = new QWidget(); + TabWidget->addTab(widget,"Album");*/ + iAlbumWidget = new CustomListWidget(); + TabWidget->addTab(iAlbumWidget,"Album"); + + qDebug()<<"Albums Tab created"; + + + + +/* + QStringList Iconpathlist; + Iconpathlist.append("C:\\data\\AlbumDefault.JPG"); + Iconpathlist.append("C:\\data\\AlbumDefault.JPG"); + Iconpathlist.append("C:\\data\\AlbumDefault.JPG"); + Iconpathlist.append("C:\\data\\AlbumDefault.JPG"); + + + TabWidget->addTab(AlbumView->CreateGridView(Iconpathlist),"Album"); + qDebug()<<"Albums Tab created"; +*/ + + iActivityListWidget = new CustomListWidget(); + TabWidget->addTab(iActivityListWidget,"Activity"); + qDebug()<<"Activity Tab created"; + + + iPlaylistWidget = new CustomListWidget(); + TabWidget->addTab(iPlaylistWidget,"PlayList"); + qDebug()<<"Music Tab created"; + + iEventslistWidget = new CustomListWidget(); + TabWidget->addTab(iEventslistWidget,"EventsList"); + qDebug()<<"Events Tab created"; + + iMusicSearchListWidget=new CustomListWidget(); + TabWidget->addTab(iMusicSearchListWidget,"SearchList"); + qDebug()<<"Search Tab created"; + + TabWidget->setGeometry(0,KHeadNameHeight + KWidgetGapFactor,ScreenSize::GetScreenRect().width(),ScreenSize::GetScreenRect().height() - 100); + + //Drawing Tool bar + ToolBar* ToolBarwidget = new ToolBar; + QStringList actionList; + actionList.append("Open"); + actionList.append("Reply"); + actionList.append("Add Services"); + ToolBarwidget->GetToolBar(m_mainWindow,actionList); + qDebug()<<"Tool bar created"; + } + + +void HomeView::getFriends() + { + qDebug()<<"Inside HomeView::getFriends()"; + + // Get the list of providers + SmfClient client; + QString intfName("org.symbian.smf.plugin.contact.fetcher"); + + SmfProviderList *providerList = client.GetServices(intfName); + qDebug()<<"client.GetServices returned a list with count = "<count(); + + // flag to check if required plugin is there + bool pluginFound = false; + foreach(SmfProvider provider, *providerList) + { + if("Facebook" == provider.serviceName()) + { + qDebug()<<"Plugin for Facebook found"; + pluginFound = true; + m_contactFetcher = new SmfContactFetcher(&provider); + bool ret = connect(m_contactFetcher, SIGNAL(friendsListAvailable(SmfContactList*, SmfError , SmfResultPage)), + this, SLOT(friendsAvailable(SmfContactList*, SmfError , SmfResultPage))); + + qDebug()<<"Connected ?"<friends(1,5); + } + } + + if(!pluginFound) + { + qDebug()<<"Plugin for Facebook not found!!!"; + QString smferrString("No Facebook plugin found!!!"); + QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok); + } + } + + +void HomeView::friendsAvailable(SmfContactList* friendsList, SmfError error, SmfResultPage resultPage) + { + qDebug()<<"Inside HomeView::friendsAvailable()"; + + m_friendsList = friendsList; + if(error) + { + SmfClient client; + QString errStr = client.errorString(error); + qDebug()<<"Error found, code = "< urlMap; + foreach(SmfContact contact, *friendsList) + { + QString name(contact.value("Name").value().firstName()); + QString status(contact.value("Presence").value().customMessage()); + if(!status.size()) + status.append("Not available"); + QUrl url(contact.value("Avatar").value().imageUrl()); + + qDebug()<<"Friends name = "<().firstName(); + qDebug()<<"Friends status msg desc = "<().customMessage(); + qDebug()<<"Friends profile image URL = "<().imageUrl(); + urlMap.insert(name, url); + } + + // Download Images + downloadImages(SmfFriendsFetch, urlMap); + + } + +void HomeView::populateFriendsWidget() + { + foreach(SmfContact contact, *m_friendsList) + { + QString name(contact.value("Name").value().firstName()); + QString status(contact.value("Presence").value().customMessage()); + if(!status.size()) + status.append("Not available"); + QString url("C:\\data\\"); + url.append(name); + url.append(".jpg"); + + // Add this contact to the list widget + iFrndsListWidget->AddListItem(url,name,status); + } + } + +void HomeView::downloadImages(const SmfItemIdentifier &identifier, const QMap urlMap) + { + qDebug()<<"Inside HomeView::downloadImages()"; + QMapIterator iter(urlMap); + + while(iter.hasNext()) + { + iter.next(); + m_downloader.downloadImage(this, iter.key(), iter.value(), identifier); + downloading = true; + } + } + + +void HomeView::Navigated2OtherTab(int tabIndex) + { + qDebug()<<"Inside HomeView::Navigated2OtherTab() for tab index = "<count()) + { + //if(!downloading) + //getPlayList(); + //getFriends(); + } + } + + // Display albums + else if(tabIndex == 1) + { + if(!iPostsListWidget->count()) + { + if(!downloading) + getPosts(); + } + } + + // Display albums + else if(tabIndex == 2) + { + if(!m_picList) + { + if(!downloading) + getPhotos(); + } + } + + // Display activities + else if(tabIndex == 3) + { + if(!iActivityListWidget->count()) + getActivities(); + } + else if(tabIndex == 4) + { + qDebug()<<"MUSICCCCCCccc? "; + if(!iPlaylistWidget->count()) + { + + getPlayList(); + + } + } + else if(tabIndex == 5) + { + qDebug()<<"MUSICCCCCCccc Events? "; + if(!iEventslistWidget->count()) + { + getEvents(); + } + } + else if(tabIndex ==6 ) + { + qDebug()<<"MUSICC Search? "; + if(!iMusicSearchListWidget->count()) + { + getRecommendationList(); + } + } + + } + +void HomeView::getPosts() + { + qDebug()<<"Inside HomeView::getPosts()"; + + SmfClient client; + QString intfName("org.symbian.smf.client.contact.posts"); + SmfProviderList *providerList = client.GetServices(intfName); + bool pluginFound = false; + qDebug()<<"client.GetServices returned a list with count = "<count(); + foreach(SmfProvider provider, *providerList) + { + if("Facebook" == provider.serviceName()) + { + qDebug()<<"Plugin for facebook found"; + pluginFound = true; + m_postProvider = new SmfPostProvider(&provider); + bool ret = connect(m_postProvider, SIGNAL(postsAvailable(SmfPostList*, SmfError , SmfResultPage)), + this, SLOT(postsAvailable(SmfPostList*, SmfError , SmfResultPage))); + + qDebug()<<"Connected ?"<posts(); + } + } + + if(!pluginFound) + { + qDebug()<<"Plugin for facebook not found!!!"; + QString smferrString("No Facebook plugin found!!!"); + QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok); + } + } + +void HomeView::postsAvailable(SmfPostList* postsList, SmfError error, SmfResultPage page) + { + Q_UNUSED(page); + + qDebug()<<"Inside HomeView::postsAvailable()"; + + m_postsList = postsList; + if(error) + { + SmfClient client; + QString errStr = client.errorString(error); + qDebug()<<"Error found, code = "< urlMap; + foreach(SmfPost post, *postsList) + { + QString name(post.owner().value("Name").value().firstName()); + QUrl url(post.owner().value("Avatar").value().imageUrl()); + + qDebug()<<"Post text = "<().firstName()); + QString text(post.description()); + + QString url("C:\\data\\"); + url.append(name); + url.append(".jpg"); + + // Add this contact to the list widget + iPostsListWidget->AddListItem(url,name,text); + } + } + +void HomeView::getAlbums() + { + qDebug()<<"Inside HomeView::getAlbums()"; + + SmfClient client; + QString intfName("org.symbian.smf.client.gallery"); + SmfProviderList *providerList = client.GetServices(intfName); + bool pluginFound = false; + qDebug()<<"client.GetServices returned a list with count = "<count(); + foreach(SmfProvider provider, *providerList) + { + if("Flickr" == provider.serviceName()) + { + qDebug()<<"Plugin for flickr found"; + pluginFound = true; + m_gallery = new SmfGallery(&provider); + bool ret = connect(m_gallery, SIGNAL(albumsAvailable(SmfPictureAlbumList*, SmfError , SmfResultPage)), + this, SLOT(albumsAvailable(SmfPictureAlbumList*, SmfError , SmfResultPage))); + + qDebug()<<"Connected ?"<albums(names, &user); + } + } + if(!pluginFound) + { + qDebug()<<"Plugin for flickr not found!!!"; + QString smferrString("No flickr plugin found!!!"); + QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok); + } + } + +void HomeView::albumsAvailable(SmfPictureAlbumList* albums, SmfError error, SmfResultPage resultPage) + { + Q_UNUSED(resultPage); + + qDebug()<<"Inside HomeView::albumsAvailable()"; + + m_albumsList = albums; + if(error) + { + SmfClient client; + QString errStr = client.errorString(error); + qDebug()<<"Error found, code = "<CreateGridView(albumPicList, albumNameList); + } + + +void HomeView::getActivities() + { + qDebug()<<"Inside HomeView::getActivities()"; + + // Get the list of providers + SmfClient client; + QString intfName("org.symbian.smf.client.activity.fetcher"); + + SmfProviderList *providerList = client.GetServices(intfName); + qDebug()<<"client.GetServices returned a list with count = "<count(); + + // flag to check if required plugin is there + bool pluginFound = false; + int index = 0; + foreach(SmfProvider provider, *providerList) + { + if("Facebook" == provider.serviceName()) + { + qDebug()<<"Plugin for Facebook found"; + pluginFound = true; + m_activityFetcher = new SmfActivityFetcher(&provider); + bool ret = connect(m_activityFetcher, SIGNAL(resultsAvailable(SmfActivityEntryList*, SmfError , SmfResultPage)), + this, SLOT(activitiesAvailable(SmfActivityEntryList*, SmfError , SmfResultPage))); + + qDebug()<<"Connected ?"<selfActivities(); + } + index++; + } + + if(!pluginFound) + { + qDebug()<<"Plugin for Facebook not found!!!"; + QString smferrString("No Facebook plugin found!!!"); + QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok); + } + } + + +void HomeView::activitiesAvailable(SmfActivityEntryList* activitiesList, SmfError error, SmfResultPage resultPage) + { + qDebug()<<"Inside HomeView::activitiesAvailable()"; + + m_activitiesList = activitiesList; + qDebug()<<"Number of activities retrieved = "<count(); + if(error) + { + SmfClient client; + QString errStr = client.errorString(error); + qDebug()<<"Error found, code = "<().firstName(); + qDebug()<<"Activity title = "<().firstName()); + QString title(activity.title().title()); + + + // Add this contact to the list widget + iActivityListWidget->AddListItem(defImagePath, name, title); + } + } + + + +void HomeView::getPhotos() + { + qDebug()<<"Inside HomeView::getPhotos()"; + + // Get the list of providers + SmfClient client; + QString intfName("org.symbian.smf.client.gallery"); + + SmfProviderList *providerList = client.GetServices(intfName); + qDebug()<<"client.GetServices returned a list with count = "<count(); + + // flag to check if required plugin is there + bool pluginFound = false; + int index = 0; + foreach(SmfProvider provider, *providerList) + { + if("Flickr" == provider.serviceName()) + { + qDebug()<<"Plugin for flickr found"; + pluginFound = true; + if(!m_gallery) + m_gallery = new SmfGallery(&provider); + bool ret = connect(m_gallery, SIGNAL(picturesAvailable(SmfPictureList*, SmfError , SmfResultPage)), + this, SLOT(picturesAvailable(SmfPictureList*, SmfError , SmfResultPage))); + + qDebug()<<"Connected ?"<pictures(list); + } + index++; + } + + if(!pluginFound) + { + qDebug()<<"Plugin for flickr not found!!!"; + QString smferrString("No Flickr plugin found!!!"); + QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok); + } + } + + +void HomeView::picturesAvailable(SmfPictureList* picList, SmfError error, SmfResultPage resultPage) + { + qDebug()<<"Inside HomeView::picturesAvailable()"; + + m_picList = picList; + if(error) + { + SmfClient client; + QString errStr = client.errorString(error); + qDebug()<<"Error found, code = "<AddListItem(m_mainWindow,albumPicList,albumNameList); +// AlbumView->CreateGridView(albumPicList,albumNameList); + + } + +void HomeView::getPlayList() + { + qDebug()<<"Inside HomeView::getPlayList()"; + + // Get the list of providers + SmfClient client; + QString intfName("org.symbian.smf.plugin.music.playlist"); + + SmfProviderList *providerList = client.GetServices(intfName); + qDebug()<<"client.GetServices returned a list with count = "<count(); + + // flag to check if required plugin is there + bool pluginFound = false; + foreach(SmfProvider provider, *providerList) + { + if("Last.fm" == provider.serviceName()) + { + qDebug()<<"Plugin for Last.fm found"; + pluginFound = true; + m_playlistService = new SmfPlaylistService(&provider); + bool ret = connect(m_playlistService, SIGNAL(playlistsListAvailable(SmfPlaylistList*, SmfError , SmfResultPage)), + this, SLOT( playListAvailable(SmfPlaylistList*, SmfError, SmfResultPage))); + + qDebug()<<"Connected ?"<playlists(1,5); + } + } + + if(!pluginFound) + { + qDebug()<<"Plugin for last.fm not found!!!"; + QString smferrString("No last.fm plugin found!!!"); + QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok); + } + } + +void HomeView::playListAvailable(SmfPlaylistList* playList, SmfError error, SmfResultPage resultPage) + { + qDebug()<<"Inside slot : playlist availaible"; + + m_playlist = playList; + if(error) + { + SmfClient client; + QString errStr = client.errorString(error); + qDebug()<<"Error found, code = "<events(location,1,5);*/ + } + } + + if(!pluginFound) + { + qDebug()<<"Plugin for last.fm not found!!!"; + QString smferrString("No last.fm plugin found!!!"); + QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok); + } + + } +void HomeView::EventListAvailable(SmfEventList* eventsList,SmfError error, SmfResultPage resultPage) + { + qDebug()<<"Inside slot : eventlist availaible"; + + m_eventList = eventsList; + if(error) + { + SmfClient client; + QString errStr = client.errorString(error); + qDebug()<<"Error found, code = "<tracks(track,1,5); + } + } + + if(!pluginFound) + { + qDebug()<<"Plugin for last.fm not found!!!"; + QString smferrString("No last.fm plugin found!!!"); + QMessageBox::information(m_mainWindow,"Error",smferrString,QMessageBox::Ok); + } + } +void HomeView::RecommendationListAvailable(SmfTrackInfoList* trackInfoList,SmfError error, SmfResultPage resultPage) + { + qDebug()<<"Inside slot : Recommendationlist availaible"; + + m_TrackinfoList = trackInfoList; + if(error) + { + SmfClient client; + QString errStr = client.errorString(error); + qDebug()<<"Error found, code = "<