Esempio n. 1
0
Signature SignerReal::sign( PrivateKey privkey, Digest hash, Monitor& monitor )
{
	if (!check_interface(monitor)) return Signature();

	Parameters params = privkey.getAlgParams(acSign, Monitor());
	if (params) setAlgParams(params,monitor);

	Padder curpad = padder;
	if (privkey.getPadder(Monitor()))
	{
		curpad = privkey.getPadder(monitor);
	} else {
		//TODO: find default padder
	}

	Error error;
	if (random)
	{
		IRef<eprovider::ProviderInterface> randomer = creator.getCreatureCurrentInterface(random);
		if (randomer) iface->setRandom(session, randomer.cast<eprovider::RandomGenerator>().get(), error);
	}

	eprovider::TheKey thekey = creator.getCreatureCurrentTheKey(privkey);

	Size hashsize = iface->getMaxHashSize(thekey, error);
	if (curpad.ok() && hashsize.bits()) hash = curpad.pad(hash, hashsize, monitor); if (!monitor) return Signature();
	Data hashblock = hash.asData();

	eprovider::Block binsign;
	RECOVER_CALL( (binsign = iface->signHash(session, hashblock.get(), hashblock.size(), thekey, error)) );

	Snapshot snapshot = creator.createSnapshot(binsign.get(), binsign.size(), binsign.encid(), iface->getKeyId(kcSignature));
	return snapshot.reviveSignature(monitor);
}
Esempio n. 2
0
Bool SignerReal::notarize( PublicKey pubkey, Signature signature, Digest hash, Monitor& monitor )
{
	if (!check_interface(monitor)) return false;

	eprovider::TheKey thepubkey = creator.getCreatureCurrentTheKey(pubkey);
	Size hashsize;
	RECOVER_CALL(hashsize = iface->getMaxHashSize(thepubkey, error));
	
	Padder curpad = padder;
	if (pubkey.getPadder(Monitor()))
	{
		curpad = pubkey.getPadder(monitor);
	} else if (signature.getPadder(Monitor()))
	{
		curpad = signature.getPadder(monitor);
	} else {
		//TODO: find default padder
	}

	if (curpad.ok() && hashsize.bits()) hash = curpad.pad(hash, hashsize, monitor); if (!monitor) return Bool();
	Data hashblock = hash.asData();
	
	Image signimage = signature.encode(monitor);
	Snapshot signblock = signimage.snapshot();

	Bool result;
	
	RECOVER_CALL( (result = iface->notarizeHash(session,hashblock.get(), hashblock.size(), signblock.get(), signblock.size(), signblock.encid(), thepubkey, error)) );

	return result;
}
Esempio n. 3
0
Monitor DisplayManager::MonitorAtPoint(POINT &pt, bool workingArea) {
    Monitor m;
    HMONITOR monitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONULL);
    if (monitor != NULL) {
        MONITORINFO mInfo = Info(monitor);
        if (workingArea) {
            return Monitor(monitor, L"Monitor@Point", mInfo.rcWork);
        } else {
            return Monitor(monitor, L"Monitor@Point", mInfo.rcMonitor);
        }
    }

    return m;
}
Esempio n. 4
0
Monitor DisplayManager::MonitorAtWindow(HWND hWnd, bool workingArea) {
    Monitor m;
    HMONITOR monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL);
    if (monitor != NULL) {
        MONITORINFO mInfo = Info(monitor);
        if (workingArea) {
            return Monitor(monitor, L"Monitor@Window", mInfo.rcWork);
        } else {
            return Monitor(monitor, L"Monitor@Window", mInfo.rcMonitor);
        }
    }

    return m;
}
Esempio n. 5
0
Monitor DisplayManager::Primary() {
    /* The Primary or 'Main' monitor is at (0, 0). */
    const POINT p = { 0, 0 };
    HMONITOR monitor = MonitorFromPoint(p, MONITOR_DEFAULTTOPRIMARY);
    MONITORINFO mInfo = Info(monitor);
    return Monitor(monitor, L"Primary", mInfo.rcMonitor);
}
Esempio n. 6
0
	StorageReal(CreatorInt& creat, IRef<eprovider::Storage> ifa, 
		Index ses) 
		: CreatureDefaultImplementation(creat)
	{
		set_interface(ifa,false,Monitor());
		session = ses;
	}
Esempio n. 7
0
// StartBuild
//------------------------------------------------------------------------------
/*static*/ void FLog::StartBuild()
{
    if ( FBuild::Get().GetOptions().m_EnableMonitor )
    {
        // TODO:B Change the monitoring log path
        //  - it's not uniquified per instance
        //  - we already have a .fbuild.tmp folder we should use
        AStackString<> fullPath;
        FileIO::GetTempDir( fullPath );
        fullPath += "FastBuild/FastBuildLog.log";

        ASSERT( g_MonitorFileStream == nullptr );
        MutexHolder lock( g_MonitorMutex );
        g_MonitorFileStream = new FileStream();
        if ( g_MonitorFileStream->Open( fullPath.Get(), FileStream::WRITE_ONLY ) == false )
        {
            delete g_MonitorFileStream;
            g_MonitorFileStream = nullptr;
        }

        Monitor( "START_BUILD %u %u\n", FBUILD_MONITOR_VERSION, Process::GetCurrentId() );
    }

    Tracing::AddCallbackOutput( &TracingOutputCallback );
}
Esempio n. 8
0
void DRRIPCache::init(char *s, char *t, uint a, uint b, uint c, uint n, uint p, uint m, bool isLite)
{
    BaseCache::init(s,t,a,b,c);
    lite = isLite;
    maxRRPV = (1<<n)-1;
    rrpv = (uint**)malloc(noOfSets*sizeof(uint*));
    for(uint i=0;i<noOfSets;++i)
        rrpv[i] = (uint*)malloc(associativity*sizeof(uint));
    for(uint i=0;i<noOfSets;++i)
    {
        for(uint j=0;j<associativity;++j)
            rrpv[i][j] = maxRRPV;
    }
    
    throttleCounter = 0;
    throttleParam = p;
    psel = Monitor();
    psel.set(m);    

    wssc_map = NULL;
    wssc_interval = 0;
    stat_total_early_prefetch = 0;
    totalPrefetchedLines = totalPrefetchedUnusedLines = 0;
    perfect_prefetch = 0;
    miss_prediction = 0;
}
Esempio n. 9
0
ServiceDescription* ServiceManager::find(ServiceFilter* svcFilter) {
	Message* findMsg = svcFilter->toMessage();
	string reqId = UUID::getUUID();
	findMsg->setMeta("type", "serviceDisc");
	findMsg->setMeta("reqId", reqId.c_str());
	_svcPub->waitForSubscribers(1);
	Thread::sleepMs(1000);
	_findRequests[reqId] = Monitor();

	_svcPub->send(findMsg);
	delete findMsg;

	_findRequests[reqId].wait();
	ScopeLock lock(&_mutex);
	_findRequests.erase(reqId);

	if (_findResponses.find(reqId) != _findResponses.end()) {
		Message* foundMsg = _findResponses[reqId];
		assert(foundMsg != NULL);
		ServiceDescription* svcDesc = new ServiceDescription(foundMsg);
		svcDesc->_svcManager = this;
		_findResponses.erase(reqId);
		delete foundMsg;
		return svcDesc;
	}
	return NULL;
}
Esempio n. 10
0
	StorageReal(CreatorInt& creat, IRef<eprovider::Storage> ifa, 
		        const wchar_t* path, bool create_if_not_exists) 
		: CreatureDefaultImplementation(creat)
	{
		set_interface(ifa,true,Monitor());
		
		Monitor monitor;
		SIMPLE_CALL( (session = ifa->createSession(error)) );
		SIMPLE_CALL( (ifa->openPath(session,path,create_if_not_exists,error)) );
		
		//TODO: what if error???
	}
Esempio n. 11
0
// StopBuild
//------------------------------------------------------------------------------
/*static*/ void FLog::StopBuild()
{
    if ( g_MonitorFileStream )
    {
        MutexHolder lock( g_MonitorMutex );
        Monitor( "STOP_BUILD\n" );
        g_MonitorFileStream->Close();

        delete g_MonitorFileStream;
        g_MonitorFileStream = nullptr;
    }

    Tracing::RemoveCallbackOutput( &TracingOutputCallback );

    if ( s_ShowProgress )
    {
        fputs( g_ClearLineString.Get(), stdout );
        m_ProgressText.Clear();
    }
}
//*=================================================================================
//*原型: void TSmartOutThread::Run()
//*功能: 读入客户端的请求, 并给出回应
//*参数: 无
//*返回: 无
//*说明: 
//*=================================================================================
void TSmartOutThread::Run()
{
	SOCKET       hClient;
	SOCKADDR_IN  sockAddr;
	int nLen = sizeof(sockAddr);
	int nBlockMode = 1 ;

	DWORD dwTick = GetTickCount();

	while( !IsShutdown() )
	{
		if( Wait(m_hServerSocket, 0, 1000) )
		{
			ZeroMemory(&sockAddr, sizeof(sockAddr));

			hClient = accept(m_hServerSocket, (SOCKADDR*)&sockAddr, &nLen);
			if( hClient != INVALID_SOCKET )
			{	
				if( ioctlsocket(hClient, FIONBIO, (DWORD*)&nBlockMode) != SOCKET_ERROR )
				{
					ProcessRequest(hClient, &sockAddr);
				}
				shutdown(hClient, SB_BOTH);
				closesocket(hClient);
				hClient = INVALID_SOCKET;
			}
		}

		if( GetTickCount() - dwTick > 10000 )
		{
			Monitor();
			dwTick = GetTickCount();
		}
	}

	CloseOutSocket();
}
Esempio n. 13
0
/**
 * Update the local favorites file and add thumb if necessary.
 */
void favoriteWindow::save()
{
	Favorite oldFav = m_favorite;

	// Update monitors
	int interval = ui->spinMonitoringInterval->value() * 60;
	Site *site = m_profile->getSites().value(ui->comboMonitoringSource->currentText());
	QList<Monitor> monitors = oldFav.getMonitors();
	if (interval == 0)
	{ monitors.clear(); }
	else if (monitors.isEmpty())
	{ monitors.append(Monitor(site, interval, QDateTime::currentDateTimeUtc())); }
	else
	{
		Monitor rep(site, interval, monitors[0].lastCheck());
		monitors[0] = rep;
	}

	m_favorite = Favorite(ui->tagLineEdit->text(), ui->noteSpinBox->value(), ui->lastViewedDateTimeEdit->dateTime(), monitors);
	m_favorite.setImagePath(savePath("thumbs/" + m_favorite.getName(true) + ".png"));

	if (oldFav.getName() != m_favorite.getName())
	{
		if (QFile::exists(savePath("thumbs/" + oldFav.getName(true) + ".png")))
		{ QFile::rename(savePath("thumbs/" + oldFav.getName(true) + ".png"), m_favorite.getImagePath()); }
		m_profile->removeFavorite(oldFav);
	}

	if (QFile::exists(ui->imageLineEdit->text()))
	{
		QPixmap img(ui->imageLineEdit->text());
		if (!img.isNull())
		{ m_favorite.setImage(img); }
	}
	m_profile->addFavorite(m_favorite);
}
Esempio n. 14
0
//=========================================================================
//----- (00000148) --------------------------------------------------------
__myevic__ void Main()
{
	InitDevices();

	InitVariables();

	// Enable chip temp sensor sampling by ADC
	if ( ISRX300 )
	{
		SYS->IVSCTL |= SYS_IVSCTL_VTEMPEN_Msk;
	}

	InitHardware();

	myprintf( "\n\nJoyetech APROM\n" );
	myprintf( "CPU @ %dHz(PLL@ %dHz)\n", SystemCoreClock, PllClock );

	SetBatteryModel();

	gFlags.sample_vbat = 1;
	ReadBatteryVoltage();

	gFlags.sample_btemp = 1;
	ReadBoardTemp();

	InitDisplay();
	MainView();
	SplashTimer = 3;

	CustomStartup();

	if ( !PD3 )
	{
		DrawScreen();
		while ( !PD3 )
			;
	}

	while ( 1 )
	{
		while ( gFlags.playing_fb )
		{
			// Flappy Bird game loop
			fbCallTimeouts();
			if ( gFlags.tick_100hz )
			{
				// 100Hz
				gFlags.tick_100hz = 0;
				ResetWatchDog();
				TimedItems();
				SleepIfIdle();
				GetUserInput();
				if ( !PE0 )
					SleepTimer = 3000;
			}
			if ( gFlags.tick_10hz )
			{
				// 10Hz
				gFlags.tick_10hz = 0;
				DataFlashUpdateTick();
			}
		}

		if ( gFlags.firing )
		{
			ReadAtoCurrent();
		}

		if ( gFlags.tick_5khz )
		{
			// 5000Hz
			gFlags.tick_5khz = 0;

			if ( gFlags.firing )
			{
				RegulateBuckBoost();
			}
		}

		if ( gFlags.tick_1khz )
		{
			// 1000Hz
			gFlags.tick_1khz = 0;

			if ( gFlags.firing )
			{
				ReadAtomizer();

				if ( ISMODETC(dfMode) )
				{
					if ( gFlags.check_mode )
					{
						CheckMode();
					}
					TweakTargetVoltsTC();
				}
				else if ( ISMODEVW(dfMode) )
				{
					TweakTargetVoltsVW();
				}
			}

			if ( dfStatus.vcom )
			{
				VCOM_Poll();
			}
		}

		if ( gFlags.tick_100hz )
		{
			// 100Hz
			gFlags.tick_100hz = 0;

			ResetWatchDog();

			if ( gFlags.read_battery )
			{
				gFlags.read_battery = 0;
			}

			TimedItems();
			SleepIfIdle();
			ReadBatteryVoltage();
			ReadBoardTemp();

			if ( gFlags.firing && BoardTemp >= 70 )
			{
				Overtemp();
			}

			if ( ISVTCDUAL )
			{
				BatteryChargeDual();
			}
			else if ( ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 || ISRX300 )
			{
				BatteryCharge();
			}

			if (( gFlags.anim3d ) && ( Screen == 1 ) && ( !EditModeTimer ))
			{
				anim3d( 0 );
			}

			if ( Screen == 60 )
			{
				AnimateScreenSaver();
			}

			if ( gFlags.firing )
			{
				if ( gFlags.read_bir && ( FireDuration > 10 ) )
				{
					ReadInternalResistance();
				}

				if ( PreheatTimer && !--PreheatTimer )
				{
					uint16_t pwr;

					if ( dfMode == 6 )
					{
						pwr = dfSavedCfgPwr[ConfigIndex];
					}
					else
					{
						pwr = dfPower;
					}

					if ( pwr > BatteryMaxPwr )
					{
						gFlags.limit_power = 1;
						PowerScale = 100 * BatteryMaxPwr / pwr;
					}
					else
					{
						gFlags.limit_power = 0;
						PowerScale = 100;
					}
				}
			}

			if ( KeyTicks >= 5 )
			{
				KeyRepeat();
			}

			GetUserInput();
		}

		if ( gFlags.tick_10hz )
		{
			// 10Hz
			gFlags.tick_10hz = 0;

			DataFlashUpdateTick();
			LEDTimerTick();

			if ( gFlags.firing )
			{
				++FireDuration;

				if ( gFlags.monitoring )
				{
					Monitor();
				}
			}

			if ( ShowWeakBatFlag )
				--ShowWeakBatFlag;

			if ( ShowProfNum )
				--ShowProfNum;

			if ( !( gFlags.firing && ISMODETC(dfMode) ) )
			{
				DrawScreen();
			}

			if ( KeyTicks < 5 )
			{
				KeyRepeat();
			}
		}

		if ( gFlags.tick_5hz )
		{
			// 5Hz
			gFlags.tick_5hz = 0;

			if ( !gFlags.rtcinit && NumBatteries )
			{
				InitRTC();
			}

			if ( gFlags.firing )
			{
				if ( TargetVolts == 0 )
				{
					ProbeAtomizer();
				}
			}
			else
			{
				if
				(	!dfStatus.off
					&& Event == 0
					&& ( AtoProbeCount < 12 )
					&& ( Screen == 0 || Screen == 1 || Screen == 5 ) )
				{
					ProbeAtomizer();
				}
			}

			if ( IsClockOnScreen() )
			{
				static uint8_t u8Seconds = 61;
				S_RTC_TIME_DATA_T rtd;

				GetRTC( &rtd );

				if ( (uint8_t)rtd.u32Second != u8Seconds )
				{
					u8Seconds = (uint8_t)rtd.u32Second;
					gFlags.refresh_display = 1;
				}
			}
		}

		if ( gFlags.tick_2hz )
		{
			// 2Hz
			gFlags.tick_2hz = 0;

			gFlags.osc_1hz ^= 1;

			if ( gFlags.firing )
			{
				if ( ISMODETC(dfMode) )
				{
					DrawScreen();
				}
			}
			else
			{
				if
				(	!dfStatus.off
					&& Event == 0
					&& ( AtoProbeCount >= 12 )
					&& ( Screen == 0 || Screen == 1 || Screen == 5 ) )
				{
					ProbeAtomizer();
				}

				if ( gFlags.monitoring )
				{
					Monitor();
				}
			}
		}

		if ( gFlags.tick_1hz )
		{
			// 1Hz
			gFlags.tick_1hz = 0;

			if ( SplashTimer )
			{
				--SplashTimer;
				
				if ( !SplashTimer )
				{
					MainView();
				}
			}

			if ( !gFlags.firing && !dfStatus.off && !EditModeTimer )
			{
				if ( HideLogo )
				{
					if ( Screen == 1 )
					{
						--HideLogo;

						if ( !HideLogo )
						{
							gFlags.refresh_display = 1;
						}
					}
				}
			}
		}

		EventHandler();

	}
}
Esempio n. 15
0
Monitor::Monitor(const Monitor &that) :
    mDisplay(that.mDisplay)
{
    Monitor(&that.mDisplay, that.mID);
}
Esempio n. 16
0
#include "Monitor/Monitor.h"

//Monitor object
Monitor mon = Monitor();

//Demo variables
int rondo = 0;
char* roboto = "BEEEEPPP";

/* This function is called once at start up ----------------------------------*/
void setup()
{
    //Initialize the Monitor
    mon.begin();
    
    //Set up the variables to be monitored
    mon.variable("robotSays",roboto,STRING);
    mon.variable("random",&rondo,INT);
    
}

/* This function loops forever --------------------------------------------*/
void loop()
{
    //Updates the Monitor; run at least once per loop for good resolution
    mon.report();
    
    rondo = random(100);
    delay(20);
}
Esempio n. 17
0
static void Test(Properties &prop) {
    FileSystemState *tablefs_data;
    tablefs_data = new tablefs::FileSystemState(prop.getPropertyInt("threshold"),
                                          prop.getProperty("metadir").c_str(),
                                          prop.getProperty("datadir").c_str(),
                                          prop.getProperty("logfile").c_str(),
                                          prop.getPropertyInt("sync.time.limit",-1));

    SetState(tablefs_data);

    Init(NULL);

    int mem_lock_size = 400;
    mem_lock_size = prop.getPropertyInt("mem.lock.size", 400);
    TraceLoader loader(mem_lock_size);
    loader.LoadTrace(prop.getProperty("tracefile").c_str());

    Monitor mon = Monitor(prop.getProperty("mon.partition"), 
                          prop.getProperty("mon.filesystem"));
    Monitor tmon = Monitor(prop.getProperty("mon.partition"), 
                           prop.getProperty("mon.filesystem"));
    mon.DoMonitor();
    tmon.DoMonitor();

    sync();

    srand(100);
    time_t time1 = time(NULL);
    int cnt = 0;
    for (int i = 0; i < loader.getNumPaths(); ++i) {
    	char filetype;
    	char* path = loader.getPath(i, filetype);
        Stat(path);
        if (filetype == 'f') {
            Mknode(path);
        } else
        if (filetype == 'd') {
            Mkdir(path);
        }
        Stat(path);
        cnt ++;
        if (cnt >= 1000) {
          tmon.DoMonitor();
          cnt = 0;
        }
    }

    time_t time2 = time(NULL);
    mon.DoMonitor();
    tmon.DoMonitor();
    printf("create directory tree , %d\n", (int) (time2 - time1));
    int nquery = prop.getPropertyInt("num.query");
    int npath = loader.getNumPaths();
    printf("nquery %d npath %d\n", nquery, npath);
    cnt = 0;
    for (int i = 0; i < nquery; ++i) {
      int pi = rand() % npath;
      char* path = loader.getPath(pi);
      if ((i & 3) == 0) {
        Chmod(path, 777);
      } else 
      if ((i & 3) == 1) {
        struct timespec tv[2];
        tv[0].tv_sec = time(NULL);
        tv[1].tv_sec = time(NULL);
        UpdateTimens(path, tv);
      } else {
        Stat(path);
      }
      cnt++;
      if (cnt >= 1000) {
        tmon.DoMonitor();
        cnt = 0;
      }
    }

    time_t time3 = time(NULL);
    mon.DoMonitor();
    tmon.DoMonitor();
    printf("update and query , %d\n", (int) (time3 - time2));

    char tpath[256];
    sprintf(tpath, "%s/test.txt", prop.getProperty("metadir").c_str()); 
    int fd = open(tpath, O_WRONLY); 
    fsync(fd);
    close(fd);
    sync();
    
    for (int i = 0; i < 20; ++i) {
      sleep(1);
      tmon.DoMonitor();
    }

    time_t time4 = time(NULL);
    mon.DoMonitor();
    tmon.DoMonitor();
    printf("sync , %d\n", (int) (time4 - time3));

    mon.Report();
    tmon.Report();

    Destroy(tablefs_data);
}
void CMemoryMonitorSession::ServiceL(const RMessage2& aMessage)
    {
    FUNC_LOG;
        
#ifndef CLIENT_REQUEST_QUEUE
    iFunction = aMessage.Function();
#endif 
    
    switch (aMessage.Function())
        {
        case EOomMonitorRequestFreeMemory:
            if (!iRequestFreeRam.IsNull())
                PanicClient(aMessage, EPanicRequestActive);
            // message will be completed when CloseAppsFinished() is called.  
            
#ifdef CLIENT_REQUEST_QUEUE
            ClientRequestQueue().RequestFreeMemoryL(aMessage);
#else
            iRequestFreeRam = aMessage;
            Monitor().RequestFreeMemoryL(aMessage.Int0(), IsDataPaged(aMessage));
#endif
            break;

        case EOomMonitorCancelRequestFreeMemory:
            if (!iRequestFreeRam.IsNull())
                iRequestFreeRam.Complete(KErrCancel);
            aMessage.Complete(KErrNone);
            break;

        case EOomMonitorThisAppIsNotExiting:
            Monitor().AppNotExiting(aMessage.Int0());
            aMessage.Complete(KErrNone);
            break;

        case EOomMonitorRequestOptionalRam:
            if (!iRequestFreeRam.IsNull())
                PanicClient(aMessage, EPanicRequestActive);
            // message will be completed when CloseAppsFinished() is called.
            
#ifdef CLIENT_REQUEST_QUEUE
            ClientRequestQueue().RequestOptionalRamL(aMessage);
#else
            iRequestFreeRam = aMessage;
            iMinimumMemoryRequested = aMessage.Int1();
            Monitor().FreeOptionalRamL(aMessage.Int0(), aMessage.Int2(), IsDataPaged(aMessage));
#endif            
            break;
            
        case EOomMonitorSetPriorityBusy:
            Monitor().SetPriorityBusy(aMessage.Int0());
            aMessage.Complete(KErrNone);
            break;
            
        case EOomMonitorSetPriorityNormal:
               Monitor().SetPriorityNormal(aMessage.Int0());
            aMessage.Complete(KErrNone);
            break;

        case EOomMonitorSetPriorityHigh:
               Monitor().SetPriorityHigh(aMessage.Int0());
            aMessage.Complete(KErrNone);
            break;

        default:
            PanicClient(aMessage, EPanicIllegalFunction);
            break;
        }
    }
Esempio n. 19
0
int main()
{
        Monitor();

        return 0;
}
void CMemoryMonitorSession::ServiceL(const RMessage2& aMessage)
    {
    FUNC_LOG;
    
    iFunction = aMessage.Function();
    RThread t;
    aMessage.Client(t);
    
    iClientId = t.SecureId();
    t.Close();
    
    TRACES1("NEW REQUEST from client %x", iClientId);
    switch (aMessage.Function())
        {
        case EGOomMonitorRequestFreeMemory:

            //Do not take any more requests from the same client if previous request being served
            if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(iClientId))
                {
                TRACES1("CANNOT PROCESS NEW REQUEST from %x", iClientId);
                aMessage.Complete(KErrInUse);
                return;
                }
            
            Server().Monitor().SetActiveClient(iClientId);
            // message will be completed when CloseAppsFinished() is called.
            if (aMessage.Int1() == 0)
                {
                iRequestFreeRam = aMessage;

                Server().Monitor().SessionInCriticalAllocation(1, iClientId);
                
                TRAPD(err, Monitor().RequestFreeMemoryL(aMessage.Int0()));
                if(err == KErrCompletion) 
                    {
                    TRACES("There is already enough memory - nothing to do");
                    Server().Monitor().SessionInCriticalAllocation(0, iClientId);
                    }
                else if (err != KErrNone )
                    {
                    // completes the message if that was left to pending
                    TRACES1("Error in RequestFreeMemory %d", err);
                    CloseAppsFinished(0, EFalse);
                    }
                }
            else
                {
                TInt appUid = aMessage.Int1();
                // if no new memory was needed, the message is completed synchronously
                iRequestFreeRam = aMessage;
                TRAP_IGNORE(Monitor().HandleFocusedWgChangeL(appUid));
                }
            break;
            
        case EGOomMonitorMemoryAllocationsComplete:
            TRACES1("ServiceL : Memory Allocations complete from %x", iClientId);
            Server().Monitor().SessionInCriticalAllocation(0, iClientId);
            aMessage.Complete(KErrNone);
            break;

        case EGOomMonitorCancelRequestFreeMemory:
            if (!iRequestFreeRam.IsNull())
                {
                iRequestFreeRam.Complete(KErrCancel);
                }
            Server().Monitor().SessionInCriticalAllocation(0, iClientId);
            aMessage.Complete(KErrNone);
            break;

        case EGOomMonitorThisAppIsNotExiting:
            Monitor().AppNotExiting(aMessage.Int0());
            aMessage.Complete(KErrNone);
            break;

        case EGOomMonitorRequestOptionalRam:
            if (!iRequestFreeRam.IsNull() && !Server().Monitor().IsSafeToProcessNewRequest(iClientId))
                {
                aMessage.Complete(KErrInUse);
                }
            Server().Monitor().SetActiveClient(iClientId);
            // message will be completed when CloseAppsFinished() is called.
            iRequestFreeRam = aMessage;
            iMinimumMemoryRequested = aMessage.Int1();
            Monitor().FreeOptionalRamL(aMessage.Int0(), aMessage.Int2());
            break;
            
        case EGOomMonitorSetPriorityBusy:
            Monitor().SetPriorityBusy(aMessage.Int0());
            aMessage.Complete(KErrNone);
            break;
            
        case EGOomMonitorSetPriorityNormal:
            Monitor().SetPriorityNormal(aMessage.Int0());
            aMessage.Complete(KErrNone);
            break;

        case EGOomMonitorSetPriorityHigh:
            Monitor().SetPriorityHigh(aMessage.Int0());
            aMessage.Complete(KErrNone);
            break;

        case EGoomMonitorAppAboutToStart:
            {
            TInt appUid = aMessage.Int0();
            aMessage.Complete(KErrNone);  
            TRAP_IGNORE(Monitor().HandleFocusedWgChangeL(appUid))
            break;
            }
           
        case EGoomMonitorAppUsesAbsoluteMemTargets:
            {
            iUseAbsoluteTargets = aMessage.Int0();
/*            TRACES2("EGoomMonitorAppUsesAbsoluteMemTargets this: 0x%x, use abs targets %d", this, iUseAbsoluteTargets);
            Server().Monitor().SessionInCriticalAllocation(iUseAbsoluteTargets);
*/          aMessage.Complete(KErrNone);     
            break;
            }    
        case EGOomMonitorRequestHWRendering:
            {
            RDebug::Printf("RAN_DEBUG : GOOM EGOomMonitorRequestHWRendering");
            if(Server().Monitor().SwitchRenderingToHW())
                aMessage.Complete(KErrNone);
            else
                aMessage.Complete(KErrNoMemory);
            
            break;
            }
        default:
            PanicClient(aMessage, EPanicIllegalFunction);
            break;
        }
    }