1 /** |
|
2 * Copyright (c) 2010 Sasken Communication Technologies Ltd. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html" |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Manasij Roy, Nalina Hariharan |
|
14 * |
|
15 * Description: |
|
16 * The Plugin util class provides the information required for the |
|
17 * plugins from Smf framework |
|
18 * |
|
19 */ |
|
20 |
|
21 #ifndef SMFPLUGINUTIL_H_ |
|
22 #define SMFPLUGINUTIL_H_ |
|
23 |
|
24 #include <QObject.h> |
|
25 #include <QNetworkAccessManager> |
|
26 |
|
27 /** |
|
28 * see http://qjson.sourceforge.net/usage.html for more details |
|
29 */ |
|
30 using namespace QJson; |
|
31 class Parser; |
|
32 |
|
33 enum SmfSignatureMethod |
|
34 { |
|
35 HMAC_SHA1, |
|
36 RSA_SHA1, |
|
37 PLAINTEXT |
|
38 }; |
|
39 |
|
40 enum SmfParsingMode |
|
41 { |
|
42 ParseForRequestContent, //Inline query format (foo=bar&bar=baz&baz=foo ...), suitable for POST requests. |
|
43 ParseForInlineQuery, // Same as ParseForRequestContent, but prepends the string with a question mark - |
|
44 // suitable for GET requests (appending parameters to the request URL) |
|
45 ParseForHeaderArguments // HTTP request header format (parameters to be put inside a request header). |
|
46 }; |
|
47 |
|
48 /** |
|
49 * The Plugin util class provides the information required for the |
|
50 * plugins from Smf framework |
|
51 */ |
|
52 class SmfPluginUtil : public QObject |
|
53 { |
|
54 Q_OBJECT |
|
55 public: |
|
56 /** |
|
57 * Method to get the instance of SmfPluginUtil class |
|
58 * @param aParser The JSON parser utility object instance |
|
59 * @return The instance of SmfPluginUtil class |
|
60 */ |
|
61 static SmfPluginUtil* getInstance ( Parser *aParser ); |
|
62 |
|
63 /** |
|
64 * Destructor |
|
65 */ |
|
66 ~SmfPluginUtil ( ); |
|
67 |
|
68 /** |
|
69 * Method called by plugins to get the handle to QJson library |
|
70 * @param aHandle [out] The QJson handle |
|
71 */ |
|
72 Parser* getJsonHandle( void ); |
|
73 |
|
74 /** |
|
75 * Method called by plugins to get the OAuth Keys. The PM sends the |
|
76 * keys only if the pluginID is that of a currently loaded plugin |
|
77 * @param aKeys [out] The OAuth keys |
|
78 * @param aRegToken The plugin's registration token |
|
79 * @param aPluginID The ID of the plugin that requests for |
|
80 * the OAuth keys |
|
81 */ |
|
82 void getAuthKeys( QMap<QString, QString> &aKeys, |
|
83 const QString aRegToken, |
|
84 const QString aPluginID ); |
|
85 |
|
86 /** |
|
87 * Method called by plugins to get the Nonce value |
|
88 * @param aStr [out] The Nonce value |
|
89 */ |
|
90 void getNonce( QString &aStr ); |
|
91 |
|
92 /** |
|
93 * Method called by plugins to generate a parameters string required to |
|
94 * access Protected Resources using OAuth authorization. |
|
95 * @param aRequestUrl The request URL |
|
96 * @param aOperation The type of http operation |
|
97 * @param aToken The access token |
|
98 * @param aTokenSecret The token secret |
|
99 * @param aSignatureMethod The signature method to be used |
|
100 * @param aParams A map of parameters to its values |
|
101 * @param aMode The mode of creation of the request |
|
102 * @return The cretd parameter string |
|
103 */ |
|
104 QByteArray createParameterString( const QString &aRequestUrl, |
|
105 QNetworkAccessManager::Operation aOperation, |
|
106 const QByteArray &aToken, |
|
107 const QByteArray &aTokenSecret, |
|
108 const SmfSignatureMethod aSignatureMethod, |
|
109 const QMultiMap<QByteArray, QByteArray> &aParams, |
|
110 const SmfParsingMode aMode); |
|
111 |
|
112 private: |
|
113 /** |
|
114 * Constructor with default argument |
|
115 * @param aParser The QJOSN parser object |
|
116 */ |
|
117 SmfPluginUtil ( Parser *aParser ); |
|
118 |
|
119 |
|
120 private: |
|
121 /** |
|
122 * The single instance of SmfPluginUtil |
|
123 */ |
|
124 static SmfPluginUtil* m_myInstance; |
|
125 |
|
126 Parser *m_jsonParser; |
|
127 |
|
128 }; |
|
129 |
|
130 #endif /* SMFPLUGINUTIL_H_ */ |
|