#include <QString>
#include <QMessageBox>
+#include <QDir>
#include "httpclient.h"
#include "mainwindow.h"
qDebug() << myMainw->settingsDialog->getRegUserName() << "+" << myMainw->settingsDialog->getRegPassword() << "+" << myMainw->settingsDialog->getRegEmail();
QBuffer *regbuffer = new QBuffer();
- QUrl qurl("http://api.speedfreak-app.com/api/register");
+ QUrl qurl("http://www.speedfreak-app.com/users/register");
QNetworkRequest request(qurl);
qDebug() << qurl.toString();
QNetworkReply *currentDownload;
myXmlwriter->writeRegistering(regbuffer,
myMainw->settingsDialog->getRegUserName(),
myMainw->settingsDialog->getRegPassword(),
- myMainw->settingsDialog->getRegEmail());
+ myMainw->settingsDialog->getRegEmail(),
+ "My car is cool");
qDebug() << "carmainwindow: regbuffer->data(): " << regbuffer->data();
currentDownload = netManager->post(request, ("xml=" + regbuffer->data()));
void HttpClient::sendResultXml(QString category, double result)
{
qDebug() << "_sendResultXml";
+ qDebug() << category;
QBuffer *xmlbuffer = new QBuffer();
- QUrl qurl("http://api.speedfreak-app.com/api/update/" + category);
+ QUrl qurl("http://www.speedfreak-app.com/results/update/" + category);
+
qDebug() << qurl.toString();
QNetworkRequest request(qurl);
QNetworkReply *currentDownload;
}
/**
- *@brief Sends route to the server in xml format.
- *Send authentication information in the header.
- *@todo Check destination URL.
+ * @brief Sends route to the server in xml format.
+ * Send authentication information in the header.
+ * @param QString filename
+ * @param int 1(send to server) or 0(no send)
+ * @todo Check destination URL.
*/
-void HttpClient::sendRouteXml()
+void HttpClient::sendRouteXml(QString oldName, QString newName, int i)
{
qDebug() << "_sendRouteXml";
- QString filename = "route.xml";
- QFile file(filename);
- if (!file.open(QFile::ReadOnly)) {
- qDebug() << "_sendRouteXml file.open() fail";
- return;
+ //QString filename = "/home/user/MyDocs/speedfreak/route/route.xml";
+ qDebug() << "__old:" + oldName;
+ QString filename = newName; //+ ".xml";
+
+ if(newName != "")
+ {
+ qDebug() << "_rename xml";
+ QDir dir(filename);
+ qDebug() << "__new:" + filename;
+ qDebug() << dir.rename(oldName, filename);
}
- QUrl qurl("http://api.speedfreak-app.com/api/update/route");
- qDebug() << qurl.toString();
- QNetworkRequest request(qurl);
- QNetworkReply *currentDownload;
+ if(i == 1)
+ {
+ qDebug() << "_send route";
+ QFile file(filename);
+ if (!file.open(QFile::ReadOnly))
+ {
+ qDebug() << "_sendRouteXml file.open() fail";
+ return;
+ }
- QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
- credentials = "Basic " + credentials.toAscii().toBase64();
- request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
+ QUrl qurl("http://speedfreak-app.com/update/route");
+ qDebug() << qurl.toString();
+ QNetworkRequest request(qurl);
+ QNetworkReply *currentDownload;
- currentDownload = netManager->post(request, ("xml=" + file.readAll()));
- connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfRoute()));
- //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
+ QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
+ credentials = "Basic " + credentials.toAscii().toBase64();
+ request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());
- //Indicating user
- if(myMainw->routeSaveDialog->routeDialog)
- myMainw->routeSaveDialog->routeDialog->setLabelInfoToUser("Sending route to server");
+ currentDownload = netManager->post(request, ("xml=" + file.readAll()));
+ connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfRoute()));
+ //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
- file.close();
+ //Indicating user
+ if(myMainw->routeSaveDialog->routeDialog)
+ myMainw->routeSaveDialog->routeDialog->setLabelInfoToUser("Sending route to server");
+
+ file.close();
+ }
}
/**
qDebug() << "_requestTopList";
qDebug() << category;
- QString urlBase = "http://api.speedfreak-app.com/api/results/";
+ QString urlBase = "http://www.speedfreak-app.com/results/list/";
QUrl qurl(urlBase + category + "/" + limit);
qDebug() << qurl.toString();
QNetworkRequest request(qurl);
void HttpClient::requestCategories()
{
qDebug() << "_requestCategories" ;
+ QUrl qurl("http://www.speedfreak-app.com/results/categories");
- QUrl qurl("http://api.speedfreak-app.com/api/categories/");
qDebug() << qurl.toString();
QNetworkRequest request(qurl);
QNetworkReply *currentDownload;
{
qDebug() << "_checkLogin";
- QUrl qurl("http://api.speedfreak-app.com/api/login/");
+ QUrl qurl("http://www.speedfreak-app.com/users/login");
qDebug() << qurl.toString();
+
QNetworkRequest request(qurl);
QNetworkReply *currentDownload;
myMainw->accstart->accRealTimeDialog->resultDialog->setSendServerButtonEnabled();
}
else {
- qDebug() << "errorcode:" << errorcode << reply->errorString();
+ //qDebug() << "errorcode:" << errorcode << reply->errorString();
//Indicating user
if(myMainw->accstart->accRealTimeDialog->resultDialog)
myMainw->topResultDialog->setLabelInfoToUser("You're not logged! Please register or log in.");
}
else {
- qDebug() << "errorcode:" << errorcode << reply->errorString();
+ //qDebug() << "errorcode:" << errorcode << reply->errorString();
//QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories ", "OK");
if(myMainw->topResultDialog)
myMainw->topResultDialog->setLabelInfoToUser("");
myMainw->settingsDialog->profileDialog->setLabelInfoToUser("Profile saved to phone");
// Send xml to server
- /*QUrl qurl("http://api.speedfreak-app.com/api/profile");
+ /*QUrl qurl("http://speedfreak-app.com/api/profile");
QNetworkRequest request(qurl);
qDebug() << qurl.toString();
QNetworkReply *currentDownload;