example/clientapi/example_usage.cpp
author cgandhi <chandradeep.gandhi@sasken.com>
Tue, 06 Apr 2010 16:35:37 +0530
changeset 2 86af6c333601
parent 1 4b1e636e8a71
child 3 0446eb7b28aa
permissions -rw-r--r--
Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts. Fixed following bugs 2381 and 2382. Added documentation Doxyfile. Modified example_usage.h to show similar usage.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
     1
#include "smfglobal.h"
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
     2
#include "smfclient.h"
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
     3
#include "smfprovider.h"
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
     4
#include "smfgallery.h"
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
     5
#include "smfcontact.h"
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
     6
#include "smfpostprovider.h"
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
     7
#include "smfcontactfetcher.h"
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
     8
#include "smfmusic.h"
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
     9
#include "smfpicture.h"
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    10
#include "smftrackinfo.h"
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    11
#include "smfmusicprofile.h"
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    12
#include "smflyrics.h"
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    13
#include <qalgorithms.h>
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    14
#include "qtcontacts.h"
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    15
#include <qdatastream.h>
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    16
#include <QSharedData>
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    17
#include <smfclientglobal.h>
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    18
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    19
using namespace QtMobility;
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
    20
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    21
class MyAppView //: public QAbstractItemView
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    22
	{
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    23
public:
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    24
	void add(QImage pic);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    25
	void add(SmfTrackInfo trackInfo);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    26
	void add(QContact qc);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    27
	void setPicture(QImage image);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    28
	void setTitle(QString cap);	
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    29
	void setIcon(QImage image);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    30
	void setDescription(QString desc);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    31
	void setProvider(SmfProvider p);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    32
	void setLyricsData(SmfLyrics l);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    33
	};
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    34
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    35
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    36
class MyApplication :public QObject
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    37
	{
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    38
	Q_OBJECT
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    39
	
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    40
public slots:
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    41
	void displayGallery();
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    42
	void showPicsSlot(SmfPictureList* pics, QString err);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    43
	void uploadPicture(QImage* picture, QList<SmfGallery> galleries);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    44
	void uploaded(bool success);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    45
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    46
	void displayFriends();
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    47
	void showlist(SmfContactList* friendsList);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    48
	void postUpdate();
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    49
	void showPosts(SmfPostList* posts, QString err);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    50
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    51
	void getMusic(SmfTrackInfo currTrack);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    52
	void showTrackSearch(SmfTrackInfoList* songs);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    53
	void showStore(SmfProviderList* stores);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    54
	void updateCurrentPlaying(QList<SmfMusicSearch> musicServices, SmfTrackInfo currTrack);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    55
	void displayLyrics(SmfTrackInfo currTrack);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    56
	void showLyrics(SmfLyricsList* list);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    57
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    58
private:
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    59
	MyAppView* m_view;
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    60
	SmfGallery* m_smfgl;
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    61
	SmfContactFetcher* m_smfcf;
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    62
	SmfMusicService* m_smfms;
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    63
	QList<SmfContact> m_myfrndz;
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    64
	};
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
    65
/** 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
    66
 * 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
    67
void MyApplication::displayGallery()
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    68
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    69
	// Some common interface for finding implementations.
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    70
	QList<SmfProvider>* galleries = SmfClient::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
    71
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    72
	// We will use the first one now
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    73
	SmfProvider smfp = galleries->value(0);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    74
	SmfGallery* myGallery = new SmfGallery(&smfp);
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    75
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    76
	// Adjust our view to show where these pictures came from
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    77
	QImage imge = smfp.serviceIcon();
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    78
	QString desc = smfp.description();
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    79
	QString name = smfp.serviceName();
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    80
	m_view->setIcon(imge);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    81
	m_view->setProvider(smfp);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    82
	m_view->setDescription(desc);
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
    83
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    84
	/**
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    85
	 * Asynchrnous request to fetch the pictures.
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    86
	 * The picturesAvailable() signal is emitted 
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    87
	 * with SmfPictureList once the pictures have arrived.
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    88
	 */
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    89
	myGallery->pictures();
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    90
	connect(myGallery,SIGNAL(picturesAvailable(SmfPictureList*, QString, SmfResultPage )),
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    91
			SLOT(showPicsSlot(SmfPictureList*, QString)));
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    92
	
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    93
	m_smfgl = myGallery;
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    94
	}
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    95
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    96
void MyApplication::showPicsSlot(SmfPictureList* pics, QString err)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    97
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    98
	//check err string if there is any error
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
    99
	if(err.compare("Err")) return;
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   100
	//if no error
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   101
	foreach(SmfPicture pic, *pics) {
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   102
		m_view->add(pic.picture() ); // do something with the picture in this gallery
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   103
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   104
	}
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
   105
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
   106
/** 2. Upload a picture captured by the user to some selection of galeries.*/
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   107
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
   108
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   109
	/**
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   110
	 * 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
   111
	 */	
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   112
	QObject::connect(m_smfcf,SIGNAL(uploadFinished(bool)),SLOT(uploaded(bool)));
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   113
	SmfPicture*  smfPic = new SmfPicture(*picture);
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   114
	// 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
   115
	// think multiple TweetDeck accounts?
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   116
	foreach(SmfGallery gallery, galleries)
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   117
		{
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   118
		gallery.upload(smfPic);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   119
		}
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   120
	}
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   121
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   122
/**
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   123
 * Slot to catch the uploading finished event
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   124
 */
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   125
void MyApplication::uploaded(bool success)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   126
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   127
	if(!success)
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
	//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
   130
		}
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
   131
	}
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
   132
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
   133
/**
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   134
 * 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
   135
 * 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
   136
 * 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
   137
 */
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   138
void MyApplication::displayFriends()
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   139
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   140
	// Some common interface for finding implementations.
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   141
	QList<SmfProvider>* contactFetcherList = SmfClient::GetServices("org.symbian.smf.contact.fetcher\0.2");
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   142
	SmfProvider smfp = contactFetcherList->value(0);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   143
	SmfContactFetcher* smfcf = new SmfContactFetcher(&smfp);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   144
	
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   145
	//Request friend list, the friendsListAvailable() signal
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   146
	//is emitted with SmfContactList once data is arrived.
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   147
	QObject::connect(smfcf,SIGNAL(friendsListAvailable(SmfContactList*, QString, SmfResultPage )),
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   148
			SLOT(showlist(SmfContactList*)));
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   149
	smfcf->friends();
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   150
	
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   151
	m_smfcf = smfcf;
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   152
	}
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
void MyApplication::showlist(SmfContactList* friendsList)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   155
	{
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
	// 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
   158
	//display service name description and the logo
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   159
	m_view->setIcon( (m_smfcf->getProvider())->serviceIcon() );
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   160
	m_view->setDescription( (m_smfcf->getProvider())->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
   161
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   162
	//now display the images
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   163
	foreach(SmfContact contact, *friendsList) {
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   164
		QVariant data = contact.value("Avatar"); 
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   165
		QImage pic = data.value<QImage>();
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   166
		QContact qc;
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   167
		contact.convert(qc);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   168
		m_view->add(qc);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   169
		m_myfrndz.append(contact);
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   170
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   171
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   172
/**
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   173
 * 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
   174
 */
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   175
void MyApplication::postUpdate()
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   176
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   177
	// Some common interface for finding implementations.
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   178
	QList<SmfProvider>* postServices = SmfClient::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
   179
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   180
	//let us use the first one
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   181
	QString servName = postServices->value(0).serviceName();
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   182
	if(!servName.compare("Facebook.com")) return;
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   183
	SmfProvider smfp = postServices->value(0);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   184
	SmfPostProvider* myPostServer = new SmfPostProvider(&smfp);
1
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
	//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
   187
	//display service name description and the logo
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   188
	m_view->setIcon((myPostServer->getProvider())->serviceIcon() );
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   189
	m_view->setProvider(myPostServer->getProvider());
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   190
	m_view->setDescription((myPostServer->getProvider())->description() );
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   191
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   192
	SmfPost reply("this is a text post", this);
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   193
	//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
   194
	// signal of SmfPostProvider to track the success
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   195
	SmfContact frnd(m_myfrndz.value(0));
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   196
	myPostServer->postDirected(reply,frnd);
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
   197
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   198
	//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
   199
	//connect to postsAvailable to show the post
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   200
	myPostServer->posts();
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   201
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   202
	QObject::connect(myPostServer,
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   203
			SIGNAL(postsAvailable(SmfPostList*, QString, SmfResultPage )),
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   204
			SLOT(showPosts(SmfPostList*, QString)));
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   205
	}
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   206
void MyApplication::showPosts(SmfPostList* posts, QString /*err*/)
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   207
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   208
	//Show the first post  
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   209
	SmfPost post = posts->at(0);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   210
	m_view->setDescription( post.toPlainText() );
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   211
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   212
/**
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   213
 * 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
   214
 */
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   215
void MyApplication::getMusic(SmfTrackInfo currTrack)
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   216
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   217
	// Some common interface for finding implementations.
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   218
	QList<SmfProvider>* smfProList = SmfClient::GetServices("org.symbian.smf.music\0.2");
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   219
	SmfProvider smfp = smfProList->value(0);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   220
	SmfMusicSearch* mServer = new SmfMusicSearch(&smfp);
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
   221
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   222
	QObject::connect(mServer,SIGNAL(trackSearchAvailable(SmfTrackInfoList*, QString,SmfResultPage )),this,SLOT(showTrackSearch(SmfTrackInfoList*)));
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   223
	QObject::connect(mServer,SIGNAL(storeSearchAvailable(SmfProviderList*, QString,SmfResultPage )),this,SLOT(showStoreSearch(SmfProviderList*)));
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   224
	//search songs similar to currently playing,
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   225
	//connect to trackSearchAvailable signal to get the result
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   226
	mServer->recommendations(currTrack);
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   227
	//display to the user
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   228
	m_view->setIcon( mServer->getProvider()->serviceIcon() );
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   229
	m_view->setProvider( mServer->getProvider());
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   230
	m_view->setDescription( mServer->getProvider()->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
   231
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   232
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
   233
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   234
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   235
void MyApplication::showTrackSearch(SmfTrackInfoList* songs)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   236
	{
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   237
	foreach(SmfTrackInfo track, *songs){
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   238
		m_view->add(track);
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   239
	}
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   240
	QList<SmfProvider>* smfProList = SmfClient::GetServices("org.symbian.smf.client.music.search\0.2");
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   241
	SmfProvider smfp = smfProList->value(0);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   242
	SmfMusicSearch* mServer = new SmfMusicSearch(&smfp);
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   243
	//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
   244
	//connect to showStoreSearch signal to display the stores for that track
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   245
	mServer->stores(songs->value(0));
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   246
	}
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   247
void MyApplication::showStore(SmfProviderList* /*stores*/)
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   248
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   249
	//show stores
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   250
	}
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
   251
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
   252
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   253
	//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
   254
	//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
   255
	//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
   256
	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
   257
		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
   258
	}
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   259
	//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
   260
	}
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
   261
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
   262
void MyApplication::displayLyrics(SmfTrackInfo currTrack)
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   263
	{
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   264
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
   265
	// Some common interface for finding implementations.
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   266
	QList<SmfProvider>* smfProList = SmfClient::GetServices("org.symbian.smf.music.lyrics\0.2","lyricsfly.com");
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   267
	SmfProvider smfp = smfProList->value(0);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   268
	SmfLyricsService* lyricsService = new SmfLyricsService(&smfp);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   269
	QObject::connect(lyricsService,SIGNAL(lyricsAvailable(SmfLyricsList*, QString, SmfResultPage )),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
   270
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   271
	//Request to get the lyrics
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   272
	//lyricsAvailable() signal of SmfLyricsService is emitted when lyrics is available
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   273
	lyricsService->lyrics(currTrack);
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   274
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   275
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   276
void MyApplication::showLyrics(SmfLyricsList* list)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   277
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   278
	//now display the latest edited lyrics
2
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   279
	//qSort(list->begin(),list->end(),caseInsensitiveLessThan);
86af6c333601 Changed the common classes for location, events. Changed APIs for paged results. Added exporting to QContacts.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 1
diff changeset
   280
	m_view->setLyricsData(list->at(0));
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   281
	}