example/sampleplugin/sampleplugin.cpp
author cgandhi <chandradeep.gandhi@sasken.com>
Thu, 15 Apr 2010 15:35:36 +0530
changeset 3 0446eb7b28aa
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:
3
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     1
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     2
// Include files
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     3
#include "sampleplugin.h"
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     4
#include <QNetworkRequest>
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     5
#include <QNetworkAccessManager>
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     6
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     7
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     8
 * Constructor with default argument
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
     9
 * @param aUtil The SmfPluginUtil instance. The plugins can
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    10
 * call the method getAuthKeys() of this class, with its pluginID to
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    11
 * get the OAuth keys, keys are returned only if this plugin is
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    12
 * authorised by Smf franework
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    13
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    14
SamplePlugin::SamplePlugin( SmfPluginUtil *aUtil )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    15
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    16
	m_provider = new SampleProviderBase();
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    17
	m_util = aUtil;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    18
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    19
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    20
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    21
 * Destructor
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    22
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    23
SamplePlugin::~SamplePlugin( )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    24
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    25
	if(m_provider)
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    26
		delete m_provider;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    27
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    28
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    29
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    30
 * Method to get a list of pictures
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    31
 * @param aRequest [out] The request data to be sent to network
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    32
 * @param aPageNum The page to be extracted
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    33
 * @param aItemsPerPage Number of items per page
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    34
 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    35
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    36
SmfPluginError SamplePlugin::pictures( SmfPluginRequestData &aRequest,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    37
		const int aPageNum,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    38
		const int aItemsPerPage )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    39
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    40
	SmfPluginError error = SmfPluginErrInvalidRequest;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    41
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    42
	// invalid arguments
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    43
	if( aPageNum < 0 || aItemsPerPage < 0 )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    44
		return error;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    45
	else
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    46
		{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    47
		// Create a map of the arguments keys and their repective values
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    48
		QMultiMap<QByteArray, QByteArray> params;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    49
		QString pageNum, itemPerPage;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    50
		pageNum.number(aPageNum);
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    51
		itemPerPage.number(aItemsPerPage);
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    52
		params.insert("method", "getpictures");
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    53
		params.insert("pagenumber", pageNum.toAscii());
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    54
		params.insert("itemsperpage", itemPerPage.toAscii());
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    55
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    56
		QNetworkAccessManager::Operation type = QNetworkAccessManager::GetOperation;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    57
		SmfSignatureMethod signMethod = HMAC_SHA1;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    58
		SmfParsingMode mode = ParseForInlineQuery;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    59
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    60
		error = createRequest(aRequest, type, signMethod, params, mode, NULL);
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    61
		}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    62
	return error;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    63
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    64
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    65
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    66
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    67
 * Method called by plugins to generate a request data
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    68
 * @param aRequest [out] The request data to be sent to network
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    69
 * @param aOperation The type of http operation
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    70
 * @param aSignatureMethod The signature method to be used
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    71
 * @param aParams A map of parameters to its values
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    72
 * @param aMode The mode of creation of the request
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    73
 * @param aPostData The data to be posted (for HTTP POST
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    74
 * only, else it will be NULL)
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    75
 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    76
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    77
SmfPluginError SamplePlugin::createRequest( SmfPluginRequestData &aRequest,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    78
		const QNetworkAccessManager::Operation aOperation,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    79
		const SmfSignatureMethod aSignatureMethod,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    80
		QMultiMap<QByteArray, QByteArray> &aParams,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    81
		const SmfParsingMode aMode,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    82
		QBuffer *aPostData )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    83
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    84
	SmfPluginError error;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    85
	QString url = m_provider->serviceUrl().toString();
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    86
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    87
	// Get the oAuth keys from The Smf Server
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    88
	QMap<QString, QString> keys;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    89
	m_util->getAuthKeys(keys, m_provider->pluginId());
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    90
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    91
	// Unable to get the tokens
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    92
	if(keys.isEmpty())
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    93
		error = SmfPluginErrInvalidApplication;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    94
	else
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    95
		{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    96
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    97
		// Get the token and token secret from keys
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    98
		QByteArray token;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
    99
		QByteArray tokenSecret;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   100
		token.append(keys.value("oauth_token"));
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   101
		tokenSecret.append(keys.value("oauth_token_secret"));
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   102
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   103
		// convert the parameters to string and sign it
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   104
		QByteArray content = m_util->createParameterString(url, aOperation, token, tokenSecret,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   105
				aSignatureMethod, aParams, aMode );
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   106
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   107
		// Unable to create the signed string
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   108
		if(content.isEmpty())
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   109
			error = SmfPluginErrInvalidRequest;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   110
		else
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   111
			{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   112
			// add the parameter string to the URL
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   113
			url.append(content);
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   114
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   115
			// set the url of the request
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   116
			aRequest.iNetworkRequest.setUrl(QUrl(url));
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   117
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   118
			// set the type of http operation to be performed
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   119
			aRequest.iHttpOperationType = aOperation;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   120
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   121
			// As it is a GET operation, set iPostData to NULL
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   122
			aRequest.iPostData = aPostData;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   123
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   124
			// For successful creation of request
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   125
			error = SmfPluginErrNone;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   126
			}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   127
		}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   128
	return error;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   129
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   130
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   131
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   132
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   133
 * Method to get a description
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   134
 * @param aRequest [out] The request data to be sent to network
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   135
 * @param aImage The image abot which the description is required
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   136
 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   137
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   138
SmfPluginError SamplePlugin::description( SmfPluginRequestData &aRequest,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   139
		const SmfPicture &aImage )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   140
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   141
	SmfPluginError error;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   142
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   143
	// Create a map of the arguments keys and their repective values
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   144
	QMultiMap<QByteArray, QByteArray> params;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   145
	params.insert("method", "getpictureDescription");
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   146
	params.insert("photoId", aImage.id().toAscii());
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   147
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   148
	QNetworkAccessManager::Operation type = QNetworkAccessManager::GetOperation;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   149
	SmfSignatureMethod signMethod = HMAC_SHA1;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   150
	SmfParsingMode mode = ParseForInlineQuery;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   151
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   152
	error = createRequest(aRequest, type, signMethod, params, mode, NULL);
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   153
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   154
	return error;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   155
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   156
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   157
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   158
 * Method to upload a picture
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   159
 * @param aRequest [out] The request data to be sent to network
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   160
 * @param aImage The image to be uploaded
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   161
 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   162
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   163
SmfPluginError SamplePlugin::upload( SmfPluginRequestData &aRequest,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   164
		const SmfPicture &aImage )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   165
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   166
	SmfPluginError error = SmfPluginErrInvalidRequest;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   167
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   168
	// Create a map of the arguments keys and their repective values
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   169
	QMultiMap<QByteArray, QByteArray> params;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   170
	params.insert("method", "upload");
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   171
	params.insert("title", aImage.title().toAscii());
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   172
	params.insert("owner", aImage.owner().toAscii());
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   173
	params.insert("description", aImage.description().toAscii());
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   174
	params.insert("tags", aImage.tags().join(" ").toAscii());
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   175
	switch(aImage.visibility())
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   176
		{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   177
		case SMFVisibilityFriend:
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   178
			params.insert("isFriend", "true");
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   179
			break;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   180
		case SMFVisibilityPublic:
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   181
			params.insert("isPublic", "true");
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   182
			break;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   183
		case SMFVisibilityFamily:
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   184
			params.insert("isFamily", "true");
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   185
			break;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   186
		case SMFVisibilityGroup:
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   187
			params.insert("isGroup", "true");
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   188
			break;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   189
		default:// SMFVisibilityPersonal
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   190
			params.insert("isPrivate", "true");
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   191
		}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   192
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   193
	QNetworkAccessManager::Operation type = QNetworkAccessManager::PostOperation;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   194
	SmfSignatureMethod signMethod = HMAC_SHA1;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   195
	SmfParsingMode mode = ParseForRequestContent;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   196
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   197
	// Write the image as png format to the buffer
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   198
	QByteArray ba;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   199
	QBuffer buffer(&ba);
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   200
	buffer.open(QIODevice::WriteOnly);
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   201
	aImage.picture().save(&buffer, "PNG");
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   202
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   203
	error = createRequest(aRequest, type, signMethod, params, mode, &buffer);
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   204
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   205
	return error;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   206
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   207
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   208
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   209
 * Method to upload a list of pictures
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   210
 * @param aRequest [out] The request data to be sent to network
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   211
 * @param aImages The list of images to be uploaded
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   212
 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   213
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   214
SmfPluginError SamplePlugin::upload( SmfPluginRequestData &aRequest,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   215
		const QList<SmfPicture> &aImages )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   216
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   217
	SmfPluginError error;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   218
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   219
	for(int index = 0; index < aImages.count(); index++)
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   220
		{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   221
		error = upload(aRequest, aImages.value(index));
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   222
		if(SmfPluginErrNone != error)
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   223
			break;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   224
		}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   225
	return error;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   226
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   227
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   228
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   229
 * Method to post comment on a picture is available
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   230
 * @param aRequest [out] The request data to be sent to network
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   231
 * @param aImage The image on which comment is to be posted
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   232
 * @param aComment The comment to be posted
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   233
 * @return SmfPluginError Plugin error if any, else SmfPluginErrNone
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   234
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   235
SmfPluginError SamplePlugin::postComment( SmfPluginRequestData &aRequest,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   236
		const SmfPicture &aImage,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   237
		const SmfComment &aComment )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   238
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   239
	SmfPluginError error = SmfPluginErrInvalidRequest;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   240
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   241
	// Create a map of the arguments keys and their repective values
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   242
	QMultiMap<QByteArray, QByteArray> params;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   243
	params.insert("method", "postComment");
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   244
	params.insert("photoId", aImage.id().toAscii());
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   245
	params.insert("comment", aImage.comments().join(" ").toAscii());
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   246
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   247
	QNetworkAccessManager::Operation type = QNetworkAccessManager::GetOperation;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   248
	SmfSignatureMethod signMethod = HMAC_SHA1;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   249
	SmfParsingMode mode = ParseForInlineQuery;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   250
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   251
	error = createRequest(aRequest, type, signMethod, params, mode, NULL);
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   252
	return error;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   253
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   254
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   255
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   256
 * Method to get the provider information
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   257
 * @return Instance of SmfProviderBase
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   258
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   259
SmfProviderBase* SamplePlugin::getProviderInfo( )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   260
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   261
	return m_provider;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   262
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   263
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   264
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   265
 * Method to get the result for a network request.
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   266
 * @param aTransportResult The result of transport operation
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   267
 * @param aReply The QNetworkReply instance for the request
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   268
 * @param aResult [out] An output parameter to the plugin manager.If the
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   269
 * return value is SmfSendRequestAgain, QVariant will be of type
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   270
 * SmfPluginRequestData.
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   271
 * For SmfGalleryPlugin: If last operation was pictures(), aResult will
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   272
 * be of type QList<SmfPicture>. If last operation was description(),
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   273
 * aResult will be of type QString. If last operation was upload() or
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   274
 * postComment(), aResult will be of type bool.
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   275
 * @param aRetType [out] SmfPluginRetType
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   276
 * @param aPageResult [out] The SmfResultPage structure variable
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   277
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   278
SmfPluginError SamplePlugin::responseAvailable(
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   279
		const SmfTransportResult &aTransportResult,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   280
		QNetworkReply *aReply,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   281
		QVariant* aResult,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   282
		SmfPluginRetType &aRetType,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   283
		SmfResultPage &aPageResult )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   284
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   285
	SmfPluginError error;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   286
	if(SmfTransportOpNoError == aTransportResult)
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   287
		{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   288
		// Assuming a JSON response, parse the response
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   289
		QByteArray response = aReply->readAll();
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   290
		m_provider->updateDataUsage(0, aReply->readBufferSize());
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   291
		bool parseResult = false;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   292
		QVariant *result = new QVariant();
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   293
		/** see http://qjson.sourceforge.net/usage.html for more details */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   294
		parseResult = m_util->getJsonHandle()->parse(response, &parseResult);
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   295
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   296
		// For parsing error
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   297
		if(!parseResult)
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   298
			{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   299
			aRetType = SmfRequestError;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   300
			error = SmfPluginErrInvalidRequest;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   301
			}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   302
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   303
		else
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   304
			{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   305
			// The plugins should convert the result to suitable format,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   306
			// like if last operation was pictures(), result should be converted to the
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   307
			// type QList<SmfPicture>. If last operation was description(), result should
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   308
			// be converted to the type QString. If last operation was upload() or
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   309
			// postComment(), result should be converted to the type bool.
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   310
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   311
			// After conversion, assign the value os result to aResult
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   312
			aResult = result;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   313
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   314
			// if the request is complete
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   315
			aRetType = SmfRequestComplete;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   316
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   317
			// if request need to be sent again
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   318
			aRetType = SmfSendRequestAgain;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   319
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   320
			error = SmfPluginErrNone;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   321
			}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   322
		}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   323
	else
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   324
		{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   325
		error = SmfPluginErrInvalidRequest;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   326
		aRetType = SmfRequestError;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   327
		}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   328
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   329
	return error;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   330
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   331
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   332
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   333
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   334
 * Constructor with default argument
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   335
 * @param aParent The parent object
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   336
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   337
SampleProviderBase::SampleProviderBase( QObject* aParent )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   338
	: SmfProviderBase(aParent)
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   339
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   340
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   341
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   342
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   343
 * Copy Constructor
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   344
 * @param aOther The reference object
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   345
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   346
SampleProviderBase::SampleProviderBase( const SampleProviderBase &aOther )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   347
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   348
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   349
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   350
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   351
 * Destructor
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   352
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   353
SampleProviderBase::~SampleProviderBase( )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   354
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   355
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   356
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   357
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   358
 * Method to get the Localisable name of the service.
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   359
 * @return The Localisable name of the service.
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   360
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   361
QString SampleProviderBase::serviceName( ) const
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   362
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   363
	return m_serviceName;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   364
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   365
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   366
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   367
 * Method to get the Logo of the service
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   368
 * @return The Logo of the service
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   369
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   370
QImage SampleProviderBase::serviceIcon( ) const
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   371
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   372
	return m_serviceIcon;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   373
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   374
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   375
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   376
 * Method to get the Readable service description
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   377
 * @return The Readable service description
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   378
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   379
QString SampleProviderBase::description( ) const
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   380
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   381
	return m_description;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   382
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   383
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   384
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   385
 * Method to get the Website of the service
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   386
 * @return The Website of the service
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   387
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   388
QUrl SampleProviderBase::serviceUrl( ) const
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   389
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   390
	return m_serviceUrl;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   391
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   392
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   393
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   394
 * Method to get the URL of the Application providing this service
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   395
 * @return The URL of the Application providing this service
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   396
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   397
QUrl SampleProviderBase::applicationUrl( ) const
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   398
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   399
	return m_applicationUrl;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   400
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   401
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   402
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   403
 * Method to get the Icon of the application
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   404
 * @return The Icon of the application
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   405
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   406
QImage SampleProviderBase::applicationIcon( ) const
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   407
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   408
	return m_applicationIcon;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   409
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   410
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   411
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   412
 * Method to get the Plugin specific ID
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   413
 * @return The Plugin specific ID
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   414
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   415
QString SampleProviderBase::pluginId( ) const
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   416
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   417
	return m_pluginId;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   418
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   419
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   420
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   421
 * Method to get the ID of the authentication application
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   422
 * for this service
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   423
 * @param aProgram The authentication application name
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   424
 * @param aArguments List of arguments required for authentication app
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   425
 * @param aMode Strting mode for authentication application
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   426
 * @return The ID of the authentication application
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   427
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   428
QString SampleProviderBase::authenticationApp( QString &aProgram,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   429
		QStringList & aArguments,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   430
		QIODevice::OpenModeFlag aMode ) const
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   431
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   432
	return m_authAppId;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   433
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   434
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   435
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   436
 * Method to get the unique registration ID provided by the
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   437
 * Smf for authorised plugins
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   438
 * @return The unique registration ID/token provided by the Smf for
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   439
 * authorised plugins
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   440
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   441
QString SampleProviderBase::smfRegistrationId( ) const
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   442
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   443
	return m_smfRegToken;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   444
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   445
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   446
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   447
 * Method to get the data usage of each plugin
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   448
 * @return The data usage structure
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   449
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   450
SmfPluginDataUsage SampleProviderBase::getDataUsage( ) const
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   451
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   452
	return m_dataUsage;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   453
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   454
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   455
/**
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   456
 * Method to update the data usage of this plugin. This method is called
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   457
 * after the plugin sends request to Plugin manager and after it receives
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   458
 * data from plugin manager.
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   459
 * @param aBytesSent The number of bytes sent, when this argument has
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   460
 * some value other than 1, aBytesReceived should be zero.
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   461
 * @param aBytesReceived The number of bytes received, when this argument
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   462
 * has some value other than 1, aBytesSent  should be zero.
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   463
 * @return Returns true if success else returns false
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   464
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   465
bool SampleProviderBase::updateDataUsage( const uint &aBytesSent,
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   466
		const uint &aBytesReceived )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   467
	{
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   468
	bool ret = true;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   469
	if( aBytesSent && !aBytesReceived )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   470
		m_dataUsage.iBytesSent += aBytesSent;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   471
	else if( !aBytesSent && aBytesReceived )
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   472
		m_dataUsage.iBytesReceived += aBytesReceived;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   473
	else
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   474
		// don't update m_dataUsage, error in arguments
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   475
		ret = false;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   476
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   477
	return ret;
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   478
	}
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   479
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   480
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   481
/*
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   482
 * Export Macro
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   483
 * plugin name : sampleplugin
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   484
 * plugin class : SamplePlugin
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   485
 */
0446eb7b28aa Updating the sample plugin and other related changes for clients and plugins
cgandhi <chandradeep.gandhi@sasken.com>
parents:
diff changeset
   486
//Q_EXPORT_PLUGIN2( sampleplugin, SamplePlugin )