|
1 |
|
2 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 // All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Nokia Corporation - initial contribution. |
|
11 // |
|
12 // Contributors: |
|
13 // |
|
14 // Description: |
|
15 // |
|
16 |
|
17 #include "timezoneserver.h" |
|
18 #include <s32file.h> |
|
19 |
|
20 CTZSrvScheduler::~CTZSrvScheduler() |
|
21 { |
|
22 delete iServer; |
|
23 } |
|
24 |
|
25 CTZSrvScheduler* CTZSrvScheduler::NewL() |
|
26 { |
|
27 CTZSrvScheduler* self = new (ELeave) CTZSrvScheduler; |
|
28 CleanupStack::PushL(self); |
|
29 CActiveScheduler::Install(self); |
|
30 // create the server |
|
31 self->iServer=CTzServer::NewL(); |
|
32 CleanupStack::Pop(); |
|
33 return self; |
|
34 } |
|
35 |
|
36 void CTZSrvScheduler::Error(TInt aError) const |
|
37 { |
|
38 if (iServer) |
|
39 { |
|
40 iServer->Error(aError); |
|
41 } |
|
42 } |
|
43 |
|
44 static void RunServerL() |
|
45 // |
|
46 // Thread top level |
|
47 // Perform all server initialisation, in particular creation of the |
|
48 // scheduler and server and then run the scheduler |
|
49 // |
|
50 { |
|
51 // create and install the active scheduler we need |
|
52 CTZSrvScheduler* s = CTZSrvScheduler::NewL(); |
|
53 CleanupStack::PushL(s); |
|
54 |
|
55 // |
|
56 // naming the server thread after the server helps to debug panics |
|
57 User::LeaveIfError(RThread().RenameMe(KTimeZoneServerName())); |
|
58 |
|
59 |
|
60 // |
|
61 // Initialisation complete, now signal the client |
|
62 RProcess::Rendezvous(KErrNone); |
|
63 // |
|
64 // Ready to run |
|
65 CActiveScheduler::Start(); |
|
66 // |
|
67 // Cleanup the scheduler |
|
68 CleanupStack::PopAndDestroy(s); |
|
69 } |
|
70 |
|
71 GLDEF_C TInt E32Main() |
|
72 // |
|
73 // Timezone server entrypoint |
|
74 // |
|
75 { |
|
76 __UHEAP_MARK; |
|
77 // |
|
78 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
79 TInt r = KErrNoMemory; |
|
80 if (cleanup) |
|
81 { |
|
82 TRAP(r, RunServerL()); |
|
83 delete cleanup; |
|
84 } |
|
85 // |
|
86 __UHEAP_MARKEND; |
|
87 return r; |
|
88 } |