smf/smfservermodule/smfcommon/smfpluginutil.h
author cgandhi
Thu, 23 Sep 2010 17:20:22 +0530
changeset 24 1cee9f1b95e0
parent 18 013a02bf2bb0
permissions -rw-r--r--
taking care of credmgr for RVCT B686 compilation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
     1
/**
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
     2
 * Copyright (c) 2010 Sasken Communication Technologies Ltd.
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
     3
 * All rights reserved.
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
     5
 * under the terms of the "Eclipse Public License v1.0" 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
     6
 * which accompanies  this distribution, and is available
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html"
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
     8
 *
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
     9
 * Initial Contributors:
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    10
 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    11
 *
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    12
 * Contributors:
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    13
 * Manasij Roy, Nalina Hariharan
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    14
 * 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    15
 * Description:
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    16
 * The Plugin util class provides the information required for the 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    17
 * plugins from Smf framework 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    18
 *
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    19
 */
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    20
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    21
#ifndef SMFPLUGINUTIL_H_
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    22
#define SMFPLUGINUTIL_H_
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    23
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    24
#include <QNetworkAccessManager>
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    25
#include <QMap>
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    26
#include <QVariant>
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    27
#include <parser.h>
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    28
#include <smfclientglobal.h>
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    29
#include <smfcredmgrclient.h>
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    30
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    31
enum SmfParsingMode
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    32
	{
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    33
	ParseForRequestContent, //Inline query format (foo=bar&bar=baz&baz=foo ...), suitable for POST requests.
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    34
	ParseForInlineQuery, // Same as ParseForRequestContent, but prepends the string with a question mark - 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    35
						// suitable for GET requests (appending parameters to the request URL) 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    36
	ParseForHeaderArguments // HTTP request header format (parameters to be put inside a request header). 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    37
	};
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    38
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    39
/**
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    40
 * The Plugin util class provides the information required for the 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    41
 * plugins from Smf framework
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    42
 */
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    43
class SMFCOMMON_EXPORT SmfPluginUtil
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    44
	{
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    45
public:
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    46
	/**
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    47
	 * Constructor
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    48
	 */
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    49
	SmfPluginUtil();
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    50
	
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    51
	/**
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    52
	 * Destructor
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    53
	 */
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    54
	~SmfPluginUtil ( );
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    55
	
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    56
	/**
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    57
    * Read JSON string from the I/O Device and converts it to a QVariant object
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    58
    * @param io Input output device
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    59
    * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    60
    * @returns a QVariant object generated from the JSON string
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    61
	 */
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    62
    QVariant parse ( QIODevice* io, bool* ok = 0 );
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    63
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    64
    /**
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    65
    * This is a method provided for convenience.
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    66
    * @param jsonData data containing the JSON object representation
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    67
    * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true.
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    68
    * @returns a QVariant object generated from the JSON string
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    69
    * @sa errorString
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    70
    * @sa errorLine
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    71
    */
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    72
    QVariant parse ( const QByteArray& jsonData, bool* ok = 0 );
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    73
    
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    74
    /**
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    75
    * This method returns the error message tha ocuured during last parsing
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    76
    * @returns a QString object containing the error message of the last parse operation
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    77
    */
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    78
    QString errorString ( ) const;
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    79
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    80
    /**
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    81
    * This method returns line number where the last QJson parsing error occurred
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    82
    * @returns the line number where the error occurred
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    83
    */
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    84
    int errorLine ( ) const;
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    85
	
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    86
    /**
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    87
     * Method called by plugins to get the OAuth Keys.
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    88
     * @param aKeys [out] The OAuth keys
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    89
     * @param aRegToken The plugin's registration token
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    90
     * @param aValidity The validity of the keys
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    91
     * @param aPluginID The ID of the plugin that requests for 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    92
     * the OAuth keys
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    93
     */
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    94
    void getAuthKeys( SmfAuthParams &aKeys, 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    95
    		const QString aRegToken, 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    96
    		const QDateTime& aValidity,
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    97
    		const QString aPluginID );
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    98
	
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
    99
	/**
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   100
	 * Method called by plugins to get the Nonce value
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   101
	 * @param aNonceString [out] The Nonce string
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   102
	 * @param aLength Lenth of the NONCE tobe generated
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   103
	 */
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   104
    void getNonce( QString &aNonceString, const qint64 aLength );
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   105
	
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   106
	/**
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   107
	 * Method called by plugins to generate a parameters string required to 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   108
	 * access Protected Resources using OAuth authorization.
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   109
	 * @param aRequestUrl The request URL
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   110
	 * @param aOperation The type of http operation
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   111
	 * @param aToken The access token
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   112
	 * @param aTokenSecret The token secret
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   113
	 * @param aSignatureMethod The signature method to be used
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   114
	 * @param aParams A map of parameters to its values
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   115
	 * @param aMode The mode of creation of the request
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   116
	 * @return The cretd parameter string
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   117
	 */
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   118
	QByteArray createParameterString( const QString &aRequestUrl, 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   119
			QNetworkAccessManager::Operation aOperation, 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   120
			const QByteArray &aToken, 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   121
			const QByteArray &aTokenSecret, 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   122
			const SmfSignatureMethod aSignatureMethod, 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   123
			const QMultiMap<QByteArray, QByteArray> &aParams, 
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   124
			const SmfParsingMode aMode);
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   125
	
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   126
private:
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   127
	/**
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   128
	 * The instance of QJson::Parser
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   129
	 */
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   130
	QJson::Parser *m_jsonParser;
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   131
	
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   132
	};
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   133
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents:
diff changeset
   134
#endif /* SMFPLUGINUTIL_H_ */