Exemplo n.º 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;
}
Exemplo n.º 2
0
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();
}
Exemplo n.º 3
0
const rho::String& CRhodesModule::getRhoRuntimePath()
{
    if ( m_strRuntimePath.length() == 0 )
    {
        char rootpath[MAX_PATH];
        int len;
        if ( (len = GetModuleFileNameA(NULL,rootpath,MAX_PATH)) == 0 )
            strcpy(rootpath,".");
        else
        {
            while( !(rootpath[len] == '\\'  || rootpath[len] == '/') )
              len--;
            rootpath[len+1]=0;
        }

        m_strRuntimePath = rootpath;
        m_strRuntimePath += "rho\\";

        for(unsigned int i = 0; i < m_strRuntimePath.length(); i++ )
            if ( m_strRuntimePath.at(i) == '\\' )
                m_strRuntimePath[i] = '/';
    }

    return m_strRuntimePath; 
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
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

}
Exemplo n.º 6
0
    virtual void relativeDatabaseBlobFilePath( const rho::String& absolutePath, rho::apiGenerator::CMethodResult& oResult)
    {
        String dbRootFolder = CFilePath::join( rho_native_rhodbpath(), RHO_EMULATOR_DIR);

        if ( String_startsWith(absolutePath, "file://") )
            dbRootFolder = "file://" + dbRootFolder;

        if ( String_startsWith(absolutePath, dbRootFolder) )
            oResult.set( absolutePath.substr( dbRootFolder.length(), absolutePath.length()-dbRootFolder.length()) );
        else
            oResult.set( absolutePath );
    }
Exemplo n.º 7
0
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);
    
}
Exemplo n.º 8
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();

}
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());
	}
}
Exemplo n.º 10
0
const rho::String& CRhodesModule::getAppName()
{
    if ( m_strAppName.length() == 0 )
    {
#if defined(APP_BUILD_CAPABILITY_SHARED_RUNTIME)
        bool bRE1App = false;
        if (!rho_wmimpl_get_is_version2())
            bRE1App = true;
        if ( bRE1App )
            m_strAppName = convertToStringA( rho_wmimpl_sharedconfig_getvalue( L"General\\Name" ) );
        else
        {
            String path = getRhoRootPath();
            String_replace(path, '/', '\\');

            int nEnd = path.find_last_of('\\');
            nEnd = path.find_last_of('\\', nEnd-1)-1;

            int nStart = path.find_last_of('\\', nEnd) +1;
            m_strAppName = path.substr( nStart, nEnd-nStart+1);
        }
#else
        m_strAppName = get_app_build_config_item("name");
#endif
    }

    return m_strAppName;
}
Exemplo n.º 11
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();

}
Exemplo n.º 12
0
const rho::String& CRhodesModule::getRhoRootPath()
{
    if ( m_strRootPath.length() == 0 )
        m_strRootPath = getRhoRuntimePath();

    return m_strRootPath;
}
Exemplo n.º 13
0
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);
}
Exemplo n.º 14
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.º 15
0
    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
    }
Exemplo n.º 16
0
EBrowserEngineType BrowserFactory::convertBrowserType(rho::String browserType)
{
    rho::String browserTypeTag;
    
    std::transform(browserType.begin(), browserType.end(), 
        std::back_inserter(browserTypeTag), ::tolower);

    if (browserTypeTag == String(IETag))
    {
        return eIE;
    }
    else if (browserTypeTag == String(webkitTag))
    {
        return eWebkit;
    }

    return eNone;
}
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;
}
Exemplo n.º 18
0
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 );
}
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;
}
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;
}
Exemplo n.º 21
0
 virtual void setFilePath( const rho::String& value, rho::apiGenerator::CMethodResult& oResult)
 {
     if (value.size() > 0)
     {
         LOGCONF().setLogFilePath(value);
     }
     else
     {
         oResult.setArgError("Log: Empty file path");
     }
 }
Exemplo n.º 22
0
void CSystemImplBase::setPushNotification( const rho::String& url,  const rho::String& url_params,  const rho::String& push_client, rho::apiGenerator::CMethodResult& oResult)
{
    String strTypes = push_client.length() > 0 ? push_client : "default";

    String item;
    String::size_type pos = 0;

    while (String_getline(strTypes, item, pos, ';')) {
        RHODESAPP().setPushNotification( url, url_params, item);
    }
}
Exemplo n.º 23
0
//--------------------------------------------------------------------------------------------------
rho::String rho_log_path()
{
    if (!s_log_path.empty())
    {
        return s_log_path;
    }
    else
    {
        return s_root_path;
    }
}
Exemplo n.º 24
0
	// Play an audio file.
	virtual void start( const rho::String& filename, rho::apiGenerator::CMethodResult& oResult)
	{
		// Check that the filename is not empty or NULL.
		if (!filename.empty() && (!m_hPlayThread))
		{
			// Store the local filename away.
			//common::convertToStringW(filename, lFilename);
			lFilename = s2ws(filename);

			// Launch the audio player.
			playLocalAudio();
		}
	}
Exemplo n.º 25
0
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.");
        }
    }
}
		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;
		}
Exemplo n.º 27
0
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);
	}
}
Exemplo n.º 28
0
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");
        }
    }
}
Exemplo n.º 29
0
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());
}
Exemplo n.º 30
0
bool CNetworkDetectionBase::SetHost(const rho::String& szHost)
{
	if (szHost.length() > 7 && szHost.compare(0, 7, "http://") == 0)
		m_szHost = szHost.substr(7);
	else if (szHost.length() > 8 && szHost.compare(0, 8, "https://") == 0)
		m_szHost = szHost.substr(8);
	else
		m_szHost = szHost;
	return true;
}