示例#1
0
void NotificationSound::beep(const rho::Hashtable<rho::String, rho::String> &propertyMap)
{
    int mseconds = 1000;
    if (propertyMap.containsKey("duration")){
        QString propDur(propertyMap.get("duration").c_str());
        quint32 value = propDur.toUInt();
        mseconds = value ? value : mseconds;
    }

    int frequency = 2000;
    if (propertyMap.containsKey("frequency")){
        QString propFreq(propertyMap.get("frequency").c_str());
        quint32 value = propFreq.toUInt();
        frequency = value ? value : frequency;
    }

    int volume = 1;
    if (propertyMap.containsKey("volume")){
        QString propVol(propertyMap.get("volume").c_str());
        quint32 value = propVol.toUInt();
        volume = value ? value : volume;
    }

    NotificationSound * sound = new NotificationSound(frequency,mseconds,volume);
    sound->run();

}
示例#2
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 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;
		}
void RhoConnectClientImpl::search( const rho::Hashtable<rho::String, rho::String>& args, rho::apiGenerator::CMethodResult& oResult) {
	getSyncThread()->stopAll();

	bool syncChanges = false;
	int progressStep = -1;
	rho::Vector<rho::String> sources;
	rho::String searchParams;
	rho::String from = "search";
	
	/* handle old-style callback setting */
	if (args.containsKey("callback")) {
		oResult.setRubyCallback(args.get("callback"));
        
        if (args.containsKey("callback_param")) {
            oResult.setCallbackParam(args.get("callback_param"));
        }
	}
		
	if (args.containsKey("from") ) {
		from = args.get("from");
	}
	
	/*this will return new arg value, overriding deprecated one, if it is present*/
	struct DeprecatedArgsHandler {
		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;
		}
	};
	
	
	String jsonSources;
	if ( DeprecatedArgsHandler::getArgValue(args,"sourceNames","source_names",jsonSources) ) {
		rho::json::CJSONEntry json(jsonSources.c_str());
		if ( json.isArray() ) {
			for( rho::json::CJSONArrayIterator array(json); !array.isEnd(); array.next()) {
				sources.push_back( array.getCurItem().getString() );
			}
		}
	}

	if (args.containsKey("offset")) {
		searchParams += "&offset=" + rho::net::URI::urlEncode(args.get("offset"));
	}
	
	rho::String maxResults;
	if ( DeprecatedArgsHandler::getArgValue(args,"maxResults","max_results",maxResults) ) {
		searchParams += "&max_results=" + rho::net::URI::urlEncode(maxResults);
	}
	
	
	rho::String jsonSearchParams;
	if ( DeprecatedArgsHandler::getArgValue(args,"searchParams","search_params",jsonSearchParams) ) {
		rho::json::CJSONEntry json(jsonSearchParams.c_str());
		if ( json.isObject() ) {
			for ( rho::json::CJSONStructIterator obj(json); !obj.isEnd(); obj.next() ) {
				rho::String key = rho::net::URI::urlEncode(obj.getCurKey());
				rho::String value = rho::net::URI::urlEncode(obj.getCurValue().getString());
				
				searchParams += "&search[" + key + "]=" + value;
			}
		}
	}
	
	rho::String strSyncChanges;
	if ( DeprecatedArgsHandler::getArgValue(args,"syncChanges","sync_changes",strSyncChanges) ) {
		syncChanges = (strSyncChanges=="true") || (strSyncChanges=="1");
	}
	
	rho::String strProgressStep;
	if ( DeprecatedArgsHandler::getArgValue(args,"progressStep","progress_step",strProgressStep) ) {
		progressStep = atoi(strProgressStep.c_str());
	}

	getSyncEngine().getNotify().setSearchNotification( new sync::CSyncNotification(oResult, true) );
	getSyncThread()->addQueueCommand(new sync::CSyncThread::CSyncSearchCommand(from,searchParams,sources,syncChanges,progressStep) );
		
	handleSyncResult(oResult);
}