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