platform/shared/common/RhodesApp.cpp in rhodes-7.1.17 vs platform/shared/common/RhodesApp.cpp in rhodes-7.4.1

- old
+ new

@@ -435,20 +435,24 @@ delete m_pInstance; m_pInstance = 0; } -#if defined(WINDOWS_PLATFORM) +#if defined(WINDOWS_PLATFORM) void CRhodesApp::waitAppStarted() { + #ifndef WINCE std::unique_lock<std::mutex> lock(wait_mutex); activated_cond.wait(lock); + #endif } void CRhodesApp::notifyAppStared() { + #ifndef WINCE activated_cond.notify_one(); + #endif } #endif CRhodesApp::CRhodesApp(const String& strRootPath, const String& strUserPath, const String& strRuntimePath) :CRhodesAppBase(strRootPath, strUserPath, strRuntimePath), @@ -736,10 +740,20 @@ #endif rho_http_sendresponse(arg, ""); } +static void callback_uicloserequest(void *arg, String const &strQuery) +{ +#ifndef RHO_NO_RUBY_API + if (!RHODESAPP().isJSApplication() && !RHODESAPP().isNodeJSApplication()) + rho_ruby_uiCloseRequest(); +#endif + + rho_http_sendresponse(arg, ""); +} + static void callback_uidestroyed(void *arg, String const &strQuery) { #ifndef RHO_NO_RUBY_API if (!RHODESAPP().isJSApplication() && !RHODESAPP().isNodeJSApplication()) rho_ruby_uiDestroyed(); @@ -756,11 +770,11 @@ } static void callback_loadallsyncsources(void *arg, String const &strQuery) { RhoAppAdapter.loadAllSyncSources(); - String strMsg; + String strMsg = ""; rho_http_sendresponse(arg, strMsg.c_str()); } static void callback_resetDBOnSyncUserChanged(void *arg, String const &strQuery) { @@ -772,10 +786,27 @@ void CRhodesApp::callUiCreatedCallback() { m_appCallbacksQueue->addQueueCommand(new CAppCallbacksQueue::Command(CAppCallbacksQueue::ui_created)); } +int CRhodesApp::callUiCloseRequestCallback() +{ + if ( m_bExit || !rho_ruby_is_started()) return 1; + + String strUrl = m_strHomeUrl + "/system/uicloserequest"; + NetResponse resp = getNetRequest().pullData( strUrl, NULL ); + if ( !resp.isOK() ) + { + LOG(ERROR) + "UI close request callback failed. Code: " + resp.getRespCode() + "; Error body: " + resp.getCharData(); + return 1; + }else{ + return 0; + } + return 1; + +} + void CRhodesApp::callUiDestroyedCallback() { if ( m_bExit/* || !rho_ruby_is_started()*/ ) return; @@ -1551,16 +1582,11 @@ String strRuntimePath = getRhoRuntimePath(); #ifndef RHODES_EMULATOR strAppRootPath += "apps"; #endif -#ifdef OS_SAILFISH - //m_httpServer = new net::CHttpServer(atoi(getFreeListeningPort()), strAppRootPath, strAppUserPath, strRuntimePath, true, false); This thing doesn't work m_httpServer = new net::CHttpServer(atoi(getFreeListeningPort()), strAppRootPath, strAppUserPath, strRuntimePath); -#else - m_httpServer = new net::CHttpServer(atoi(getFreeListeningPort()), strAppRootPath, strAppUserPath, strRuntimePath); -#endif m_httpServer->register_uri("/system/geolocation", rubyext::CGeoLocation::callback_geolocation); m_httpServer->register_uri("/system/syncdb", callback_syncdb); m_httpServer->register_uri("/system/redirect_to", callback_redirect_to); m_httpServer->register_uri("/system/map", callback_map); m_httpServer->register_uri("/system/shared", callback_shared); @@ -1574,10 +1600,11 @@ m_httpServer->register_uri("/AppManager/loader/load", callback_AppManager_load); m_httpServer->register_uri("/system/getrhomessage", callback_getrhomessage); m_httpServer->register_uri("/system/activateapp", callback_activateapp); m_httpServer->register_uri("/system/deactivateapp", callback_deactivateapp); m_httpServer->register_uri("/system/uicreated", callback_uicreated); + m_httpServer->register_uri("/system/uicloserequest", callback_uicloserequest); m_httpServer->register_uri("/system/uidestroyed", callback_uidestroyed); m_httpServer->register_uri("/system/loadserversources", callback_loadserversources); m_httpServer->register_uri("/system/resetDBOnSyncUserChanged", callback_resetDBOnSyncUserChanged); m_httpServer->register_uri("/system/loadallsyncsources", callback_loadallsyncsources); m_httpServer->register_uri("/system/logger", callback_logger); @@ -1783,10 +1810,16 @@ #ifdef OS_MACOSX if (rho_conf_is_property_exists("ios_https_local_server")!=0) { force_https = rho_conf_getBool("ios_https_local_server")!=0; } #endif + +#ifdef OS_ANDROID + const char* value = get_app_build_config_item("local_https_server_with_client_checking"); + force_https = value && strcmp(value, "1") == 0; +#endif + if (force_https) { m_strHomeUrl = "https://127.0.0.1:"; } else { m_strHomeUrl = "http"; @@ -2919,9 +2952,19 @@ else { RAWLOGC_ERROR("RhodesApp", "UI created callback is missing because application instance is NULL"); } } + +int rho_rhodesapp_callUiCloseRequestCallback() //return zero if you whant to suppress closing +{ + if ( rho::common::CRhodesApp::getInstance() ){ + return RHODESAPP().callUiCloseRequestCallback(); + } + + return 1; +} + void rho_rhodesapp_callUiDestroyedCallback() { if ( rho::common::CRhodesApp::getInstance() ) RHODESAPP().callUiDestroyedCallback();