String open (const BigInteger& inputChannels, const BigInteger& outputChannels,
                 double sampleRate, int bufferSizeSamples)
    {
        if (client == 0)
        {
            lastError = "No JACK client running";
            return lastError;
        }

        lastError = String::empty;
        close();

        juce::jack_set_process_callback (client, processCallback, this);
        juce::jack_on_shutdown (client, shutdownCallback, this);
        juce::jack_activate (client);
        isOpen_ = true;

        if (! inputChannels.isZero())
        {
            const char** const ports = juce::jack_get_ports (client, 0, 0, /* JackPortIsPhysical | */ JackPortIsOutput);

            if (ports != 0)
            {
                const int numInputChannels = inputChannels.getHighestBit() + 1;

                for (int i = 0; i < numInputChannels; ++i)
                {
                    const String portName (ports[i]);

                    if (inputChannels[i] && portName.upToFirstOccurrenceOf (":", false, false) == getName())
                    {
                        int error = juce::jack_connect (client, ports[i], juce::jack_port_name ((jack_port_t*) inputPorts[i]));
                        if (error != 0)
                            jack_Log ("Cannot connect input port " + String (i) + " (" + String (ports[i]) + "), error " + String (error));
                    }
                }

                free (ports);
            }
        }

        if (! outputChannels.isZero())
        {
            const char** const ports = juce::jack_get_ports (client, 0, 0, /* JackPortIsPhysical | */ JackPortIsInput);

            if (ports != 0)
            {
                const int numOutputChannels = outputChannels.getHighestBit() + 1;

                for (int i = 0; i < numOutputChannels; ++i)
                {
                    const String portName (ports[i]);

                    if (outputChannels[i] && portName.upToFirstOccurrenceOf (":", false, false) == getName())
                    {
                        int error = juce::jack_connect (client, juce::jack_port_name ((jack_port_t*) outputPorts[i]), ports[i]);
                        if (error != 0)
                            jack_Log ("Cannot connect output port " + String (i) + " (" + String (ports[i]) + "), error " + String (error));
                    }
                }

                free (ports);
            }
        }

        return lastError;
    }
Esempio n. 2
0
static String _get_data_dir() {

	JNIEnv *env = ThreadAndroid::get_env();
	jstring s =(jstring)env->CallObjectMethod(godot_io,_getDataDir);
	return String(env->GetStringUTFChars( s, NULL ));
}
Esempio n. 3
0
bool SVGRenderBase::prepareToRenderSVGContent(RenderObject* object, RenderObject::PaintInfo& paintInfo, const FloatRect& repaintRect, SVGResourceFilter*& filter, SVGResourceFilter* rootFilter)
{
#if !ENABLE(FILTERS)
    UNUSED_PARAM(filter);
    UNUSED_PARAM(rootFilter);
#endif

    ASSERT(object);
    SVGElement* svgElement = static_cast<SVGElement*>(object->node());
    ASSERT(svgElement && svgElement->document() && svgElement->isStyled());

    SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(svgElement);
    const RenderStyle* style = object->style();
    ASSERT(style);

    const SVGRenderStyle* svgStyle = style->svgStyle();
    ASSERT(svgStyle);

    // Setup transparency layers before setting up filters!
    float opacity = style->opacity();
    if (opacity < 1.0f) {
        paintInfo.context->clip(repaintRect);
        paintInfo.context->beginTransparencyLayer(opacity);
    }

    if (ShadowData* shadow = svgStyle->shadow()) {
        paintInfo.context->clip(repaintRect);
        paintInfo.context->setShadow(IntSize(shadow->x, shadow->y), shadow->blur, shadow->color, style->colorSpace());
        paintInfo.context->beginTransparencyLayer(1.0f);
    }

#if ENABLE(FILTERS)
    AtomicString filterId(svgStyle->filter());
#endif

    AtomicString clipperId(svgStyle->clipPath());
    AtomicString maskerId(svgStyle->maskElement());

    Document* document = object->document();

#if ENABLE(FILTERS)
    SVGResourceFilter* newFilter = getFilterById(document, filterId, object);
    if (newFilter == rootFilter) {
        // Catch <text filter="url(#foo)">Test<tspan filter="url(#foo)">123</tspan></text>.
        // The filter is NOT meant to be applied twice in that case!
        filter = 0;
        filterId = String();
    } else
        filter = newFilter;
#endif

    SVGResourceClipper* clipper = getClipperById(document, clipperId, object);
    SVGResourceMasker* masker = getMaskerById(document, maskerId, object);

    if (masker) {
        masker->addClient(styledElement);
        if (!masker->applyMask(paintInfo.context, object))
            return false;
    } else if (!maskerId.isEmpty())
        svgElement->document()->accessSVGExtensions()->addPendingResource(maskerId, styledElement);

    if (clipper) {
        clipper->addClient(styledElement);
        clipper->applyClip(paintInfo.context, object->objectBoundingBox());
    } else if (!clipperId.isEmpty())
        svgElement->document()->accessSVGExtensions()->addPendingResource(clipperId, styledElement);

#if ENABLE(FILTERS)
    if (filter) {
        filter->addClient(styledElement);
        if (!filter->prepareFilter(paintInfo.context, object))
            return false;
    } else if (!filterId.isEmpty())
        svgElement->document()->accessSVGExtensions()->addPendingResource(filterId, styledElement);
#endif

    return true;
}
String VisualScriptReturn::get_output_sequence_port_text(int p_port) const {

	return String();
}
Esempio n. 5
0
Variant _jobject_to_variant(JNIEnv * env, jobject obj) {

	jclass c = env->GetObjectClass(obj);
	bool array;
	String name = _get_class_name(env, c, &array);
	//print_line("name is " + name + ", array "+Variant(array));

	if (name == "java.lang.String") {

		return String::utf8(env->GetStringUTFChars( (jstring)obj, NULL ));
	};


	if (name == "[Ljava.lang.String;") {

		jobjectArray arr = (jobjectArray)obj;
		int stringCount = env->GetArrayLength(arr);
		//print_line("String array! " + String::num(stringCount));
		DVector<String> sarr;

		for (int i=0; i<stringCount; i++) {
			jstring string = (jstring) env->GetObjectArrayElement(arr, i);
			const char *rawString = env->GetStringUTFChars(string, 0);
			sarr.push_back(String(rawString));
		}

		return sarr;
	};

	if (name == "java.lang.Boolean") {

		jmethodID boolValue = env->GetMethodID(c, "booleanValue", "()Z");
		bool ret = env->CallBooleanMethod(obj, boolValue);
		return ret;
	};

	if (name == "java.lang.Integer") {

		jclass nclass = env->FindClass("java/lang/Number");
		jmethodID intValue = env->GetMethodID(nclass, "intValue", "()I");
		int ret = env->CallIntMethod(obj, intValue);
		return ret;
	};

	if (name == "[I") {

		jintArray arr = (jintArray)obj;
		int fCount = env->GetArrayLength(arr);
		DVector<int> sarr;
		sarr.resize(fCount);

		DVector<int>::Write w = sarr.write();
		env->GetIntArrayRegion(arr,0,fCount,w.ptr());
		w = DVector<int>::Write();
		return sarr;
	};

	if (name == "[B") {

		jbyteArray arr = (jbyteArray)obj;
		int fCount = env->GetArrayLength(arr);
		DVector<uint8_t> sarr;
		sarr.resize(fCount);

		DVector<uint8_t>::Write w = sarr.write();
		env->GetByteArrayRegion(arr,0,fCount,reinterpret_cast<signed char*>(w.ptr()));
		w = DVector<uint8_t>::Write();
		return sarr;
	};

	if (name == "java.lang.Float" || name == "java.lang.Double") {

		jclass nclass = env->FindClass("java/lang/Number");
		jmethodID doubleValue = env->GetMethodID(nclass, "doubleValue", "()D");
		double ret = env->CallDoubleMethod(obj, doubleValue);
		return ret;
	};

	if (name == "[D") {

		jdoubleArray arr = (jdoubleArray)obj;
		int fCount = env->GetArrayLength(arr);
		RealArray sarr;
		sarr.resize(fCount);

		RealArray::Write w = sarr.write();

		for (int i=0; i<fCount; i++) {

			double n;
			env->GetDoubleArrayRegion(arr, i, 1, &n);
			w.ptr()[i] = n;

		};
		return sarr;
	};

	if (name == "[F") {

		jfloatArray arr = (jfloatArray)obj;
		int fCount = env->GetArrayLength(arr);
		RealArray sarr;
		sarr.resize(fCount);


		RealArray::Write w = sarr.write();

		for (int i=0; i<fCount; i++) {

			float n;
			env->GetFloatArrayRegion(arr, i, 1, &n);
			w.ptr()[i] = n;

		};
		return sarr;
	};


	if (name == "[Ljava.lang.Object;") {

		jobjectArray arr = (jobjectArray)obj;
		int objCount = env->GetArrayLength(arr);
		Array varr;

		for (int i=0; i<objCount; i++) {
			jobject jobj = env->GetObjectArrayElement(arr, i);
			Variant v = _jobject_to_variant(env, jobj);
			varr.push_back(v);
		}

		return varr;
	};

	if (name == "com.android.godot.Dictionary") {

		Dictionary ret;
		jclass oclass = c;
		jmethodID get_keys = env->GetMethodID(oclass, "get_keys", "()[Ljava/lang/String;");
		jobjectArray arr = (jobjectArray)env->CallObjectMethod(obj, get_keys);

		StringArray keys = _jobject_to_variant(env, arr);

		jmethodID get_values = env->GetMethodID(oclass, "get_values", "()[Ljava/lang/Object;");
		arr = (jobjectArray)env->CallObjectMethod(obj, get_values);

		Array vals = _jobject_to_variant(env, arr);

		//print_line("adding " + String::num(keys.size()) + " to Dictionary!");
		for (int i=0; i<keys.size(); i++) {

			ret[keys[i]] = vals[i];
		};

		return ret;
	};

	return Variant();
};
Esempio n. 6
0
void SubString::printOn(ostream& strm) const
// Print this SubString on output stream strm.
{
        strm << String(*this);
}
Esempio n. 7
0
int
hstcpcli::response_recv(size_t& num_flds_r)
{
  if (error_code < 0) {
    return error_code;
  }
  clear_error();
  if (num_req_bufd > 0 || num_req_sent == 0 || num_req_rcvd > 0 ||
    response_end_offset != 0) {
    close();
    return set_error(-1, "response_recv: protocol out of sync");
  }
  cur_row_offset = 0;
  num_flds_r = num_flds = 0;
  if (fd.get() < 0) {
    return set_error(-1, "read: closed");
  }
  size_t offset = 0;
  while (true) {
    const char *const lbegin = readbuf.begin() + offset;
    const char *const lend = readbuf.end();
    if (lbegin < lend)
    {
      const char *const nl = memchr_char(lbegin, '\n', lend - lbegin);
      if (nl != 0) {
        offset += (nl + 1) - lbegin;
        break;
      }
      offset += lend - lbegin;
    }
    if (read_more() <= 0) {
      close();
      error_code = -1;
      return error_code;
    }
  }
  response_end_offset = offset;
  --num_req_sent;
  ++num_req_rcvd;
  char *start = readbuf.begin();
  char *const finish = start + response_end_offset - 1;
  const size_t resp_code = read_ui32(start, finish);
  skip_one(start, finish);
  num_flds_r = num_flds = read_ui32(start, finish);
  if (resp_code != 0) {
    skip_one(start, finish);
    char *const err_begin = start;
    read_token(start, finish);
    char *const err_end = start;
    String e = String(err_begin, err_end - err_begin, &my_charset_bin);
    if (!e.length()) {
      e = String("unknown_error", &my_charset_bin);
    }
    return set_error(resp_code, e);
  }
  cur_row_offset = start - readbuf.begin();
  DBG(fprintf(stderr, "[%s] ro=%zu eol=%zu\n",
    String(readbuf.begin(), readbuf.begin() + response_end_offset)
      .c_str(),
    cur_row_offset, response_end_offset));
  DBG(fprintf(stderr, "RES 0\n"));
  if (flds.max_element < num_flds)
  {
    if (allocate_dynamic(&flds, num_flds))
      return set_error(-1, "out of memory");
  }
  flds.elements = num_flds;
  return 0;
}
Esempio n. 8
0
String NumberInputType::serialize(const Decimal& value) const
{
    if (!value.isFinite())
        return String();
    return serializeForNumberType(value);
}
String RenderThemeChromiumAndroid::extraMediaControlsStyleSheet()
{
    return String(mediaControlsAndroidUserAgentStyleSheet, sizeof(mediaControlsAndroidUserAgentStyleSheet));
}
Esempio n. 10
0
BOOLEAN ExecuteGameEvent( EVENT *pEvent )
{
	SOLDIERTYPE		*pSoldier;

	// Switch on event type
	switch( pEvent->uiEvent )
	{
			case E_PLAYSOUND:

				memcpy( &EPlaySound, pEvent->pData, pEvent->uiDataSize );

				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Play Sound");
				PlayJA2Sample( EPlaySound.usIndex, EPlaySound.usRate, EPlaySound.ubVolume, EPlaySound.ubLoops, EPlaySound.uiPan );
				break;

			case S_CHANGESTATE:

				memcpy( &SChangeState, pEvent->pData, pEvent->uiDataSize );

				// Get soldier pointer from ID
				if ( GetSoldier( &pSoldier, SChangeState.usSoldierID ) == FALSE )
				{
					// Handle Error?
					DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Invalid Soldier ID");
					break;
				}

				// check for error
				if( pSoldier->uiUniqueSoldierIdValue != SChangeState.uiUniqueId )
				{
					break;
				}

				// Call soldier function
//				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Event Pump: ChangeState %S (%d)", gAnimControl[ SChangeState.ubNewState ].zAnimStr, SChangeState.usSoldierID ) );
				pSoldier->EVENT_InitNewSoldierAnim( SChangeState.usNewState, SChangeState.usStartingAniCode, SChangeState.fForce );
				break;

			case S_CHANGEDEST:

				memcpy( &SChangeDest, pEvent->pData, pEvent->uiDataSize );

				// Get soldier pointer from ID
				if ( GetSoldier( &pSoldier, SChangeDest.usSoldierID ) == FALSE )
				{
					// Handle Error?
					DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Event Pump: Invalid Soldier ID #%d", SChangeDest.usSoldierID) );
					break;
				}

				// check for error
				if( pSoldier->uiUniqueSoldierIdValue != SChangeDest.uiUniqueId )
				{
					break;
				}

				// Call soldier function
				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Change Dest");
				pSoldier->EVENT_SetSoldierDestination( (UINT8) SChangeDest.usNewDestination );
				break;

			case S_SETPOSITION:

				memcpy( &SSetPosition, pEvent->pData, pEvent->uiDataSize );

				// Get soldier pointer from ID
				if ( GetSoldier( &pSoldier, SSetPosition.usSoldierID ) == FALSE )
				{
					// Handle Error?
					DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Invalid Soldier ID");
					break;
				}

				// check for error
				if( pSoldier->uiUniqueSoldierIdValue != SSetPosition.uiUniqueId )
				{
					break;
				}

				// Call soldier function
//				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Event Pump: SetPosition ( %f %f ) ( %d )", SSetPosition.dNewXPos, SSetPosition.dNewYPos, SSetPosition.usSoldierID ) );
				pSoldier->EVENT_SetSoldierPosition( SSetPosition.dNewXPos, SSetPosition.dNewYPos );
				break;

			case S_GETNEWPATH:

				memcpy( &SGetNewPath, pEvent->pData, pEvent->uiDataSize );

				// Get soldier pointer from ID
				if ( GetSoldier( &pSoldier, SGetNewPath.usSoldierID ) == FALSE )
				{
					// Handle Error?
					DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Invalid Soldier ID");
					break;
				}

				// check for error
				if( pSoldier->uiUniqueSoldierIdValue != SGetNewPath.uiUniqueId )
				{
					break;
				}
				// Call soldier function
				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: GetNewPath");
				pSoldier->EVENT_GetNewSoldierPath( SGetNewPath.sDestGridNo, SGetNewPath.usMovementAnim );
				break;

			case S_BEGINTURN:

				memcpy( &SBeginTurn, pEvent->pData, pEvent->uiDataSize );

				// Get soldier pointer from ID
				if ( GetSoldier( &pSoldier, SBeginTurn.usSoldierID ) == FALSE )
				{
					// Handle Error?
					DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Invalid Soldier ID");
					break;
				}

				// check for error
				if( pSoldier->uiUniqueSoldierIdValue != SBeginTurn.uiUniqueId )
				{
					break;
				}

				// Call soldier function
				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: BeginTurn");
				pSoldier->EVENT_BeginMercTurn( FALSE, 0 );
				break;

			case S_CHANGESTANCE:

				memcpy( &SChangeStance, pEvent->pData, pEvent->uiDataSize );

				// Get soldier pointer from ID
				if ( GetSoldier( &pSoldier, SChangeStance.usSoldierID ) == FALSE )
				{
					// Handle Error?
					DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Invalid Soldier ID");
					break;
				}

				// check for error
				if( pSoldier->uiUniqueSoldierIdValue != SChangeStance.uiUniqueId )
				{
					break;
				}
				// Call soldier function
				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: ChangeStance");
				pSoldier->ChangeSoldierStance( SChangeStance.ubNewStance );
				break;

			case S_SETDIRECTION:

				memcpy( &SSetDirection, pEvent->pData, pEvent->uiDataSize );

				// Get soldier pointer from ID
				if ( GetSoldier( &pSoldier, SSetDirection.usSoldierID ) == FALSE )
				{
					// Handle Error?
					DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Invalid Soldier ID");
					break;
				}

				// check for error
				if( pSoldier->uiUniqueSoldierIdValue != SSetDirection.uiUniqueId )
				{
					break;
				}

				// Call soldier function
				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Event Pump: SetDirection: Dir( %d )", SSetDirection.usNewDirection)	);
				pSoldier->EVENT_SetSoldierDirection( SSetDirection.usNewDirection );
				break;

			case S_SETDESIREDDIRECTION:

				memcpy( &SSetDesiredDirection, pEvent->pData, pEvent->uiDataSize );

				// Get soldier pointer from ID
				if ( GetSoldier( &pSoldier, SSetDesiredDirection.usSoldierID ) == FALSE )
				{
					// Handle Error?
					DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Invalid Soldier ID");
					break;
				}

				// check for error
				if( pSoldier->uiUniqueSoldierIdValue != SSetDesiredDirection.uiUniqueId )
				{
					break;
				}

				// Call soldier function
				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Event Pump: SetDesiredDirection: Dir( %d )", SSetDesiredDirection.usDesiredDirection)	);
				pSoldier->EVENT_SetSoldierDesiredDirection( (UINT8) SSetDesiredDirection.usDesiredDirection );
				break;


			case S_BEGINFIREWEAPON:

				memcpy( &SBeginFireWeapon, pEvent->pData, pEvent->uiDataSize );

				// Get soldier pointer from ID
				if ( GetSoldier( &pSoldier, SBeginFireWeapon.usSoldierID ) == FALSE )
				{
					pSoldier = NULL;
					break;
					// Handle Error?
					// DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Invalid Soldier ID");
				}

				// check for error
				if( pSoldier->uiUniqueSoldierIdValue != SBeginFireWeapon.uiUniqueId )
				{
					break;
				}

				// Call soldier function
				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Begin Fire Weapon");
				pSoldier->sTargetGridNo = SBeginFireWeapon.sTargetGridNo;
				pSoldier->bTargetLevel = SBeginFireWeapon.bTargetLevel;
				pSoldier->bTargetCubeLevel = SBeginFireWeapon.bTargetCubeLevel;
				pSoldier->EVENT_FireSoldierWeapon( SBeginFireWeapon.sTargetGridNo );
				break;

			case S_FIREWEAPON:

				memcpy( &SFireWeapon, pEvent->pData, pEvent->uiDataSize );

				// Get soldier pointer from ID
				if ( GetSoldier( &pSoldier, SFireWeapon.usSoldierID ) == FALSE )
				{
					// Handle Error?
					DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Invalid Soldier ID");
					break;
				}

					// check for error
				if( pSoldier->uiUniqueSoldierIdValue != SFireWeapon.uiUniqueId )
				{
					break;
				}


				// Call soldier function
				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: FireWeapon");
				pSoldier->sTargetGridNo = SFireWeapon.sTargetGridNo;
				pSoldier->bTargetLevel = SFireWeapon.bTargetLevel;
				pSoldier->bTargetCubeLevel = SFireWeapon.bTargetCubeLevel;
				FireWeapon( pSoldier, SFireWeapon.sTargetGridNo	);
				break;


			case S_WEAPONHIT:

				memcpy( &SWeaponHit, pEvent->pData, pEvent->uiDataSize );
				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Event Pump: WeaponHit %d Damage", SWeaponHit.sDamage ) );
				WeaponHit( SWeaponHit.usSoldierID, SWeaponHit.usWeaponIndex, SWeaponHit.sDamage, SWeaponHit.sBreathLoss, SWeaponHit.usDirection, SWeaponHit.sXPos, SWeaponHit.sYPos, SWeaponHit.sZPos, SWeaponHit.sRange, SWeaponHit.ubAttackerID, SWeaponHit.fHit, SWeaponHit.ubSpecial, SWeaponHit.ubLocation );
				break;

			case S_STRUCTUREHIT:

				memcpy( &SStructureHit, pEvent->pData, pEvent->uiDataSize );
				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Event Pump: StructureHit" ) );
				StructureHit( SStructureHit.iBullet, SStructureHit.usWeaponIndex, SStructureHit.bWeaponStatus, SStructureHit.ubAttackerID, SStructureHit.sXPos, SStructureHit.sYPos, SStructureHit.sZPos, SStructureHit.usStructureID, SStructureHit.iImpact, TRUE );
				break;

			case S_WINDOWHIT:

				memcpy( &SWindowHit, pEvent->pData, pEvent->uiDataSize );
				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Event Pump: WindowHit" ) );
				WindowHit( SWindowHit.sGridNo, SWindowHit.usStructureID, SWindowHit.fBlowWindowSouth, SWindowHit.fLargeForce );
				break;

			case S_MISS:

				memcpy( &SMiss, pEvent->pData, pEvent->uiDataSize );
				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Event Pump: Shot Miss ( obsolete )" ) );
				//ShotMiss( SMiss.ubAttackerID );
				break;

			case S_NOISE:
				memcpy( &SNoise, pEvent->pData, pEvent->uiDataSize );
				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Event Pump: Noise from %d at %d/%d, type %d volume %d", SNoise.ubNoiseMaker, SNoise.sGridNo, SNoise.bLevel, SNoise.ubNoiseType, SNoise.ubVolume ) );
				OurNoise( SNoise.ubNoiseMaker, SNoise.sGridNo, SNoise.bLevel, SNoise.ubTerrType, SNoise.ubVolume, SNoise.ubNoiseType, SNoise.zNoiseMessage );
				break;

			case S_STOP_MERC:

				memcpy( &SStopMerc, pEvent->pData, pEvent->uiDataSize );

				// Get soldier pointer from ID
				if ( GetSoldier( &pSoldier, SStopMerc.usSoldierID ) == FALSE )
				{
					// Handle Error?
					DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Invalid Soldier ID");
					break;
				}

				if( pSoldier->uiUniqueSoldierIdValue != SStopMerc.uiUniqueId )
				{
					break;
				}

				// Call soldier function
				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Event Pump: Stop Merc at Gridno %d", SStopMerc.sGridNo ));
				pSoldier->EVENT_StopMerc( SStopMerc.sGridNo, SStopMerc.ubDirection );
				break;


			default:

				DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Invalid Event Received");
				return( FALSE );

	}

	return( TRUE );
}
Esempio n. 11
0
void TransitAccess::Read_Skims (Skim_Itr &itr)
{
	int org, ndes, table, number;
	Db_Mat_Ptr skim_ptr;
	Doubles table_data, *table_ptr;
	Dbls_Itr dbls_itr;
	double *data;

	skim_ptr = skim_files [itr->index];
	number = itr->number;

	Show_Message (String ("Reading %s -- Record") % skim_ptr->File_Type ());
	Set_Progress ();

	ndes = skim_ptr->Num_Des ();

	//---- allocate skim matrix memory ----

	if (itr->time.size () == 0) {
		itr->time.assign (nzones, table_data);
		itr->distance.assign (nzones, table_data);

		for (dbls_itr = itr->time.begin (); dbls_itr != itr->time.end (); dbls_itr++) {
			dbls_itr->assign (ndes, 0.0);
		}
		for (dbls_itr = itr->distance.begin (); dbls_itr != itr->distance.end (); dbls_itr++) {
			dbls_itr->assign (ndes, 0.0);
		}
	}

	//---- read the skim data into memory ----

	if (itr->time_table < itr->dist_table) {
		for (org=1; org <= nzones; org++) {
			Show_Progress ();

			table = itr->time_table;
			table_ptr = &itr->time [org-1];
			data = &table_ptr->at (0);

			if (!skim_ptr->Read (data, org, table)) {
				Error (String ("Reading Skim Group=%d, Time Table=%d, Origin=%d") % number % table % org);
			}
			table = itr->dist_table;
			table_ptr = &itr->distance [org-1];
			data = &table_ptr->at (0);

			if (!skim_ptr->Read (data, org, table)) {
				Error (String ("Reading Skim Group=%d, Distance Table=%d, Origin=%d") % number % table % org);
			}
		}
	} else {
		for (org=1; org <= nzones; org++) {
			Show_Progress ();

			table = itr->dist_table;
			table_ptr = &itr->distance [org-1];
			data = &table_ptr->at (0);

			if (!skim_ptr->Read (data, org, table)) {
				Error (String ("Reading Skim Group=%d, Distance Table=%d, Origin=%d") % number % table % org);
			}
			table = itr->time_table;
			table_ptr = &itr->time [org-1];
			data = &table_ptr->at (0);

			if (!skim_ptr->Read (data, org, table)) {
				Error (String ("Reading Skim Group=%d, Time Table=%d, Origin=%d") % number % table % org);
			}
		}
	}
	End_Progress ();
	skim_ptr->Close ();
}
Esempio n. 12
0
String FontPlatformData::description() const
{
    return String();
}
    //==============================================================================
    void scanForDevices()
    {
        hasScanned = true;
        inputNames.clear();
        inputIds.clear();
        outputNames.clear();
        outputIds.clear();

        if (juce_libjackHandle == nullptr)
        {
            juce_libjackHandle = dlopen ("libjack.so", RTLD_LAZY);

            if (juce_libjackHandle == nullptr)
                return;
        }

        // open a dummy client
        jack_status_t status;
        jack_client_t* client = juce::jack_client_open ("JuceJackDummy", JackNoStartServer, &status);

        if (client == 0)
        {
            dumpJackErrorMessage (status);
        }
        else
        {
            // scan for output devices
            const char** ports = juce::jack_get_ports (client, 0, 0, /* JackPortIsPhysical | */ JackPortIsOutput);

            if (ports != 0)
            {
                int j = 0;
                while (ports[j] != 0)
                {
                    String clientName (ports[j]);
                    clientName = clientName.upToFirstOccurrenceOf (":", false, false);

                    if (clientName != String (JUCE_JACK_CLIENT_NAME)
                         && ! inputNames.contains (clientName))
                    {
                        inputNames.add (clientName);
                        inputIds.add (ports [j]);
                    }

                    ++j;
                }

                free (ports);
            }

            // scan for input devices
            ports = juce::jack_get_ports (client, 0, 0, /* JackPortIsPhysical | */ JackPortIsInput);

            if (ports != 0)
            {
                int j = 0;
                while (ports[j] != 0)
                {
                    String clientName (ports[j]);
                    clientName = clientName.upToFirstOccurrenceOf (":", false, false);

                    if (clientName != String (JUCE_JACK_CLIENT_NAME)
                         && ! outputNames.contains (clientName))
                    {
                        outputNames.add (clientName);
                        outputIds.add (ports [j]);
                    }

                    ++j;
                }

                free (ports);
            }

            juce::jack_client_close (client);
        }
    }
 static void errorCallback (const char* msg)
 {
     jack_Log ("JackAudioIODevice::errorCallback " + String (msg));
 }
void TextCheckingParagraph::invalidateParagraphRangeValues()
{
    m_checkingStart = m_checkingEnd = -1;
    m_offsetAsRange = nullptr;
    m_text = String();
}
String RenderThemeChromiumAndroid::extraDefaultStyleSheet()
{
    return RenderThemeChromiumDefault::extraDefaultStyleSheet() +
        String(themeChromiumAndroidUserAgentStyleSheet, sizeof(themeChromiumAndroidUserAgentStyleSheet));
}
Esempio n. 17
0
void SubString::dumpOn(ostream& strm) const
// Dump this SubString on output stream strm.
{
        strm << String(*this);
        strm << '[' << st->p << '(' << position() << ',' << sl << ")]";
}
Esempio n. 18
0
namespace openfl{

Void AssetData_obj::__construct()
{
HX_STACK_PUSH("AssetData::new","openfl/Assets.hx",1053);
{
}
;
	return null();
}

AssetData_obj::~AssetData_obj() { }

Dynamic AssetData_obj::__CreateEmpty() { return  new AssetData_obj; }
hx::ObjectPtr< AssetData_obj > AssetData_obj::__new()
{  hx::ObjectPtr< AssetData_obj > result = new AssetData_obj();
	result->__construct();
	return result;}

Dynamic AssetData_obj::__Create(hx::DynamicArray inArgs)
{  hx::ObjectPtr< AssetData_obj > result = new AssetData_obj();
	result->__construct();
	return result;}


AssetData_obj::AssetData_obj()
{
}

void AssetData_obj::__Mark(HX_MARK_PARAMS)
{
	HX_MARK_BEGIN_CLASS(AssetData);
	HX_MARK_MEMBER_NAME(type,"type");
	HX_MARK_MEMBER_NAME(path,"path");
	HX_MARK_MEMBER_NAME(id,"id");
	HX_MARK_END_CLASS();
}

void AssetData_obj::__Visit(HX_VISIT_PARAMS)
{
	HX_VISIT_MEMBER_NAME(type,"type");
	HX_VISIT_MEMBER_NAME(path,"path");
	HX_VISIT_MEMBER_NAME(id,"id");
}

Dynamic AssetData_obj::__Field(const ::String &inName,bool inCallProp)
{
	switch(inName.length) {
	case 2:
		if (HX_FIELD_EQ(inName,"id") ) { return id; }
		break;
	case 4:
		if (HX_FIELD_EQ(inName,"type") ) { return type; }
		if (HX_FIELD_EQ(inName,"path") ) { return path; }
	}
	return super::__Field(inName,inCallProp);
}

Dynamic AssetData_obj::__SetField(const ::String &inName,const Dynamic &inValue,bool inCallProp)
{
	switch(inName.length) {
	case 2:
		if (HX_FIELD_EQ(inName,"id") ) { id=inValue.Cast< ::String >(); return inValue; }
		break;
	case 4:
		if (HX_FIELD_EQ(inName,"type") ) { type=inValue.Cast< ::openfl::AssetType >(); return inValue; }
		if (HX_FIELD_EQ(inName,"path") ) { path=inValue.Cast< ::String >(); return inValue; }
	}
	return super::__SetField(inName,inValue,inCallProp);
}

void AssetData_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_CSTRING("type"));
	outFields->push(HX_CSTRING("path"));
	outFields->push(HX_CSTRING("id"));
	super::__GetFields(outFields);
};

static ::String sStaticFields[] = {
	String(null()) };

static ::String sMemberFields[] = {
	HX_CSTRING("type"),
	HX_CSTRING("path"),
	HX_CSTRING("id"),
	String(null()) };

static void sMarkStatics(HX_MARK_PARAMS) {
	HX_MARK_MEMBER_NAME(AssetData_obj::__mClass,"__mClass");
};

static void sVisitStatics(HX_VISIT_PARAMS) {
	HX_VISIT_MEMBER_NAME(AssetData_obj::__mClass,"__mClass");
};

Class AssetData_obj::__mClass;

void AssetData_obj::__register()
{
	hx::Static(__mClass) = hx::RegisterClass(HX_CSTRING("openfl.AssetData"), hx::TCanCast< AssetData_obj> ,sStaticFields,sMemberFields,
	&__CreateEmpty, &__Create,
	&super::__SGetClass(), 0, sMarkStatics, sVisitStatics);
}

void AssetData_obj::__boot()
{
}

} // end namespace openfl
Esempio n. 19
0
String WebEditorClient::getAutoCorrectSuggestionForMisspelledWord(const String&)
{
    notImplemented();
    return String();
}
Esempio n. 20
0
String LocalisedStrings::translateWithCurrentMappings (const char* text)
{
    return juce::translate (String (text));
}
Esempio n. 21
0
bool VisualScriptInputFilter::_get(const StringName& p_name,Variant &r_ret) const{

	if (p_name=="filter_count") {
		r_ret=filters.size();
		return true;
	}


	if (String(p_name).begins_with("filter_")) {

		int idx = String(p_name).replace_first("filters_","").get_slice("/",0).to_int();

		ERR_FAIL_INDEX_V(idx,filters.size(),false);

		String what = String(p_name).get_slice("/",1);


		if (what=="type") {
			r_ret=filters[idx].type;
			return true;
		}
		if (what=="device") {
			r_ret=filters[idx].device;
			return true;
		}

		switch(filters[idx].type) {

			case InputEvent::KEY: {

				if (what=="scancode") {
					if (filters[idx].key.scancode==0)
						r_ret=String();
					else {

						r_ret=keycode_get_string(filters[idx].key.scancode);
					}

				} else if (what=="unicode") {


					if (filters[idx].key.unicode==0) {
						r_ret=String();
					} else {
						CharType str[2]={ (CharType)filters[idx].key.unicode, 0};
						r_ret=String(str);
					}

				} else if (what=="pressed") {

					r_ret=filters[idx].key.pressed;
				} else if (what=="echo") {

					r_ret=filters[idx].key.echo;

				} else if (what=="mod_alt") {
					r_ret=filters[idx].key.mod.alt;

				} else if (what=="mod_shift") {
					r_ret=filters[idx].key.mod.shift;

				} else if (what=="mod_ctrl") {
					r_ret=filters[idx].key.mod.control;

				} else  if (what=="mod_meta") {
					r_ret=filters[idx].key.mod.meta;
				} else {
					return false;
				}

				return true;
			} break;
			case InputEvent::MOUSE_MOTION: {


				if (what=="button_mask") {
					r_ret=filters[idx].mouse_motion.button_mask;

				} else if (what=="mod_alt") {
					r_ret=filters[idx].mouse_motion.mod.alt;

				} else if (what=="mod_shift") {
					r_ret=filters[idx].mouse_motion.mod.shift;

				} else if (what=="mod_ctrl") {
					r_ret=filters[idx].mouse_motion.mod.control;

				} else  if (what=="mod_meta") {
					r_ret=filters[idx].mouse_motion.mod.meta;
				} else {
					return false;
				}

				return true;

			} break;
			case InputEvent::MOUSE_BUTTON: {

				if (what=="button_index") {
					r_ret=filters[idx].mouse_button.button_index;
				} else if (what=="pressed") {
					r_ret=filters[idx].mouse_button.pressed;
				} else if (what=="doubleclicked") {
					r_ret=filters[idx].mouse_button.doubleclick;

				} else if (what=="mod_alt") {
					r_ret=filters[idx].mouse_button.mod.alt;

				} else if (what=="mod_shift") {
					r_ret=filters[idx].mouse_button.mod.shift;

				} else if (what=="mod_ctrl") {
					r_ret=filters[idx].mouse_button.mod.control;

				} else  if (what=="mod_meta") {
					r_ret=filters[idx].mouse_button.mod.meta;
				} else {
					return false;
				}
				return true;

			} break;
			case InputEvent::JOYSTICK_MOTION: {

				if (what=="axis_index") {
					r_ret=filters[idx].joy_motion.axis>>1;
				} else if (what=="mode") {
					r_ret=filters[idx].joy_motion.axis&1;
				} else if (what=="treshold") {
					r_ret=filters[idx].joy_motion.axis_value;
				} else {
					return false;
				}
				return true;


			} break;
Esempio n. 22
0
 String startString() {
   return String(this);
 }
Esempio n. 23
0
bool VisualScriptInputFilter::_set(const StringName& p_name, const Variant& p_value) {

	if (p_name=="filter_count") {
		filters.resize(p_value);
		_change_notify();
		ports_changed_notify();
		return true;
	}


	if (String(p_name).begins_with("filter_")) {

		int idx = String(p_name).replace_first("filters_","").get_slice("/",0).to_int();

		ERR_FAIL_INDEX_V(idx,filters.size(),false);

		String what = String(p_name).get_slice("/",1);


		if (what=="type") {
			filters[idx]=InputEvent();
			filters[idx].type=InputEvent::Type(int(p_value));
			if (filters[idx].type==InputEvent::JOYSTICK_MOTION) {
				filters[idx].joy_motion.axis_value=0.5; //for treshold
			} else if (filters[idx].type==InputEvent::KEY) {
				filters[idx].key.pressed=true; //put these as true to make it more user friendly
			} else if (filters[idx].type==InputEvent::MOUSE_BUTTON) {
				filters[idx].mouse_button.pressed=true;
			} else if (filters[idx].type==InputEvent::JOYSTICK_BUTTON) {
				filters[idx].joy_button.pressed=true;
			} else if (filters[idx].type==InputEvent::SCREEN_TOUCH) {
				filters[idx].screen_touch.pressed=true;
			} else if (filters[idx].type==InputEvent::ACTION) {
				filters[idx].action.pressed=true;
			}
			_change_notify();
			ports_changed_notify();

			return true;
		}
		if (what=="device") {
			filters[idx].device=p_value;
			ports_changed_notify();
			return true;
		}

		switch(filters[idx].type) {

			case InputEvent::KEY: {

				if (what=="scancode") {
					String sc = p_value;
					if (sc==String()) {
						filters[idx].key.scancode=0;
					} else {
						filters[idx].key.scancode=find_keycode(p_value);
					}

				} else if (what=="unicode") {

					String uc = p_value;

					if (uc==String()) {
						filters[idx].key.unicode=0;
					} else {
						filters[idx].key.unicode=uc[0];
					}

				} else if (what=="pressed") {

					filters[idx].key.pressed=p_value;
				} else if (what=="echo") {

					filters[idx].key.echo=p_value;

				} else if (what=="mod_alt") {
					filters[idx].key.mod.alt=p_value;

				} else if (what=="mod_shift") {
					filters[idx].key.mod.shift=p_value;

				} else if (what=="mod_ctrl") {
					filters[idx].key.mod.control=p_value;

				} else  if (what=="mod_meta") {
					filters[idx].key.mod.meta=p_value;
				} else {
					return false;
				}
				ports_changed_notify();

				return true;
			} break;
			case InputEvent::MOUSE_MOTION: {


				if (what=="button_mask") {
					filters[idx].mouse_motion.button_mask=p_value;

				} else if (what=="mod_alt") {
					filters[idx].mouse_motion.mod.alt=p_value;

				} else if (what=="mod_shift") {
					filters[idx].mouse_motion.mod.shift=p_value;

				} else if (what=="mod_ctrl") {
					filters[idx].mouse_motion.mod.control=p_value;

				} else  if (what=="mod_meta") {
					filters[idx].mouse_motion.mod.meta=p_value;
				} else {
					return false;
				}

				ports_changed_notify();
				return true;

			} break;
			case InputEvent::MOUSE_BUTTON: {

				if (what=="button_index") {
					filters[idx].mouse_button.button_index=p_value;
				} else if (what=="pressed") {
					filters[idx].mouse_button.pressed=p_value;
				} else if (what=="doubleclicked") {
					filters[idx].mouse_button.doubleclick=p_value;

				} else if (what=="mod_alt") {
					filters[idx].mouse_button.mod.alt=p_value;

				} else if (what=="mod_shift") {
					filters[idx].mouse_button.mod.shift=p_value;

				} else if (what=="mod_ctrl") {
					filters[idx].mouse_button.mod.control=p_value;

				} else  if (what=="mod_meta") {
					filters[idx].mouse_button.mod.meta=p_value;
				} else {
					return false;
				}
				ports_changed_notify();
				return true;

			} break;
			case InputEvent::JOYSTICK_MOTION: {

				if (what=="axis") {
					filters[idx].joy_motion.axis=int(p_value)<<1|filters[idx].joy_motion.axis;
				} else if (what=="mode") {
					filters[idx].joy_motion.axis|=int(p_value);
				} else if (what=="treshold") {
					filters[idx].joy_motion.axis_value=p_value;
				} else {
					return false;
				}
				ports_changed_notify();
				return true;


			} break;
			case InputEvent::JOYSTICK_BUTTON: {

				if (what=="button_index") {
					filters[idx].joy_button.button_index=p_value;
				} else if (what=="pressed") {
					filters[idx].joy_button.pressed=p_value;
				} else {
					return false;
				}
				ports_changed_notify();
				return true;

			} break;
			case InputEvent::SCREEN_TOUCH: {

				if (what=="finger_index") {
					filters[idx].screen_touch.index=p_value;
				} else if (what=="pressed") {
					filters[idx].screen_touch.pressed=p_value;
				} else {
					return false;
				}
				ports_changed_notify();
				return true;
			} break;
			case InputEvent::SCREEN_DRAG: {
				if (what=="finger_index") {
					filters[idx].screen_drag.index=p_value;
				} else {
					return false;
				}
				ports_changed_notify();
				return true;
			} break;
			case InputEvent::ACTION: {


				if (what=="action_name") {

					List<PropertyInfo> pinfo;
					Globals::get_singleton()->get_property_list(&pinfo);
					int index=1;

					for(List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
						const PropertyInfo &pi=E->get();

						if (!pi.name.begins_with("input/"))
							continue;

						String name = pi.name.substr(pi.name.find("/")+1,pi.name.length());
						if (name==String(p_value)) {

							filters[idx].action.action=index;
							ports_changed_notify();
							return true;
						}

						index++;
					}

					filters[idx].action.action=0;
					ports_changed_notify();

					return false;

				} else if (what=="pressed") {

					filters[idx].action.pressed=p_value;
					ports_changed_notify();
					return true;
				}


			} break;

		}
	}
	return false;
}
Esempio n. 24
0
int main (int argc, char * argv [])
{
    Boolean verbose = (getenv ("PEGASUS_TEST_VERBOSE")) ? true : false;

    if (argc != 3)
    {
        cerr << "Usage: " << argv [0] << 
            " child-read-handle child-write-handle" << endl;
        PEGASUS_TEST_ASSERT (0);
    }

    String readHandleStr (argv [1]);
    CString readHandle = readHandleStr.getCString ();
    String writeHandleStr (argv [2]);
    CString writeHandle = writeHandleStr.getCString ();

    try
    {
        //
        //  Create pipe instances
        //
        AutoPtr <AnonymousPipe> pipeFromParent 
            (new AnonymousPipe (readHandle, NULL));
        AutoPtr <AnonymousPipe> pipeToParent 
            (new AnonymousPipe (NULL, writeHandle));

#if defined (PEGASUS_OS_VMS)
            //
            //  Child: Close parent handles
            //
            pipeFromParent->closeWriteHandle ();
            pipeToParent->closeReadHandle ();
#endif
        //
        //  Test readBuffer and writeBuffer
        //
        Uint32 bufferLength;
        AnonymousPipe::Status readBufferStatus = pipeFromParent->readBuffer
            ((char *) &bufferLength, sizeof (Uint32));
    
        if (readBufferStatus != AnonymousPipe::STATUS_SUCCESS)
        {
            cerr << "Child failed to read request length: "
                << readBufferStatus << endl;
            PEGASUS_TEST_ASSERT (0);
        }

        if (bufferLength == 0)
        {
            cerr << "Child read request length of 0" << endl;
            PEGASUS_TEST_ASSERT (0);
        }

        AutoArrayPtr <char> requestBuffer (new char [bufferLength + 1]);
        do
        {
            readBufferStatus = pipeFromParent->readBuffer (requestBuffer.get (),
                bufferLength);
        } while (readBufferStatus == AnonymousPipe::STATUS_INTERRUPT);

        if (readBufferStatus != AnonymousPipe::STATUS_SUCCESS)
        {
            cerr << "Child failed to read request data: " << readBufferStatus 
                << endl;
            PEGASUS_TEST_ASSERT (0);
        }

        requestBuffer.get () [bufferLength] = '\0';
        if (verbose)
        {
            cout << "Request received by child: " << requestBuffer.get () 
                << endl;
        }

        PEGASUS_TEST_ASSERT (strcmp (requestBuffer.get (), "Hello world") == 0);

        Buffer responseBuffer;
        char buffer [16];
        sprintf (buffer, "%s", "Good-bye");
        responseBuffer.append (buffer, strlen (buffer));
        AnonymousPipe::Status writeBufferStatus;
        bufferLength = responseBuffer.size();

        writeBufferStatus = pipeToParent->writeBuffer
            ((const char *) &bufferLength, sizeof (Uint32));

        if (writeBufferStatus == AnonymousPipe::STATUS_SUCCESS)
        {
            writeBufferStatus = pipeToParent->writeBuffer 
                (responseBuffer.getData (), bufferLength);
            if (writeBufferStatus != AnonymousPipe::STATUS_SUCCESS)
            {
                cerr << "Child failed to write response data: "
                    << writeBufferStatus << endl;
                PEGASUS_TEST_ASSERT (0);
            }
        }
        else
        {
            cerr << "Child failed to write response length: "
                << writeBufferStatus << endl;
            PEGASUS_TEST_ASSERT (0);
        }

        //
        //  Test readMessage and writeMessage
        //
        CIMMessage * message;
        AnonymousPipe::Status readMessageStatus = pipeFromParent->readMessage
            (message);
        
        AutoPtr<CIMGetInstanceRequestMessage> request;
        request.reset(dynamic_cast<CIMGetInstanceRequestMessage*>(message));
        PEGASUS_TEST_ASSERT (request.get() != 0);

        if (verbose)
        {
            cout << "CIMGetInstanceRequestMessage received by child" << endl;
        }

        PEGASUS_TEST_ASSERT (request->getType () == 
            CIM_GET_INSTANCE_REQUEST_MESSAGE);
        PEGASUS_TEST_ASSERT (request->messageId == String ("00000001"));
        PEGASUS_TEST_ASSERT (request->nameSpace.equal 
              (CIMNamespaceName ("root/test/A")));
        PEGASUS_TEST_ASSERT (request->instanceName ==
              CIMObjectPath ("MCCA_TestClass.theKey=1"));
        PEGASUS_TEST_ASSERT (request->localOnly == true);
        PEGASUS_TEST_ASSERT (request->includeQualifiers == false);
        PEGASUS_TEST_ASSERT (request->includeClassOrigin == false);
        PEGASUS_TEST_ASSERT (request->propertyList.isNull ());
        PEGASUS_TEST_ASSERT (request->authType == String::EMPTY);
        PEGASUS_TEST_ASSERT (request->userName == String::EMPTY);
        PEGASUS_TEST_ASSERT (
            ((ContentLanguageListContainer)request->operationContext.get
            (ContentLanguageListContainer::NAME)).getLanguages().size() == 0);
        PEGASUS_TEST_ASSERT (
            ((AcceptLanguageListContainer)request->operationContext.get
            (AcceptLanguageListContainer::NAME)).getLanguages().size() == 0);

        AcceptLanguageListContainer allc1(
            request->operationContext.get(AcceptLanguageListContainer::NAME));
        PEGASUS_TEST_ASSERT ( allc1.getLanguages().size() == 0 );
        AcceptLanguageListContainer allc2(allc1);
        PEGASUS_TEST_ASSERT ( allc2.getLanguages().size() == 0 );
        AcceptLanguageListContainer allc3 = allc2;
        PEGASUS_TEST_ASSERT ( allc3.getLanguages().size() == 0 );

        CIMInstance anInstance;
        AutoPtr <CIMGetInstanceResponseMessage> response
            (new CIMGetInstanceResponseMessage
                (String ("00000002"),
                CIMException (CIM_ERR_FAILED),
                QueueIdStack()));
        response->setCimInstance(anInstance);

        AnonymousPipe::Status writeMessageStatus =
            pipeToParent->writeMessage (response.get ());
        if (writeMessageStatus != AnonymousPipe::STATUS_SUCCESS)
        {
            cerr << "Child failed to write response message: "
                << writeMessageStatus << endl;
            PEGASUS_TEST_ASSERT (0);
        }
    }
    catch (Exception & e)
    {
        cerr << "Exception occurred in child: " << e.getMessage () << endl;
        PEGASUS_TEST_ASSERT (0);
    }
    catch (...)
    {
        cerr << "Unknown error occurred in child" << endl;
        PEGASUS_TEST_ASSERT (0);
    }

    return 0;
}
Esempio n. 25
0
jvalue _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_arg, bool force_jobject = false) {

	jvalue v;

	switch(p_type) {

		case Variant::BOOL: {

			if (force_jobject) {
				jclass bclass = env->FindClass("java/lang/Boolean");
				jmethodID ctor = env->GetMethodID(bclass, "<init>", "(Z)V");
				jvalue val;
				val.z = (bool)(*p_arg);
				jobject obj = env->NewObjectA(bclass, ctor, &val);
				v.l = obj;
			} else {
				v.z=*p_arg;
			};
		} break;
		case Variant::INT: {

			if (force_jobject) {

				jclass bclass = env->FindClass("java/lang/Integer");
				jmethodID ctor = env->GetMethodID(bclass, "<init>", "(I)V");
				jvalue val;
				val.i = (int)(*p_arg);
				jobject obj = env->NewObjectA(bclass, ctor, &val);
				v.l = obj;

			} else {
				v.i=*p_arg;
			};
		} break;
		case Variant::REAL: {

			if (force_jobject) {

				jclass bclass = env->FindClass("java/lang/Double");
				jmethodID ctor = env->GetMethodID(bclass, "<init>", "(D)V");
				jvalue val;
				val.d = (double)(*p_arg);
				jobject obj = env->NewObjectA(bclass, ctor, &val);
				v.l = obj;

			} else {
				v.f=*p_arg;
			};
		} break;
		case Variant::STRING: {

			String s = *p_arg;
			jstring jStr = env->NewStringUTF(s.utf8().get_data());
			v.l=jStr;
		} break;
		case Variant::STRING_ARRAY: {

			DVector<String> sarray = *p_arg;
			jobjectArray arr = env->NewObjectArray(sarray.size(),env->FindClass("java/lang/String"),env->NewStringUTF(""));

			for(int j=0;j<sarray.size();j++) {

				env->SetObjectArrayElement(arr,j,env->NewStringUTF( sarray[j].utf8().get_data() ));
			}
			v.l=arr;

		} break;

		case Variant::DICTIONARY: {

			Dictionary dict = *p_arg;
			jclass dclass = env->FindClass("com/android/godot/Dictionary");
			jmethodID ctor = env->GetMethodID(dclass, "<init>", "()V");
			jobject jdict = env->NewObject(dclass, ctor);

			Array keys = dict.keys();

			jobjectArray jkeys = env->NewObjectArray(keys.size(), env->FindClass("java/lang/String"), env->NewStringUTF(""));
			for (int j=0; j<keys.size(); j++) {
				env->SetObjectArrayElement(jkeys, j, env->NewStringUTF(String(keys[j]).utf8().get_data()));
			};

			jmethodID set_keys = env->GetMethodID(dclass, "set_keys", "([Ljava/lang/String;)V");
			jvalue val;
			val.l = jkeys;
			env->CallVoidMethodA(jdict, set_keys, &val);

			jobjectArray jvalues = env->NewObjectArray(keys.size(), env->FindClass("java/lang/Object"), NULL);

			for (int j=0; j<keys.size(); j++) {
				Variant var = dict[keys[j]];
				val = _variant_to_jvalue(env, var.get_type(), &var, true);
				env->SetObjectArrayElement(jvalues, j, val.l);
			};

			jmethodID set_values = env->GetMethodID(dclass, "set_values", "([Ljava/lang/Object;)V");
			val.l = jvalues;
			env->CallVoidMethodA(jdict, set_values, &val);

			v.l = jdict;
		} break;

		case Variant::INT_ARRAY: {

			DVector<int> array = *p_arg;
			jintArray arr = env->NewIntArray(array.size());
			DVector<int>::Read r = array.read();
			env->SetIntArrayRegion(arr,0,array.size(),r.ptr());
			v.l=arr;

		} break;
		case Variant::RAW_ARRAY: {
			DVector<uint8_t> array = *p_arg;
			jbyteArray arr = env->NewByteArray(array.size());
			DVector<uint8_t>::Read r = array.read();
			env->SetByteArrayRegion(arr,0,array.size(),reinterpret_cast<const signed char*>(r.ptr()));
			v.l=arr;

		} break;
		case Variant::REAL_ARRAY: {

			DVector<float> array = *p_arg;
			jfloatArray arr = env->NewFloatArray(array.size());
			DVector<float>::Read r = array.read();
			env->SetFloatArrayRegion(arr,0,array.size(),r.ptr());
			v.l=arr;

		} break;
		default: {

			v.i = 0;
		} break;

	}
	return v;
};
Esempio n. 26
0
bool launcherApplication::Elevate(const StringArray& commandLineArray)
{
#if defined(JUCE_LINUX) || defined(JUCE_BSD)
    if (geteuid() == 0) {
        return true;
    }

    String parameters("--user root /usr/bin/env ");

    const char *var = getenv("DISPLAY");
    if (var) {
        String s("DISPLAY=" + String(var).quoted());
        parameters += s + " ";
    }

    var = getenv("XAUTHORITY");
    if (var) {
        String s("XAUTHORITY=" + String(var).quoted());
        parameters += s + " ";
    }

    String launcher(File::getSpecialLocation(
                File::currentExecutableFile).getFullPathName());
    if (launcher.contains(" ")) {
        launcher = launcher.quoted();
    }

    parameters += String(" ") + launcher;
    for (int i = 0; i < commandLineArray.size(); i++)
    {
        parameters += " ";
        if (commandLineArray[i].contains(" "))
            parameters += commandLineArray[i].quoted();
        else
            parameters += commandLineArray[i];
    }

    File pkexec("/usr/bin/pkexec");
    if (pkexec.exists() && pkexec.startAsProcess(parameters)) {
        quit();
    }

    pkexec = "/usr/local/bin/pkexec";
    if (pkexec.exists() && pkexec.startAsProcess(parameters)) {
        quit();
    }

#elif defined(JUCE_WINDOWS)
    BOOL fIsRunAsAdmin = FALSE;
    DWORD dwError = ERROR_SUCCESS;
    PSID pAdministratorsGroup = NULL;

    SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
    if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID,
                DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &pAdministratorsGroup)) {
        dwError = GetLastError();
        goto cleanup;
    }

    if (!CheckTokenMembership(NULL, pAdministratorsGroup, &fIsRunAsAdmin)) {
        dwError = GetLastError();
        goto cleanup;
    }

cleanup:
    if (pAdministratorsGroup) {
        FreeSid(pAdministratorsGroup);
        pAdministratorsGroup = NULL;
    }

    if (dwError != ERROR_SUCCESS) {
        throw dwError;
    }

    if (fIsRunAsAdmin) {
        return true;
    }

    TCHAR szPath[MAX_PATH];
    if (!GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath))) {
        dwError = GetLastError();
        throw dwError;
    }

    String commandLine;
    for (int i = 0; i < commandLineArray.size(); i++) {
        if (commandLineArray[i].contains(" ")) {
            commandLine += String("\"") + commandLineArray[i] + String("\"");
        } else {
            commandLine += commandLineArray[i];
        }
        if (i + 1 < commandLineArray.size()) {
            commandLine += " ";
        }
    }

    SHELLEXECUTEINFO sei = { 0 };
    sei.cbSize = sizeof(SHELLEXECUTEINFO);
    sei.lpVerb = _T("runas");
    sei.lpFile = szPath;
    sei.lpParameters = commandLine.toUTF8();
    sei.nShow = SW_NORMAL;
    if (ShellExecuteEx(&sei)) {
        _exit(1);
    }

#elif defined(JUCE_MAC)
    if (geteuid() == 0) {
        return true;
    }

    String launcher(File::getSpecialLocation(
                File::currentExecutableFile).getFullPathName());

    const char * execpath = launcher.toRawUTF8();
    char * args[] = { NULL };

    OSStatus           err;
    AuthorizationRef   ref;
    AuthorizationFlags flags;

    flags = kAuthorizationFlagDefaults;
    err   = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, flags, &ref);
    if ( err != errAuthorizationSuccess ) {
        quit();
    }

    AuthorizationItem    _temp = { kAuthorizationRightExecute, 0, NULL, 0 };
    AuthorizationRights rights = { 1, &_temp };

    flags = kAuthorizationFlagDefaults
          | kAuthorizationFlagInteractionAllowed
          | kAuthorizationFlagPreAuthorize
          | kAuthorizationFlagExtendRights;

    err  = AuthorizationCopyRights(ref, &rights, NULL, flags, NULL);
    if ( err != errAuthorizationSuccess ) {
        AuthorizationFree(ref, kAuthorizationFlagDefaults);
        quit();
    }

    flags = kAuthorizationFlagDefaults;
    err  = AuthorizationExecuteWithPrivileges(ref, execpath, flags, args, NULL);
    AuthorizationFree(ref, kAuthorizationFlagDefaults);

    // Probably overkill.
    if ( err != errAuthorizationSuccess ) {
        quit();
    }
#endif // JUCE_MAC

    return false;
}
Esempio n. 27
0
static String _get_unique_id() {

    JNIEnv *env = ThreadAndroid::get_env();
    jstring s =(jstring)env->CallObjectMethod(godot_io,_getUniqueID);
    return String(env->GetStringUTFChars( s, NULL ));
}
Esempio n. 28
0
void launcherApplication::initialise(const String& commandLine)
{
    File appDataDirectory(File::getSpecialLocation(File::userApplicationDataDirectory));

#if defined(JUCE_LINUX) || defined(JUCE_BSD)
    settingsDirectory = appDataDirectory.getChildFile(".tremulous");
#elif defined(JUCE_WINDOWS)
    settingsDirectory = appDataDirectory.getChildFile("Tremulous");
#elif defined(JUCE_MAC)
    // FIXME/Verify
    settingsDirectory = appDataDirectory.getChildFile("Application Support").getChildFile("Tremulous");
#endif

    File logFile(settingsDirectory.getChildFile("launcher.log"));
    logger = new FileLogger(logFile, ProjectInfo::projectName, 0);
    Logger::setCurrentLogger(logger);

    // TODO: Parse arguments
    StringArray commandLineArray(getCommandLineParameterArray());
    for (int i = 0; i < commandLineArray.size(); i++) {
      Logger::writeToLog(String("arg") + String(i) + String(": ") + commandLineArray[i]);
    }

    config = new IniFile(settingsDirectory.getChildFile("launcher.ini"));

    File defaultBasepath;
    File defaultHomepath(settingsDirectory);

#if defined(JUCE_LINUX) || defined(JUCE_BSD)
    defaultBasepath = "/usr/local/games/tremulous";
#elif defined(JUCE_WINDOWS)
    defaultBasepath = File::getSpecialLocation(File::globalApplicationsDirectory).getChildFile("Tremulous");
#elif defined(JUCE_MAC)
    //  FIXME/Verify
    defaultBasepath = File::getSpecialLocation(File::globalApplicationsDirectory).getChildFile("Tremulous");
#endif

    config->setDefault("general", "overpath", defaultBasepath.getFullPathName());
    config->setDefault("general", "basepath", defaultBasepath.getFullPathName());
    config->setDefault("general", "homepath", defaultHomepath.getFullPathName());

    config->setDefault("updater", "downloads", defaultBasepath.getChildFile("updater").getChildFile("downloads").getFullPathName());

#if defined(JUCE_LINUX)
 #if __x86_64__
    String defaultPlatform("linux64");
 #else
    String defaultPlatform("linux32");
 #endif
#elif defined(JUCE_BSD) && defined(__FreeBSD__)
 #if __x86_64__
    String defaultPlatform("freebsd64");
 #else
    String defaultPlatform("freebsd32");
 #endif
#elif defined(JUCE_WINDOWS)
 #if _WIN64 || __x86_64__
    String defaultPlatform("win64");
 #else
    String defaultPlatform("win32");
 #endif
#elif defined(JUCE_MAC)
    String defaultPlatform("mac");
#endif

    config->setDefault("updater", "platform", defaultPlatform);
    config->setDefault("updater", "channel", "release");
    config->setDefault("updater", "checkForUpdates", 1);
    config->setDefault("updater", "verifySignature", 1);

    LookAndFeel *laf = &LookAndFeel::getDefaultLookAndFeel();
    laf->setColour(AlertWindow::backgroundColourId, Colour(0xFF111111));
    laf->setColour(AlertWindow::textColourId, Colour(0xFFFFFFFF));
    laf->setColour(AlertWindow::outlineColourId, Colour(0xFF333333));

    laf->setColour(TextButton::buttonColourId, Colour(0xFF333333));
    laf->setColour(TextButton::textColourOffId, Colour(0xFFFFFFFF));

    // Delete old launcher if it exists
    File launcherPath(File::getSpecialLocation(
            File::SpecialLocationType::currentApplicationFile));

    File oldLauncherPath(launcherPath.getFullPathName() + ".old");
    oldLauncherPath.deleteFile();

    initLauncher();
}
	outFields->push(HX_CSTRING("needsSoftKeyboard"));
	outFields->push(HX_CSTRING("moveForSoftKeyboard"));
	outFields->push(HX_CSTRING("mouseEnabled"));
	outFields->push(HX_CSTRING("doubleClickEnabled"));
	super::__GetFields(outFields);
};

static ::String sStaticFields[] = {
	HX_CSTRING("nme_display_object_set_mouse_enabled"),
	HX_CSTRING("nme_display_object_set_needs_soft_keyboard"),
	HX_CSTRING("nme_display_object_get_needs_soft_keyboard"),
	HX_CSTRING("nme_display_object_set_moves_for_soft_keyboard"),
	HX_CSTRING("nme_display_object_get_moves_for_soft_keyboard"),
	HX_CSTRING("nme_display_object_dismiss_soft_keyboard"),
	HX_CSTRING("nme_display_object_request_soft_keyboard"),
	String(null()) };

static ::String sMemberFields[] = {
	HX_CSTRING("get_needsSoftKeyboard"),
	HX_CSTRING("set_needsSoftKeyboard"),
	HX_CSTRING("get_moveForSoftKeyboard"),
	HX_CSTRING("set_moveForSoftKeyboard"),
	HX_CSTRING("set_mouseEnabled"),
	HX_CSTRING("get_mouseEnabled"),
	HX_CSTRING("__asInteractiveObject"),
	HX_CSTRING("requestSoftKeyboard"),
	HX_CSTRING("__dismissSoftKeyboard"),
	HX_CSTRING("__mouseEnabled"),
	HX_CSTRING("doubleClickEnabled"),
	String(null()) };
Esempio n. 30
0
    void runTestInitialisation()
    {
        beginTest ("Int32");
        {
            int value = 123456789;

            OSCArgument arg (value);

            expect (arg.getType() == OSCTypes::int32);

            expect (arg.isInt32());
            expect (! arg.isFloat32());
            expect (! arg.isString());
            expect (! arg.isBlob());

            expect (arg.getInt32() == value);
        }

        beginTest ("Float32");
        {
            float value = 12345.6789f;

            OSCArgument arg (value);

            expect (arg.getType() == OSCTypes::float32);

            expect (! arg.isInt32());
            expect (arg.isFloat32());
            expect (! arg.isString());
            expect (! arg.isBlob());

            expect (arg.getFloat32() == value);


        }

        beginTest ("String");
        {
            String value = "Hello, World!";
            OSCArgument arg (value);

            expect (arg.getType() == OSCTypes::string);

            expect (! arg.isInt32());
            expect (! arg.isFloat32());
            expect (arg.isString());
            expect (! arg.isBlob());

            expect (arg.getString() == value);
        }

        beginTest ("String (from C string)");
        {
            OSCArgument arg ("Hello, World!");

            expect (arg.getType() == OSCTypes::string);

            expect (! arg.isInt32());
            expect (! arg.isFloat32());
            expect (arg.isString());
            expect (! arg.isBlob());

            expect (arg.getString() == String ("Hello, World!"));
        }

        beginTest ("Blob");
        {
            const size_t numBytes = 412;
            MemoryBlock blob = getMemoryBlockWithRandomData (numBytes);

            OSCArgument arg (blob);

            expect (arg.getType() == OSCTypes::blob);

            expect (! arg.isInt32());
            expect (! arg.isFloat32());
            expect (! arg.isString());
            expect (arg.isBlob());

            expect (arg.getBlob() == blob);
        }

        beginTest ("Copy, move and assignment");
        {
            {
                int value = -42;
                OSCArgument arg (value);

                OSCArgument copy = arg;
                expect (copy.getType() == OSCTypes::int32);
                expect (copy.getInt32() == value);

                OSCArgument assignment ("this will be overwritten!");
                assignment = copy;
                expect (assignment.getType() == OSCTypes::int32);
                expect (assignment.getInt32() == value);
           }
           {
                const size_t numBytes = 412;
                MemoryBlock blob = getMemoryBlockWithRandomData (numBytes);
                OSCArgument arg (blob);

                OSCArgument copy = arg;
                expect (copy.getType() == OSCTypes::blob);
                expect (copy.getBlob() == blob);

                OSCArgument assignment ("this will be overwritten!");
                assignment = copy;
                expect (assignment.getType() == OSCTypes::blob);
                expect (assignment.getBlob() == blob);
           }
        }
    }