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