|
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 |
|
56 public: |
|
57 /** |
|
58 * Method to get the instance of SmfPluginUtil class |
|
59 * @param aParser The JSON parser utility object instance |
|
60 * @return The instance of SmfPluginUtil class |
|
61 */ |
|
62 static SmfPluginUtil* getInstance ( Parser *aParser ); |
|
63 |
|
64 /** |
|
65 * Destructor |
|
66 */ |
|
67 ~SmfPluginUtil ( ); |
|
68 |
|
69 /** |
|
70 * Method called by plugins to get the handle to QJson library |
|
71 * @param aHandle [out] The QJson handle |
|
72 */ |
|
73 Parser* getJsonHandle( void ); |
|
74 |
|
75 /** |
|
76 * Method called by plugins to get the OAuth Keys. The PM sends the |
|
77 * keys only if the pluginID is that of a currently loaded plugin |
|
78 * @param aKeys [out] The OAuth keys |
|
79 * @param aPluginID The ID of the plugin that requests for |
|
80 * the OAuth keys |
|
81 */ |
|
82 void getAuthKeys( QMap<QString, QString> &aKeys, QString aPluginID ); |
|
83 |
|
84 /** |
|
85 * Method called by plugins to get the Nonce value |
|
86 * @param aStr [out] The Nonce value |
|
87 */ |
|
88 void getNonce( QString &aStr ); |
|
89 |
|
90 /** |
|
91 * Method called by plugins to generate a parameters string required to |
|
92 * access Protected Resources using OAuth authorization. |
|
93 * @param aRequestUrl The request URL |
|
94 * @param aOperation The type of http operation |
|
95 * @param aToken The access token |
|
96 * @param aTokenSecret The token secret |
|
97 * @param aSignatureMethod The signature method to be used |
|
98 * @param aParams A map of parameters to its values |
|
99 * @param aMode The mode of creation of the request |
|
100 * @return The cretd parameter string |
|
101 */ |
|
102 QByteArray createParameterString( const QString &aRequestUrl, |
|
103 QNetworkAccessManager::Operation aOperation, |
|
104 const QByteArray &aToken, |
|
105 const QByteArray &aTokenSecret, |
|
106 const SmfSignatureMethod aSignatureMethod, |
|
107 const QMultiMap<QByteArray, QByteArray> &aParams, |
|
108 const SmfParsingMode aMode); |
|
109 |
|
110 private: |
|
111 /** |
|
112 * Constructor with default argument |
|
113 * @param aParent The parent object |
|
114 */ |
|
115 SmfPluginUtil ( Parser *aParser ); |
|
116 |
|
117 |
|
118 private: |
|
119 /** |
|
120 * The single instance of SmfPluginUtil |
|
121 */ |
|
122 static SmfPluginUtil* m_myInstance; |
|
123 |
|
124 Parser *m_jsonParser; |
|
125 |
|
126 }; |
|
127 |
|
128 #endif /* SMFPLUGINUTIL_H_ */ |