Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
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);    
    
    
    
}
Ejemplo n.º 3
0
RHO_GLOBAL jstring JNICALL Java_com_rhomobile_rhodes_Rhodes_normalizeUrl
  (JNIEnv *, jobject, jstring strUrl)
{
    std::string const &s = rho_cast<std::string>(strUrl);
    char *normalized = rho_http_normalizeurl(s.c_str());
    jstring newStr = rho_cast<jstring>(normalized);
    free(normalized);
    return newStr;
}
Ejemplo n.º 4
0
void RhoBluetoothManager::fireRhodeCallback(const char* callback_url, const char* body) {
	LOG(INFO)  + "RhoBluetoothManager::fireRhodeCallback( "+callback_url+", "+body+")";
	rho_net_request_with_data(rho_http_normalizeurl(callback_url), body);
	//rho_rhodesapp_callBluetoothCallback(callback_url, body);
	/*
	HWND main_wnd = getMainWnd();
	char* mcallback = new char[strlen(callback_url)+1];
	strcpy(mcallback, callback_url);
	char* mbody = new char[strlen(body)+1];
	strcpy(mbody, body);
	::PostMessage(main_wnd, WM_BLUETOOTH_CALLBACK, (WPARAM)mcallback, (LPARAM)mbody);
	*/
}
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
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;
    }
}
Ejemplo n.º 7
0
RHO_GLOBAL void JNICALL Java_com_rhomobile_barcode_Barcode_callback
  (JNIEnv *env, jclass, jstring callback_url, jstring body) {
    rho_net_request_with_data(rho_http_normalizeurl(rho_cast<std::string>(callback_url).c_str()), rho_cast<std::string>(body).c_str());
}