コード例 #1
0
rho::String js_s_Megamodule_getObjectByIndex(const rho::String& strObjID, rho::json::CJSONArray& argv, const rho::String& strCallbackID, const rho::String& strJsVmID, const rho::String& strCallbackParam)
{
    RAWTRACE2("%s(id=%s)", __FUNCTION__, strObjID.c_str());

    MethodResultJni result(false);
    if(!result)
    {
        result.setError("JNI error: failed to initialize MethodResult java object");
        RAWLOG_ERROR("JNI error: failed to initialize MethodResult java object ^^^");
        return CMethodResultConvertor().toJSON(result);
    }


    int argc = argv.getSize();
    if((argc < 1) || (argc > 1))
    {
        result.setArgError("Wrong number of arguments");
        RAWLOG_ERROR1("Wrong number of arguments: %d ^^^", argc);
        return CMethodResultConvertor().toJSON(result);
    }
    
    if(strCallbackID.length() != 0)
    {
        result.setCallBack(strCallbackID, strCallbackParam);
    }

    result.setObjectClassPath("Rho.Examples.Megamodule");
    RAWTRACE("Object class path is set");
    ObjectProxy::getObjectByIndex(argumentsAdapter(argv), result); 
    rho::String res = CMethodResultConvertor().toJSON(result);
    RAWTRACE(res.c_str());
    RAWTRACE2("%s(id=%s) end ^^^", __FUNCTION__, strObjID.c_str());
    return res;
}
コード例 #2
0
rho::String js_Megamodule_getIntegerProperty(const rho::String& strObjID, rho::json::CJSONArray& argv, const rho::String& strCallbackID, const rho::String& strJsVmID, const rho::String& strCallbackParam)
{
    RAWTRACE2("%s(id=%s)", __FUNCTION__, strObjID.c_str());

    MethodResultJni result(false);
    if(!result)
    {
        result.setError("JNI error: failed to initialize MethodResult java object");
        RAWLOG_ERROR("JNI error: failed to initialize MethodResult java object ^^^");
        return CMethodResultConvertor().toJSON(result);
    }

    ObjectProxy megamodule(strObjID);

    int argc = argv.getSize();
    if((argc < 0) || (argc > 0))
    {
        result.setArgError("Wrong number of arguments");
        RAWLOG_ERROR1("Wrong number of arguments: %d ^^^", argc);
        return CMethodResultConvertor().toJSON(result);
    }
    
    if(strCallbackID.length() != 0)
    {
        result.setCallBack(strCallbackID, strCallbackParam);
    }

    megamodule.getIntegerProperty(argumentsAdapter(argv), result); 
    rho::String res = CMethodResultConvertor().toJSON(result);
    RAWTRACE(res.c_str());
    RAWTRACE2("%s(id=%s) end ^^^", __FUNCTION__, strObjID.c_str());
    return res;
}
コード例 #3
0
void rho_wmimpl_tabbar_setTabBadge(int tabIndex,  const rho::String& badge)
{
#ifdef OS_WINCE
    getAppWindow().getTabbar().SetBadge(tabIndex, badge.c_str());
#else
    getAppWindow().tabbarBadge(tabIndex, badge.c_str());
#endif

}
コード例 #4
0
ファイル: MainWindowQt.cpp プロジェクト: pla1207/rhodes
void CMainWindow::setProxy(const rho::String& host, const rho::String& port, const rho::String& login, const rho::String& password)
{
	if (host.length()) {
		QNetworkProxy proxy;
		proxy.setType(QNetworkProxy::HttpCachingProxy);
		proxy.setHostName(host.c_str());
		if (port.length())
			proxy.setPort(atoi(port.c_str()));
		if (login.length())
			proxy.setUser(login.c_str());
		if (password.length())
			proxy.setPassword(password.c_str());
		CRhodesProxyFactory::getInstance()->setProxy(proxy);
	}
}
コード例 #5
0
ファイル: SQLite3Impl.cpp プロジェクト: raj-odc/rhodes
void CSQLite3Impl::isTableExist( const rho::String& tableName, rho::apiGenerator::CMethodResult& oResult)
{
    int result;

    result = rho_db_is_table_exist(m_pDB, tableName.c_str());
    oResult.set(result ? true : false);
}
コード例 #6
0
void RhoConnectClientImpl::setSourceProperty( const rho::String& sourceName,  const rho::String& propertyName,  const rho::String& propertyValue, rho::apiGenerator::CMethodResult& oResult) {
	
	sync::CSyncSource* src = getSyncEngine().findSourceByName(sourceName);
	if ( src != 0 ) {
		sync::CSyncEngine::getSourceOptions().setProperty(src->getID(), propertyName.c_str(), propertyValue.c_str());
	}
}
コード例 #7
0
rho::String js_GenPropBag_getStringProp(const rho::String& strObjID, rho::json::CJSONArray& argv, const rho::String& strCallbackID, const rho::String& strJsVmID, const rho::String& strCallbackParam)
{
    RAWTRACE3("getStringProp(strObjID = %s, strCallbackID = %s, strJsVmID = %s)", strObjID.c_str(), strCallbackID.c_str(), strJsVmID.c_str());

    rho::apiGenerator::CMethodResult oRes;


    oRes.setRequestedType(CMethodResult::eString);

    rho::common::CInstanceClassFunctorBase<rho::apiGenerator::CMethodResult>* pFunctor = 0;
    int argc = argv.getSize();

    rho::IGenPropBag* pObj = rho::CGenPropBagFactoryBase::getInstance()->getModuleByID(strObjID);







    if ( oRes.hasCallback() )
    {
        pFunctor = rho_makeInstanceClassFunctor1( pObj, &rho::IGenPropBag::getStringProp,  oRes );
        rho::CGenPropBagFactoryBase::getGenPropBagSingletonS()->addCommandToQueue( pFunctor );
    }
    else
    {

        pObj->getStringProp(  oRes );
    }

    return oRes.toJSON();

}
コード例 #8
0
rho::String js_s_Externalstorage_getSDPath(const rho::String& strObjID, rho::json::CJSONArray& argv, const rho::String& strCallbackID, const rho::String& strJsVmID, const rho::String& strCallbackParam)
{
    RAWTRACE3("getSDPath(strObjID = %s, strCallbackID = %s, strJsVmID = %s)", strObjID.c_str(), strCallbackID.c_str(), strJsVmID.c_str());

    rho::apiGenerator::CMethodResult oRes;


    oRes.setRequestedType(CMethodResult::eString);

    rho::common::CInstanceClassFunctorBase<rho::apiGenerator::CMethodResult>* pFunctor = 0;
    int argc = argv.getSize();







    if ( oRes.hasCallback() )
    {
        pFunctor = rho_makeInstanceClassFunctor1( rho::CExternalstorageFactoryBase::getExternalstorageSingletonS(), &rho::IExternalstorageSingleton::getSDPath,  oRes );
        rho::CExternalstorageFactoryBase::getExternalstorageSingletonS()->addCommandToQueue( pFunctor );
    }
    else 
    {

        rho::CExternalstorageFactoryBase::getExternalstorageSingletonS()->getSDPath(  oRes );
    }

    return oRes.toJSON();

}
コード例 #9
0
ファイル: CSystemImpl.cpp プロジェクト: anshul123/rhodes
void CSystemImpl::setHttpProxyURI( const rho::String& value, CMethodResult& oResult)
{
	if ( value.length() )
        rho_sys_set_http_proxy_url( value.c_str() );
    else
        rho_sys_unset_http_proxy();
}
コード例 #10
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);

}
コード例 #11
0
ファイル: ApplicationImpl.cpp プロジェクト: rhomobile/rhodes
    virtual void setTitle( const rho::String& title, rho::apiGenerator::CMethodResult& oResult)
    {
        RHOCONF().setString("title_text", title, false);

#if defined(OS_WINCE) || defined (OS_WINDOWS_DESKTOP) || defined(RHODES_EMULATOR)
        rho_title_change(0, title.c_str());
#endif
    }
コード例 #12
0
ファイル: SystemImplBase.cpp プロジェクト: ihorsavka/rhodes
void CSystemImplBase::replaceCurrentBundle( const rho::String& pathToBundle,  const rho::Hashtable<rho::String, rho::String>& params, rho::apiGenerator::CMethodResult& oResult)
{
    bool do_not_restart_app = false, not_thread_mode = false;
    if( params.containsKey("do_not_restart_app") )
        convertFromStringA( params.get("do_not_restart_app").c_str(), do_not_restart_app );
    if( params.containsKey("not_thread_mode") )
        convertFromStringA( params.get("not_thread_mode").c_str(), not_thread_mode );

    rho_sys_replace_current_bundleEx( pathToBundle.c_str(), params.containsKey("callback") ? params.get("callback").c_str():0, do_not_restart_app, not_thread_mode );
}
コード例 #13
0
rho::String js_Cordovabarcode_scan(const rho::String& strObjID, rho::json::CJSONArray& argv, const rho::String& strCallbackID, const rho::String& strJsVmID, const rho::String& strCallbackParam)
{
    RAWTRACE2("%s(id=%s)", __FUNCTION__, strObjID.c_str());

    MethodResultJni result(false);
    if(!result)
    {
        result.setError("JNI error: failed to initialize MethodResult java object");
        RAWLOG_ERROR("JNI error: failed to initialize MethodResult java object ^^^");
        return CMethodResultConvertor().toJSON(result);
    }

    ObjectProxy cordovabarcode(strObjID);

    int argc = argv.getSize();
    if((argc < 1) || (argc > 1))
    {
        result.setArgError("Wrong number of arguments");
        RAWLOG_ERROR1("Wrong number of arguments: %d ^^^", argc);
        return CMethodResultConvertor().toJSON(result);
    }
    
    if(strCallbackID.length() != 0)
    {
        result.setCallBack(strCallbackID, strCallbackParam);
    }

    if(!result.hasCallback())
    {
        if(!result.isError())
        {
            result.setArgError("No callback handler provided");
        }
        RAWLOG_ERROR1("Error setting callback: %s", result.getErrorMessage().c_str());
        return CMethodResultConvertor().toJSON(result);
    }

    cordovabarcode.scan(argumentsAdapter(argv), result); 
    rho::String res = CMethodResultConvertor().toJSON(result);
    RAWTRACE(res.c_str());
    RAWTRACE2("%s(id=%s) end ^^^", __FUNCTION__, strObjID.c_str());
    return res;
}
コード例 #14
0
static VALUE Cordovabarcode_scan(int argc, VALUE *argv, const rho::String& id)
{
    RAWTRACE2("%s(id=%s)", __FUNCTION__, id.c_str());
    MethodResultJni result(true);
    if(!result)
    {
        RAWLOG_ERROR("JNI error: failed to initialize MethodResult java object ^^^");
        result.setError("JNI error: failed to initialize MethodResult java object");
        return CMethodResultConvertor().toRuby(result, false);
    }
    
    RAWTRACE("MethodResultJni instance is created");

    ObjectProxy cordovabarcode(id);

    if((argc < 2) || (argc > 3))
    {
        RAWLOG_ERROR1("Wrong number of arguments: %d ^^^", argc);
        result.setArgError("Wrong number of arguments");
        return CMethodResultConvertor().toRuby(result, false);
    }
    
    unsigned realParamCount = (argc < 1) ? argc : 1;
    std::vector<VALUE> arguments(argv, argv + realParamCount);
    
    RAWTRACE1("Count of passed arguments: %d", arguments.size());
    
    if(argc > 1)
    {
        if (rho_ruby_is_proc(argv[1]) || rho_ruby_is_method(argv[1]))
        {
            result.setRubyProcCallBack(argv[1]);
            RAWTRACE("Ruby proc callback is set");
        } else
        {
            if(argc > 2)
                result.setCallBack(argv[1], argv[2]);
            else
                result.setCallBack(argv[1]);
            
            RAWTRACE("Callback URL is set");
        }
        if(!result.hasCallback())
        {
            RAWLOG_ERROR("Error setting callback ^^^");
            return CMethodResultConvertor().toRuby(result, false);
        }
    }

    cordovabarcode.scan(argumentsAdapter(arguments), result); 
    RAWTRACE("Native metod has invoked, converting result");
    VALUE res = CMethodResultConvertor().toRuby(result, false);
    RAWTRACE(__FUNCTION__);
    return res;
}
コード例 #15
0
rho::String js_s_SimpleOnlyStaticModule_joinStrings(rho::json::CJSONArray& argv, const rho::String& strObjID)
{
    RAWTRACE2("%s(id=%s)", __FUNCTION__, strObjID.c_str());

    MethodResultJni result;
    if(!result)
    {
        result.setError("JNI error: failed to initialize MethodResult java object");
        RAWLOG_ERROR("JNI error: failed to initialize MethodResult java object ^^^");
        return result.toJson();
    }


    int argc = argv.getSize();
    if((argc < 1) || (argc > 3))
    {
        result.setArgError("Wrong number of arguments");
        RAWLOG_ERROR1("Wrong number of arguments: %d ^^^", argc);
        return result.toJson();
    }
    
    if(argc > 1)
    {
        if(argc > 2)
            result.setCallBack(argv[1], argv[2]);
        else
            result.setCallBack(argv[1]);
    
        if(!result.hasCallBackUrl())
        {
            RAWLOG_ERROR("Error setting callback ^^^");
            return result.toJson();
        }
    }

    ObjectProxy::joinStrings(argumentsAdapter(argv), result); 
    rho::String res = 
        result.toJson();

    RAWTRACE2("%s(id=%s) end ^^^", __FUNCTION__, strObjID.c_str());
    return res;
}
コード例 #16
0
ファイル: Sensor_impl.cpp プロジェクト: Fr3eZer/rhodes
void CSensorImpl::setProperty(const rho::String& propertyName,  const rho::String& propertyValue, rho::apiGenerator::CMethodResult& oResult)
{
    LOG(TRACE) + "Received request to set property : " + m_sensorId + " : " + propertyName + " = " + propertyValue;
    if (NULL == m_rawSensor)
    {
        oResult.setError("No sensor found. Cannot set property " + propertyName);
    } else
    {
        if (_stricmp(propertyName.c_str(), "minimumGap") == 0)
        {
            int minimumGap = atoi(propertyValue.c_str());
            if (minimumGap < 200)
            {
                minimumGap = 200;
            }
            this->m_rawSensor->setMinimumGap(minimumGap);            
        } else
        {
            oResult.setError(propertyName + " is readonly or is invalid.");
        }
    }
}
コード例 #17
0
		static bool getArgValue( const rho::Hashtable<rho::String, rho::String>& args, const rho::String& newArgName, const rho::String& deprecatedArgName, rho::String& realArgValue ) {
			bool found = false;
			if ( args.containsKey(deprecatedArgName) ) {
				RAWLOG_WARNING2("'%s' argument is deprecated for search. Use '%s' instead.",deprecatedArgName.c_str(),newArgName.c_str());
				realArgValue = args.get(deprecatedArgName);
				found = true;
			}
			if ( args.containsKey(newArgName) ) {
				realArgValue = args.get(newArgName);
				found = true;
			}
			return found;
		}
コード例 #18
0
ファイル: Barcode1.cpp プロジェクト: kumarvegeta/rhodes
void CBarcode1::setDefaultID(const rho::String& id)
{
    RAWTRACE1("setDefaultID(id = \"%s\")", id.c_str());

    JNIEnv *env = jniInit();
    if (!env) {
        RAWLOG_ERROR("JNI initialization failed");
        return;
    }

    jhobject instance = getSingleton(env);
    jhstring jhId = rho_cast<jstring>(env, id);
    env->CallVoidMethod(instance.get(), s_midSetDefaultID, jhId.get());
}
コード例 #19
0
ファイル: Sensor_impl.cpp プロジェクト: Fr3eZer/rhodes
void CSensorImpl::getProperty(const rho::String& propertyName, rho::apiGenerator::CMethodResult& oResult)
{
    LOG(TRACE) + "Received request for get property : " + m_sensorId + " : " + propertyName;
    if (NULL == m_rawSensor)
    {
        oResult.setError("No sensor found. Cannot set " + propertyName);
    } else
    {
        if (_stricmp(propertyName.c_str(), "minimumGap") == 0)
        {
            oResult.set(this->m_rawSensor->getMinimumGap());
        } else if (_stricmp(propertyName.c_str(), "type") == 0)
        {
            oResult.set(this->m_rawSensor->getType());
        } else if (_stricmp(propertyName.c_str(), "status") == 0)
        {
            oResult.set(this->m_rawSensor->getStatus());
        } else
        {
            oResult.setError("Invalid attribute");
        }
    }
}
コード例 #20
0
ファイル: BundleUpdate.cpp プロジェクト: nhinze/rhodes
void callback_system_update_bundle(void *arg, rho::String const &strQuery)
{
    const char* s = strQuery.c_str();
    
    rho::String qURL = "";
    rho::String qServerIP = "";
    rho::String qServerPort = "";
    bool isRefresh = false;
    
    
    rho::common::CTokenizer oTokenizer(strQuery, "&");
    while (oTokenizer.hasMoreTokens())
    {
        rho::String tok = oTokenizer.nextToken();
        if (tok.length() == 0)
        continue;
        
        size_t nPos = tok.find("package_url=");
        if ( nPos != rho::String::npos )
        {
            qURL = strQuery.substr(nPos+12);
        }
        if ( rho::String_startsWith(tok, "package_url=") )
        {
            qURL = tok.substr(12);
        }else if ( rho::String_startsWith( tok, "server_ip=") )
        {
            qServerIP = tok.substr(10);
        }else if ( rho::String_startsWith( tok, "server_port=") )
        {
            qServerPort = tok.substr(12);
        }else if ( rho::String_startsWith( tok, "refresh_after_update=") )
        {
            rho::String srefresh = tok.substr(21);
            if ((srefresh.compare("false") != 0) && (srefresh.compare("0") != 0) && (srefresh.compare("FALSE") != 0)) {
                isRefresh = true;
            }
        }
    }

    rho::String our_responce_server_url = "http://";
    our_responce_server_url = our_responce_server_url + qServerIP + ":" + qServerPort + "/response_from_device";
    
    rho_http_sendresponse(arg, "");
    
    
    BundleUpdateThreadQueue::BUCommand* cmd = new BundleUpdateThreadQueue::BUCommand(qURL, our_responce_server_url, isRefresh);
    getBundleUpdateThreadQueueSignletone()->addQueueCommand(cmd);
    
}
コード例 #21
0
ファイル: HttpServer.cpp プロジェクト: kumarvegeta/rhodes
void CHttpServer::call_ruby_proc( rho::String const &query, String const &body )
{
    unsigned long valProc = 0;
    convertFromStringA( query.c_str(), valProc );

    HeaderList headers;
    headers.addElement(HttpHeader("Content-Type","application/x-www-form-urlencoded"));
    VALUE req = create_request_hash("", "", "", "", "POST", "", String(), headers, body);
    addHashToHash(req,"proc",valProc);

    VALUE data = callFramework(req);
    String strReply = String(getStringFromValue(data), getStringLenFromValue(data));
    rho_ruby_releaseValue(data);

    send_response(strReply);
}
コード例 #22
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;
 }
コード例 #23
0
rho::String js_s_Mpos_enumerate(const rho::String& strObjID, rho::json::CJSONArray& argv, const rho::String& strCallbackID, const rho::String& strJsVmID, const rho::String& strCallbackParam)
{
    RAWTRACE3("enumerate(strObjID = %s, strCallbackID = %s, strJsVmID = %s)", strObjID.c_str(), strCallbackID.c_str(), strJsVmID.c_str());

#ifdef OS_ANDROID
    if ( jnienv() == 0 )
    {
        rho_nativethread_start();
    }
#endif

    rho::apiGenerator::CMethodResult oRes;


    oRes.setParamName( "result" );
    oRes.setJSObjectClassPath( "Rho.Mpos" );
    oRes.setRequestedType(CMethodResult::eStringArray);

    rho::common::CInstanceClassFunctorBase<rho::apiGenerator::CMethodResult>* pFunctor = 0;
    int argc = argv.getSize();





    oRes.setCallInUIThread(false);
    oRes.setJSCallback( strCallbackID );
    oRes.setCallbackParam( strCallbackParam );



    if ( oRes.hasCallback() )
    {
        pFunctor = rho_makeInstanceClassFunctor1( rho::CMposFactoryBase::getMposSingletonS(), &rho::IMposSingleton::enumerate,  oRes );
        rho::CMposFactoryBase::getMposSingletonS()->addCommandToQueue( pFunctor );
    }
    else 
    {

        rho::CMposFactoryBase::getMposSingletonS()->enumerate(  oRes );
    }
    
    return oRes.toJSON();

}
コード例 #24
0
rho::String js_Mpos_getAllProperties(const rho::String& strObjID, rho::json::CJSONArray& argv, const rho::String& strCallbackID, const rho::String& strJsVmID, const rho::String& strCallbackParam)
{
    RAWTRACE3("getAllProperties(strObjID = %s, strCallbackID = %s, strJsVmID = %s)", strObjID.c_str(), strCallbackID.c_str(), strJsVmID.c_str());

#ifdef OS_ANDROID
    if ( jnienv() == 0 )
    {
        rho_nativethread_start();
    }
#endif

    rho::apiGenerator::CMethodResult oRes;


    oRes.setRequestedType(CMethodResult::eStringHash);

    rho::common::CInstanceClassFunctorBase<rho::apiGenerator::CMethodResult>* pFunctor = 0;
    int argc = argv.getSize();

    rho::IMpos* pObj = rho::CMposFactoryBase::getInstance()->getModuleByID(strObjID);





    oRes.setCallInUIThread(false);
    oRes.setJSCallback( strCallbackID );
    oRes.setCallbackParam( strCallbackParam );



    if ( oRes.hasCallback() )
    {
        pFunctor = rho_makeInstanceClassFunctor1( pObj, &rho::IMpos::getAllProperties,  oRes );
        rho::CMposFactoryBase::getMposSingletonS()->addCommandToQueue( pFunctor );
    }
    else 
    {

        pObj->getAllProperties(  oRes );
    }
    
    return oRes.toJSON();

}
コード例 #25
0
ファイル: LedImpl.cpp プロジェクト: Malisent/rhodes
	CLedImpl(const rho::String& strID): CLedBase()
    {
		RHODESAPP().getExtManager().registerExtension(("NFYLED" + strID), this );
		m_bAppHasFocus = true;
		m_iID = atoi(strID.c_str());
		m_bNotificationsLoaded = FALSE;
		m_pNotifications = new CNotificationLoader();
		m_eCurrentState = -1;
		if (m_pNotifications)
			m_bNotificationsLoaded = m_pNotifications->LoadNotificationDLL();
		if (!m_pNotifications || !m_bNotificationsLoaded)
			LOG(ERROR) + "Notification LED API is unavailable on this device, library could not be loaded";
		//  The id is the index in the vector of notification objects available in the EMDK
		//  find our index
		if (m_pNotifications && m_bNotificationsLoaded)
		{
			NOTIFY_FINDINFO notifyObject;
			HANDLE	hFindHandle = NULL;
			SI_ALLOC_ALL(&notifyObject);
			notifyObject.StructInfo.dwUsed = 0;
			if(m_pNotifications->lpfn_Notify_FindFirst(&notifyObject, &hFindHandle) == E_NTFY_SUCCESS)
			{
				int iObCount = 0;
				do 
				{
					if(iObCount == m_iID)
					{
						//  This is our LED
						m_szName = new WCHAR[wcslen(notifyObject.szObjectName) + 1];
						wcscpy(m_szName, notifyObject.szObjectName);
						break;
					}
					iObCount++;
					SI_ALLOC_ALL(&notifyObject);
					notifyObject.StructInfo.dwUsed = 0;
				} while(m_pNotifications->lpfn_Notify_FindNext(&notifyObject, hFindHandle) == E_NTFY_SUCCESS);
			}
			m_pNotifications->lpfn_Notify_FindClose(hFindHandle);
		}
    }
コード例 #26
0
ファイル: Sensor_impl.cpp プロジェクト: Fr3eZer/rhodes
CSensorImpl::CSensorImpl(const rho::String& strID) : CSensorBase(), m_rawSensor(NULL), m_callbackMethodResult(NULL)
{
    m_hashProps.put("ID", strID); //TODO: understand backgrounf
    if (SCM_MOTOROLA_SOLUTIONS == g_sensorChipManfacturer)
    {
        LOG(INFO) + "Initialising Motorola Sensor Interface for type " + strID;
        RHODESAPP().getExtManager().registerExtension((strID), this);
        // its a motorola sensor, use the motorola class
        sensormodule::CRawMotoSensor *rawSensor = new sensormodule::CRawMotoSensor(strID.c_str());
        if (NULL != rawSensor)
        {
            if (rawSensor->RegisterSensor(this))
            {
                m_rawSensor = rawSensor;
                m_sensorId = strID;
            }
            else
                delete rawSensor;
        }
    }

}
コード例 #27
0
ファイル: SystemImplBase.cpp プロジェクト: ihorsavka/rhodes
void CSystemImplBase::zipFile( const rho::String& localPathToZip,  const rho::String& localPathToFile,  const rho::String& password, CMethodResult& oResult)
{
    ZRESULT res;

#if defined(UNICODE) && defined(WIN32) && !defined(OS_WP8)
    rho::StringW strZipFilePathW;
    convertToStringW(localPathToZip.c_str(), strZipFilePathW);

    CFilePath oPath(localPathToFile);
    rho::StringW strFileNameW;
    convertToStringW(oPath.getBaseName(), strFileNameW);

    rho::StringW strToZipPathW;
    convertToStringW(localPathToFile.c_str(), strToZipPathW);

    HZIP hz = CreateZip(strZipFilePathW.c_str(), password.c_str());
    if ( !hz )
        res = -1;
    else
    {
        res = ZipAdd( hz, strFileNameW.c_str(), strToZipPathW.c_str() );

        res = CloseZip(hz);
    }

#else
    HZIP hz = CreateZip((TCHAR*)localPathToZip.c_str(), password.c_str());
    if(!hz)
    {
        res = -1;
    } else
    {
        CFilePath oPath(localPathToFile);
        res = ZipAdd(hz, (TCHAR*)oPath.getBaseName(), (TCHAR*)localPathToFile.c_str());
        res = CloseZip(hz);
    }
#endif

    oResult.set(res);
}
コード例 #28
0
ファイル: BundleUpdate.cpp プロジェクト: nhinze/rhodes
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;
    }
}
コード例 #29
0
ファイル: rhodes.cpp プロジェクト: bkumar/rhodes
const char* rho_native_rhopath()
{
    return g_rootPath.c_str();
}
コード例 #30
0
ファイル: Rhodes.cpp プロジェクト: parrotbait/rhodes
// 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 CRhodesModule::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.

#if !defined(OS_WINDOWS_DESKTOP)
    SetLastError(0);
    HANDLE hEvent = CreateEvent( NULL, false, false, CMainWindow::GetWndClassInfo().m_wc.lpszClassName );

    if ( !m_bRestarting && hEvent != NULL && GetLastError() == ERROR_ALREADY_EXISTS)
    {
        // Rho Running so could bring to foreground
        HWND hWnd = FindWindow(CMainWindow::GetWndClassInfo().m_wc.lpszClassName, NULL);

        if (hWnd)
        {
            ShowWindow(hWnd, SW_SHOW);
            SendMessage( hWnd, PB_WINDOW_RESTORE, NULL, TRUE);
            SetForegroundWindow( hWnd );

            COPYDATASTRUCT cds = {0};
            cds.cbData = m_strTabName.length()+1;
            cds.lpData = (char*)m_strTabName.c_str();
            SendMessage( hWnd, WM_COPYDATA, (WPARAM)WM_WINDOW_SWITCHTAB, (LPARAM)(LPVOID)&cds);
        }

        return S_FALSE;
    }
#endif

    if ( !rho_sys_check_rollback_bundle(rho_native_rhopath()) )
    {
        rho_sys_impl_exit_with_errormessage( "Bundle update", "Application is corrupted. Reinstall it, please.");
        return S_FALSE;
    }

#if defined(APP_BUILD_CAPABILITY_SHARED_RUNTIME)
    rho_logconf_Init((rho_wmimpl_get_logpath()[0]==0 ? m_strRootPath.c_str() : rho_wmimpl_get_logpath()), m_strRootPath.c_str(), m_logPort.c_str());
    if (rho_wmimpl_get_logurl()[0]!=0)
        LOGCONF().setLogURL(rho_wmimpl_get_logurl());
    if (rho_wmimpl_get_logmaxsize())
        LOGCONF().setMaxLogFileSize(*rho_wmimpl_get_logmaxsize());
    if (rho_wmimpl_get_loglevel())
        LOGCONF().setMinSeverity(*rho_wmimpl_get_loglevel());
    if (rho_wmimpl_get_fullscreen())
        RHOCONF().setBool("full_screen", true, false);
    if (rho_wmimpl_get_logmemperiod())
        LOGCONF().setCollectMemoryInfoInterval(*rho_wmimpl_get_logmemperiod());
#else
    rho_logconf_Init(m_strRootPath.c_str(), m_strRootPath.c_str(), m_logPort.c_str());
#endif // APP_BUILD_CAPABILITY_SHARED_RUNTIME

    LOGCONF().setMemoryInfoCollector(CLogMemory::getInstance());

#ifdef RHODES_EMULATOR
    RHOSIMCONF().setAppConfFilePath(CFilePath::join( m_strRootPath, RHO_EMULATOR_DIR"/rhosimconfig.txt").c_str());
    RHOSIMCONF().loadFromFile();
    if ( m_strRhodesPath.length() > 0 )
        RHOSIMCONF().setString("rhodes_path", m_strRhodesPath, false );
    RHOCONF().setString("rhosim_platform", RHOSIMCONF().getString("platform"), false);
    RHOCONF().setString("app_version", RHOSIMCONF().getString("app_version"), false);
	String start_path = RHOSIMCONF().getString("start_path");
    if ( start_path.length() > 0 )
	    RHOCONF().setString("start_path", start_path, false);
    RHOSIMCONF().setString("ext_path", RHOSIMCONF().getString("ext_path") + CFilePath::join( m_strRhodesPath, "/lib/extensions/debugger;"), false);
    RHOSIMCONF().setString("ext_path", RHOSIMCONF().getString("ext_path") + CFilePath::join( m_strRhodesPath, "/lib/extensions/uri;"), false);
    RHOSIMCONF().setString("ext_path", RHOSIMCONF().getString("ext_path") + CFilePath::join( m_strRhodesPath, "/lib/extensions/timeout;"), false);
    RHOSIMCONF().setString("ext_path", RHOSIMCONF().getString("ext_path") + CFilePath::join( m_strRhodesPath, "/lib/extensions/digest;"), false);
    RHOSIMCONF().setString("ext_path", RHOSIMCONF().getString("ext_path") + CFilePath::join( m_strRhodesPath, "/lib/extensions/openssl;"), false);
#endif

    if ( !rho_rhodesapp_canstartapp(g_strCmdLine.c_str(), " /-,") )
    {
		LOG(INFO) + "This is hidden app and can be started only with security key.";
		if (RHOCONF().getString("invalid_security_token_start_path").length() <= 0)
        {
#ifdef OS_WINDOWS_DESKTOP
	    ::MessageBoxW(0, L"This is hidden app and can be started only with security key.", L"Security Token Verification Failed", MB_ICONERROR | MB_OK);
#endif
			return S_FALSE;
        }
    }

	LOG(INFO) + "Rhodes started";
#ifdef OS_WINDOWS_DESKTOP
	if (m_strHttpProxy.length() > 0) {
		parseHttpProxyURI(m_strHttpProxy);
	} else
#endif
	{
		if (RHOCONF().isExist("http_proxy_url")) {
			parseHttpProxyURI(RHOCONF().getString("http_proxy_url"));
#if defined(OS_WINDOWS_DESKTOP) || defined(RHODES_EMULATOR)
		} else {
			// it's important to call this method from here to perform
			// a proper initialization of proxy implementation for Win32
			GetAppWindow().setProxy();
#endif
		}
	}

#ifdef RHODES_EMULATOR
    if (RHOSIMCONF().getString("debug_host").length() > 0)
        SetEnvironmentVariableA("RHOHOST", RHOSIMCONF().getString("debug_host").c_str() );
    if (RHOSIMCONF().getString("debug_port").length() > 0)
        SetEnvironmentVariableA("rho_debug_port", RHOSIMCONF().getString("debug_port").c_str() );
#endif

	//Check for bundle directory is exists.
	HANDLE hFind;
	WIN32_FIND_DATA wfd;
	
	// rootpath + "rho/"
	if (m_strRootPath.at(m_strRootPath.length()-1) == '/') 
    {
		hFind = FindFirstFile(convertToStringW(m_strRootPath.substr(0, m_strRootPath.find_last_of('/'))).c_str(), &wfd);
	} 
    else if (m_strRootPath.at(m_strRootPath.length()-1) == '\\') 
    {
		//delete all '\' from the end of the pathname
		int i = m_strRootPath.length();
		for ( ; i != 1; i--) {
			if (m_strRootPath.at(i-1) != '\\')
				break;
		}

		hFind = FindFirstFile(convertToStringW(m_strRootPath.substr(0, i)).c_str(), &wfd);
	}

	if (INVALID_HANDLE_VALUE == hFind || !(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) 
    {
		int last = 0, pre_last = 0;
		last = getRhoRootPath().find_last_of('\\');
		pre_last = getRhoRootPath().substr(0, last).find_last_of('\\');
		String appName = getRhoRootPath().substr(pre_last + 1, last - pre_last - 1);

		String messageText = "Bundle directory \"" + 
								m_strRootPath.substr(0, m_strRootPath.find_last_of('/')) + 
								"\" is  missing\n";

		LOG(INFO) + messageText;
		int msgboxID = MessageBox(NULL,
									convertToStringW(messageText).c_str(),
									convertToStringW(appName).c_str(),
									MB_ICONERROR | MB_OK);


		return S_FALSE;
    }

    if (RHOCONF().getBool("Application.autoStart"))
        createAutoStartShortcut();

    rho::common::CRhodesApp::Create(m_strRootPath, m_strRootPath, m_strRuntimePath);

    bool bRE1App = false;

#if defined(APP_BUILD_CAPABILITY_SHARED_RUNTIME)
    if (!rho_wmimpl_get_is_version2())
        bRE1App = true;
#endif

    RHODESAPP().setJSApplication(bRE1App || _AtlModule.isJSApplication());

#if defined(APP_BUILD_CAPABILITY_SHARED_RUNTIME)
    if ((!rho_wmimpl_get_is_version2()) && (rho_wmimpl_get_startpage()[0] != 0)) {
        String spath = convertToStringA(rho_wmimpl_get_startpage());
        RHOCONF().setString("start_path", spath, false);
    }
#endif // APP_BUILD_CAPABILITY_SHARED_RUNTIME

    DWORD dwStyle = m_bMinimized ? 0 : WS_VISIBLE;

#ifdef OS_WINCE
    m_appWindow.getTabbar().SetStartTabName(m_strTabName);
#else
    m_appWindow.setStartTabName(m_strTabName);
#endif

#if !defined(_WIN32_WCE)
    dwStyle |= WS_OVERLAPPEDWINDOW;
#endif
    // Create the main application window
#if defined(OS_WINDOWS_DESKTOP)
#ifdef RHODES_EMULATOR
    StringW windowTitle = convertToStringW(RHOSIMCONF().getString("app_name"));
#else
    StringW windowTitle = convertToStringW(RHODESAPP().getAppTitle());
#endif
    m_appWindow.Initialize(windowTitle.c_str());
    if (NULL == m_appWindow.m_hWnd)
    {
        return S_FALSE;
    }
    if (m_bMinimized)
        nShowCmd = SW_MINIMIZE;

    m_appWindow.ShowWindow(nShowCmd);

#else
    String strTitle = RHODESAPP().getAppTitle();
    m_appWindow.Create(NULL, CWindow::rcDefault, convertToStringW(strTitle).c_str(), dwStyle);

    if (NULL == m_appWindow.m_hWnd)
    {
        return S_FALSE;
    }

    m_appWindow.InvalidateRect(NULL, TRUE);
    m_appWindow.UpdateWindow();

    m_appWindow.initBrowserWindow();

    if (m_bMinimized)
        m_appWindow.ShowWindow(SW_MINIMIZE);
#endif

/*
    if (bRE1App)
    {
#if defined(APP_BUILD_CAPABILITY_MOTOROLA)
        registerRhoExtension();
#endif

#if !defined( APP_BUILD_CAPABILITY_WEBKIT_BROWSER ) && defined(OS_WINCE)
	    m_appWindow.Navigate2(_T("about:blank"), -1 );
#endif //!APP_BUILD_CAPABILITY_WEBKIT_BROWSER

        rho_webview_navigate(RHOCONF().getString("start_path").c_str(), 0 );
    }
    else
    { */
        RHODESAPP().startApp();

#if !defined( APP_BUILD_CAPABILITY_WEBKIT_BROWSER ) && defined(OS_WINCE)
        // Navigate to the "loading..." page
	    m_appWindow.Navigate2(_T("about:blank"), -1 );
#endif //APP_BUILD_CAPABILITY_WEBKIT_BROWSER
    //}

#if defined(_WIN32_WCE)&& !defined( OS_PLATFORM_MOTCE )

    DWORD dwConnCount = 0;
    hr = RegistryGetDWORD( SN_CONNECTIONSNETWORKCOUNT_ROOT,
		SN_CONNECTIONSNETWORKCOUNT_PATH, 
		SN_CONNECTIONSNETWORKCOUNT_VALUE, 
        &dwConnCount
    );
    rho_sysimpl_sethas_network((dwConnCount > 1) ? 1 : 0);

    DWORD dwCellConnected = 0;
    hr = RegistryGetDWORD( SN_CONNECTIONSNETWORKCOUNT_ROOT,
		SN_CELLSYSTEMCONNECTED_PATH, 
		SN_CELLSYSTEMCONNECTED_VALUE, 
        &dwCellConnected
    );
    rho_sysimpl_sethas_cellnetwork(dwCellConnected);

	// 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);

	hr = RegistryNotifyWindow(SN_CONNECTIONSNETWORKCOUNT_ROOT,
		SN_CELLSYSTEMCONNECTED_PATH, 
		SN_CELLSYSTEMCONNECTED_VALUE, 
		m_appWindow.m_hWnd, 
		WM_CONNECTIONSNETWORKCELL, 
		0, 
		NULL, 
		&g_hNotifyCell);

#endif

    return S_OK;
}