|
1 /* |
|
2 * Copyright (c) 2008 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: Server Main for Events Handler Server |
|
15 * |
|
16 */ |
|
17 |
|
18 // SYSTEM INCLUDES |
|
19 #include <e32std.h> |
|
20 #include <e32base.h> |
|
21 #include <coemain.h> |
|
22 #include <eikenv.h> |
|
23 #include <eikproc.h> |
|
24 |
|
25 // USER INCLUDES |
|
26 #include "evthandlerserver.h" |
|
27 #include "evthandlerclientserver.h" |
|
28 #include "evthandlerserverstartup.h" |
|
29 #include "evtserverappui.h" |
|
30 #include "evtserverapp.h" |
|
31 #include "evtserverappdocument.h" |
|
32 #include "evtdebug.h" |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // void EvtHandlerServerStartup::StartEvtHandlerServerL() |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 void EvtHandlerServerStartup::StartEvtHandlerServerL() |
|
39 /* |
|
40 * Perform all server initialisation, in particular creation of the |
|
41 * scheduler and server and then run the scheduler |
|
42 */ |
|
43 { |
|
44 EVTUIDEBUG( "+ EvtHandlerServerStartup::StartEvtHandlerServerL()" ); |
|
45 |
|
46 // naming the server thread after the server helps to debug panics |
|
47 User::LeaveIfError( RThread::RenameMe( KEvtHandlerServerName ) ); |
|
48 // |
|
49 // create the server (leave it on the cleanup stack) |
|
50 CEvtHandlerServer::NewLC(); |
|
51 // |
|
52 // Initialisation complete, now signal the client |
|
53 RProcess::Rendezvous( KErrNone ); |
|
54 // |
|
55 // Ready to run - Start the Scheduler |
|
56 CEikonEnv::Static()->Execute(); |
|
57 // |
|
58 // Cleanup the server |
|
59 CleanupStack::PopAndDestroy( ); |
|
60 |
|
61 EVTUIDEBUG( "- EvtHandlerServerStartup::StartEvtHandlerServerL()" ); |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // TInt EvtHandlerServerStartup::StartEvtHandlerServer() |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 TInt EvtHandlerServerStartup::StartEvtHandlerServer() |
|
69 { |
|
70 EVTUIDEBUG( "+ EvtHandlerServerStartup::StartEvtHandlerServer()" ); |
|
71 __UHEAP_MARK; |
|
72 TInt ret = KErrNoMemory; |
|
73 // We need the Control Environment for handling Key lock while launching the Global note |
|
74 // We need AppUi to Hide the Server from Fast Swap Window(FSW). |
|
75 CEikonEnv* env = new CEikonEnv(); |
|
76 if ( env ) |
|
77 { |
|
78 TRAP(ret, env->ConstructL()); |
|
79 if( !ret && env->AppUi() == NULL ) |
|
80 { |
|
81 CApaApplication* app = new CEvtServerApp; |
|
82 if ( app ) |
|
83 { |
|
84 env->WsSession().Flush(); |
|
85 CEikDocument* doc = NULL; |
|
86 TRAP_IGNORE( doc = static_cast<CEikDocument*>(app->CreateDocumentL( env->Process() )) ); |
|
87 if( doc ) |
|
88 { |
|
89 CEikAppUi* appUi = NULL; |
|
90 TRAP_IGNORE( appUi = static_cast<CEikAppUi*>( doc->CreateAppUiL() ) ); |
|
91 if(appUi) |
|
92 { |
|
93 appUi->SetDocument( doc ); |
|
94 TRAPD( err, appUi->ConstructL()); |
|
95 if(!err) |
|
96 { |
|
97 env->SetAppUi( appUi ); |
|
98 TRAP( ret, StartEvtHandlerServerL() ); |
|
99 } |
|
100 appUi->SetDocument( NULL ); |
|
101 } |
|
102 delete doc; |
|
103 } |
|
104 delete app; |
|
105 } |
|
106 } |
|
107 env->PrepareToExit(); |
|
108 env->DestroyEnvironment(); |
|
109 } |
|
110 __UHEAP_MARKEND; |
|
111 EVTUIDEBUG1( "- EvtHandlerServerStartup::StartEvtHandlerServer()", ret ); |
|
112 return ret; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // TInt E32Main |
|
117 // Server process entry-point |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 TInt E32Main() |
|
121 { |
|
122 EVTUIDEBUG( "+ E32Main() start" ); |
|
123 return EvtHandlerServerStartup::StartEvtHandlerServer(); |
|
124 } |
|
125 |
|
126 // End of File |