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