sl@0
|
1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <fbs.h>
|
sl@0
|
17 |
#include "SERVER.H"
|
sl@0
|
18 |
|
sl@0
|
19 |
// general dll routines for starting the server etc.
|
sl@0
|
20 |
|
sl@0
|
21 |
GLDEF_C void Panic(TFbsPanic aPanic)
|
sl@0
|
22 |
{
|
sl@0
|
23 |
User::Panic(KFBSERVPanicCategory,aPanic);
|
sl@0
|
24 |
}
|
sl@0
|
25 |
|
sl@0
|
26 |
GLDEF_C void CheckFbsNotRunning()
|
sl@0
|
27 |
{
|
sl@0
|
28 |
TFindChunk find(KFBSERVSharedChunkName);
|
sl@0
|
29 |
TFullName name;
|
sl@0
|
30 |
__ASSERT_ALWAYS(find.Next(name) == KErrNotFound, Panic(EFbsPanicStartupFailed));
|
sl@0
|
31 |
}
|
sl@0
|
32 |
|
sl@0
|
33 |
GLDEF_C TInt FbsMain()
|
sl@0
|
34 |
{
|
sl@0
|
35 |
TInt ret;
|
sl@0
|
36 |
ret = User::SetProcessCritical(User::ESystemCritical);
|
sl@0
|
37 |
__ASSERT_ALWAYS(ret==KErrNone,User::Panic(KFBSERVPanicCategory,KErrServerTerminated));
|
sl@0
|
38 |
ret = User::SetCritical(User::ESystemCritical);
|
sl@0
|
39 |
__ASSERT_ALWAYS(ret==KErrNone,User::Panic(KFBSERVPanicCategory,KErrServerTerminated));
|
sl@0
|
40 |
RProcess().SetPriority(EPriorityHigh);
|
sl@0
|
41 |
|
sl@0
|
42 |
CFbActiveScheduler* as=NULL;
|
sl@0
|
43 |
CFontBitmapServer* fbs=NULL;
|
sl@0
|
44 |
__UHEAP_MARK;
|
sl@0
|
45 |
CTrapCleanup* tc=CTrapCleanup::New();
|
sl@0
|
46 |
__ASSERT_ALWAYS(tc,User::Panic(KFBSERVPanicCategory,KErrServerTerminated));
|
sl@0
|
47 |
// Rename thread
|
sl@0
|
48 |
ret = User::RenameThread(KFBSERVGlobalThreadName);
|
sl@0
|
49 |
__ASSERT_ALWAYS(ret==KErrNone,User::Panic(KFBSERVPanicCategory,KErrServerTerminated));
|
sl@0
|
50 |
TRAP(ret,as=new(ELeave) CFbActiveScheduler);
|
sl@0
|
51 |
__ASSERT_ALWAYS(ret==KErrNone,User::Panic(KFBSERVPanicCategory,KErrServerTerminated));
|
sl@0
|
52 |
CActiveScheduler::Install(as);
|
sl@0
|
53 |
TRAP(ret,fbs=CFontBitmapServer::NewL());
|
sl@0
|
54 |
__ASSERT_ALWAYS(ret==KErrNone,User::Panic(KFBSERVPanicCategory,KErrServerTerminated));
|
sl@0
|
55 |
RProcess::Rendezvous(KErrNone);
|
sl@0
|
56 |
CActiveScheduler::Start();
|
sl@0
|
57 |
delete as;
|
sl@0
|
58 |
delete fbs;
|
sl@0
|
59 |
delete tc;
|
sl@0
|
60 |
__UHEAP_MARKEND;
|
sl@0
|
61 |
return(0);
|
sl@0
|
62 |
}
|
sl@0
|
63 |
|
sl@0
|
64 |
CFbActiveScheduler::CFbActiveScheduler():
|
sl@0
|
65 |
CActiveScheduler()
|
sl@0
|
66 |
{
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
void CFbActiveScheduler::Error(TInt /*anError*/) const
|
sl@0
|
70 |
{
|
sl@0
|
71 |
Panic(EFbsPanicActiveSchedulerError);
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
GLDEF_C TInt E32Main()
|
sl@0
|
75 |
{
|
sl@0
|
76 |
CheckFbsNotRunning();
|
sl@0
|
77 |
return(FbsMain());
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|