/// <summary> /// Fetches all available reports for the given device /// </summary> /// <param name="device">Name of the device to select reports for (GL_RENDERER) </param> /// <returns></returns> vector<reportInfo> VulkanDatabase::fetchDeviceReports(string device) { vector<reportInfo> reportList; string httpReply; stringstream urlss; urlss << getBaseUrl() << "services/gl_getdevicereports.php?glrenderer=" << device; string url; url = encodeUrl(urlss.str()); httpReply = httpGet(url); if (!httpReply.empty()) { QXmlStreamReader xmlReader(&httpReply[0]); while (!xmlReader.atEnd()) { if ((xmlReader.name() == "report") && (xmlReader.isStartElement())) { reportInfo report; report.device = device; QXmlStreamAttributes xmlAttribs = xmlReader.attributes(); report.operatingSystem = xmlAttribs.value("os").toString().toStdString(); report.reportId = xmlAttribs.value("id").toInt(); report.version = xmlReader.readElementText().toStdString(); reportList.push_back(report); } xmlReader.readNext(); } }; return reportList; }
void GUIHelpViewer::on_commandBackToOvwerView_clicked() { currentUrl = getBaseUrl() + "/index.html"; #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) ui->webView->load(this->currentUrl); #endif }
QNetworkRequest DmapClient::getBaseRequest(QString arguments, bool sid, bool rid, bool header) { QString url = getBaseUrl(); url.append(arguments); if (sid) { if(!url.endsWith('?')) { url.append('&'); } url.append(getSid_formated()); } if (rid) { if(!url.endsWith('?')) { url.append('&'); } url.append(getRid_formated()); } QNetworkRequest request; if (header) { request.setRawHeader("Authorization", authenticationHeader); } request.setUrl(QUrl(url)); return request; }
void StorageService::UpdateDocumentByDocId(string dbName, string collectionName, string docId,string json, CCObject* pTarget, cocos2d::SEL_CallFuncND pSelector) { App42StorageResponse *response = new App42StorageResponse(pTarget,pSelector); try { Util::throwExceptionIfStringNullOrBlank(dbName, "Database Name"); Util::throwExceptionIfStringNullOrBlank(collectionName, "Collection Name"); Util::throwExceptionIfStringNullOrBlank(docId, "Doc ID"); Util::throwExceptionIfStringNullOrBlank(json, "Json String"); Util::throwExceptionIfTargetIsNull(pTarget, "Callback's Target"); Util::throwExceptionIfCallBackIsNull(pSelector, "Callback"); } catch (App42Exception *e) { std::string ex = e->what(); response->httpErrorCode = e->getHttpErrorCode(); response->appErrorCode = e->getAppErrorCode(); response->errorDetails = ex; response->isSuccess = false; if (pTarget && pSelector) { (pTarget->*pSelector)((cocos2d::CCNode *)pTarget, response); } delete e; e = NULL; return; } map<string, string> postMap; string timestamp = Util::getTimeStamp(); populateSignParams(postMap); postMap["dbName"] = dbName; postMap["collectionName"] = collectionName; postMap["docId"] = docId; string storageBody = BuildStorageBody(json); postMap["body"] = storageBody; string signature = Util::signMap(secretKey, postMap); string resource = "storage/updateByDocId/dbName/"; resource.append(dbName + "/collectionName/"); resource.append(collectionName+"/docId/"); resource.append(docId); string baseUrl = getBaseUrl(resource); baseUrl.append("?"); std::vector<std::string> headers; map<string, string> metaHeaders; populateMetaHeaderParams(metaHeaders); Util::BuildHeaders(metaHeaders, headers); Util::BuildHeaders(apiKey, timestamp, VERSION, signature, headers); Util::executePut(baseUrl, headers, storageBody.c_str(), response, callfuncND_selector(App42StorageResponse::onComplete)); }
void EmailService::getEmailConfigurations(App42CallBack* pTarget, SEL_App42CallFuncND pSelector) { App42EmailResponse *response = new App42EmailResponse::App42EmailResponse(pTarget,pSelector); try { Util::throwExceptionIfTargetIsNull(pTarget, "Callback's Target"); Util::throwExceptionIfCallBackIsNull(pSelector, "Callback"); } catch (App42Exception *e) { std::string ex = e->what(); response->httpErrorCode = e->getHttpErrorCode(); response->appErrorCode = e->getAppErrorCode(); response->errorDetails = ex; response->isSuccess = false; if (pTarget && pSelector) { (pTarget->*pSelector)((App42CallBack *)pTarget, response); } delete e; e = NULL; return; } string timestamp = Util::getTimeStamp(); /** * Creating SignParams and signature */ map<string, string> signParams; populateSignParams(signParams); string signature = Util::signMap(secretKey, signParams); /** * Creating URL */ string resource = "email"; resource.append("/configuration"); string baseUrl = getBaseUrl(resource); baseUrl.append("?"); string encodedUrl = url_encode(baseUrl); // Util::app42Trace("\n baseUrl = %s",baseUrl.c_str()); // Util::app42Trace("\n createUserbody = %s",createUserbody.c_str()); /** * Creating Headers */ std::vector<std::string> headers; map<string, string> metaHeaders; populateMetaHeaderParams(metaHeaders); Util::BuildHeaders(metaHeaders, headers); Util::BuildHeaders(apiKey, timestamp, VERSION, signature, headers); /** * Initiating Http call */ Util::executeGet(encodedUrl, headers, response, httpresponse_selector(App42UserResponse::onComplete)); }
void StorageService::FindDocumentByQuery(string dbName, string collectionName, Query *query, CCObject* pTarget, cocos2d::SEL_CallFuncND pSelector) { App42StorageResponse *response = new App42StorageResponse(pTarget,pSelector); try { Util::throwExceptionIfStringNullOrBlank(dbName, "Database Name"); Util::throwExceptionIfStringNullOrBlank(collectionName, "Collection Name"); Util::throwExceptionIfTargetIsNull(pTarget, "Callback's Target"); Util::throwExceptionIfCallBackIsNull(pSelector, "Callback"); } catch (App42Exception *e) { std::string ex = e->what(); response->httpErrorCode = e->getHttpErrorCode(); response->appErrorCode = e->getAppErrorCode(); response->errorDetails = ex; response->isSuccess = false; if (pTarget && pSelector) { (pTarget->*pSelector)((cocos2d::CCNode *)pTarget, response); } delete e; e = NULL; return; } string resource = "storage/findDocsByQuery/dbName/"; resource.append(dbName + "/collectionName/"); resource.append(collectionName); string url = getBaseUrl(resource); string timestamp = Util::getTimeStamp(); map<string, string> getMap; Util::BuildGetSigningMap(apiKey, timestamp, VERSION, getMap); getMap["dbName"] = dbName; getMap["collectionName"] = collectionName; getMap["jsonQuery"] = query->getString(); //Util::printMap(getMap); string signature = Util::signMap(secretKey, getMap); url.append("?"); map<string, string> queryParamsMap; queryParamsMap["jsonQuery"]=query->getString(); string queryString = buildQueryString(queryParamsMap); url.append(queryString); //char *encodedUrl = Util::url_encode(url); printf("\nQueryString=%s",queryString.c_str()); std::vector<std::string> headers; map<string, string> metaHeaders; populateMetaHeaderParams(metaHeaders); Util::BuildHeaders(metaHeaders, headers); Util::BuildHeaders(apiKey, timestamp, VERSION, signature, headers); Util::executeGet(url.c_str(),headers, response, callfuncND_selector(App42StorageResponse::onComplete)); }
/// <summary> /// Posts the given url to the db report update script /// </summary> /// <returns>Coma separated list of updated caps</returns> string VulkanDatabase::postReportForUpdate(string xml) { string httpReply; stringstream urlss; urlss << getBaseUrl() << "services/updatereport.php"; httpReply = httpPost(urlss.str(), xml); return httpReply; }
/// <summary> /// Fechtes an xml with all report data from the online database /// </summary> /// <param name="reportId">id of the report to get the report xml for</param> /// <returns>xml string</returns> string VulkanDatabase::fetchReport(int reportId) { string reportXml; stringstream urlss; urlss << getBaseUrl() << "services/ggetreport.php?id=" << reportId; reportXml = httpGet(urlss.str()); return reportXml; }
void GameService::GetAllGamesCount(App42CallBack* pTarget, SEL_App42CallFuncND pSelector) { App42GameResponse *response = new App42GameResponse(pTarget,pSelector); try { Util::throwExceptionIfTargetIsNull(pTarget, "Callback's Target"); Util::throwExceptionIfCallBackIsNull(pSelector, "Callback"); } catch (App42Exception *e) { std::string ex = e->what(); response->httpErrorCode = e->getHttpErrorCode(); response->appErrorCode = e->getAppErrorCode(); response->errorDetails = ex; response->isSuccess = false; if (pTarget && pSelector) { (pTarget->*pSelector)((App42CallBack *)pTarget, response); } delete e; e = NULL; return; } string timestamp = Util::getTimeStamp(); /** * Creating SignParams and signature */ map<string, string> signParams; Util::BuildGetSigningMap(apiKey, timestamp, VERSION, signParams); string signature = Util::signMap(secretKey, signParams); /** * Creating URL */ string resource = "game/"; resource.append("count"); string url = getBaseUrl(resource); url.append("?"); string encodedUrl = url_encode(url); /** * Creating Headers */ std::vector<std::string> headers; map<string, string> metaHeaders; populateMetaHeaderParams(metaHeaders); Util::BuildHeaders(metaHeaders, headers); Util::BuildHeaders(apiKey, timestamp, VERSION, signature, headers); /** * Initiating Http call */ Util::executeGet(encodedUrl,headers, response, app42response_selector(App42GameResponse::onComplete)); }
void StorageService::FindDocumentByKeyValue(string dbName, string collectionName, string key,string value, CCObject* pTarget, cocos2d::SEL_CallFuncND pSelector) { App42StorageResponse *response = new App42StorageResponse(pTarget,pSelector); try { Util::throwExceptionIfStringNullOrBlank(dbName, "Database Name"); Util::throwExceptionIfStringNullOrBlank(collectionName, "Collection Name"); Util::throwExceptionIfStringNullOrBlank(key, "Key"); Util::throwExceptionIfStringNullOrBlank(value, "Value"); Util::throwExceptionIfTargetIsNull(pTarget, "Callback's Target"); Util::throwExceptionIfCallBackIsNull(pSelector, "Callback"); } catch (App42Exception *e) { std::string ex = e->what(); response->httpErrorCode = e->getHttpErrorCode(); response->appErrorCode = e->getAppErrorCode(); response->errorDetails = ex; response->isSuccess = false; if (pTarget && pSelector) { (pTarget->*pSelector)((cocos2d::CCNode *)pTarget, response); } delete e; e = NULL; return; } string resource = "storage/findDocByKV/dbName/"; resource.append(dbName+ "/collectionName/"); resource.append(collectionName+ "/"); resource.append(key+ "/"); resource.append(value+ "/"); string url = getBaseUrl(resource); string timestamp = Util::getTimeStamp(); map<string, string> getMap; Util::BuildGetSigningMap(apiKey, timestamp, VERSION, getMap); getMap["dbName"] = dbName; getMap["collectionName"] = collectionName; getMap["key"] = key; getMap["value"] = value; string signature = Util::signMap(secretKey, getMap); url.append("?"); //Util::app42Trace("\n baseUrl = %s",url.c_str()); std::vector<std::string> headers; map<string, string> metaHeaders; populateMetaHeaderParams(metaHeaders); Util::BuildHeaders(metaHeaders, headers); Util::BuildHeaders(apiKey, timestamp, VERSION, signature, headers); Util::executeGet(url,headers, response, callfuncND_selector(App42StorageResponse::onComplete)); }
void GUIHelpViewer::showHelpForModule(DM::Module* m) { if (!m){ #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) ui->webView->load(getBaseUrl() + "/index.html"); #endif return; } if (!m->getHelpUrl().empty()) { this->currentUrl =getBaseUrl() + "/" +QString::fromStdString(m->getHelpUrl()); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) ui->webView->load(this->currentUrl); #endif return; } this->currentUrl =getBaseUrl() + "/index.html"; #if QT_VERSION< QT_VERSION_CHECK(5, 0, 0) ui->webView->load(getBaseUrl() + "/index.html"); #endif }
GUIHelpViewer::GUIHelpViewer(QWidget *parent) : QWidget(parent) { #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) ui = new Ui::GUIHelpViewer(); // QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, // true); ui->setupUi(this); this->url_view_not_avaiable = QUrl(getBaseUrl() + "/index.html"); #endif }
void RewardService::CreateReward(string rewardName,string description, App42CallBack* pTarget, SEL_App42CallFuncND pSelector) { App42RewardResponse *response = new App42RewardResponse::App42RewardResponse(pTarget,pSelector); try { Util::throwExceptionIfStringNullOrBlank(description, "Description"); Util::throwExceptionIfStringNullOrBlank(rewardName, "Reward Name"); Util::throwExceptionIfTargetIsNull(pTarget, "Callback's Target"); Util::throwExceptionIfCallBackIsNull(pSelector, "Callback"); } catch (App42Exception *e) { std::string ex = e->what(); response->httpErrorCode = e->getHttpErrorCode(); response->appErrorCode = e->getAppErrorCode(); response->errorDetails = ex; response->isSuccess = false; if (pTarget && pSelector) { (pTarget->*pSelector)((App42CallBack *)pTarget, response); } delete e; e = NULL; return; } map<string, string> postMap; populateSignParams(postMap); string rewardbody = BuildCreateRewardBody(rewardName, description); postMap["body"] = rewardbody; string signature = Util::signMap(secretKey, postMap); string baseUrl = getBaseUrl("game/reward"); baseUrl.append("?"); //Util::app42Trace("\n baseUrl = %s",baseUrl.c_str()); //Util::app42Trace("\n createRewardbody = %s",rewardbody.c_str()); std::vector<std::string> headers; map<string, string> metaHeaders; populateMetaHeaderParams(metaHeaders); Util::BuildHeaders(metaHeaders, headers); string timestamp = Util::getTimeStamp(); Util::BuildHeaders(apiKey, timestamp, VERSION, signature, headers); Util::executePost(baseUrl, headers, rewardbody.c_str(), response, httpresponse_selector(App42RewardResponse::onComplete)); }
void RewardService::GetGameRewardPointsForUser(string gameName, string userName, App42CallBack* pTarget, SEL_App42CallFuncND pSelector) { App42RewardResponse *response = new App42RewardResponse::App42RewardResponse(pTarget,pSelector); try { Util::throwExceptionIfStringNullOrBlank(gameName, "Game Name"); Util::throwExceptionIfStringNullOrBlank(userName, "User Name"); Util::throwExceptionIfTargetIsNull(pTarget, "Callback's Target"); Util::throwExceptionIfCallBackIsNull(pSelector, "Callback"); } catch (App42Exception *e) { std::string ex = e->what(); response->httpErrorCode = e->getHttpErrorCode(); response->appErrorCode = e->getAppErrorCode(); response->errorDetails = ex; response->isSuccess = false; if (pTarget && pSelector) { (pTarget->*pSelector)((App42CallBack *)pTarget, response); } delete e; e = NULL; return; } string resource = "game/reward/"; resource.append(gameName+"/"); resource.append(userName); string url = getBaseUrl(resource); string timestamp = Util::getTimeStamp(); map<string, string> getMap; Util::BuildGetSigningMap(apiKey, timestamp, VERSION, getMap); getMap["gameName"] = gameName; getMap["userName"] = userName; string signature = Util::signMap(secretKey, getMap); url.append("?"); //Util::app42Trace("\n baseUrl = %s",url.c_str()); std::vector<std::string> headers; map<string, string> metaHeaders; populateMetaHeaderParams(metaHeaders); Util::BuildHeaders(metaHeaders, headers); Util::BuildHeaders(apiKey, timestamp, VERSION, signature, headers); Util::executeGet(url,headers, response, httpresponse_selector(App42RewardResponse::onComplete)); }
/// <summary> /// Gets the Id of a report from the online database /// </summary> /// <param name="description">Description of the report to get the Id for</param> /// <returns></returns> int VulkanDatabase::getReportId(VulkanDeviceInfo device) { string reply; stringstream urlss; urlss << getBaseUrl() << "/services/getreportid.php?" << "devicename=" << device.props.deviceName << "&driverversion=" << device.getDriverVersion() << "&osname=" << device.os.name << "&osversion=" << device.os.version << "&osarchitecture=" << device.os.architecture; string url = encodeUrl(urlss.str()); reply = httpGet(url); return (!reply.empty()) ? atoi(reply.c_str()) : -1; }
QUrl MapAdapterWMS::tileQuery(const int& x, const int& y, const int& controller_zoom) const { // Get the url's query details. QUrlQuery url_query(getBaseUrl()); // Calculate the number of coordinates per tile. const int coord_per_tile_x = 360.0 / projection::get().tilesX(controller_zoom); const int coord_per_tile_y = 180.0 / projection::get().tilesY(controller_zoom); // Set BBOX (x1,y1,x2,y2). url_query.removeQueryItem("BBOX"); url_query.addQueryItem("BBOX", getBBox(-180 + x * coord_per_tile_x, 90 - (y + 1) * coord_per_tile_y, (-180 + x * coord_per_tile_x) + coord_per_tile_x, (90 - (y + 1) * coord_per_tile_y) + coord_per_tile_y)); // Create a new url with the modified url query. QUrl modified_url(getBaseUrl()); modified_url.setQuery(url_query); // Return the modified url. return QUrl(modified_url); }
void ScoreService::AddScore(string gameName, string userName, double score, Object* pTarget, cocos2d::SEL_CallFuncND pSelector) { App42GameResponse *response = new App42GameResponse::App42GameResponse(pTarget,pSelector); try { Util::throwExceptionIfStringNullOrBlank(gameName, "Game Name"); Util::throwExceptionIfStringNullOrBlank(userName, "User Name"); Util::throwExceptionIfTargetIsNull(pTarget, "Callback's Target"); Util::throwExceptionIfCallBackIsNull(pSelector, "Callback"); } catch (App42Exception *e) { std::string ex = e->what(); response->httpErrorCode = e->getHttpErrorCode(); response->appErrorCode = e->getAppErrorCode(); response->errorDetails = ex; response->isSuccess = false; if (pTarget && pSelector) { (pTarget->*pSelector)((cocos2d::Node *)pTarget, response); } delete e; e = NULL; return; } map<string, string> postMap; populateSignParams(postMap); string addScoreBody = BuildScoreBody(gameName, userName,score); postMap["body"] = addScoreBody; string signature = Util::signMap(secretKey, postMap); string baseUrl = getBaseUrl("game/score/add"); baseUrl.append("?"); //Util::app42Trace("\n baseUrl = %s",baseUrl.c_str()); //Util::app42Trace("\n addScoreBody = %s",addScoreBody.c_str()); std::vector<std::string> headers; map<string, string> metaHeaders; populateMetaHeaderParams(metaHeaders); Util::BuildHeaders(metaHeaders, headers); string timestamp = Util::getTimeStamp(); Util::BuildHeaders(apiKey, timestamp, VERSION, signature, headers); Util::executePost(baseUrl, headers, addScoreBody.c_str(), response, httpresponse_selector(App42GameResponse::onComplete)); }
void GameService::GetAllGames(CCObject* pTarget, cocos2d::SEL_CallFuncND pSelector) { App42GameResponse *response = new App42GameResponse::App42GameResponse(pTarget,pSelector); try { Util::throwExceptionIfTargetIsNull(pTarget, "Callback's Target"); Util::throwExceptionIfCallBackIsNull(pSelector, "Callback"); } catch (App42Exception *e) { std::string ex = e->what(); response->httpErrorCode = e->getHttpErrorCode(); response->appErrorCode = e->getAppErrorCode(); response->errorDetails = ex; response->isSuccess = false; if (pTarget && pSelector) { (pTarget->*pSelector)((cocos2d::CCNode *)pTarget, response); } delete e; e = NULL; return; } string resource = "game/"; string url = getBaseUrl(resource); string timestamp = Util::getTimeStamp(); map<string, string> getMap; Util::BuildGetSigningMap(apiKey, timestamp, VERSION, getMap); string signature = Util::signMap(secretKey, getMap); url.append("?"); //Util::app42Trace("\n baseUrl = %s",url.c_str()); std::vector<std::string> headers; map<string, string> metaHeaders; populateMetaHeaderParams(metaHeaders); Util::BuildHeaders(metaHeaders, headers); Util::BuildHeaders(apiKey, timestamp, VERSION, signature, headers); Util::executeGet(url,headers, response, callfuncND_selector(App42GameResponse::onComplete)); }
/// <summary> /// Checks if the online database can be reached /// </summary> bool VulkanDatabase::checkServerConnection() { manager = new QNetworkAccessManager(NULL); QUrl qurl(QString::fromStdString(getBaseUrl() + "/services/serverstate.php")); if (dbLogin) { qurl.setUserName(dbUser); qurl.setPassword(dbPass); } QNetworkReply* reply = manager->get(QNetworkRequest(qurl)); QEventLoop loop; connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); loop.exec(QEventLoop::ExcludeUserInputEvents); return (reply->error() == QNetworkReply::NoError); }
/// <summary> /// Fetches all available devices from the online database and lists them in the ui /// </summary> /// <returns>List of reports as vector</returns> vector<string> VulkanDatabase::fetchDevices() { vector<string> deviceList; string httpReply; stringstream urlss; urlss << getBaseUrl() << "services/gl_getdevices.php"; httpReply = httpGet(urlss.str()); if (!httpReply.empty()) { QXmlStreamReader xmlReader(&httpReply[0]); while (!xmlReader.atEnd()) { if ((xmlReader.name() == "device") && (xmlReader.isStartElement())) { deviceList.push_back(xmlReader.readElementText().toStdString()); } xmlReader.readNext(); } } return deviceList; }
void UploadService::UploadFile(string fileName, string filePath,string fileType, string description,App42CallBack* pTarget, SEL_App42CallFuncND pSelector) { App42UploadResponse *response = new App42UploadResponse::App42UploadResponse(pTarget,pSelector); try { Util::throwExceptionIfStringNullOrBlank(fileName, "File Name"); Util::throwExceptionIfStringNullOrBlank(filePath, "File Path"); Util::throwExceptionIfStringNullOrBlank(fileType, "File Type"); Util::throwExceptionIfStringNullOrBlank(description, "Description"); Util::throwExceptionIfTargetIsNull(pTarget, "Callback's Target"); Util::throwExceptionIfCallBackIsNull(pSelector, "Callback"); } catch (App42Exception *e) { std::string ex = e->what(); response->httpErrorCode = e->getHttpErrorCode(); response->appErrorCode = e->getAppErrorCode(); response->errorDetails = ex; response->isSuccess = false; if (pTarget && pSelector) { (pTarget->*pSelector)((App42CallBack *)pTarget, response); } delete e; e = NULL; return; } try { /** * Creating SignParams and signature */ map<string, string> signParams; string timestamp = Util::getTimeStamp(); populateSignParams(signParams); signParams["dbName"] = dbName; signParams["collectionName"] = collectionName; string signature = Util::signMap(secretKey, signParams); /** * Creating URL */ string resource = "storage/insert/dbName/"; resource.append(dbName + "/collectionName/"); resource.append(collectionName); string baseUrl = getBaseUrl(resource); baseUrl.append("?"); /** * Creating Headers */ std::vector<std::string> headers; map<string, string> metaHeaders; populateMetaHeaderParams(metaHeaders); Util::BuildHeaders(metaHeaders, headers); Util::BuildHeaders(apiKey, timestamp, VERSION, signature, headers); /** * Initiating Http call */ //Util::executePost(baseUrl, headers, storageBody.c_str(), response, httpresponse_selector(App42StorageResponse::onComplete)); } catch (exception *e) { throw e; } }