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 #include <smfpluginutil.h> |
|
22 |
|
23 // Static data initialisation |
|
24 SmfPluginUtil* SmfPluginUtil::m_myInstance = NULL; |
|
25 |
|
26 /** |
|
27 * Method to get the instance of SmfPluginUtil class |
|
28 * @return The instance of SmfPluginUtil class |
|
29 */ |
|
30 SmfPluginUtil* SmfPluginUtil::getInstance ( ) |
|
31 { |
|
32 if(NULL == m_myInstance) |
|
33 m_myInstance = new SmfPluginUtil(); |
|
34 return m_myInstance; |
|
35 } |
|
36 |
|
37 /** |
|
38 * Constructor with default argument |
|
39 */ |
|
40 SmfPluginUtil::SmfPluginUtil ( ) |
|
41 { |
|
42 m_jsonParser = new QJson::Parser; |
|
43 } |
|
44 |
|
45 /** |
|
46 * Destructor |
|
47 */ |
|
48 SmfPluginUtil::~SmfPluginUtil ( ) |
|
49 { |
|
50 if(m_jsonParser) |
|
51 delete m_jsonParser; |
|
52 |
|
53 if(m_myInstance) |
|
54 delete m_myInstance; |
|
55 } |
|
56 |
|
57 |
|
58 /** |
|
59 * Read JSON string from the I/O Device and converts it to a QVariant object |
|
60 * @param io Input output device |
|
61 * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true. |
|
62 * @returns a QVariant object generated from the JSON string |
|
63 */ |
|
64 QVariant SmfPluginUtil::parse ( QIODevice* io, bool* ok ) |
|
65 { |
|
66 return m_jsonParser->parse(io, ok); |
|
67 } |
|
68 |
|
69 /** |
|
70 * This is a method provided for convenience. |
|
71 * @param jsonData data containing the JSON object representation |
|
72 * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true. |
|
73 * @returns a QVariant object generated from the JSON string |
|
74 * @sa errorString |
|
75 * @sa errorLine |
|
76 */ |
|
77 QVariant SmfPluginUtil::parse ( const QByteArray& jsonData, bool* ok ) |
|
78 { |
|
79 return m_jsonParser->parse(jsonData, ok); |
|
80 } |
|
81 |
|
82 /** |
|
83 * This method returns the error message tha ocuured during last parsing |
|
84 * @returns a QString object containing the error message of the last parse operation |
|
85 */ |
|
86 QString SmfPluginUtil::errorString ( ) const |
|
87 { |
|
88 return m_jsonParser->errorString(); |
|
89 } |
|
90 |
|
91 /** |
|
92 * This method returns line number where the last QJson parsing error occurred |
|
93 * @returns the line number where the error occurred |
|
94 */ |
|
95 int SmfPluginUtil::errorLine ( ) const |
|
96 { |
|
97 return m_jsonParser->errorLine(); |
|
98 } |
|
99 |
|
100 /** |
|
101 * Method called by plugins to get the OAuth Keys. The PM sends the |
|
102 * keys only if the pluginID is that of a currently loaded plugin |
|
103 * @param aKeys [out] The OAuth keys |
|
104 * @param aRegToken The plugin's registration token |
|
105 * @param aPluginID The ID of the plugin that requests for |
|
106 * the OAuth keys |
|
107 */ |
|
108 void SmfPluginUtil::getAuthKeys( QMap<QString, QString> &aKeys, |
|
109 const QString aRegToken, |
|
110 const QString aPluginID ) |
|
111 { |
|
112 Q_UNUSED(aKeys) |
|
113 Q_UNUSED(aRegToken) |
|
114 Q_UNUSED(aPluginID) |
|
115 //// Call Credential manager function to get the keys passing the |
|
116 //// registration token and the plugin |
|
117 } |
|
118 |
|
119 /** |
|
120 * Method called by plugins to get the Nonce value |
|
121 * @param aNonceString [out] The Nonce string |
|
122 */ |
|
123 void SmfPluginUtil::getNonce( QString &aNonceString ) |
|
124 { |
|
125 Q_UNUSED(aNonceString) |
|
126 //// Call Credential manager function to get the nonce string |
|
127 } |
|
128 |
|
129 /** |
|
130 * Method called by plugins to generate a parameters string required to |
|
131 * access Protected Resources using OAuth authorization. |
|
132 * @param aRequestUrl The request URL |
|
133 * @param aOperation The type of http operation |
|
134 * @param aToken The access token |
|
135 * @param aTokenSecret The token secret |
|
136 * @param aSignatureMethod The signature method to be used |
|
137 * @param aParams A map of parameters to its values |
|
138 * @param aMode The mode of creation of the request |
|
139 * @return The cretd parameter string |
|
140 */ |
|
141 QByteArray SmfPluginUtil::createParameterString( const QString &aRequestUrl, |
|
142 QNetworkAccessManager::Operation aOperation, |
|
143 const QByteArray &aToken, |
|
144 const QByteArray &aTokenSecret, |
|
145 const SmfSignatureMethod aSignatureMethod, |
|
146 const QMultiMap<QByteArray, QByteArray> &aParams, |
|
147 const SmfParsingMode aMode) |
|
148 { |
|
149 Q_UNUSED(aRequestUrl) |
|
150 Q_UNUSED(aOperation) |
|
151 Q_UNUSED(aToken) |
|
152 Q_UNUSED(aTokenSecret) |
|
153 Q_UNUSED(aSignatureMethod) |
|
154 Q_UNUSED(aParams) |
|
155 Q_UNUSED(aMode) |
|
156 return QByteArray(); |
|
157 //// Call Credential manager function to create and sign the parameter string |
|
158 } |
|
159 |
|