- Timestamp:
- Sep 17, 2015, 9:11:21 PM (11 years ago)
- Branches:
- master
- Children:
- a2330fc
- Parents:
- e498070
- Location:
- src
- Files:
-
- 12 added
- 7 edited
-
CMakeLists.txt (modified) (1 diff)
-
lib/silibconfig.h.in (modified) (1 diff)
-
lib/siwebserviceclient.cpp (modified) (4 diffs)
-
lib/siwebserviceclient.h (modified) (2 diffs)
-
testing/CMakeLists.txt (added)
-
testing/private/webserverrunner.cpp (added)
-
testing/private/webserverrunner.h (added)
-
testing/sitestingconfig.h.in (added)
-
testing/sitestingglobal.h (added)
-
testing/webserverprocess.cpp (added)
-
testing/webserverprocess.h (added)
-
tests/CMakeLists.txt (added)
-
tests/siweatherstationtest.cpp (added)
-
tests/siweatherstationtest.h (added)
-
tests/siwebserviceclienttest.cpp (added)
-
tests/siwebserviceclienttest.h (added)
-
webservice/config/config.php.in (modified) (1 diff)
-
webservice/htdocs/SiWeather/Webservice/Location.php (modified) (1 diff)
-
webservice/htdocs/SiWeather/Webservice/WebserviceApi.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/CMakeLists.txt
re498070 r915dc18 24 24 FIND_PACKAGE(Qt5Network REQUIRED) 25 25 ADD_SUBDIRECTORY(lib) 26 IF(BUILD_TESTING) 27 FIND_PACKAGE(Qt5Test REQUIRED) 28 ADD_SUBDIRECTORY(testing) 29 ADD_SUBDIRECTORY(tests) 30 ENDIF() 26 31 ENDIF(WITH_STATIONCLIENT) 27 32 IF(WITH_WEBSERVICE) -
src/lib/silibconfig.h.in
re498070 r915dc18 1 1 /* 2 Copyright (C) 201 0 - 2012EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.2 Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved. 3 3 4 4 This library is free software; you can redistribute it and/or -
src/lib/siwebserviceclient.cpp
re498070 r915dc18 45 45 } 46 46 47 SiWebserviceClient::ReplyType SiWebserviceClient::stationsRegister( SiWeatherStationstation, QString &error)47 SiWebserviceClient::ReplyType SiWebserviceClient::stationsRegister(const SiWeatherStation &station, QString &error) 48 48 { 49 49 if(!_networkManager) 50 50 return Error; 51 51 52 if(station.name().isEmpty() || station.city().isEmpty() || station.eMail().isEmpty() ){52 if(station.name().isEmpty() || station.city().isEmpty() || station.eMail().isEmpty() || station.type().isEmpty()){ 53 53 error = tr("Station has empty name, city or eMail address. All of these are needed!"); 54 54 return Error; … … 61 61 jsonStation["latitude"] = Library::geoCoordinateToString(station.latitude()); 62 62 jsonStation["email"] = station.eMail(); 63 jsonStation["type"] = station.type(); 64 jsonStation["typeUrl"] = station.typeUrl().toString(); 63 65 QJsonDocument jsonDocument(jsonStation); 64 66 65 67 QNetworkRequest request; 66 request.setUrl(QString("%1%2").arg(_baseUrl.toString()).arg(" /stations/register"));68 request.setUrl(QString("%1%2").arg(_baseUrl.toString()).arg("index.php/stations/register")); 67 69 request.setRawHeader("User-Agent", QString("SiWeather Library %1").arg(Library::version()).toUtf8()); 68 70 request.setHeader(QNetworkRequest::ContentTypeHeader, … … 81 83 82 84 QByteArray data = reply->readAll(); 83 QJsonDocument jsonDocument = QJsonDocument::fromBinaryData(data); 85 reply->deleteLater(); 86 87 QJsonDocument jsonDocument = QJsonDocument::fromJson(data); 84 88 QJsonObject json = jsonDocument.object(); 85 89 if(!json.contains("result")){ 86 90 emit finishedStationsRegister(false, "", tr("No result in response found")); 91 emit finished(StationsRegister, false, data); 87 92 return; 88 93 } 89 94 if(json["result"].toString() != "success"){ 90 95 emit finishedStationsRegister(false, "", tr("Operation failed for reason: %1").arg(json["message"].toString())); 96 emit finished(StationsRegister, false, data); 91 97 return; 92 98 } 93 99 if(!json.contains("uuid")){ 94 100 emit finishedStationsRegister(false, "", tr("No uuid in response found")); 101 emit finished(StationsRegister, false, data); 95 102 return; 96 103 } 97 emit finishedStationsRegister(true, QUuid(json["uuid"].toString()), ""); 98 emit finished(StationsRegister, data); 99 reply->deleteLater(); 104 emit finishedStationsRegister(true, QUuid(json["uuid"].toString()), json["message"].toString()); 105 emit finished(StationsRegister, false, data); 100 106 } 101 107 … … 120 126 return reply; 121 127 } 122 -
src/lib/siwebserviceclient.h
re498070 r915dc18 48 48 * @brief Registers a station at the server and emits error() or finishedStationsRegister() if finished. 49 49 */ 50 ReplyType stationsRegister( SiWeatherStation station, QString &error);50 ReplyType stationsRegister(const SiWeather::Library::SiWeatherStation& station, QString& error); 51 51 52 52 signals: 53 void error( ReplyType replyType, const QString &errorMessage) const;53 void error(SiWeather::Library::SiWebserviceClient::ReplyType replyType, const QString &errorMessage) const; 54 54 /** 55 55 * @brief Generic finish signal for all requests. Use specialized finished signals instead! … … 57 57 * @see finishedStationsRegister 58 58 */ 59 void finished( ReplyType replyType, const QByteArray &data) const;59 void finished(SiWeather::Library::SiWebserviceClient::ReplyType replyType, bool result, const QByteArray &data) const; 60 60 void finishedStationsRegister(bool result, const QUuid &uuid, const QString &message) const; 61 61 -
src/webservice/config/config.php.in
re498070 r915dc18 21 21 $config = [ 22 22 "mode" => "@WEBSERVICE_MODE@", 23 "webserviceBaseUrl" => " http://@WEBSERVICE_SERVER_HOST@:@WEBSERVICE_SERVER_PORT@@WEBSERVICE_BASE_URL@",23 "webserviceBaseUrl" => "@WEBSERVICE_BASE_URL_COMPLETE@", 24 24 "spatialiteExtension" => "mod_spatialite.so", 25 25 "geonamesUsername" => "@WEBSERVICE_GEONAMES_USERNAME@", -
src/webservice/htdocs/SiWeather/Webservice/Location.php
re498070 r915dc18 50 50 $this->setRegion($regionName, $regionCode); 51 51 $this->setCountry($countryName, $countryCode); 52 $this->setLocation($l ongitude, $latitude);52 $this->setLocation($latitude, $longitude); 53 53 $this->setTimezone($timeZone); 54 54 } -
src/webservice/htdocs/SiWeather/Webservice/WebserviceApi.php
re498070 r915dc18 203 203 } 204 204 if(!$validatedLocation){ 205 $message = "The city (". $json[ city] .") and location (". $json["latitude"] .", ". $json["longitude"] .") you send, does not suite with locations we found at your given location (city, latitude, longitude):\n";205 $message = "The city (". $json["city"] .") and location (". $json["latitude"] .", ". $json["longitude"] .") you send, does not suite with locations we found at your given location (city, latitude, longitude):\n"; 206 206 foreach($locations as $location){ 207 207 $message .= " ". $location->city() .": ". $location->latitude() .", ". $location->longitude() ."\n";
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/siweather/chrome/site/your_project_logo.png)