|
1 // Copyright (c) 2004-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 // Main entry point in the process |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 #include "sbmain.h" |
|
23 #include "sblog.h" |
|
24 #include "sbeserver.h" |
|
25 #include "abserver.h" |
|
26 #include <connect/tserverstart.h> |
|
27 #include "sbedataownermanager.h" |
|
28 #include "ecom/ecom.h" |
|
29 |
|
30 namespace conn |
|
31 { |
|
32 |
|
33 void CSBActiveScheduler::Error(TInt aError) const |
|
34 /** |
|
35 Executed by the active scheduler when an error occurs. Ideally errors |
|
36 should be handled in the RunError() method of active objects and |
|
37 not in here. |
|
38 |
|
39 It logs an error and stops the active scheduler, which will cause |
|
40 execution to terminate. |
|
41 |
|
42 @param aError The error code |
|
43 */ |
|
44 { |
|
45 RDebug::Print(_L("Secure Backup unhandled error %d"), aError); |
|
46 Stop(); |
|
47 } |
|
48 } |
|
49 |
|
50 |
|
51 using namespace conn; |
|
52 |
|
53 // |
|
54 // EKA1 server startup code - platform unspecific. |
|
55 |
|
56 |
|
57 static void RunServerL() |
|
58 /** |
|
59 Installs active scheduler, creates the CSBEServer and CABServer objects, |
|
60 signals the client, and begins to handle client requests.. |
|
61 |
|
62 @param aStart A TServerStart object passed in by the client |
|
63 @leave RThread::Rename() If an error is returned |
|
64 */ |
|
65 { |
|
66 // |
|
67 // Create and install an active scheduler. |
|
68 CSBActiveScheduler* pScheduler = new (ELeave) CSBActiveScheduler(); |
|
69 CleanupStack::PushL(pScheduler); |
|
70 CActiveScheduler::Install(pScheduler); |
|
71 |
|
72 CDataOwnerManager* pDOM = CDataOwnerManager::NewLC(); |
|
73 |
|
74 // create the two servers to run in this process |
|
75 CSBEServer* pSBEServer = CSBEServer::NewLC(pDOM); |
|
76 CABServer* pABServer = CABServer::NewLC(pDOM); |
|
77 |
|
78 // register the AB Server with the DOM |
|
79 pDOM->SetActiveBackupServer(pABServer); |
|
80 |
|
81 // Rename the thread (for debugging) |
|
82 User::RenameThread(KSBImageName); |
|
83 |
|
84 RProcess::Rendezvous(KErrNone); |
|
85 |
|
86 // |
|
87 // Start the AS. Will return after 2 seconds |
|
88 // of inactivity on the server. |
|
89 CSBActiveScheduler::Start(); |
|
90 |
|
91 TDriveList driveList; |
|
92 TBURPartType burPartType = EBURUnset; |
|
93 TBackupIncType buIncType = ENoBackup; |
|
94 driveList.FillZ(); |
|
95 |
|
96 // Ensure that the device is put back into normal mode, in case a disconnection has ocurred |
|
97 pDOM->SetBURModeL(driveList, burPartType, buIncType); |
|
98 |
|
99 CleanupStack::PopAndDestroy(pABServer); |
|
100 CleanupStack::PopAndDestroy(pSBEServer); |
|
101 CleanupStack::PopAndDestroy(pDOM); |
|
102 CleanupStack::PopAndDestroy(pScheduler); |
|
103 } |
|
104 |
|
105 |
|
106 static TInt RunServer() |
|
107 /** |
|
108 Creates cleanup framework and call leaving variant of RunServer |
|
109 |
|
110 @param aStart A TServerStart object |
|
111 @return Any error trapped by RunServerL |
|
112 */ |
|
113 { |
|
114 __UHEAP_MARK; |
|
115 CTrapCleanup* pCleanup = CTrapCleanup::New(); |
|
116 TInt nRet = KErrNoMemory; |
|
117 |
|
118 if(pCleanup != NULL) |
|
119 { |
|
120 #ifdef __OOM_TESTING__ |
|
121 TInt i = 0; |
|
122 while (nRet == KErrNoMemory || nRet == KErrNone) |
|
123 { |
|
124 __UHEAP_SETFAIL(RHeap::EDeterministic,i++); |
|
125 __UHEAP_MARK; |
|
126 |
|
127 TRAP(nRet, RunServerL()); |
|
128 // required because we have an indirect |
|
129 // dependency on ecom, we apparently need |
|
130 // need to clean up after our dependencies |
|
131 REComSession::FinalClose(); |
|
132 |
|
133 __UHEAP_MARKEND; |
|
134 __UHEAP_RESET; |
|
135 } |
|
136 #else |
|
137 TRAP(nRet, RunServerL()); |
|
138 #endif |
|
139 delete pCleanup; |
|
140 } |
|
141 |
|
142 // required because we have an indirect |
|
143 // dependency on ecom, we apparently need |
|
144 // need to clean up after our dependencies |
|
145 REComSession::FinalClose(); |
|
146 |
|
147 __UHEAP_MARKEND; |
|
148 return nRet; |
|
149 } |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 TInt E32Main() |
|
156 /** |
|
157 Standard Symbian OS entry point |
|
158 |
|
159 @return Symbian OS internal value. |
|
160 */ |
|
161 { |
|
162 TInt nRet = KErrNone; |
|
163 |
|
164 nRet = RunServer(); |
|
165 |
|
166 return nRet; |
|
167 } |
|
168 |
|
169 |