virtual void onSuccess(double latitude, double longitude, const char* adress) { char* buf = new char[2048]; if (buf == NULL) { RAWLOG_ERROR("can not allocate temporary char buffer in GeoLocation callback"); return; } if (adress != NULL) { rho::String coded_adr = adress; coded_adr = rho::net::URI::urlEncode(coded_adr); sprintf(buf,"&rho_callback=1&status=ok&tag=%d&latitude=%f&longitude=%f&adress=%s", mTag, (float)latitude, (float)longitude, coded_adr.c_str()); } else { sprintf(buf,"&rho_callback=1&status=ok&tag=%d&latitude=%f&longitude=%f", mTag, (float)latitude, (float)longitude); } char* norm_url = rho_http_normalizeurl(mCallback.c_str()); rho_net_request_with_data(norm_url, buf); rho_http_free(norm_url); delete buf; //delete this; }
RHO_GLOBAL void JNICALL Java_com_rhomobile_barcode_Barcode_enumeratecallback (JNIEnv *env, jclass, jstring callback_url) { char* url = rho_http_normalizeurl(rho_cast<std::string>(env, callback_url).c_str()); char body[2048]; strcpy(body, "&status=ok&rho_callback=1&"); strcat(body, (RHODESAPP().addCallbackObject( new RhoScannersListContainer(), "scannerArray")).c_str()); char* norm_url = rho_http_normalizeurl(url); rho_net_request_with_data(norm_url, body); rho_http_free(norm_url); }
virtual void onError(rho::String const &description) { char* buf = new char[2048]; if (buf == NULL) { RAWLOG_ERROR("can not allocate temporary char buffer in GeoLocation callback"); return; } sprintf(buf,"&rho_callback=1&status=error&description=%s", description.c_str()); char* norm_url = rho_http_normalizeurl(mCallback.c_str()); rho_net_request_with_data(norm_url, buf); rho_http_free(norm_url); delete buf; //delete this; }
void callback_system_update_bundle_callback(void *arg, rho::String const &strQuery) { const char* s = strQuery.c_str(); // status ok,error,need_sync // message "bla bla bla" rho::String qStatus = ""; rho::String qMessage = ""; rho::common::CTokenizer oTokenizer(strQuery, "&"); while (oTokenizer.hasMoreTokens()) { rho::String tok = oTokenizer.nextToken(); if (tok.length() == 0) continue; if ( rho::String_startsWith(tok, "status=") ) { qStatus = tok.substr(7); }else if ( rho::String_startsWith( tok, "message=") ) { qMessage = tok.substr(8); } } rho::String query = ""; bool our_refresh_webview = false; rho::String our_responce_server_url = ""; BundleUpdateThreadQueue::BUCommand* cmd = getBundleUpdateThreadQueueSignletone()->getCurrentBUCommand(); if (cmd != NULL) { our_refresh_webview = cmd->refresh_webview; our_responce_server_url = cmd->responce_url; } rho::String message = "Unrecognizing Situation during update bundle! Restart application and reconnect device to server !"; if (qStatus.compare("ok") == 0) { message = "Update bundle was finished !"; query = "&status=ok"; if (our_refresh_webview) { rho_webview_refresh(-1); } } if (qStatus.compare("error") == 0) { message = "Error when update Bundle : " + qMessage + " !"; query = "&status=error&message="+message; } if (qStatus.compare("need_sync") == 0) { message = "Your application files too old. Request for full Bundle update was sended to server !"; query = "&status=need_full_update"; } alert_show_status("Development Extras", message.c_str(), "OK"); //alert_show_popup(&p); rho_http_sendresponse(arg, ""); // send responce to server char* norm_url = rho_http_normalizeurl(our_responce_server_url.c_str()); query = query + make_info_string(false); rho_net_request_with_data_in_separated_thread(norm_url, query.c_str()); rho_http_free(norm_url); // remove temporary files rho::String fileZipLocalDir = rho::common::CFilePath::join(RHODESAPPBASE().getRhoUserPath(), "RhoBundle"); //rho_file_impl_delete_folder(fileZipLocalDir.c_str()); rho::common::CRhoFile::deleteFolder(fileZipLocalDir.c_str()); if (cmd != NULL) { cmd->canContinue = true; } }
RHO_GLOBAL void JNICALL Java_com_rhomobile_barcode_Barcode_callback (JNIEnv *env, jclass, jstring callback_url, jstring body) { char* url = rho_http_normalizeurl(rho_cast<std::string>(env, callback_url).c_str()); rho_net_request_with_data(url, rho_cast<std::string>(env, body).c_str()); rho_http_free(url); }