speed = location->getSpeed(); //Returns current speed in km/h.
track = location->getTrack(); //Returns direction of motion in degrees(0-359).
- QFile routeTempFile("routetemp.xml");//Temp xml.
+ QFile routeTempFile(".//speedfreak_route/routetemp.xml");//Temp xml.
//If GPS find 4 or more satellite and signal stregth is 30 or more.
if (location->getSatellitesInUse() >= 4 && location->getSignalStrength() >= 30)
recordingStatus = false;
//Write final xml.
- QFile file("route.xml");
+ QFile file(".//speedfreak_route/route.xml");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return;
writeRouteXml(&file, 1);
{
xmlwriter.setDevice(device);
- //Write temp xml (routetemp.xml).
+ //Write temp xml (.//speedfreak_route/routetemp.xml).
if ( round == 0 )
{
xmlwriter.writeStartElement("Point");
xmlwriter.writeEndElement();//Point
}
- //Write final xml (route.xml).
+ //Write final xml (.//speedfreak_route/route.xml).
else if ( round == 1 )
{
xmlwriter.writeStartDocument();
xmlwriter.writeAttribute("Points", QString::number(roundCounter));
//Open temp xml and read points
- QFile tempFile("routetemp.xml");
+ QFile tempFile(".//speedfreak_route/routetemp.xml");
if (!tempFile.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QTextStream readRoute(&tempFile);
#include <QString>
#include <QMessageBox>
+#include <QDir>
#include "httpclient.h"
#include "mainwindow.h"
}
/**
- *@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 s, int i)
{
qDebug() << "_sendRouteXml";
- QString filename = "route.xml";
- QFile file(filename);
- if (!file.open(QFile::ReadOnly)) {
- qDebug() << "_sendRouteXml file.open() fail";
- return;
+ QString filename = ".//speedfreak_route/route.xml";
+
+ if(s != "")
+ {
+ qDebug() << "_rename xml";
+ filename = s + ".xml";
+ QDir dir(filename);
+ qDebug() << dir.rename(".//speedfreak_route/route.xml", 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://api.speedfreak-app.com/api/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();
+ }
}
/**
void requestRegistration();
void checkLogin();
void sendResultXml(QString category, double result);
- void sendRouteXml();
+ void sendRouteXml(QString, int);
void requestTopList(QString category, QString limit);
void requestCategories();
void ackOfResult();
delete customButtonHelp;
}
-
/**
*
*/
}
/**
- *This function is used to set items to category combobox. Top-tab view.
+ *This function is used to set items to category combobox.
*@param
*/
void MainWindow::setCategoryCompoBox()
/**
* This function send route data to server.
*/
-void MainWindow::clientSendRoute()
+void MainWindow::clientSendRoute(QString s,int i)
{
if(httpClient)
- httpClient->sendRouteXml();
+ httpClient->sendRouteXml(s,i);
}
/**
if(!routeSaveDialog)
routeSaveDialog = new RouteSaveDialog;
- connect(routeSaveDialog, SIGNAL(sendroute()), this, SLOT(clientSendRoute()));
+ connect(routeSaveDialog, SIGNAL(sendroute(QString,int)), this, SLOT(clientSendRoute(QString,int)));
connect(routeSaveDialog, SIGNAL(rejected()), this, SLOT(killDialog()));
routeSaveDialog->show();
}
private slots:
void clientRequestCategoryList();
void clientRequestTopList(int index);
- void clientSendRoute();
+ void clientSendRoute(QString,int);
void clientRegUserToServer();
void clientUserLogin();
void clientSendResult(QString category, double result);
QFile file;
file.setFileName( rFile);//"routetemp.xml");
+ //file.setFileName( ".//speedfreak_route/routetemp.xml");
if (!file.open(QIODevice::ReadOnly))
{
QMessageBox::about(0, "Error", "File not found");
return false;
}
-emit progressbar(5);
+ emit progressbar(5);
vertexList.clear();
emit progressbar(50);
while(!file.atEnd())
void RouteDialog::on_sendPushButton_clicked()
{
ui->sendPushButton->setEnabled(false);
- emit sendroute();
+
+
+ QString folder = "speedfreak_route";
+
+ if(!QDir(folder).exists())
+ {
+ QDir().mkdir(folder);
+ }
+
+ QString fileName = QFileDialog::getSaveFileName(this, tr("Save Route"),
+ ".//" + folder);//, tr("Route files (*.xml)"));
+ qDebug() << fileName;
+
+ int server = QMessageBox::question(this, "Save route to server?", "", 4,3);
+ if(server == 3) // Yes button
+ {
+ qDebug() << "__save to server";
+ emit sendroute(fileName,1); // Save route.
+ }
+ else if(server == 4) // No button
+ {
+ qDebug() << "__no save";
+
+ if(fileName != "")
+ emit sendroute(fileName,0); // Save route.
+ }
}
/**
HelpRoutingDialog *helpRoutingDialog;
signals:
- void sendroute();
+ void sendroute(QString,int);
void progressbar(int);
protected:
#include <QDebug>
#include <QPainter>
#include <QFileDialog>
+#include <QDir>
const QPoint arrowStartEast(100, 100);
const QPoint arrowEndEast(140, 100);
location = new Maemo5Location(this);
gpsData = new GPSData(location);
connect(location,SIGNAL(agnss()),this,SLOT(gpsStatus()));
+
+ // Route folder
+ QString folder = "speedfreak_route";
+ if(!QDir(folder).exists())
+ {
+ QDir().mkdir(folder);
+ }
}
/**
ui->labelRoutePicture->setVisible(0);
timerRoutePicture->stop();
location->stopPollingGPS();
+/*
+ // Progress bar
+ if(!calibrateDialog)
+ {
+ calibrateDialog = new CalibrateDialog();
+ }
+
+ progressbarPoints = 100;
+ progressbarIteration = 0;
+ calibrateDialog->resetProgressValue();
+ calibrateDialog->setMaxValue( progressbarPoints );
+ calibrateDialog->setTitle("Calculating route...");
+ calibrateDialog->show();
+
+
+ if(!routeDialog)
+ {
+ routeDialog = new RouteDialog(this);
+ }
+
+ connect(routeDialog, SIGNAL(sendroute(QString,int)), this, SLOT(sendRoute(QString,int)));
+ connect(routeDialog, SIGNAL(progressbar(int)), this, SLOT(setProgressbar(int)));
+ connect(routeDialog, SIGNAL(rejected()), this, SLOT(killRouteDialog()));
+ //connect(routeDialog, SIGNAL(killRoute()), this, SLOT(killRouteDialog()));
+
+ QString routeFile = QString(".//speedfreak_route/routetemp.xml");
+ if (routeDialog->readRouteFromFile( routeFile ) == true)
+ {
+ //calibrateDialog->close();
+ routeDialog->show();
+ }
+ else
+ {
+ //calibrateDialog->close();
+ }
+calibrateDialog->close();*/
//Set GPS speed labels in visible
ui->labelGpsSpeed->setVisible(0);
/**
* This slot function is called when routeDialog emit sendroute (sendPushButton).
*/
-void RouteSaveDialog::sendRoute()
+void RouteSaveDialog::sendRoute(QString s,int i)
{
- emit sendroute(); //Emit mainwindow clientSendRoute
+ emit sendroute(s,i); //Emit mainwindow clientSendRoute
}
/**
void timerSatellitePictureTimeout();
void timerRoutePictureTimeout();
void gpsStatus();
- void sendRoute();
+ void sendRoute(QString,int);
void killHelpDialog();
void killRouteDialog();
void setProgressbar(int i);
signals:
- void sendroute();
+ void sendroute(QString,int);
};