2 * Http client Connects application to server.
4 * @author Tiina Kivilinna-Korhola <tiina.kivilinna-korhola@fudeco.com>
5 * @author Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
6 * @author Toni Jussila <toni.jussila@fudeco.com>
7 * @copyright (c) 2010 Speed Freak team
8 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 #include <QMessageBox>
14 #include "httpclient.h"
15 #include "mainwindow.h"
18 *@brief Constructor, connects object to GUI
19 *@param Pointer to carmainwindow, which is temporarily used during development
21 HttpClient::HttpClient(MainWindow *myCarw)
23 qDebug() << "__HttpClient";
25 netManager = new QNetworkAccessManager();
26 myXmlwriter = new XmlWriter();
27 myXmlreader = new XmlReader();
28 connect(myXmlreader, SIGNAL(userInfo(QStringList*)), this, SLOT(sendUsersInfo(QStringList*)));
34 HttpClient::~HttpClient()
36 qDebug() << "__~HttpClient" ;
45 *@brief Sends registration information to the server in xml format.
46 *Reads user name, password and emaol address from resuldialogs internal variables.
48 void HttpClient::requestRegistration()
50 qDebug() << "_requestRegistration" ;
51 qDebug() << myMainw->settingsDialog->registerDialog->getRegUserName() << "+" << myMainw->settingsDialog->registerDialog->getRegPassword() << "+" << myMainw->settingsDialog->registerDialog->getRegEmail();
53 QBuffer *regbuffer = new QBuffer();
54 QUrl qurl("http://www.speedfreak-app.com/users/register");
55 QNetworkRequest request(qurl);
56 qDebug() << qurl.toString();
57 QNetworkReply *currentDownload;
59 regbuffer->open(QBuffer::ReadWrite);
61 // Without profile dialog
62 /*myXmlwriter->writeRegistering(regbuffer,
63 myMainw->settingsDialog->getRegUserName(),
64 myMainw->settingsDialog->getRegPassword(),
65 myMainw->settingsDialog->getRegEmail());*/
66 // With profile dialog
67 /*myXmlwriter->writeRegistering(regbuffer,
68 myMainw->settingsDialog->getRegUserName(),
69 myMainw->settingsDialog->getRegPassword(),
70 myMainw->settingsDialog->getRegEmail(),
71 myMainw->settingsDialog->profileDialog->getDescription());
72 myMainw->settingsDialog->profileDialog->getManufacturer(),
73 myMainw->settingsDialog->profileDialog->getType(),
74 myMainw->settingsDialog->profileDialog->getModel(),
75 myMainw->settingsDialog->profileDialog->getDescription(),
76 myMainw->settingsDialog->profileDialog->getPicture());*/
77 // New way: Registerdialog = register + Profiledialog
78 myXmlwriter->writeRegistering(regbuffer,
79 myMainw->settingsDialog->registerDialog->getRegUserName(),
80 myMainw->settingsDialog->registerDialog->getRegPassword(),
81 myMainw->settingsDialog->registerDialog->getRegEmail(),
82 myMainw->settingsDialog->registerDialog->getDescription());
84 qDebug() << "carmainwindow: regbuffer->data(): " << regbuffer->data();
86 currentDownload = netManager->post(request, ("xml=" + regbuffer->data()));
87 connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfRegistration()));
88 //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
91 if(myMainw->settingsDialog->registerDialog)
92 myMainw->settingsDialog->registerDialog->setLabelInfoToUser("Reguesting registration from server");
98 *@brief Sends result(s) to the server in xml format.
99 *Send authentication information in the header.
101 void HttpClient::sendResultXml(QString category, double result)
103 qDebug() << "_sendResultXml";
104 qDebug() << category;
106 QBuffer *xmlbuffer = new QBuffer();
108 QUrl qurl("http://www.speedfreak-app.com/results/update/" + category);
110 qDebug() << qurl.toString();
111 QNetworkRequest request(qurl);
112 QNetworkReply *currentDownload;
114 xmlbuffer->open(QBuffer::ReadWrite);
115 myXmlwriter->writeResult(xmlbuffer, result);
116 qDebug() << "carmainwindow: xmlbuffer->data(): " << xmlbuffer->data();
118 QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
119 credentials = "Basic " + credentials.toAscii().toBase64();
120 request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
122 currentDownload = netManager->post(request, ("xml=" + xmlbuffer->data()));
123 connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfResult()));
124 //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
127 if(myMainw->accstart->accRealTimeDialog->resultDialog)
128 myMainw->accstart->accRealTimeDialog->resultDialog->setLabelInfoToUser("Sending result to server");
134 * @brief Sends route to the server in xml format.
135 * Send authentication information in the header.
136 * @param QString filename
137 * @param int 1(send to server) or 0(no send)
138 * @todo Check destination URL.
140 void HttpClient::sendRouteXml(QString oldName, QString newName, int i)
142 qDebug() << "_sendRouteXml";
144 //QString filename = "/home/user/MyDocs/speedfreak/route/route.xml";
145 qDebug() << "__old:" + oldName;
146 QString filename = newName; //+ ".xml";
150 qDebug() << "_rename xml";
152 qDebug() << "__new:" + filename;
153 qDebug() << dir.rename(oldName, filename);
158 qDebug() << "_send route";
159 QFile file(filename);
160 if (!file.open(QFile::ReadOnly))
162 qDebug() << "_sendRouteXml file.open() fail";
166 QUrl qurl("http://speedfreak-app.com/update/route");
167 qDebug() << qurl.toString();
168 QNetworkRequest request(qurl);
169 QNetworkReply *currentDownload;
171 QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
172 credentials = "Basic " + credentials.toAscii().toBase64();
173 request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
175 currentDownload = netManager->post(request, ("xml=" + file.readAll()));
176 connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfRoute()));
177 //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
180 if(myMainw->routeSaveDialog->routeDialog)
181 myMainw->routeSaveDialog->routeDialog->setLabelInfoToUser("Sending route to server");
188 *@brief Request the Top10List of certain category from the server.
189 *Send authentication information in the header.
190 *@param Category of results.
191 *@param Limit, the number of results.
193 void HttpClient::requestTopList(QString category, QString limit)
195 qDebug() << "_requestTopList";
196 qDebug() << category;
198 QString urlBase = "http://www.speedfreak-app.com/results/list_results/";
199 QUrl qurl(urlBase + category + "/" + limit);
200 qDebug() << qurl.toString();
201 QNetworkRequest request(qurl);
202 QNetworkReply *currentDownload;
204 QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
205 credentials = "Basic " + credentials.toAscii().toBase64();
206 request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
208 currentDownload = netManager->post(request, ("data=" ));
209 connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfToplist()));
210 //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
213 if(myMainw->topResultDialog)
214 myMainw->topResultDialog->setLabelInfoToUser("Reguesting top10 list from server");
218 *@brief Request categories list from the server.
219 *Send authentication information in the header.
221 void HttpClient::requestCategories()
223 qDebug() << "_requestCategories" ;
225 QUrl qurl("http://www.speedfreak-app.com/results/categories");
226 qDebug() << qurl.toString();
227 QNetworkRequest request(qurl);
228 QNetworkReply *currentDownload;
230 QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
231 credentials = "Basic " + credentials.toAscii().toBase64();
232 request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
234 currentDownload = netManager->post(request, ("data=" ));
235 connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfCategories()));
236 //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
239 if(myMainw->topResultDialog)
240 myMainw->topResultDialog->setLabelInfoToUser("Reguesting categories from server");
244 *@brief Check that username and password exist on the server.
245 *Send authentication information in the header.
247 void HttpClient::checkLogin()
249 qDebug() << "_checkLogin";
251 QUrl qurl("http://www.speedfreak-app.com/users/login");
252 qDebug() << qurl.toString();
254 QNetworkRequest request(qurl);
255 QNetworkReply *currentDownload;
257 QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
258 credentials = "Basic " + credentials.toAscii().toBase64();
259 request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
261 currentDownload = netManager->post(request, ("data=" ));
262 connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfLogin()));
263 //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
266 if(myMainw->settingsDialog)
267 myMainw->settingsDialog->setLabelInfoToUser("Checking login validity from server");
271 *@brief React to servers responce after result has been sent.
273 void HttpClient::ackOfResult()
275 qDebug() << "_ackOfResult";
278 if(myMainw->accstart->accRealTimeDialog->resultDialog)
279 myMainw->accstart->accRealTimeDialog->resultDialog->setLabelInfoToUser("");
281 QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
283 QNetworkReply::NetworkError errorcode;
284 errorcode = reply->error();
286 qDebug() << "errorcode:" << errorcode << reply->errorString();
289 if(myMainw->accstart->accRealTimeDialog->resultDialog)
290 QMessageBox::about(myMainw->accstart->accRealTimeDialog->resultDialog, "Server reply to result sending ",reply->errorString());
291 if(myMainw->accstart->accRealTimeDialog->resultDialog)
292 myMainw->accstart->accRealTimeDialog->resultDialog->setLabelInfoToUser("Error");
293 if(myMainw->accstart->accRealTimeDialog->resultDialog)
294 myMainw->accstart->accRealTimeDialog->resultDialog->setSendServerButtonEnabled();
298 if(myMainw->accstart->accRealTimeDialog->resultDialog)
299 QMessageBox::about(myMainw->accstart->accRealTimeDialog->resultDialog, "Server reply to result sending", "Result received " + reply->readAll());
300 if(myMainw->accstart->accRealTimeDialog->resultDialog)
301 myMainw->accstart->accRealTimeDialog->resultDialog->setLabelInfoToUser("Result received");
306 *@brief React to servers responce after route has been sent.
308 void HttpClient::ackOfRoute()
310 qDebug() << "_ackOfRoute";
312 if(myMainw->routeSaveDialog->routeDialog)
313 myMainw->routeSaveDialog->routeDialog->setLabelInfoToUser("");
315 QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
317 QNetworkReply::NetworkError errorcode;
318 errorcode = reply->error();
320 qDebug() << "errorcode:" << errorcode << reply->errorString();
321 if(myMainw->routeSaveDialog->routeDialog)
322 QMessageBox::about(myMainw->routeSaveDialog->routeDialog, "Server reply to route sending ",reply->errorString());
323 if(myMainw->routeSaveDialog->routeDialog)
324 myMainw->routeSaveDialog->routeDialog->setSendServerButtonEnabled();
327 qDebug() << "errorcode:" << errorcode << reply->errorString();
328 if(myMainw->routeSaveDialog->routeDialog)
329 QMessageBox::about(myMainw->routeSaveDialog->routeDialog, "Server reply to route sending", "Route received " + reply->readAll());
334 *@brief React to servers responce after registration has been sent.
335 *@todo Implement consequencies of reply.
337 void HttpClient::ackOfRegistration()
339 qDebug() << "_ackOfRegistration";
341 if(myMainw->settingsDialog)
342 myMainw->settingsDialog->registerDialog->setLabelInfoToUser("");
344 QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
346 QNetworkReply::NetworkError errorcode;
347 errorcode = reply->error();
349 qDebug() << "errorcode:" << errorcode << reply->errorString();
350 if(myMainw->settingsDialog->registerDialog)
351 QMessageBox::about(myMainw->settingsDialog->registerDialog, "Server reply to registration",reply->readAll());
354 qDebug() << "errorcode=0" << errorcode << reply->errorString();
355 if(myMainw->settingsDialog->registerDialog)
357 QMessageBox::about(myMainw->settingsDialog->registerDialog, "Server reply to registration", "User registration " + reply->readAll());
358 myMainw->settingsDialog->registerDialog->clearRegisterLineEdits();
364 *@brief React to servers responce after request for categories has been sent.
366 void HttpClient::ackOfCategories()
368 qDebug() << "_ackOfCategories";
370 if(myMainw->topResultDialog)
371 myMainw->topResultDialog->setLabelInfoToUser("");
373 QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
374 myXmlreader->xmlReadCategories(reply);
376 QNetworkReply::NetworkError errorcode;
377 errorcode = reply->error();
379 qDebug() << "errorcode:" << errorcode << reply->errorString();
380 //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories",reply->errorString());
381 if(myMainw->topResultDialog)
382 myMainw->topResultDialog->setLabelInfoToUser("You're not logged! Please register or log in.");
385 //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories ", "OK");
386 if(myMainw->topResultDialog)
387 myMainw->topResultDialog->setLabelInfoToUser("");
392 *@brief React to servers responce after request of TopList in certain category has been sent.
394 void HttpClient::ackOfLogin()
396 qDebug() << "_ackOffLogin";
398 if(myMainw->settingsDialog)
399 myMainw->settingsDialog->setLabelInfoToUser("");
401 QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
403 QNetworkReply::NetworkError errorcode;
404 errorcode = reply->error();
407 qDebug() << "errorcode:" << errorcode << reply->errorString();
408 if(myMainw->settingsDialog)
410 QMessageBox::about(myMainw->settingsDialog, "Server does not recognize your username. Please registrate.",reply->errorString());
411 myMainw->settingsDialog->usernameOk(false);
416 qDebug() << "errorcode:" << errorcode << reply->errorString();
417 if(myMainw->settingsDialog)
418 QMessageBox::about(myMainw->settingsDialog, "Server reply to login", "User login " + reply->readAll());
419 // here signal emit to mainwindow for username setting to main panel
421 if( myMainw->settingsDialog)
423 myMainw->settingsDialog->usernameOk(true);
424 myMainw->settingsDialog->close();
430 *@brief Reports errors, when server has sent error signal.
432 void HttpClient::errorFromServer(QNetworkReply::NetworkError errorcode)
434 qDebug() << "_errorFromServer";
435 QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
438 qDebug() << "errorcode:" << errorcode;
439 //Note that errors are already reported on other each functions for server communication
440 //QMessageBox::about(myMainw, "Server reported an error", reply->errorString());
443 qDebug() << "errorcode:" << errorcode << reply->errorString();
444 qDebug() << reply->readAll();
449 *@brief React to servers responce after request of TopList in certain category has been sent.
451 void HttpClient::ackOfToplist()
453 qDebug() << "_ackOfToplist";
454 QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
455 myXmlreader->xmlReadTop10Results(reply,myMainw->settingsDialog->getUserName());
457 QNetworkReply::NetworkError errorcode;
458 errorcode = reply->error();
460 qDebug() << "errorcode:" << errorcode << reply->errorString();
462 if(myMainw->topResultDialog)
464 //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting top 10 list",reply->errorString());
465 myMainw->topResultDialog->setLabelInfoToUser("No results ;(");
469 qDebug() << "errorcode:" << errorcode << reply->errorString();
471 if(myMainw->topResultDialog)
473 //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting top 10 list", "OK " + reply->readAll());
474 myMainw->topResultDialog->setLabelInfoToUser("");
480 * This function sends profile to the server in xml format.
481 * Send authentication information in the header.
483 void HttpClient::sendProfileXml()
485 qDebug() << "_sendProfileXml";
487 QString userName = myMainw->settingsDialog->getUserName();
488 QString filename = userName + "_profile.xml";
489 QFile file(filename);
490 if (!file.open(QFile::ReadWrite | QFile::Text))
492 qDebug() << "_xmlWrite fail";
495 myXmlwriter->writeProfileXmlFile(&file, userName,
496 myMainw->settingsDialog->registerDialog->getManufacturer(),
497 myMainw->settingsDialog->registerDialog->getType(),
498 myMainw->settingsDialog->registerDialog->getModel(),
499 myMainw->settingsDialog->registerDialog->getDescription(),
500 myMainw->settingsDialog->registerDialog->getPicture());
503 if(myMainw->settingsDialog->registerDialog)
504 myMainw->settingsDialog->registerDialog->setLabelInfoToUser("Profile saved to phone");
506 // Send xml to server
507 /*QUrl qurl("http://speedfreak-app.com/api/profile");
508 QNetworkRequest request(qurl);
509 qDebug() << qurl.toString();
510 QNetworkReply *currentDownload;
512 QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
513 credentials = "Basic " + credentials.toAscii().toBase64();
514 request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
516 currentDownload = netManager->post(request, ("xml=" + file.readAll()));
517 bool error = connect(currentDownload, SIGNAL(finished()), this, SLOT(ackOfProfile()));*/
521 // Send picture to server
522 /*if(myMainw->settingsDialog->profileDialog->getPicture() != "" && error == false)
524 QFile pictureFile( myMainw->settingsDialog->profileDialog->getPicture() );
525 if (!pictureFile.open(QIODevice::ReadOnly))
527 qDebug() << "__picture read fail";
530 currentDownload = netManager->post(request, pictureFile.readAll());
531 connect(currentDownload, SIGNAL(finished()), this, SLOT(ackOfSendingPicture()));
537 * This slot function react to servers responce after request of profile has been sent.
539 bool HttpClient::ackOfProfile()
541 qDebug() << "__ackOfProfile";
542 QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
543 QNetworkReply::NetworkError errorcode;
544 errorcode = reply->error();
546 qDebug() << "errorcode:" << errorcode << reply->errorString();
548 if(myMainw->settingsDialog->registerDialog)
550 //QMessageBox::about(myMainw->settingsDialog->profileDialog, "Server reply to requesting profile",reply->errorString());
551 myMainw->settingsDialog->registerDialog->setLabelInfoToUser("Profile save to server - fail");
556 qDebug() << "errorcode:" << errorcode << reply->errorString();
558 if(myMainw->settingsDialog->registerDialog)
560 //QMessageBox::about(myMainw->settingsDialog->profileDialog, "Server reply to requesting profile", "OK " + reply->readAll());
561 myMainw->settingsDialog->registerDialog->setLabelInfoToUser("Profile saved to server");
567 * This slot function react to servers responce after request of picture has been sent.
569 void HttpClient::ackOfSendingPicture()
571 qDebug() << "__ackOfSendingPicture";
572 QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
573 QNetworkReply::NetworkError errorcode;
574 errorcode = reply->error();
576 qDebug() << "errorcode:" << errorcode << reply->errorString();
578 if(myMainw->settingsDialog->registerDialog)
580 //QMessageBox::about(myMainw->settingsDialog->profileDialog, "Server reply to requesting picture",reply->errorString());
581 myMainw->settingsDialog->registerDialog->setLabelInfoToUser("Picture save to server - fail");
585 qDebug() << "errorcode:" << errorcode << reply->errorString();
587 if(myMainw->settingsDialog->registerDialog)
589 //QMessageBox::about(myMainw->settingsDialog->profileDialog, "Server reply to requesting picture", "OK " + reply->readAll());
590 myMainw->settingsDialog->registerDialog->setLabelInfoToUser("Picture saved to server");
596 *@brief Request the user information of certain user from the server.
597 *Send authentication information in the header.
598 *@param username which information we want.
600 void HttpClient::requestUserInfo(QString username)
602 qDebug() << "_requestUsersInfo" ;
604 QUrl qurl("http://speedfreak-app.com/users/info/" + username);
605 qDebug() << qurl.toString();
606 QNetworkRequest request(qurl);
607 QNetworkReply *currentDownload;
609 QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
610 credentials = "Basic " + credentials.toAscii().toBase64();
611 request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
613 currentDownload = netManager->post(request, ("data=" ));
614 connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfUserInfo()));
616 //qDebug() << "requestUserInfo";
621 *@brief React to servers responce after request the user information of certain user.
623 void HttpClient::ackOfUserInfo()
625 qDebug() << "ackUserInfo";
626 /*QString fileName = "user.xml";
627 QFile file(fileName);
628 //file.setFileName( "routetemp.xml");
629 if (!file.open(QFile::ReadOnly))
631 qDebug() << "_xmlShow fail";
635 myXmlreader->xmlReadUserInfo(&file);
638 QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
639 myXmlreader->xmlReadUserInfo(reply);
641 //for(int i = 0; i < myXmlreader->usersList->count(); i++)
643 // myMainw->settingsDialog->sendUsernameToUsersDialog(myXmlreader->usersList->at(i));
648 *@brief Request the users list of all users from the server.
649 *Send authentication information in the header.
651 void HttpClient::requestUsers()
653 qDebug() << "_requestUsers" ;
655 QUrl qurl("http://www.speedfreak-app.com/users/list_all");
656 qDebug() << qurl.toString();
657 QNetworkRequest request(qurl);
658 QNetworkReply *currentDownload;
660 QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
661 credentials = "Basic " + credentials.toAscii().toBase64();
662 request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
664 currentDownload = netManager->post(request, ("data=" ));
665 connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfUsers()));
668 //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
671 //if(myMainw->topResultDialog)
672 //myMainw->topResultDialog->setLabelInfoToUser("Reguesting categories from server");
678 *@brief React to servers responce after request the users list of all users.
680 void HttpClient::ackOfUsers()
682 qDebug() << "ackUsers";
683 /* QString fileName = "jtn.xml";
684 QFile file(fileName);
685 //file.setFileName( "routetemp.xml");
686 if (!file.open(QFile::ReadOnly))
688 qDebug() << "_xmlShow fail";
692 myXmlreader->xmlReadUsers(&file);
695 for(int i = 0; i < myXmlreader->usersList->count(); i++)
697 myMainw->settingsDialog->sendUsernameToUsersDialog(myXmlreader->usersList->at(i));
700 qDebug() << "ackUsers";
702 //if(myMainw->topResultDialog)
703 // myMainw->topResultDialog->setLabelInfoToUser("");
705 QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
706 myXmlreader->xmlReadUsers(reply);
708 for(int i = 0; i < myXmlreader->usersList->count(); i++)
710 myMainw->usersDialog->appendUserToList(myXmlreader->usersList->at(i));
712 /* QNetworkReply::NetworkError errorcode;
713 errorcode = reply->error();
715 qDebug() << "errorcode:" << errorcode << reply->errorString();
716 //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories",reply->errorString());
717 if(myMainw->topResultDialog)
718 myMainw->topResultDialog->setLabelInfoToUser("You're not logged! Please register or log in.");
721 qDebug() << "errorcode:" << errorcode << reply->errorString();
722 //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories ", "OK");
723 if(myMainw->topResultDialog)
724 myMainw->topResultDialog->setLabelInfoToUser("");
729 * This slot function called when userInfo signal is emitted from xmlreader.
730 *@param usersInfo includes information from certain user.
732 void HttpClient::sendUsersInfo(QStringList* usersInfo)
734 myMainw->usersDialog->setUserInfo(usersInfo);