|
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 <QNetworkAccessManager> |
|
25 #include <QMap> |
|
26 #include <parser.h> |
|
27 #include <smfclientglobal.h> |
|
28 |
|
29 enum SmfSignatureMethod |
|
30 { |
|
31 HMAC_SHA1, |
|
32 RSA_SHA1, |
|
33 PLAINTEXT |
|
34 }; |
|
35 |
|
36 enum SmfParsingMode |
|
37 { |
|
38 ParseForRequestContent, //Inline query format (foo=bar&bar=baz&baz=foo ...), suitable for POST requests. |
|
39 ParseForInlineQuery, // Same as ParseForRequestContent, but prepends the string with a question mark - |
|
40 // suitable for GET requests (appending parameters to the request URL) |
|
41 ParseForHeaderArguments // HTTP request header format (parameters to be put inside a request header). |
|
42 }; |
|
43 |
|
44 /** |
|
45 * The Plugin util class provides the information required for the |
|
46 * plugins from Smf framework |
|
47 */ |
|
48 class SMFCLIENT_EXPORT SmfPluginUtil |
|
49 { |
|
50 public: |
|
51 /** |
|
52 * Method to get the instance of SmfPluginUtil class |
|
53 * @return The instance of SmfPluginUtil class |
|
54 */ |
|
55 static SmfPluginUtil* getInstance ( ); |
|
56 |
|
57 /** |
|
58 * Destructor |
|
59 */ |
|
60 ~SmfPluginUtil ( ); |
|
61 |
|
62 /** |
|
63 * Method called by plugins to get the handle to QJson library |
|
64 * @return The QJson handle |
|
65 */ |
|
66 QJson::Parser* getJsonHandle( void ); |
|
67 |
|
68 /** |
|
69 * Method called by plugins to get the OAuth Keys. The PM sends the |
|
70 * keys only if the pluginID is that of a currently loaded plugin |
|
71 * @param aKeys [out] The OAuth keys |
|
72 * @param aRegToken The plugin's registration token |
|
73 * @param aPluginID The ID of the plugin that requests for |
|
74 * the OAuth keys |
|
75 */ |
|
76 void getAuthKeys( QMap<QString, QString> &aKeys, |
|
77 const QString aRegToken, |
|
78 const QString aPluginID ); |
|
79 |
|
80 /** |
|
81 * Method called by plugins to get the Nonce value |
|
82 * @param aNonceString [out] The Nonce string |
|
83 */ |
|
84 void getNonce( QString &aNonceString ); |
|
85 |
|
86 /** |
|
87 * Method called by plugins to generate a parameters string required to |
|
88 * access Protected Resources using OAuth authorization. |
|
89 * @param aRequestUrl The request URL |
|
90 * @param aOperation The type of http operation |
|
91 * @param aToken The access token |
|
92 * @param aTokenSecret The token secret |
|
93 * @param aSignatureMethod The signature method to be used |
|
94 * @param aParams A map of parameters to its values |
|
95 * @param aMode The mode of creation of the request |
|
96 * @return The cretd parameter string |
|
97 */ |
|
98 QByteArray createParameterString( const QString &aRequestUrl, |
|
99 QNetworkAccessManager::Operation aOperation, |
|
100 const QByteArray &aToken, |
|
101 const QByteArray &aTokenSecret, |
|
102 const SmfSignatureMethod aSignatureMethod, |
|
103 const QMultiMap<QByteArray, QByteArray> &aParams, |
|
104 const SmfParsingMode aMode); |
|
105 |
|
106 private: |
|
107 /** |
|
108 * Constructor with default argument |
|
109 */ |
|
110 SmfPluginUtil ( ); |
|
111 |
|
112 |
|
113 private: |
|
114 /** |
|
115 * The single instance of SmfPluginUtil |
|
116 */ |
|
117 static SmfPluginUtil* m_myInstance; |
|
118 |
|
119 /** |
|
120 * The instance of QJson::Parser |
|
121 */ |
|
122 QJson::Parser *m_jsonParser; |
|
123 |
|
124 }; |
|
125 |
|
126 #endif /* SMFPLUGINUTIL_H_ */ |