Tests/SmfMusicEventsnService/SmfMusicEventsnService.cpp
author cgandhi
Mon, 11 Oct 2010 21:59:54 +0530
changeset 26 83d6a149c755
child 27 b3e1347ac96a
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:
26
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
     1
/****************************************************************************
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
     2
**
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
     3
** Trolltech hereby grants a license to use the Qt/Eclipse Integration
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
     4
** plug-in (the software contained herein), in binary form, solely for the
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
     5
** purpose of creating code to be used with Trolltech's Qt software.
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
     6
**
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
     7
** Qt Designer is licensed under the terms of the GNU General Public
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
     8
** License versions 2.0 and 3.0 ("GPL License"). Trolltech offers users the
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
     9
** right to use certain no GPL licensed software under the terms of its GPL
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    10
** Exception version 1.2 (http://trolltech.com/products/qt/gplexception).
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    11
**
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    12
** THIS SOFTWARE IS PROVIDED BY TROLLTECH AND ITS CONTRIBUTORS (IF ANY) "AS
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    13
** IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    14
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    15
** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    16
** OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    17
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    18
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    19
** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    20
** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    21
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    22
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    23
**
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    24
** Since we now have the GPL exception I think that the "special exception
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    25
** is no longer needed. The license text proposed above (other than the
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    26
** special exception portion of it) is the BSD license and we have added
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    27
** the BSD license as a permissible license under the exception.
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    28
**
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    29
****************************************************************************/
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    30
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    31
#include <qdebug.h>
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    32
#include <smfclient.h>
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    33
#include <smfcontactfetcher.h>
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    34
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    35
#include "SmfMusicEventsnService.h"
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    36
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    37
SmfTestApp::SmfTestApp(QWidget *parent)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    38
    : QWidget(parent)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    39
{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    40
	ui.setupUi(this);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    41
	m_contactFetcher = NULL;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    42
	m_providerList = NULL;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    43
}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    44
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    45
SmfTestApp::~SmfTestApp()
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    46
{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    47
	if(m_contactFetcher)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    48
		delete m_contactFetcher;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    49
	if(m_providerList)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    50
		delete m_providerList;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    51
}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    52
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    53
void SmfTestApp::getFacebookFriends()
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    54
	{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    55
	qDebug()<<"Inside SmfTestApp::getFacebookFriends()";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    56
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    57
	// Get the list of providers
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    58
	SmfClient client;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    59
	QString intfName("org.symbian.smf.plugin.contact.fetcher");
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    60
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    61
	m_providerList = client.GetServices(intfName);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    62
	qDebug()<<"client.GetServices returned a list with count = "<<m_providerList->count();
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    63
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    64
	// flag to check if required plugin is there
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    65
	bool pluginFound = false;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    66
	foreach(SmfProvider provider, *m_providerList)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    67
		{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    68
		if("Facebook" == provider.serviceName())
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    69
			{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    70
			qDebug()<<"Plugin for Facebook found";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    71
			pluginFound = true;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    72
			m_contactFetcher = new SmfContactFetcher(&provider);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    73
			SmfError err = m_contactFetcher->friends(1, 10);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    74
			qDebug()<<"Ret value of friends() = "<<err;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    75
			
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    76
			bool connected = connect(m_contactFetcher, SIGNAL(friendsListAvailable(SmfContactList*, SmfError , SmfResultPage)),
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    77
					this, SLOT(friendsListAvailable(SmfContactList*, SmfError , SmfResultPage)));
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    78
			qDebug()<<"Signal-slot connected ? = "<<connected;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    79
			}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    80
		}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    81
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    82
	if(!pluginFound)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    83
		{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    84
		qDebug()<<"Plugin for Facebook not found!!!";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    85
		}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    86
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    87
	qDebug()<<"Returning from SmfTestApp::getFacebookFriends()";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    88
	}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    89
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    90
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    91
void SmfTestApp::friendsListAvailable ( SmfContactList* list, SmfError error, SmfResultPage resultPage )
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    92
	{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    93
	Q_UNUSED(resultPage)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    94
	qDebug()<<"Inside SmfTestApp::friendsListAvailable()";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    95
			
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    96
	if(error)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    97
		{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    98
		SmfClient client;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
    99
		QString errStr = client.errorString(error);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   100
		qDebug()<<"Error found, code = "<<error;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   101
		qDebug()<<"Error string is = "<<errStr;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   102
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   103
		return;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   104
		}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   105
		
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   106
	//display friends information
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   107
	int count = 0;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   108
	qDebug()<<"Number of friends retrieved = "<<list->count();
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   109
	if(0 == list->count())
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   110
		{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   111
		qDebug()<<"No friends available!!!";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   112
		return;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   113
		}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   114
		
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   115
	foreach(SmfContact contact, *list)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   116
		{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   117
		qDebug()<<"Friends name = "<<contact.value("Name").value<QContactName>().firstName();
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   118
		qDebug()<<"Friends status msg desc = "<<contact.value("Presence").value<QContactPresence>().customMessage();
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   119
		qDebug()<<"Friends profile image URL = "<<contact.value("Avatar").value<QContactAvatar>().imageUrl();
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   120
		qDebug()<<"";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   121
		}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   122
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   123
	delete list;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   124
	}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   125
//chinmaya
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   126
void SmfTestApp::lastFm()
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   127
	{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   128
	qDebug()<<"Inside SmfTestApp::lastFm()";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   129
		
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   130
	// Get the list of providers
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   131
	SmfClient client;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   132
	QString intfName("org.symbian.smf.plugin.music.service");
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   133
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   134
	m_providerList = client.GetServices(intfName);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   135
	qDebug()<<"client.GetServices returned a list with count = "<<m_providerList->count();
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   136
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   137
	// flag to check if required plugin is there
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   138
	bool pluginFound = false;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   139
	foreach(SmfProvider provider, *m_providerList)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   140
		{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   141
		if("last.fm" == provider.serviceName())
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   142
			{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   143
			qDebug()<<"Plugin for last.fm found";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   144
			pluginFound = true;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   145
			SmfMusicService *m_musicService = new SmfMusicService(&provider);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   146
			SmfError err = m_musicService->userMusicInfo();			
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   147
			bool connected = QObject::connect(m_musicService,SIGNAL(userMusicInfoAvailable(SmfMusicProfile*,SmfError)),
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   148
					this,SLOT(userMusicInfoAvlbl(SmfMusicProfile*,SmfError)));
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   149
			qDebug() <<"Smfmusicservice::userMusicInfo" ;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   150
			qDebug()<<"Signal-slot connected ? = "<<connected;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   151
			}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   152
		}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   153
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   154
	if(!pluginFound)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   155
		{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   156
		qDebug()<<"Plugin for last.fm not found!!!";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   157
		}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   158
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   159
	qDebug()<<"Returning from SmfTestApp::last.fm()";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   160
	}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   161
void SmfTestApp::userMusicInfoAvlbl(SmfMusicProfile*,SmfError)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   162
	{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   163
	qDebug()<<"User music info";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   164
	}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   165
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   166
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   167
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   168
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   169
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   170
void SmfTestApp::FacebookFiltered()
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   171
	{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   172
	qDebug()<<"Inside SmfTestApp::FacebookFiltered()";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   173
		
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   174
	// Get the list of providers
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   175
	SmfClient client;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   176
	QString intfName("org.symbian.smf.client.activity.fetcher");
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   177
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   178
	m_providerList = client.GetServices(intfName);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   179
	qDebug()<<"client.GetServices returned a list with count = "<<m_providerList->count();
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   180
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   181
	// flag to check if required plugin is there
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   182
	bool pluginFound = false;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   183
	foreach(SmfProvider provider, *m_providerList)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   184
		{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   185
		if("Facebook" == provider.serviceName())
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   186
			{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   187
			qDebug()<<"Plugin for Facebook found";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   188
			pluginFound = true;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   189
			SmfActivityFetcher *p_smfActivityFetcher = new SmfActivityFetcher(&provider);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   190
			QList<SmfActivityObjectType> Article;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   191
			
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   192
			SmfActivityObjectType SmfActivityObjTypeComment;			
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   193
			Article.append(SmfActivityObjTypeComment);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   194
			
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   195
			// specify some dummy value for Article
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   196
			int pageNum = 1,perPage=1;			  
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   197
			SmfError err = p_smfActivityFetcher->filtered(Article);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   198
			bool connected = QObject::connect(p_smfActivityFetcher,SIGNAL(resultsAvailable(SmfActivityEntryList*, SmfError, SmfResultPage)),
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   199
					this,SLOT(resultsAvailableSlot(SmfActivityEntryList*, SmfError, SmfResultPage)));
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   200
			qDebug() <<"SmfActivityFetcher::filter" ;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   201
			qDebug()<<"Signal-slot connected ? = "<<connected;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   202
			}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   203
		}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   204
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   205
	if(!pluginFound)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   206
		{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   207
		qDebug()<<"Plugin for Facebook not found!!!";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   208
		}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   209
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   210
	qDebug()<<"Returning from SmfTestApp::getFacebookFriends()";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   211
	}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   212
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   213
void SmfTestApp::FacebookActivities()
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   214
	{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   215
	qDebug()<<"Inside SmfTestApp::FacebookFiltered()";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   216
		
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   217
	// Get the list of providers
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   218
	SmfClient client;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   219
	QString intfName("org.symbian.smf.client.activity.fetcher");
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   220
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   221
	m_providerList = client.GetServices(intfName);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   222
	qDebug()<<"client.GetServices returned a list with count = "<<m_providerList->count();
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   223
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   224
	// flag to check if required plugin is there
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   225
	bool pluginFound = false;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   226
	foreach(SmfProvider provider, *m_providerList)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   227
		{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   228
		if("Facebook" == provider.serviceName())
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   229
			{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   230
			qDebug()<<"Plugin for Facebook found";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   231
			pluginFound = true;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   232
			SmfActivityFetcher *p_smfActivityFetcher = new SmfActivityFetcher(&provider);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   233
			QContactName Name;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   234
			//Name.setFirstName("Siddartha");
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   235
			//Name.setLastName("Chandra");
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   236
			
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   237
			SmfContact aFriend;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   238
			// add some dummy values to aFriend methods
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   239
			QString str;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   240
			str.append("Name");
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   241
			QVariant var = QVariant::fromValue<QContactName>(Name);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   242
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   243
			aFriend.setValue(str,var);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   244
			QContactGuid guid;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   245
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   246
			// contact->value("Guid").value<QContactGuid>() ;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   247
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   248
			QString userId = "558588290";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   249
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   250
			guid.setGuid(userId); 
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   251
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   252
			QVariant contactId = QVariant::fromValue<QContactGuid>(guid);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   253
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   254
			aFriend.setValue("Guid",contactId);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   255
			int pageNum = 1,perPage=2;			  
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   256
			SmfError err = p_smfActivityFetcher->friendsActivities(aFriend,pageNum,perPage);
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   257
			bool connected = QObject::connect(p_smfActivityFetcher,SIGNAL(resultsAvailable(SmfActivityEntryList*, SmfError, SmfResultPage)),
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   258
					this,SLOT(resultsAvailableSlot(SmfActivityEntryList*, SmfError, SmfResultPage)));
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   259
			qDebug() <<"SmfActivityFetcher::filter" ;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   260
			qDebug()<<"Signal-slot connected ? = "<<connected;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   261
			}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   262
		}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   263
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   264
	if(!pluginFound)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   265
		{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   266
		qDebug()<<"Plugin for Facebook not found!!!";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   267
		}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   268
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   269
	qDebug()<<"Returning from SmfTestApp::getFacebookFriends()";
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   270
	}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   271
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   272
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   273
void SmfTestApp::resultsAvailableSlot(SmfActivityEntryList *ptr, SmfError _t2, SmfResultPage _t3)
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   274
	{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   275
	qDebug()<<"inside resultsAvailableSlot";	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   276
	//qDebug()<<"data"<<SmfActivityEntryList->_t3;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   277
	qDebug()<<ptr->at(0).id();
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   278
	foreach(SmfActivityEntry contact, (*ptr))
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   279
		{
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   280
		qDebug()<<"SmfActivityEntry id = "<<contact.id();
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   281
		/*qDebug()<<"Friends status msg desc = "<<contact.;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   282
		qDebug()<<"Friends profile image URL = "<<contact.value("Avatar").value<QContactAvatar>().imageUrl();
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   283
		qDebug()<<"";*/
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   284
		}
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   285
	
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   286
	delete ptr;
83d6a149c755 Submitting following changes -
cgandhi
parents:
diff changeset
   287
	}