void CLogSocketSink::processCommand(IQueueCommand* pCmd) { LogCommand *cmd = (LogCommand *)pCmd; if (!cmd) return; getNetRequest().doRequest( "POST", cmd->m_url, cmd->m_body, 0, 0 ); }
void rho_do_send_log(rho::apiGenerator::CMethodResult& oResult) { String strDevicePin, strClientID; net::IRhoSession* pSession = 0; if ( sync::RhoconnectClientManager::haveRhoconnectClientImpl() ) { strDevicePin = rho::sync::RhoconnectClientManager::clientRegisterGetDevicePin(); strClientID = rho::sync::RhoconnectClientManager::syncEnineReadClientID(); pSession = rho::sync::RhoconnectClientManager::getRhoSession(); } String strQuery; String strLogUrl = RHOCONF().getString("Log.destinationURI"); if ( strLogUrl.length() == 0 ) { strLogUrl = RHOCONF().getPath("logserver"); if ( strLogUrl.length() == 0 ) strLogUrl = RHOCONF().getPath("syncserver"); strQuery = strLogUrl + "client_log?" + "client_id=" + strClientID + "&device_pin=" + strDevicePin + "&log_name=" + RHOCONF().getString("logname"); }else { String strSign = "?"; if ( strrchr(strLogUrl.c_str(), '?') ) strSign = "&"; strQuery = strLogUrl + strSign + "client_id=" + strClientID + "&device_pin=" + strDevicePin; } net::CMultipartItem oItem; oItem.m_strFilePath = LOGCONF().getLogFilePath(); oItem.m_strContentType = "application/octet-stream"; boolean bOldSaveToFile = LOGCONF().isLogToFile(); LOGCONF().setLogToFile(false); NetRequest oNetRequest; oNetRequest.setSslVerifyPeer(false); NetResponse resp = getNetRequest(&oNetRequest).pushMultipartData( strQuery, oItem, pSession, null ); LOGCONF().setLogToFile(bOldSaveToFile); boolean isOK = true; if ( !resp.isOK() ) { LOG(ERROR) + "send_log failed : network error - " + resp.getRespCode() + "; Body - " + resp.getCharData(); isOK = false; } Hashtable<String, String> hashRes; hashRes["status"] = isOK ? "ok" : "error"; oResult.set(hashRes); RHODESAPPBASE().setSendingLog(false); }
void BundleUpdateThreadQueue::processCommand(IQueueCommand *pCmd) { BUCommand *cmd = (BUCommand*)pCmd; rho::String fileURL = cmd->bundle_url; rho::String fileZipLocalDir = rho::common::CFilePath::join(RHODESAPPBASE().getRhoUserPath(), "RhoBundle"); rho::String fileZipLocalPath = rho::common::CFilePath::join(fileZipLocalDir, "upgrade_bundle.zip"); const char* flz = fileZipLocalPath.c_str(); // 0 remove old files rho::common::CRhoFile::deleteFolder(fileZipLocalDir.c_str()); //rho_file_impl_delete_folder(fileZipLocalDir.c_str()); rho::common::CRhoFile::recursiveCreateDir(fileZipLocalDir.c_str(), RHODESAPPBASE().getRhoUserPath().c_str()); // 1 download zip rho::Hashtable<rho::String, rho::String> mapHeaders; mapHeaders["User-Agent"] = "Mozilla-5.0"; rho::apiGenerator::CMethodResult oResult; bool overwriteFile = true; bool createFolders = true; bool fileExists = false; NetRequest oNetRequest; NetResponse resp = getNetRequest(&oNetRequest).pullFile( fileURL, fileZipLocalPath, NULL, &mapHeaders,overwriteFile,createFolders,&fileExists); if (resp.isSuccess()) { int o; o = 9; } else { int r; r = 9; } // 2 unpack zip int zip_res = rho_sys_unzip_file(fileZipLocalPath.c_str(), ""); if (zip_res >= 0) { int o; o = 9; } else { int r; r = 9; // error // send request for full_update rho::String message = "ERROR when downloading and unpack Bundle ["; message = message + fileURL + "] ! Cancel update !"; alert_show_status("Development Extras", message.c_str(), "OK"); return; } // 3 call update bundle bool do_not_restart_app = true; bool not_thread_mode = true; bool check_filelist = true; rho::String cb_url = /*RHODESAPPBASE().getHomeUrl()*/ "http://127.0.0.1:";//37579/development/update_bundle_callback"; cb_url = cb_url + DevHTTPServer::getInstance()->getPort() + "/development/update_bundle_callback"; const char* hu = cb_url.c_str(); cmd->canContinue = false; rho_sys_replace_current_bundleEx( fileZipLocalDir.c_str(), cb_url.c_str(), do_not_restart_app, not_thread_mode, check_filelist, true ); // wait responce while (!cmd->canContinue) { sleep(30); } }