example/clientapi/example_usage.cpp
author cgandhi <chandradeep.gandhi@sasken.com>
Thu, 15 Apr 2010 15:35:36 +0530
changeset 3 0446eb7b28aa
parent 2 86af6c333601
child 5 edb9dc8273d9
permissions -rw-r--r--
Updating the sample plugin and other related changes for clients and plugins
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;
3
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 2
diff changeset
    60
	SmfClient client;
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
    61
	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
    62
	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
    63
	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
    64
	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
    65
	};
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
    66
/** 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
    67
 * 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
    68
void MyApplication::displayGallery()
1
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.
3
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 2
diff changeset
    71
	QList<SmfProvider>* galleries = client.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
    72
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    73
	// 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
    74
	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
    75
	SmfGallery* myGallery = new SmfGallery(&smfp);
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    76
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    77
	// 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
    78
	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
    79
	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
    80
	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
    81
	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
    82
	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
    83
	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
    84
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    85
	/**
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    86
	 * Asynchrnous request to fetch the pictures.
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    87
	 * The picturesAvailable() signal is emitted 
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    88
	 * with SmfPictureList once the pictures have arrived.
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    89
	 */
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
    90
	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
    91
	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
    92
			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
    93
	
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
    94
	m_smfgl = myGallery;
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    95
	}
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
    96
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
    97
void MyApplication::showPicsSlot(SmfPictureList* pics, QString err)
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
	//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
   100
	if(err.compare("Err")) return;
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   101
	//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
   102
	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
   103
		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
   104
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   105
	}
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
   106
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
   107
/** 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
   108
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
   109
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   110
	/**
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   111
	 * 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
   112
	 */	
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
   113
	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
   114
	SmfPicture*  smfPic = new SmfPicture(*picture);
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   115
	// 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
   116
	// 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
   117
	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
   118
		{
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
		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
   120
		}
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   121
	}
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
   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
/**
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
 * 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
   125
 */
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   126
void MyApplication::uploaded(bool success)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   127
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   128
	if(!success)
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
	//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
   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
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
   134
/**
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   135
 * 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
   136
 * 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
   137
 * 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
   138
 */
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   139
void MyApplication::displayFriends()
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   140
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   141
	// Some common interface for finding implementations.
3
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 2
diff changeset
   142
	QList<SmfProvider>* contactFetcherList = client.GetServices("org.symbian.smf.contact.fetcher\0.2");
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
   143
	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
   144
	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
   145
	
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
   146
	//Request friend list, the friendsListAvailable() signal
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   147
	//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
   148
	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
   149
			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
   150
	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
   151
	
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
   152
	m_smfcf = smfcf;
1
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
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   155
void MyApplication::showlist(SmfContactList* friendsList)
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
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   158
	// 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
   159
	//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
   160
	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
   161
	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
   162
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   163
	//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
   164
	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
   165
		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
   166
		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
   167
		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
   168
		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
   169
		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
   170
		m_myfrndz.append(contact);
1
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
/**
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   174
 * 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
   175
 */
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   176
void MyApplication::postUpdate()
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   177
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   178
	// Some common interface for finding implementations.
3
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 2
diff changeset
   179
	QList<SmfProvider>* postServices = client.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
   180
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   181
	//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
   182
	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
   183
	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
   184
	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
   185
	SmfPostProvider* myPostServer = new SmfPostProvider(&smfp);
1
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
	//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
   188
	//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
   189
	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
   190
	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
   191
	m_view->setDescription((myPostServer->getProvider())->description() );
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   192
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
   193
	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
   194
	//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
   195
	// 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
   196
	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
   197
	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
   198
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   199
	//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
   200
	//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
   201
	myPostServer->posts();
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   202
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
   203
	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
   204
			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
   205
			SLOT(showPosts(SmfPostList*, QString)));
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   206
	}
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
   207
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
   208
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   209
	//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
   210
	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
   211
	m_view->setDescription( post.toPlainText() );
1
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
/**
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   214
 * 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
   215
 */
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
   216
void MyApplication::getMusic(SmfTrackInfo currTrack)
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   217
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   218
	// Some common interface for finding implementations.
3
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 2
diff changeset
   219
	QList<SmfProvider>* smfProList = client.GetServices("org.symbian.smf.music\0.2");
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
   220
	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
   221
	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
   222
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
   223
	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
   224
	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
   225
	//search songs similar to currently playing,
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   226
	//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
   227
	mServer->recommendations(currTrack);
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   228
	//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
   229
	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
   230
	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
   231
	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
   232
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   233
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
   234
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   235
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   236
void MyApplication::showTrackSearch(SmfTrackInfoList* songs)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   237
	{
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
   238
	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
   239
		m_view->add(track);
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   240
	}
3
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 2
diff changeset
   241
	QList<SmfProvider>* smfProList = client.GetServices("org.symbian.smf.client.music.search\0.2");
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
   242
	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
   243
	SmfMusicSearch* mServer = new SmfMusicSearch(&smfp);
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   244
	//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
   245
	//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
   246
	mServer->stores(songs->value(0));
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   247
	}
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
   248
void MyApplication::showStore(SmfProviderList* /*stores*/)
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   249
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   250
	//show stores
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   251
	}
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
   252
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
   253
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   254
	//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
   255
	//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
   256
	//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
   257
	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
   258
		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
   259
	}
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   260
	//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
   261
	}
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
   262
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
   263
void MyApplication::displayLyrics(SmfTrackInfo currTrack)
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   264
	{
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
   265
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
   266
	// Some common interface for finding implementations.
3
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 2
diff changeset
   267
	QList<SmfProvider>* smfProList = client.GetServices("org.symbian.smf.music.lyrics\0.2","lyricsfly.com");
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
   268
	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
   269
	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
   270
	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
   271
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   272
	//Request to get the lyrics
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   273
	//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
   274
	lyricsService->lyrics(currTrack);
1
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
	}
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   277
void MyApplication::showLyrics(SmfLyricsList* list)
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   278
	{
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   279
	//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
   280
	//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
   281
	m_view->setLyricsData(list->at(0));
1
4b1e636e8a71 Updating the interfaces for SMFClient and SMFPlugins
cgandhi <chandradeep.gandhi@sasken.com>
parents: 0
diff changeset
   282
	}