example/clientapi/example_usage.cpp
author cgandhi <chandradeep.gandhi@sasken.com>
Thu, 25 Mar 2010 14:44:08 +0530
changeset 1 4b1e636e8a71
parent 0 5d2360e70d9f
child 2 86af6c333601
permissions -rw-r--r--
Updating the interfaces for SMFClient and SMFPlugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     1
#include <smf/smfprovider.h>
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     2
#include <smf/smfgallery.h>
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     3
#include <smf/smfcontact.h>
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     4
#include <smf/smfpostprovider.h>
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     5
#include <smf/smffcontactfetcher.h>
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     6
#include <smf/smfmusic.h>
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     7
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     8
/** 1. Display a gallery on the screen for some remote service.
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     9
 * assume m_view is some gallery view object in the application.*/
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    10
void MyApplication::displayGallery()
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    11
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    12
	// Some common interface for finding implementations.
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    13
	QList<SmfGallery> galleries = Smf::GetServices("org.symbian.smf.gallery\0.2");
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    14
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    15
	// We will use the first one now
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    16
	SmfGallery myGallery = galleries[0];
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    17
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    18
	// Adjust our view to show where these pictures came from
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    19
	m_view.setIcon(myGallery.serviceIcon());
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    20
	m_view.setProvder(myGallery.serviceName());
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    21
	m_view.setDescription(myGallery.description());
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    22
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    23
	/**
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    24
	 * Asynchrnous request to fetch the pictures.
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    25
	 * The picturesAvailable() signal is emitted 
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    26
	 * with SmfPictureList once the pictures have arrived.
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    27
	 */
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    28
	myGallery.pictures();
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    29
	QObject::connect(myGallery,SIGNAL(picturesAvailable(SmfPictureList*, QString, int)),this,SLOT(showPicsSlot(SmfPictureList*, QString)));
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    30
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    31
}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    32
void MyApplication::showPicsSlot(SmfPictureList* pics, QString err)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    33
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    34
	//check err string if there is any error
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    35
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    36
	//if no error
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    37
	foreach(SmfPicture* pic, pics) {
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    38
		m_view.add(pic); // do something with the picture in this gallery
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    39
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    40
	}
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    41
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    42
/** 2. Upload a picture captured by the user to some selection of galeries.*/
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    43
void MyApplication::uploadPicture(QImage picture, QList<SmfGallery> galleries)
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    44
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    45
	/**
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    46
	 * When uploading is finished we can check the success of the uploading
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    47
	 */	
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    48
	QObject::connect(myGallery,SIGNAL(uploadFinished(bool)),this,SLOT(uploaded(bool)));
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    49
	// The list could be from a selection of galleries chosen by the user,
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    50
	// think multiple TweetDeck accounts?
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    51
	foreach(SmfGallery gallery, galleries) {
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    52
		gallery.upload(picture);
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    53
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    54
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    55
void MyApplication::uploaded(bool success)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    56
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    57
	if(!success)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    58
		{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    59
	//error occured while uploading
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    60
		}
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    61
	}
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    62
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    63
/**
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    64
 * 3. This is an example of displaying the friends profile image in a view from one or more
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    65
 * service provider. Note that this service can be provided by any kind of service provider,
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    66
 * e.g. last.fm music service where users maintain profiles and friends.
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    67
 */
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    68
void MyApplication::displayFriends()
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    69
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    70
	// Some common interface for finding implementations.
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    71
	QList<SmfContactFetcher> contactFetcherList = Smf::GetServices("org.symbian.smf.contact.fetcher\0.2");
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    72
	//Request friend list,
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    73
	//The friendsListAvailable() signal
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    74
	//is emitted with SmfContactList once data is arrived.
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    75
	QObject::Connect(contactFetcherList[0],SIGNAL(friendsListAvailable(SmfContactList*, QString, int)),
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    76
			this,SLOT(showlist(SmfContactList*));
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    77
	fetcher.friends();
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    78
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    79
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    80
void MyApplication::showlist(SmfContactList* friendsList)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    81
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    82
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    83
	// Adjust our view to show where these pictures came from
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    84
	//display service name description and the logo
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    85
	m_view.setIcon( myFetcher.serviceIcon() );
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    86
	m_view.setProvider( myFetcher.serviceName() );
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    87
	m_view.setDescription( myFetcher.description() );
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    88
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    89
	//now display the images
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    90
	foreach(SmfContact* contact, friendsList) {
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    91
		QImage pic = contact.value("Avatar");
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    92
		m_view.setPicture(pic);
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    93
		m_view.setTitle(contact.value("Name"));
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    94
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    95
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    96
/**
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    97
 * 4. This is an example of posting and reading user updates to social netowrking sites
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    98
 */
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    99
void MyApplication::postUpdate()
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   100
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   101
	// Some common interface for finding implementations.
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   102
	QList<SmfPostProvider> postServices = Smf::GetServices("org.symbian.smf.contact.posts\0.2");
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   103
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   104
	//let us use the first one
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   105
	SmfPostProvider myPostServer = postServices[ 0 ];
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   106
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   107
	//Adjust our view to show where these posts came from (e.g. tweets from twitter)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   108
	//display service name description and the logo
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   109
	m_view.setIcon( myPostServer.serviceIcon() );
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   110
	m_view.setProvider( myPostServer.serviceName() );
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   111
	m_view.setDescription( myPostServer.description() );
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   112
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   113
	SmfPost reply = new SmfPost(sampleString,samplmage, sampleUrl);
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   114
	//post my udpate to be visible to all, connect to updatePostFinished()
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   115
	// signal of SmfPostProvider to track the success
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   116
	myPostServer.updatePost(reply);
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   117
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   118
	//Asynchronously get all posts to me in my profle (e.g. twits from all friends)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   119
	//connect to postsAvailable to show the post
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   120
	postServices.getPosts();
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   121
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   122
	QObject::Connect(myPostServer,SIGNAL(postsAvailable(SmfPostList*, QString, int)),this,SLOT(showPosts(SmfPostList*, QString)));
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   123
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   124
void MyApplication::showPosts(SmfPostList* posts, QString err)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   125
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   126
	//Show the first post  
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   127
	m_view.setPostData(posts->at(0));
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   128
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   129
/**
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   130
 * 5. This is an example of getting song recommendations from a social netowrking sites
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   131
 */
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   132
void MyApplication::getMusic()
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   133
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   134
	// Some common interface for finding implementations.
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   135
	QList<SmfMusicSearch> musicServices = Smf::GetServices("org.symbian.smf.music\0.2");
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   136
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   137
	//let us use the first one
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   138
	SmfMusicSearch mServer = musicServices.at(0);
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   139
	QObject::Connect(mServer,SIGNAL(trackSearchAvailable(SmfTrackInfoList*, QString,int)),this,SLOT(showTrackSearch(SmfTrackInfoList*)));
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   140
	QObject::Connect(mServer,SIGNAL(storeSearchAvailable(SmfProviderList*, QString,int)),this,SLOT(showStoreSearch(SmfProviderList*)));
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   141
	//search songs similar to currently playing,
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   142
	//connect to trackSearchAvailable signal to get the result
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   143
	mServer.recommendations(currTrack);
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   144
	//display to the user
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   145
	m_view.setIcon( mServer.serviceIcon() );
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   146
	m_view.setProvider( mServer.serviceName() );
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   147
	m_view.setDescription( mServer.description() );
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   148
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   149
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   150
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   151
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   152
void MyApplication::showTrackSearch(SmfTrackInfoList* songs)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   153
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   154
	foreach(SmfTrackInfo* track, songs){
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   155
		m_view.add(track);
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   156
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   157
	//allow user to select a track and get purchase links
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   158
	//connect to showStoreSearch signal to display the stores for that track
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   159
	mServer.stores(selectedTrack);
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   160
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   161
void MyApplication::showStoreSearch(SmfProviderList* stores)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   162
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   163
	//show stores
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   164
	}
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   165
void MyApplication::updateCurrentPlaying(QList<SmfMusicSearch> musicServices, SmfTrackInfo currTrack)
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   166
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   167
	//after purchasing and downloading is over, user plays the track
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   168
	//now post the current platying track to all service providers
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   169
	//postFinished() signal of SmfMusicSearch can be tracked to check the success of the posts
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   170
	foreach(SmfMusicSearch provider, musicServices) {
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   171
		provider.postCurrentPlaying(currTrack);
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   172
	}
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   173
	//postCurrentPlaying is also a slot funtion, may be application can use connect
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   174
	}
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   175
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   176
void MyApplication::displayLyrics(SmfTrackInfo currTrack)
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   177
	{
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   178
	// Some common interface for finding implementations.
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   179
	SmfLyricsService lyricsService = Smf::GetServices("org.symbian.smf.music.lyrics\0.2","lyricsfly.com");
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   180
	QObject::connect(lyricsService,SIGNAL(lyricsAvailable(SmfLyricsList*, QString, int)),this,SLOT(showLyrics(SmfLyricsList*));
0
5d2360e70d9f Application level use cases to illustrate the goal of SMF. Pushing the draft header files for SMF client and one sample application cpp
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   181
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   182
	//Request to get the lyrics
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   183
	//lyricsAvailable() signal of SmfLyricsService is emitted when lyrics is available
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   184
	lyricsService.lyrics(currTrack);
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   185
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   186
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   187
void MyApplication::showLyrics(SmfLyricsList* list)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   188
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   189
	//now display the latest edited lyrics
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   190
	qSort(list->begin(),list->end(),caseCompareTimeMoreThan);
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   191
	m_view.setLyricsData(list->at(0));
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   192
	}