os/graphics/fbs/fontandbitmapserver/sfbs/FBSMAIN.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/fbs/fontandbitmapserver/sfbs/FBSMAIN.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,79 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <fbs.h>
    1.20 +#include "SERVER.H"
    1.21 +
    1.22 +// general dll routines for starting the server etc.
    1.23 +
    1.24 +GLDEF_C void Panic(TFbsPanic aPanic)
    1.25 +	{
    1.26 +	User::Panic(KFBSERVPanicCategory,aPanic);
    1.27 +	}
    1.28 +
    1.29 +GLDEF_C void CheckFbsNotRunning()
    1.30 +	{
    1.31 +	TFindChunk find(KFBSERVSharedChunkName);
    1.32 +	TFullName name;
    1.33 +	__ASSERT_ALWAYS(find.Next(name) == KErrNotFound, Panic(EFbsPanicStartupFailed));
    1.34 +	}
    1.35 +
    1.36 +GLDEF_C TInt FbsMain()
    1.37 +	{
    1.38 +    TInt ret;
    1.39 +	ret = User::SetProcessCritical(User::ESystemCritical);
    1.40 +	__ASSERT_ALWAYS(ret==KErrNone,User::Panic(KFBSERVPanicCategory,KErrServerTerminated));
    1.41 +    ret = User::SetCritical(User::ESystemCritical);
    1.42 +	__ASSERT_ALWAYS(ret==KErrNone,User::Panic(KFBSERVPanicCategory,KErrServerTerminated));
    1.43 +    RProcess().SetPriority(EPriorityHigh);
    1.44 +    
    1.45 +	CFbActiveScheduler* as=NULL;
    1.46 +	CFontBitmapServer* fbs=NULL;
    1.47 +	__UHEAP_MARK;
    1.48 +	CTrapCleanup* tc=CTrapCleanup::New();
    1.49 +	__ASSERT_ALWAYS(tc,User::Panic(KFBSERVPanicCategory,KErrServerTerminated));
    1.50 +	// Rename thread
    1.51 +	ret = User::RenameThread(KFBSERVGlobalThreadName);
    1.52 +	__ASSERT_ALWAYS(ret==KErrNone,User::Panic(KFBSERVPanicCategory,KErrServerTerminated));
    1.53 +	TRAP(ret,as=new(ELeave) CFbActiveScheduler);
    1.54 +	__ASSERT_ALWAYS(ret==KErrNone,User::Panic(KFBSERVPanicCategory,KErrServerTerminated));
    1.55 +	CActiveScheduler::Install(as);
    1.56 +	TRAP(ret,fbs=CFontBitmapServer::NewL());
    1.57 +	__ASSERT_ALWAYS(ret==KErrNone,User::Panic(KFBSERVPanicCategory,KErrServerTerminated));
    1.58 +	RProcess::Rendezvous(KErrNone);
    1.59 +	CActiveScheduler::Start();
    1.60 +	delete as;
    1.61 +	delete fbs;
    1.62 +	delete tc;
    1.63 +	__UHEAP_MARKEND;
    1.64 +	return(0);
    1.65 +	}
    1.66 +
    1.67 +CFbActiveScheduler::CFbActiveScheduler():
    1.68 +	CActiveScheduler()
    1.69 +	{
    1.70 +	}
    1.71 +
    1.72 +void CFbActiveScheduler::Error(TInt /*anError*/) const
    1.73 +	{
    1.74 +	Panic(EFbsPanicActiveSchedulerError);
    1.75 +	}
    1.76 +
    1.77 +GLDEF_C TInt E32Main()
    1.78 +	{
    1.79 +	CheckFbsNotRunning();
    1.80 +	return(FbsMain());
    1.81 +	}
    1.82 +