Ejemplo n.º 1
0
void rho_splash_screen_start()
{
    RHODESAPP().getSplashScreen().start();
}
Ejemplo n.º 2
0
RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_RhodesService_doRequestAsync
  (JNIEnv *env, jclass, jstring strUrl)
{
    std::string url = rho_cast<std::string>(env, strUrl);
    RHODESAPP().runCallbackInThread(url, "");
}
Ejemplo n.º 3
0
RHO_GLOBAL jstring JNICALL Java_com_rhomobile_rhodes_RhodesAppOptions_getBlobPath
  (JNIEnv *env, jclass)
{
    const char *s = RHODESAPP().getBlobsDirPath().c_str();
    return rho_cast<jhstring>(env, s).release();
}
Ejemplo n.º 4
0
boolean CRhoTimer::checkTimers()
{
    RAWTRACE("CRhoTimer::checkTimers");

    synchronized(m_mxAccess);

    boolean bRet = false;
    CTimeInterval curTime = CTimeInterval::getCurrentTime();
    for( int i = (int)m_arItems.size()-1; i >= 0; i--)
    {
        CTimerItem oItem = m_arItems.elementAt(i);
		if(oItem.m_overflow==false)
		{

			if ( curTime.toULong() >= oItem.m_oFireTime.toULong() )
			{
                RAWTRACE("CRhoTimer::checkTimers: firing timer");
				m_arItems.removeElementAt(i);
				if ( RHODESAPP().callTimerCallback(oItem.m_strCallback, oItem.m_strCallbackData) )
					bRet = true;
			}

		}
		else
		{
			if ( curTime.toULong() >= oItem.m_oFireTime.toULong() )
			{
				if((curTime.toULong()-oItem.m_oFireTime.toULong())<=oItem.m_nInterval)
				{
                    RAWTRACE("CRhoTimer::checkTimers: firing timer");
					m_arItems.removeElementAt(i);
					if ( RHODESAPP().callTimerCallback(oItem.m_strCallback, oItem.m_strCallbackData) )
						bRet = true;
				}

			}

		}
    }

    for( int i = (int)m_arNativeItems.size()-1; i >= 0; i--)
    {
        CNativeTimerItem oItem = m_arNativeItems.elementAt(i);
        
        if(oItem.m_overflow==false)
		{
            if ( curTime.toULong() >= oItem.m_oFireTime.toULong() )
            {
                RAWTRACE("CRhoTimer::checkTimers: firing native timer");
                m_arNativeItems.removeElementAt(i);
                if ( oItem.m_pCallback->onTimer() )
                    bRet = true;
            }
        }
        else
        {
            if ( curTime.toULong() >= oItem.m_oFireTime.toULong() )
			{
				if((curTime.toULong()-oItem.m_oFireTime.toULong())<=oItem.m_nInterval)
				{
                    RAWTRACE("CRhoTimer::checkTimers: firing native timer");
                    m_arNativeItems.removeElementAt(i);
                    if ( oItem.m_pCallback->onTimer() )
                        bRet = true;
				}

			}
        }
    }


    return bRet;
}
Ejemplo n.º 5
0
void QtMainWindow::on_actionRotate180_triggered()
{
	RHODESAPP().callScreenRotationCallback(this->width(), this->height(), 180);
}
Ejemplo n.º 6
0
	void DoViewNavigate(char* url) 
    {
        rho::String strUrl = RHODESAPP().canonicalizeRhoUrl(url);
        ::PostMessage( m_appWindow.m_hWnd, WM_COMMAND, IDM_NAVIGATE, (LPARAM)wce_mbtowc(strUrl.c_str()) );
    }
Ejemplo n.º 7
0
extern "C" char* webview_current_location(int index) {
    return const_cast<char*>(RHODESAPP().getCurrentUrl(index).c_str());
}
Ejemplo n.º 8
0
void CExtManager::executeRubyCallbackWithJsonBody( const char* szCallback, const char* szCallbackBody, const char* szCallbackData, bool bWaitForResponse)
{
    RHODESAPP().callCallbackWithJsonBody(szCallback, szCallbackBody, szCallbackData, bWaitForResponse );
}
Ejemplo n.º 9
0
StringW CExtManager::getCurrentUrl()
{
    return convertToStringW(RHODESAPP().getCurrentUrl(rho_webview_active_tab()));
}
Ejemplo n.º 10
0
RHO_GLOBAL jstring JNICALL Java_com_rhomobile_rhodes_RhodesService_currentLocation(JNIEnv * env, jclass, jint jTab)
{
    std::string strLocation = RHODESAPP().getCurrentUrl(static_cast<int>(jTab));
    RAWTRACE2("Controller currentLocation (tab: %d): %s", static_cast<int>(jTab), strLocation.c_str());
    return rho_cast<jstring>(env, strLocation);
}
Ejemplo n.º 11
0
bool CHttpServer::run()
{
    LOG(INFO) + "Start HTTP server";

    if (!init())
        return false;

    m_active = true;

    RHODESAPP().notifyLocalServerStarted();

    for(;;) 
    {
        RAWTRACE("Waiting for connections...");
#ifndef RHO_NO_RUBY_API
        if (rho_ruby_is_started())
            rho_ruby_start_threadidle();
#endif
        fd_set readfds;
        FD_ZERO(&readfds);
        FD_SET(m_listener, &readfds);

        timeval tv = {0,0};
        unsigned long nTimeout = RHODESAPP().getTimer().getNextTimeout();
        tv.tv_sec = nTimeout/1000;
        tv.tv_usec = (nTimeout - tv.tv_sec*1000)*1000;
        int ret = select(m_listener+1, &readfds, NULL, NULL, (tv.tv_sec == 0 && tv.tv_usec == 0 ? 0 : &tv) );
#ifndef RHO_NO_RUBY_API
        if (rho_ruby_is_started())
            rho_ruby_stop_threadidle();
#endif
        bool bProcessed = false;
        if (ret > 0) 
        {
            if (FD_ISSET(m_listener, &readfds))
            {
                //RAWTRACE("Before accept...");
                SOCKET conn = accept(m_listener, NULL, NULL);
                //RAWTRACE("After accept...");
                if (!m_active) {
                    RAWTRACE("Stop HTTP server");
                    return true;
                }
                if (conn == INVALID_SOCKET) {
        #if !defined(WINDOWS_PLATFORM)
                    if (RHO_NET_ERROR_CODE == EINTR)
                        continue;
        #endif
                    RAWLOG_ERROR1("Can not accept connection: %d", RHO_NET_ERROR_CODE);
                    return false;
                }

                RAWTRACE("Connection accepted, process it...");
                VALUE val;
#ifndef RHO_NO_RUBY_API                
                if (rho_ruby_is_started())
                {
                    if ( !RHOCONF().getBool("enable_gc_while_request") )                
                        val = rho_ruby_disable_gc();
                }
#endif
                m_sock = conn;
                bProcessed = process(m_sock);
#ifndef RHO_NO_RUBY_API
                if (rho_ruby_is_started())
                {
                    if ( !RHOCONF().getBool("enable_gc_while_request") )
                        rho_ruby_enable_gc(val);
                }
#endif
                RAWTRACE("Close connected socket");
                closesocket(m_sock);
                m_sock = INVALID_SOCKET;
            }
        }
        else if ( ret == 0 ) //timeout
        {
            bProcessed = RHODESAPP().getTimer().checkTimers();
        }
        else
        {
            RAWLOG_ERROR1("select error: %d", ret);
            return false;
        }
#ifndef RHO_NO_RUBY_API
        if (rho_ruby_is_started())
        {
            if ( bProcessed )
            {
                LOG(INFO) + "GC Start.";
                rb_gc();
                LOG(INFO) + "GC End.";
            }
        }
#endif
    }
}
CSimpleOnlyStaticModuleSingletonBase::CSimpleOnlyStaticModuleSingletonBase()
{
    RHODESAPP().getExtManager().registerExtension( "SimpleOnlyStaticModule", this );
}
CCordovabarcodeSingletonBase::CCordovabarcodeSingletonBase()
{
    RHODESAPP().getExtManager().registerExtension( "Cordovabarcode", this );
}
Ejemplo n.º 14
0
void rho_splash_screen_hide()
{
    RHODESAPP().getSplashScreen().hide();
}
Ejemplo n.º 15
0
RHO_GLOBAL jstring JNICALL Java_com_rhomobile_rhodes_RhodesService_getBlobPath
  (JNIEnv *env, jclass)
{
    const char *s = RHODESAPP().getBlobsDirPath().c_str();
    return rho_cast<jstring>(env, s);
}
Ejemplo n.º 16
0
LRESULT CRhoMapViewDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	SetWindowText(_T("MapView"));

#if defined(_WIN32_WCE) 

#if !defined (OS_PLATFORM_MOTCE)
	SHINITDLGINFO shidi = { SHIDIM_FLAGS, m_hWnd, SHIDIF_SIZEDLGFULLSCREEN };
	RHO_ASSERT(SHInitDialog(&shidi));


	SHMENUBARINFO mbi = { sizeof(mbi), 0 };
	mbi.hwndParent = m_hWnd;
	mbi.nToolBarId = IDR_GETURL_MENUBAR;//IDR_MAPVIEW;
	mbi.hInstRes = _AtlBaseModule.GetResourceInstance();
	
	SHCreateMenuBar(&mbi);
#else
	m_hWndCommandBar = CommandBar_Create(_AtlBaseModule.GetResourceInstance(), m_hWnd, 1);
	CommandBar_AddAdornments(m_hWndCommandBar, 0, 0 );
    CommandBar_Show(m_hWndCommandBar, TRUE);
#endif //OS_WINCE

	//::SetWindowLong(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, 
	//	GWL_EXSTYLE,
	//	::GetWindowLong(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, GWL_EXSTYLE) | WS_EX_TRANSPARENT);


	RECT r;
	::GetClientRect(m_hWnd, &r);

	RHO_MAP_TRACE2("execute rho_map_create( w = %d,  h = %d )", r.right - r.left, r.bottom - r.top);
	ourMapView = rho_map_create(mParams, &ourDrawingDevice, r.right - r.left, r.bottom - r.top);
	rho_param_free(mParams);
	mParams = NULL;


	if (ourMapView != NULL) {
		int minz = ourMapView->minZoom();
		int maxz = ourMapView->maxZoom();
		RHO_MAP_TRACE2("request Zoom limits: minZoom = %d,  maxZoom = %d", minz, maxz);
		::SendMessage(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, TBM_SETRANGEMIN, FALSE, minz); 
		::SendMessage(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, TBM_SETRANGEMAX, FALSE, maxz); 
		int dwPos = ourMapView->zoom();
		dwPos = ourMapView->maxZoom() - (dwPos - ourMapView->minZoom());
		::SendMessage(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, TBM_SETPOS, TRUE, dwPos); 

		String strImagePath = "lib/res/blue_pushpin.png";
		String fullImagePath = CFilePath::join( RHODESAPP().getRhoRuntimePath(), strImagePath);
		IDrawingImage* pinImg = ourDrawingDevice.createImage(fullImagePath, true);

        PIN_INFO pin_info = {0};
		pin_info.x_offset = -10;
		pin_info.y_offset = -35;
		pin_info.click_rect_x = -10;
		pin_info.click_rect_y = -35;
		pin_info.click_rect_width = 72;
		pin_info.click_rect_height = 72;

		ourMapView->setPinImage(pinImg, pin_info);

		strImagePath = "lib/res/callout.png";
		fullImagePath = CFilePath::join( RHODESAPP().getRhoRuntimePath(), strImagePath);
		IDrawingImage* pinCalloutImg = ourDrawingDevice.createImage(fullImagePath, true);

        PIN_INFO pin_callout_info = {0};
		pin_callout_info.x_offset = 5;
		pin_callout_info.y_offset = 0;
		pin_callout_info.click_rect_width = 179;
		pin_callout_info.click_rect_height = 64;

		ourMapView->setPinCalloutImage(pinCalloutImg, pin_callout_info);

		strImagePath = "lib/res/callout_link.png";
		fullImagePath = CFilePath::join( RHODESAPP().getRhoRuntimePath(), strImagePath);
		IDrawingImage* pinCalloutLinkImg = ourDrawingDevice.createImage(fullImagePath, true);
		ourMapView->setPinCalloutLinkImage(pinCalloutLinkImg, pin_callout_info);

		strImagePath = "lib/res/esri.png";
		fullImagePath = CFilePath::join( RHODESAPP().getRhoRuntimePath(), strImagePath);
		IDrawingImage* esriLogoImg = ourDrawingDevice.createImage(fullImagePath, true);
		ourMapView->setESRILogoImage(esriLogoImg);
	}

#else 

	//CreateButtons();
	//GotoDlgCtrl(m_btnOk);

#endif

	requestRedraw();

	return FALSE;
}
Ejemplo n.º 17
0
IBrowserEngine* BrowserFactory::createWebkit(HWND hwndParent)
{
	RHODESAPP().getExtManager().getEngineEventMngr().setEngineType(rho::engineeventlistner::eWebkit);
	return rho_wmimpl_get_webkitBrowserEngine(hwndParent, rho_wmimpl_get_appinstance());
}
Ejemplo n.º 18
0
VALUE rho_sys_get_property(char* szPropName) 
{
	if (!szPropName || !*szPropName) 
        return rho_ruby_get_NIL();
    
    VALUE res;
#ifdef RHODES_EMULATOR
    if (rho_simimpl_get_property(szPropName, &res))
        return res;
#endif

    if (rho_sysimpl_get_property(szPropName, &res))
        return res;

	if (strcasecmp("platform",szPropName) == 0) 
        return rho_ruby_create_string(rho_rhodesapp_getplatform());

	if (strcasecmp("has_network",szPropName) == 0) 
        return rho_sys_has_network();

	if (strcasecmp("locale",szPropName) == 0) 
        return rho_sys_get_locale();

	if (strcasecmp("screen_width",szPropName) == 0) 
        return rho_ruby_create_integer(rho_sys_get_screen_width());

	if (strcasecmp("screen_height",szPropName) == 0) 
        return rho_ruby_create_integer(rho_sys_get_screen_height());

	if (strcasecmp("real_screen_width",szPropName) == 0) 
        return rho_ruby_create_integer(rho_sys_get_screen_width());
    
	if (strcasecmp("real_screen_height",szPropName) == 0) 
        return rho_ruby_create_integer(rho_sys_get_screen_height());

	if (strcasecmp("device_id",szPropName) == 0) 
    {
        rho::String strDeviceID = "";
        if ( rho::sync::CClientRegister::getInstance() )
            strDeviceID = rho::sync::CClientRegister::getInstance()->getDevicePin();

        return rho_ruby_create_string(strDeviceID.c_str());
    }

    if (strcasecmp("phone_id", szPropName) == 0)
        return rho_ruby_create_string(""); 

	if (strcasecmp("full_browser",szPropName) == 0) 
        return rho_ruby_create_boolean(1);

	if (strcasecmp("rhodes_port",szPropName) == 0) 
        return rho_ruby_create_integer(atoi(RHODESAPP().getFreeListeningPort()));

	if (strcasecmp("free_server_port",szPropName) == 0) 
        return rho_ruby_create_integer(RHODESAPP().determineFreeListeningPort());

	if (strcasecmp("is_emulator",szPropName) == 0) 
        return rho_ruby_create_boolean(0);

	if (strcasecmp("has_touchscreen",szPropName) == 0)
        return rho_ruby_create_boolean(1);

	if (strcasecmp("has_sqlite",szPropName) == 0)
        return rho_ruby_create_boolean(1);
    
    if (strcasecmp("security_token_not_passed",szPropName) == 0) {
        int passed = 0;
        if ((RHODESAPP().isSecurityTokenNotPassed())) {
            passed = 1;
        }
        return rho_ruby_create_boolean(passed);
    }

	if (strcasecmp("is_motorola_device",szPropName) == 0)
#ifdef APP_BUILD_CAPABILITY_MOTOROLA
        return rho_ruby_create_boolean(1);
#else
        return rho_ruby_create_boolean(0);
#endif

	if (strcasecmp("has_cell_network",szPropName) == 0) 
        return rho_sys_has_network();

	if (strcasecmp("has_wifi_network",szPropName) == 0) 
        return rho_sys_has_network();

    RAWLOG_ERROR1("Unknown Rho::System property : %s", szPropName);

    return rho_ruby_get_NIL();
}
Ejemplo n.º 19
0
extern "C" void webview_set_menu_items(VALUE valMenu) 
{
    RHODESAPP().setViewMenu(valMenu);
}
Ejemplo n.º 20
0
bool CKeyModule::ProcessKeyUp (WPARAM wparam, LPARAM lparam, INSTANCE_DATA *pdata)
{


    char key [8];
    bool handled, matched;

    // Assume key is not handled
    handled = FALSE;
    // Get key code from message
    int code = (int) wparam;


    if(code == VK_F11)
    {

        LOG(INFO) + "F11 Handled in Keyup";
        // Flag to show if we have found a match for the key
        matched = FALSE;

        // Convert to decimal text
        sprintf (key, "%d", code);

        // Check for specific key
        CKeyMapEntry *pentry = pdata->pKeyMap->Find (code);

        if (pentry)
        {
            if (pentry->nRemap)
            {
                // If it's remapped always mark it as handled and don't fire the event
                handled = TRUE;

                // Insert replacement key
                keybd_event (pentry->nRemap, 0, KEYEVENTF_SILENT, 0);
                keybd_event (pentry->nRemap, 0, KEYEVENTF_KEYUP | KEYEVENTF_SILENT, 0);
            }
            else
            {
                if (pentry->psNavigate.hasCallback())
                {
                    rho::Hashtable<rho::String, rho::String> keyData;
                    keyData.put("keyValue", key);
                    pentry->psNavigate.set(keyData);
                }
                handled = !pentry->bDispatch;
            }

            matched = TRUE;
        }

        // Check for all keys
        if (!matched)
        {
            if (pdata->psAllKeysNavigate.hasCallback())
            {
                rho::Hashtable<rho::String, rho::String> keyData;
                keyData.put("keyValue", key);
                pdata->psAllKeysNavigate.set(keyData);
                handled = !pdata->bAllKeysDispatch;
            }
        }

        // Check for home key
        if (!matched)
        {
            if (pdata->nHomeKey && pdata->nHomeKey == code)
            {
                // Call back to core to request home navigate
                LOG(INFO) + "Home Key has been pressed, navigating to application start page";
                RHODESAPP().navigateToUrl(RHODESAPP().getStartUrl());

                handled = TRUE;
                matched = TRUE;
            }
        }

        // Flag that subsequent WM_CHAR should be suppressed if we are handling the key
        pdata->bSuppressChar = handled;

        //return handled;

    }

    // Clear WM_CHAR suppression
    pdata->bSuppressChar = FALSE;

    return handled;
}
Ejemplo n.º 21
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;
    }
Ejemplo n.º 22
0
 void rho_sys_start_timer( int interval, const char *url, const char* params)
 {
     RHODESAPP().getTimer().addTimer(interval, url, params);
 }
Ejemplo n.º 23
0
void QtMainWindow::on_actionRotateLeft_triggered()
{
	this->resize(this->height(), this->width());
	this->adjustWebInspector();
	RHODESAPP().callScreenRotationCallback(this->width(), this->height(), -90);
}
Ejemplo n.º 24
0
 void rho_sys_stop_timer( const char *url )
 {
     RHODESAPP().getTimer().stopTimer(url);
 }
Ejemplo n.º 25
0
RHO_GLOBAL jstring JNICALL Java_com_rhomobile_rhodes_RhodesAppOptions_getAppBackUrl
  (JNIEnv *env, jclass)
{
    const char *s = RHODESAPP().getAppBackUrl().c_str();
    return rho_cast<jstring>(env, s);
}
Ejemplo n.º 26
0
 void rho_sys_set_push_notification(const char *url, const char* params)
 {
     RHODESAPP().setPushNotification(url, params);
 }
Ejemplo n.º 27
0
RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_RhodesApplication_setStartParameters
  (JNIEnv *env, jclass, jstring strUrl)
{
    std::string url = rho_cast<std::string>(env, strUrl);
    RHODESAPP().setStartParameters(url.c_str());
}
Ejemplo n.º 28
0
RHO_GLOBAL jstring JNICALL Java_com_rhomobile_rhodes_RhodesService_getAppBackUrl
  (JNIEnv *env, jobject)
{
    const char *s = RHODESAPP().getAppBackUrl().c_str();
    return rho_cast<jstring>(env, s);
}
Ejemplo n.º 29
0
RHO_GLOBAL jboolean JNICALL Java_com_rhomobile_rhodes_RhodesService_isOnStartPage
  (JNIEnv *env, jclass)
{
    bool res = RHODESAPP().isOnStartPage();
    return (jboolean)res;
}
Ejemplo n.º 30
0
/*static*/ bool  _CRhoAppAdapter::callCallbackOnSyncUserChanged()
{
    return RHODESAPP().getApplicationEventReceiver()->onSyncUserChanged(); 
}