Exemplo n.º 1
0
//--------------------------------------------------------------------------------------------------
RHO_GLOBAL void android_setup(JNIEnv *env)
{
    jclass clsRE = getJNIClass(RHODES_JAVA_CLASS_RUNTIME_EXCEPTION);
    if (!clsRE)
        return;

    // Init logconf
    rho_logconf_Init(rho_log_path().c_str(), rho_root_path().c_str(), "");
    if (rho_root_path().compare(rho_shared_path()) != 0)
    {
        rho_conf_Init_from_shared_path(rho_shared_path().c_str());
    }
  if(!(RHOCONF().isExist("useAssetFS")) || RHOCONF().getBool("useAssetFS")) {
    struct rlimit rlim;
    if (getrlimit(RLIMIT_NOFILE, &rlim) == -1)
    {
        env->ThrowNew(clsRE, "Can not get maximum number of open files");
        return;
    }
    if (rlim.rlim_max < (unsigned long)RHO_FD_BASE)
    {
        env->ThrowNew(clsRE, "Current limit of open files is less then RHO_FD_BASE");
        return;
    }
    if (rlim.rlim_cur > (unsigned long)RHO_FD_BASE)
    {
        rlim.rlim_cur = RHO_FD_BASE;
        rlim.rlim_max = RHO_FD_BASE;
        if (setrlimit(RLIMIT_NOFILE, &rlim) == -1)
        {
            env->ThrowNew(clsRE, "Can not set maximum number of open files");
            return;
        }
    }
  }

    if (!set_posix_environment(env, clsRE)) return;

    if (::chdir(rho_root_path().c_str()) == -1)
    {
        env->ThrowNew(clsRE, "Can not chdir to HOME directory");
        return;
    }

    // Init SQLite temp directory
    sqlite3_temp_directory = (char*)s_sqlite_path.c_str();

   
   

    // Disable log to stdout as on android all stdout redirects to /dev/null
    RHOCONF().setBool("LogToOutput", false, true);
    LOGCONF().setLogToOutput(false);
    // Add android system log sink
    LOGCONF().setLogView(s_logSink);

    LOGCONF().setMemoryInfoCollector(s_memory_info_collector);

}
Exemplo n.º 2
0
RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_RhodesService_createRhodesApp
  (JNIEnv *env, jobject)
{
    jclass clsRE = getJNIClass(RHODES_JAVA_CLASS_RUNTIME_EXCEPTION);
    if (!clsRE)
        return;

    struct rlimit rlim;
    if (getrlimit(RLIMIT_NOFILE, &rlim) == -1)
    {
        env->ThrowNew(clsRE, "Can not get maximum number of open files");
        return;
    }
    if (rlim.rlim_max < (unsigned long)RHO_FD_BASE)
    {
        env->ThrowNew(clsRE, "Current limit of open files is less then RHO_FD_BASE");
        return;
    }
    if (rlim.rlim_cur > (unsigned long)RHO_FD_BASE)
    {
        rlim.rlim_cur = RHO_FD_BASE;
        rlim.rlim_max = RHO_FD_BASE;
        if (setrlimit(RLIMIT_NOFILE, &rlim) == -1)
        {
            env->ThrowNew(clsRE, "Can not set maximum number of open files");
            return;
        }
    }

    if (!set_capabilities(env)) return;

    // Init SQLite temp directory
    sqlite3_temp_directory = (char*)g_sqlite_journals_path.c_str();

    const char* szRootPath = rho_native_rhopath();

    // Init logconf
    rho_logconf_Init(szRootPath);

    // Disable log to stdout as on android all stdout redirects to /dev/null
    RHOCONF().setBool("LogToOutput", false);
    RHOCONF().saveToFile();
    LOGCONF().setLogToOutput(false);
    // Add android system log sink
    LOGCONF().setLogView(rho::common::g_androidLogSink);

    // Start Rhodes application
    rho_rhodesapp_create(szRootPath);
}
Exemplo n.º 3
0
RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_Rhodes_createRhodesApp
  (JNIEnv *env, jobject, jstring path)
{
    g_rootPath = rho_cast<std::string>(path);

    // Init SQLite temp directory
    sqlite3_temp_directory = (char*)"/sqlite_stmt_journals";

    const char* szRootPath = rho_native_rhopath();

    // Init logconf
    rho_logconf_Init(szRootPath);

    // Disable log to stdout as on android all stdout redirects to /dev/null
    RHOCONF().setBool("LogToOutput", false);
    RHOCONF().saveToFile();
    LOGCONF().setLogToOutput(false);
    // Add android system log sink
    LOGCONF().setLogView(rho::common::g_androidLogSink);

    // Start Rhodes application
    rho_rhodesapp_create(szRootPath);
}
Exemplo n.º 4
0
	bool ParseCommandLine(LPCTSTR lpCmdLine, HRESULT* pnRetCode ) throw( ) {
		m_nRestarting = 1;

		TCHAR szTokens[] = _T("-/");
		LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens);
		while (lpszToken != NULL)
		{
			if (WordCmpI(lpszToken, _T("Restarting"))==0) {
				m_nRestarting = 10;
			}
#if defined(OS_WINDOWS)
			else if (wcsncmp(lpszToken, _T("approot"),7)==0) {
				char* token = wce_wctomb(lpszToken);
				//parseToken will allocate extra byte at the end of the returned token value
				char* path = parseToken( token, strlen(token) );
				if (path) {
					int len = strlen(path);
					if (!(path[len]=='\\' || path[len]=='/')) {
						path[len] = '\\';
						path[len+1]  = 0;
					}
					__setRootPath(path);
					free(path);
				}
				free(token);
			}
#endif
			lpszToken = FindOneOf(lpszToken, szTokens);
		}

		//
		rho_logconf_Init(RhoGetRootPath());
		//	runAllLogTests();

		return __super::ParseCommandLine(lpCmdLine, pnRetCode);
	}
Exemplo n.º 5
0
    // This method is called immediately before entering the message loop.
    // It contains initialization code for the application.
    // Returns:
    // S_OK => Success. Continue with RunMessageLoop() and PostMessageLoop().
    // S_FALSE => Skip RunMessageLoop(), call PostMessageLoop().
    // error code => Failure. Skip both RunMessageLoop() and PostMessageLoop().
    HRESULT PreMessageLoop(int nShowCmd) throw()
    {
        HRESULT hr = __super::PreMessageLoop(nShowCmd);
        if (FAILED(hr))
        {
            return hr;
        }
        // Note: In this sample, we don't respond differently to different hr success codes.

        // Allow only one instance of the application.
        // the "| 0x01" activates the correct owned window of the previous instance's main window
		HWND hWnd = NULL;
		for (int wait = 0; wait < m_nRestarting; wait++) {
			hWnd = FindWindow(CMainWindow::GetWndClassInfo().m_wc.lpszClassName, NULL);
			if (hWnd && m_nRestarting > 1) {
				Sleep(1000);
			} else {
				break;
			}
		}
		//EnumWindows(EnumRhodesWindowsProc, (LPARAM)&hWnd);

		if (hWnd)
		{
			SetForegroundWindow( HWND( DWORD(hWnd) | 0x01 ) );
			return S_FALSE;
		}

        // Create the main application window
        m_appWindow.Create(NULL, CWindow::rcDefault, TEXT("Rhodes"));
        if (NULL == m_appWindow.m_hWnd)
        {
            return S_FALSE;
        }

        rho_logconf_Init(m_strRootPath.c_str());
        LOG(INFO) + "Rhodes started";
        rho::common::CRhodesApp::Create(m_strRootPath );
        RHODESAPP().startApp();

       // m_pServerHost = new CServerHost();
        // Starting local server
        //m_pServerHost->Start(m_appWindow.m_hWnd);
        // Navigate to the "loading..." page
		m_appWindow.Navigate2(_T("about:blank"));
        // Show the main application window
        m_appWindow.ShowWindow(nShowCmd);

#if defined(_WIN32_WCE)
		// Register for changes in the number of network connections
		hr = RegistryNotifyWindow(SN_CONNECTIONSNETWORKCOUNT_ROOT,
			SN_CONNECTIONSNETWORKCOUNT_PATH, 
			SN_CONNECTIONSNETWORKCOUNT_VALUE, 
			m_appWindow.m_hWnd, 
			WM_CONNECTIONSNETWORKCOUNT, 
			0, 
			NULL, 
			&g_hNotify);
#endif
        return S_OK;
    }