|
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 "{License}" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "{LicenseUrl}". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Narasimhulu Kavadapu, Sasken Communication Technologies Ltd - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Siddhartha Chandra, Satish Kanteti Sasken Communication Technologies Ltd |
|
14 * Description: |
|
15 * class to handle calls to rest Server API's |
|
16 */ |
|
17 |
|
18 #include "requestSP.h" |
|
19 #include "sessionSP.h" |
|
20 #include "xmlParser.h" |
|
21 #include "errorCodes.h" |
|
22 |
|
23 #include <QNetworkRequest> |
|
24 #include <QXmlSimpleReader> |
|
25 #include <QXmlInputSource> |
|
26 #include <QCryptographicHash> |
|
27 #include <QtAlgorithms> |
|
28 #include <QDebug> |
|
29 |
|
30 #include "hash.h" |
|
31 //#include "IMCVCODC.H" |
|
32 |
|
33 #include <keys.h> |
|
34 #include <qnetworkproxy.h> |
|
35 #include <QSslConfiguration> |
|
36 /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
37 // global |
|
38 |
|
39 static const QString kAPIVersion = "1.0"; |
|
40 static const QString kAPIFormat = "XML"; |
|
41 static const QString kStringBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f"; |
|
42 |
|
43 ////////////////////////////////////////////////////////////////////////////////////////////////// |
|
44 |
|
45 static bool caseInsensitiveLessThan(const QString &s1, const QString &s2) |
|
46 { |
|
47 return s1.toLower() < s2.toLower(); |
|
48 } |
|
49 |
|
50 /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
51 // Static class functions |
|
52 |
|
53 FBRequest* FBRequest::request() |
|
54 { |
|
55 return FBRequest::requestWithSession(FBSession::session()); |
|
56 } |
|
57 |
|
58 FBRequest* FBRequest::requestWithSession (FBSession* aSession) |
|
59 { |
|
60 FBRequest* request = new FBRequest(aSession); |
|
61 return request; |
|
62 } |
|
63 |
|
64 /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
65 // instance public functions |
|
66 FBRequest::FBRequest(FBSession* aSession) : iSession ( aSession ), iNetworkAccessManager ( this ) |
|
67 {} |
|
68 |
|
69 const QDateTime& FBRequest::timeStamp() const |
|
70 { |
|
71 return iTimestamp; |
|
72 } |
|
73 |
|
74 void FBRequest::connect() |
|
75 { |
|
76 qDebug()<<"Inside FBRequest::connect()"; |
|
77 emit requestLoading(); |
|
78 |
|
79 //QString url ; |
|
80 //url = iUrl; |
|
81 //qDebug()<<"url"<<url; |
|
82 |
|
83 QNetworkRequest request; |
|
84 |
|
85 QSslConfiguration config( QSslConfiguration::defaultConfiguration() ); |
|
86 request.setSslConfiguration( config ); |
|
87 //url = "https://api.linkedin.com/uas/oauth/authorize?oauth_token=8b6d81ed-1f1e-404f-8318-53018c65b87b"; |
|
88 // request.setUrl(QUrl(url)); |
|
89 QUrl myurl = kRequestTokenUrl; |
|
90 request.setUrl(myurl); |
|
91 //QString myurl1 = "http://www.facebook.com/connect/login_success.html"; |
|
92 QString Authorization = "OAuth oauth_nonce=\"" + iSession->stroauth_nonce + "\",oauth_callback=\"oob\",oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"" + iSession->stroauth_timestamp + "\", oauth_consumer_key=\"" + kConsumerKey + "\", oauth_signature=\"" + iSession->stroauth_signature.toAscii().toPercentEncoding() + "\", oauth_version=\"1.0\""; |
|
93 qDebug()<<"Authorization: "<<Authorization; |
|
94 QByteArray auth = Authorization.toUtf8(); |
|
95 qDebug()<<"auth:"<<auth; |
|
96 request.setRawHeader("Authorization",auth); |
|
97 const QString contentType = "multipart/form-data; boundary=" + kStringBoundary; |
|
98 request.setHeader (QNetworkRequest::ContentTypeHeader, contentType); |
|
99 |
|
100 QByteArray postBody ; |
|
101 generatePostBody (postBody); |
|
102 |
|
103 pbar = new progressbar; |
|
104 pbar->show(); |
|
105 proxysettings(); |
|
106 QNetworkReply* reply = iNetworkAccessManager.post(request, postBody); |
|
107 |
|
108 QObject::connect(reply, SIGNAL(finished()), this, SLOT(networkReplyFinished())); |
|
109 QObject::connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), |
|
110 this, SLOT(networkReplyError(QNetworkReply::NetworkError))); |
|
111 |
|
112 |
|
113 } |
|
114 void FBRequest::proxysettings() |
|
115 { |
|
116 #ifdef EMULATORTESTING |
|
117 qDebug()<<"proxysettings"; |
|
118 |
|
119 // Reading the keys, CSM Stubbed - START |
|
120 QFile file("c:\\data\\DoNotShare.txt"); |
|
121 if (!file.open(QIODevice::ReadOnly)) |
|
122 { |
|
123 qDebug()<<"File to read the windows username and password could not be opened, returning!!!"; |
|
124 return; |
|
125 } |
|
126 |
|
127 QByteArray arr = file.readAll(); |
|
128 QList<QByteArray> list = arr.split(' '); |
|
129 file.close(); |
|
130 |
|
131 QString username(list[0]); |
|
132 QString password(list[1]); |
|
133 |
|
134 QString httpProxy = "10.1.0.214";//ipwproxy.sasken.com |
|
135 QString httpPort = "3128"; |
|
136 |
|
137 QString httpUser =username;/* This could be taken thru an QDialog implmentation to remove the Hard coding */ |
|
138 QString httpPass =password;/* This could be taken thru an QDialog implmentation to remove the Hard coding */ |
|
139 |
|
140 /*==Classes used from Network Module==*/ |
|
141 QNetworkProxy proxy; |
|
142 |
|
143 proxy.setType(QNetworkProxy::HttpProxy); |
|
144 proxy.setHostName(httpProxy); |
|
145 proxy.setPort(httpPort.toInt()); |
|
146 proxy.setUser(httpUser); |
|
147 proxy.setPassword(httpPass); |
|
148 |
|
149 QNetworkProxy::setApplicationProxy(proxy); |
|
150 #endif |
|
151 } |
|
152 /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
153 // instance private functions |
|
154 QString FBRequest::sha1() |
|
155 { |
|
156 qDebug()<<"Insha1"; |
|
157 CSHA1* sha=CSHA1::NewL(); |
|
158 TBuf8<100> keyVal; |
|
159 keyVal.Copy(_L8("sasken")); |
|
160 CHMAC* hmac=CHMAC::NewL(keyVal,sha); |
|
161 //TBuf8<1024> baseString; |
|
162 TPtrC8 hashedSig(hmac->Hash(_L8("sasken"))); |
|
163 TBuf8<1024>bufr; |
|
164 bufr.Copy(hashedSig); |
|
165 QByteArray digest = QByteArray::fromRawData((char*)bufr.Ptr(),bufr.Length()); |
|
166 qDebug()<<"digest.toHex();"<<digest.toHex(); |
|
167 |
|
168 if(hmac) |
|
169 { |
|
170 delete hmac; |
|
171 hmac=NULL; |
|
172 } |
|
173 /* TBuf8<1024>bufr; |
|
174 bufr.Copy(hashedSig); |
|
175 QByteArray digest = QByteArray::fromRawData((char*)bufr.Ptr(),bufr.Length()); |
|
176 qDebug()<<"digest.toHex();"<<digest.toHex(); |
|
177 qDebug()<<"digest"<<digest;*/ |
|
178 return digest.toHex(); |
|
179 } |
|
180 |
|
181 bool FBRequest::isSpecialMethod() const { |
|
182 return ( iMethod.compare("facebook.auth.getSession", Qt::CaseInsensitive) == 0 |
|
183 || iMethod.compare("facebook.auth.createToken", Qt::CaseInsensitive) == 0 ); |
|
184 } |
|
185 |
|
186 QString FBRequest::urlForMethod (const QString& aMethod) const { |
|
187 |
|
188 Q_UNUSED(aMethod) |
|
189 return iSession->apiURL(); |
|
190 } |
|
191 |
|
192 QString FBRequest::generateGetURL() const |
|
193 { |
|
194 qDebug()<<"Inside FBRequest::generateGetURL()"; |
|
195 const QUrl url(iUrl); |
|
196 const QString queryPrefix = url.hasQuery() ? "&" : "?"; |
|
197 |
|
198 QStringList pairs; |
|
199 DictionaryIterator i(iParams); |
|
200 |
|
201 while (i.hasNext()) { |
|
202 i.next(); |
|
203 pairs << i.key().toUtf8() + "=" + i.value().toUtf8(); |
|
204 } |
|
205 |
|
206 return iUrl + queryPrefix + pairs.join("&"); |
|
207 } |
|
208 |
|
209 QString FBRequest::generateCallId() const { |
|
210 QDateTime dateTime = QDateTime::currentDateTime(); |
|
211 uint secs = dateTime.toTime_t(); |
|
212 QString result = QString::number(secs, 10); |
|
213 return result; |
|
214 } |
|
215 /* |
|
216 * |
|
217 httpMethod + "&" + |
|
218 url_encode( base_uri ) + "&" + |
|
219 sorted_query_params.each { | k, v | |
|
220 url_encode ( k ) + "%3D" + |
|
221 url_encode ( v ) |
|
222 }.join("%26") |
|
223 * |
|
224 */ |
|
225 /*QString FBRequest::generateSig(Dictionary Params) |
|
226 { |
|
227 QString joined; |
|
228 joined = "POST"; |
|
229 joined += "&"; |
|
230 joined += kRequestTokenUrl.toAscii().toPercentEncoding() + "&"; |
|
231 QStringList keys = Params.keys(); |
|
232 qSort(keys.begin(), keys.end(), caseInsensitiveLessThan); |
|
233 QListIterator<QString> i(keys); |
|
234 int count = 0; |
|
235 while (i.hasNext()) |
|
236 { |
|
237 count++; |
|
238 if(count > 1) |
|
239 joined.append("%26"); |
|
240 const QString key = i.next(); |
|
241 joined.append(key.toAscii().toPercentEncoding()); |
|
242 joined.append("%3D"); |
|
243 joined.append(Params.value(key).toAscii().toPercentEncoding()); |
|
244 } |
|
245 qDebug()<<"joined"<<joined; |
|
246 //uncomment for testing key |
|
247 //joined = "POST&https%3A%2F%2Fapi.linkedin.com%2Fuas%2Foauth%2FrequestToken&oauth_callback%3Dhttp%253A%252F%252Flocalhost%252Foauth_callback%26oauth_consumer_key%3DABCDEFGHIJKLMNOPQRSTUVWXYZ%26oauth_nonce%3DoqwgSYFUD87MHmJJDv7bQqOF2EPnVus7Wkqj5duNByU%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1259178158%26oauth_version%3D1.0"; |
|
248 TBuf<1024> sid(joined.utf16()); |
|
249 |
|
250 QByteArray digest1 = QByteArray::fromRawData((char*)sid.Ptr(),sid.Length()); |
|
251 qDebug()<<"digest1: "<<digest1; |
|
252 TBuf8<1024>buff;//(sid); |
|
253 buff.Copy(sid); |
|
254 QByteArray digest2 = QByteArray::fromRawData((char*)buff.Ptr(),buff.Length()); |
|
255 qDebug()<<"digest2: "<<digest2; |
|
256 |
|
257 //signature |
|
258 CSHA1* sha=CSHA1::NewL(); |
|
259 |
|
260 QByteArray key= kConsumerSecret.toUtf8(); |
|
261 key = key.toPercentEncoding(); |
|
262 key.append("&"); |
|
263 key.append(iSession->stroauth_TokenSecret.toAscii().toPercentEncoding()); |
|
264 TPtrC8 myDataDescriptor( reinterpret_cast<const TText8*> (key.constData()),key.size()); |
|
265 |
|
266 //Take a copy of the data |
|
267 HBufC8* buffer12 = HBufC8::New(myDataDescriptor.Length()); |
|
268 |
|
269 Q_CHECK_PTR(buffer12); |
|
270 buffer12->Des().Copy(myDataDescriptor ); |
|
271 TPtr8 tptr = buffer12->Des(); |
|
272 |
|
273 TBuf8<100> keyVal; |
|
274 keyVal.Copy(tptr); |
|
275 //keyVal.Copy(buffer12); |
|
276 CHMAC* hmac=CHMAC::NewL(keyVal,sha); |
|
277 //TBuf8<1024> baseString; |
|
278 TPtrC8 hashedSig(hmac->Hash(buff)); |
|
279 TBuf8<1024>bufr; |
|
280 bufr.Copy(hashedSig); |
|
281 QByteArray digest = QByteArray::fromRawData((char*)bufr.Ptr(),bufr.Length()); |
|
282 qDebug()<<"digest.toHex() "<<digest.toHex(); |
|
283 QByteArray base64 = digest.toBase64(); |
|
284 qDebug()<<"Base64 Encoded "<<base64; |
|
285 if(hmac) |
|
286 { |
|
287 delete hmac; |
|
288 hmac=NULL; |
|
289 } |
|
290 |
|
291 return base64; |
|
292 |
|
293 }*/ |
|
294 QString FBRequest::generateSig(Dictionary Params) |
|
295 { |
|
296 QString joined; |
|
297 joined = "POST"; |
|
298 joined += "&"; |
|
299 joined += kRequestTokenUrl.toAscii().toPercentEncoding() + "&"; |
|
300 |
|
301 QStringList keys = Params.keys(); |
|
302 qSort(keys.begin(), keys.end(), caseInsensitiveLessThan); |
|
303 QListIterator<QString> i(keys); |
|
304 int count = 0; |
|
305 while (i.hasNext()) |
|
306 { |
|
307 count++; |
|
308 if(count > 1) |
|
309 joined.append("%26"); |
|
310 const QString key = i.next(); |
|
311 joined.append(key.toAscii().toPercentEncoding()); |
|
312 joined.append("%3D"); |
|
313 joined.append(Params.value(key).toAscii().toPercentEncoding()); |
|
314 } |
|
315 qDebug()<<"joined"<<joined; |
|
316 //uncomment for testing key |
|
317 //joined = "POST&https%3A%2F%2Fapi.twitter.com%2Foauth%2Frequest_token&oauth_callback%3Dhttp%253A%252F%252Flocalhost%253A3005%252Fthe_dance%252Fprocess_callback%253Fservice_provider_id%253D11%26oauth_consumer_key%3DGDdmIQH6jhtmLUypg82g%26oauth_nonce%3DQP70eNmVz8jvdPevU3oJD2AfF7R7odC2XJcn4XlZJqk%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1272323042%26oauth_version%3D1.0"; |
|
318 TBuf<1024> sid(joined.utf16()); |
|
319 |
|
320 QByteArray digest1 = QByteArray::fromRawData((char*)sid.Ptr(),sid.Length()); |
|
321 qDebug()<<"digest1: "<<digest1; |
|
322 TBuf8<1024>buff;//(sid); |
|
323 buff.Copy(sid); |
|
324 QByteArray digest2 = QByteArray::fromRawData((char*)buff.Ptr(),buff.Length()); |
|
325 qDebug()<<"digest2: "<<digest2; |
|
326 |
|
327 //signature |
|
328 CSHA1* sha=CSHA1::NewL(); |
|
329 //uncomment for testing key |
|
330 //QByteArray key= "MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98"; |
|
331 QByteArray key= kConsumerSecret.toUtf8().toPercentEncoding(); |
|
332 key.append("&"); |
|
333 key.append(iSession->stroauth_TokenSecret.toUtf8().toPercentEncoding()); |
|
334 qDebug()<<"Key:"<<key; |
|
335 TPtrC8 myDataDescriptor( reinterpret_cast<const TText8*> (key.constData()),key.size()); |
|
336 |
|
337 //Take a copy of the data |
|
338 HBufC8* buffer12 = HBufC8::New(myDataDescriptor.Length()); |
|
339 |
|
340 Q_CHECK_PTR(buffer12); |
|
341 buffer12->Des().Copy(myDataDescriptor ); |
|
342 TPtr8 tptr = buffer12->Des(); |
|
343 |
|
344 TBuf8<100> keyVal; |
|
345 keyVal.Copy(tptr); |
|
346 |
|
347 CHMAC* hmac=CHMAC::NewL(keyVal,sha); |
|
348 |
|
349 TPtrC8 hashedSig(hmac->Hash(buff)); |
|
350 TBuf8<1024>bufr; |
|
351 bufr.Copy(hashedSig); |
|
352 QByteArray digest = QByteArray::fromRawData((char*)bufr.Ptr(),bufr.Length()); |
|
353 qDebug()<<"digest.toHex() "<<digest.toHex(); |
|
354 QByteArray base64 = digest.toBase64(); |
|
355 qDebug()<<"Base64 Encoded "<<base64; |
|
356 if(hmac) |
|
357 { |
|
358 delete hmac; |
|
359 hmac=NULL; |
|
360 } |
|
361 |
|
362 return base64; |
|
363 } |
|
364 void FBRequest::generatePostBody( QByteArray& body ) |
|
365 { |
|
366 qDebug()<<"Inside FBRequest::generatePostBody()"; |
|
367 QString endLine = "\r\n--" + kStringBoundary + "\r\n"; |
|
368 body.append( "--" + kStringBoundary.toUtf8() + "\r\n" ) ; |
|
369 |
|
370 |
|
371 DictionaryIterator i (iParams); |
|
372 |
|
373 while (i.hasNext()) |
|
374 { |
|
375 i.next(); |
|
376 |
|
377 body.append("Content-Disposition: form-data; name=\"" + i.key().toUtf8() + "\"\r\n\r\n" ); |
|
378 body.append(i.value().toUtf8()); |
|
379 body.append(endLine.toUtf8()); |
|
380 } |
|
381 |
|
382 |
|
383 if (iDataParam.size()) |
|
384 { |
|
385 if (iDataParamPicture) |
|
386 { |
|
387 body.append("Content-Disposition: form-data; filename=\"photo\"\r\n" ); |
|
388 body.append("Content-Type: image/png\r\n\r\n" ); |
|
389 } |
|
390 else |
|
391 { |
|
392 body.append("Content-Disposition: form-data; filename=\"data\"\r\n"); |
|
393 body.append("Content-Type: content/unknown\r\n\r\n"); |
|
394 } |
|
395 |
|
396 body.append(iDataParam); |
|
397 body.append(endLine.toUtf8()); |
|
398 |
|
399 } |
|
400 } |
|
401 |
|
402 void FBRequest::handleResponseData( const QByteArray& aResponseData ) |
|
403 { |
|
404 qDebug()<<"Inside FBRequest::handleResponseData()"; |
|
405 FBError error; |
|
406 QVariant result = parseXMLResponse( aResponseData, error); |
|
407 if (error.code() != 0) |
|
408 { |
|
409 emit requestFailedWithFacebookError(error); |
|
410 } |
|
411 else |
|
412 { |
|
413 emit requestDidLoad(result); |
|
414 } |
|
415 |
|
416 delete pbar; |
|
417 } |
|
418 |
|
419 void FBRequest::post( const QString& aUrl, const Dictionary& aParams) |
|
420 { |
|
421 qDebug()<<"Inside FBRequest::post()"; |
|
422 iUrl = aUrl; |
|
423 iParams = aParams; |
|
424 |
|
425 iSession->send(this); |
|
426 } |
|
427 |
|
428 void FBRequest::cancel() |
|
429 { |
|
430 qDebug()<<"Inside FBRequest::cancel()"; |
|
431 } |
|
432 |
|
433 |
|
434 void FBRequest::call (const QString& aMethod, const Dictionary& aParams) |
|
435 { |
|
436 QByteArray dataParams; |
|
437 callWithDataParams(aMethod, aParams, dataParams, false); |
|
438 |
|
439 } |
|
440 |
|
441 void FBRequest::callWithDataParams (const QString& aMethod, const Dictionary& aParams, const QByteArray& aDataParam, bool aDataParamPicture) |
|
442 { |
|
443 Q_UNUSED(aDataParam) |
|
444 Q_UNUSED(aDataParamPicture) |
|
445 Q_UNUSED(aParams) |
|
446 iUrl = urlForMethod(aMethod); |
|
447 iUrl += aMethod; |
|
448 qDebug()<<"URL inside call with Data Params"<<iUrl; |
|
449 //iMethod = aMethod; |
|
450 //iParams = aParams; |
|
451 /* iParams["oauth_nonce"] = iSession->stroauth_nonce; |
|
452 iParams["oauth_signature_method"] = "HMAC-SHA1"; |
|
453 iParams["oauth_timestamp"] = iSession->stroauth_timestamp; |
|
454 iParams["oauth_consumer_key"] = kConsumerKey; |
|
455 iParams["sig"]=iSession->stroauth_signature; |
|
456 iParams["oauth_version"] = "1.0";*/ |
|
457 //iDataParam = aDataParam; |
|
458 // iDataParamPicture = aDataParamPicture; |
|
459 |
|
460 // iParams["method"] = iMethod; |
|
461 // iParams["api_key"] = iSession->apiKey(); |
|
462 // iParams["v"] = kAPIVersion; |
|
463 // iParams["format"] = kAPIFormat; |
|
464 |
|
465 /* if (!isSpecialMethod()) |
|
466 { |
|
467 iParams["session_key"] = iSession->sessionKey(); |
|
468 iParams["call_id"] = generateCallId(); |
|
469 |
|
470 if (iSession->sessionSecret().length()) |
|
471 { |
|
472 iParams["ss"] = "1"; |
|
473 } |
|
474 }*/ |
|
475 |
|
476 // XXX: workaround what seems to be a Qt bug with the extras-devel libraries. |
|
477 // QString signature = generateSig(iParams); |
|
478 // iParams["sig"] = signature; |
|
479 // XXX: end workaround. |
|
480 |
|
481 iSession->send(this); |
|
482 } |
|
483 |
|
484 |
|
485 QVariant FBRequest::parseXMLResponse ( const QByteArray& aResponseData, FBError& aError) |
|
486 { |
|
487 qDebug()<<"Inside FBRequest::handleResponseData()"; |
|
488 QXmlInputSource input; |
|
489 input.setData(aResponseData); |
|
490 |
|
491 FBXMLHandler handler; |
|
492 QXmlSimpleReader parser; |
|
493 parser.setContentHandler(&handler); |
|
494 bool result = parser.parse(&input); |
|
495 |
|
496 QVariant rootObject = handler.rootObject(); |
|
497 |
|
498 if (handler.parseError() || !result) |
|
499 { |
|
500 aError.setCode( FBRESPONSE_PARSE_ERROR ); |
|
501 aError.setDescription("parser was unable to parse the xml response from facebook server."); |
|
502 |
|
503 return QVariant(); |
|
504 } |
|
505 else if (handler.rootName().compare("error_response")==0) |
|
506 { |
|
507 QVariantHash errorDict = rootObject.toHash(); |
|
508 |
|
509 bool result; |
|
510 int errorCode = errorDict.value("error_code").toInt(&result); |
|
511 |
|
512 aError.setCode( errorCode ); |
|
513 aError.setDescription( errorDict.value("error_msg").toString() ); |
|
514 |
|
515 return rootObject; |
|
516 } |
|
517 else |
|
518 { |
|
519 return rootObject; |
|
520 } |
|
521 |
|
522 } |
|
523 |
|
524 /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
525 // instance provate slots |
|
526 void FBRequest::networkReplyError ( QNetworkReply::NetworkError aCode ) |
|
527 { |
|
528 emit requestFailedWithNetworkError(aCode ); |
|
529 } |
|
530 |
|
531 void FBRequest::networkReplyFinished () |
|
532 { |
|
533 qDebug()<<"Inside FBRequest::networkReplyFinished()"; |
|
534 QNetworkReply* reply = static_cast<QNetworkReply*> ( sender() ); |
|
535 QByteArray responseData = reply->readAll(); |
|
536 if(responseData != "") |
|
537 { |
|
538 qDebug()<<"response data:"<<responseData; |
|
539 QList<QByteArray>MyString = responseData.split('&'); |
|
540 QList<QByteArray>token = MyString[0].split('='); |
|
541 qDebug()<<token.at(1); |
|
542 iSession->stroauth_Token=token.at(1); |
|
543 QList<QByteArray>token_secret = MyString[1].split('='); |
|
544 qDebug()<<token_secret.at(1); |
|
545 iSession->stroauth_TokenSecret=token_secret.at(1); |
|
546 // handleResponseData ( responseData ); |
|
547 qDebug()<<"iSession->stroauth_Token"<<iSession->stroauth_Token; |
|
548 if(responseData.contains("oauth_token")) |
|
549 { |
|
550 emit LoadLoginPage(); |
|
551 qDebug()<<"Signal:LoadLoginPage() is emitted"; |
|
552 } |
|
553 } |
|
554 else |
|
555 { |
|
556 qDebug()<<"Response not available"; |
|
557 } |
|
558 } |