|
1 /* |
|
2 * Copyright (c) 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 the License "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: Java platform 2.0 javarestoreconverter process. |
|
15 * Java restore executes this when restoring Java 1.x |
|
16 * applications that must be converted to Java 2.x |
|
17 * applications. |
|
18 */ |
|
19 |
|
20 |
|
21 #include <e32std.h> |
|
22 #include <e32base.h> |
|
23 #include <f32file.h> |
|
24 |
|
25 #include "javauids.h" |
|
26 #include "restoreconvertmidlet.h" |
|
27 #include "logger.h" |
|
28 |
|
29 // The secure Uid of javabackup.exe |
|
30 _LIT_SECURE_ID(KJavaBackupSecureID, 0x1028246F); |
|
31 |
|
32 |
|
33 /** |
|
34 * Allow starting process only from Java Restore, |
|
35 * allow running only one instance of the process, |
|
36 * create file server connection, |
|
37 * create active scheduler and start it |
|
38 * |
|
39 */ |
|
40 static void RestoreConvertJavaAppsL() |
|
41 { |
|
42 _LIT(KPreinstallerMatch, "javarestoreconverter*"); |
|
43 TFindProcess find(KPreinstallerMatch); |
|
44 TFullName ignoreName; |
|
45 find.Next(ignoreName); |
|
46 |
|
47 // Can only have one javarestoreconverter. If a second is found exit |
|
48 if (find.Next(ignoreName) == KErrNone) |
|
49 { |
|
50 ELOG(EJavaPreinstaller, "javarestoreconverter.exe already running."); |
|
51 User::Leave(KErrAlreadyExists); |
|
52 } |
|
53 |
|
54 // The only time that this application should be executed |
|
55 // is when java restore calls it. |
|
56 // Allow starting javarestoreconverter.exe from test programs in |
|
57 // debug builds. |
|
58 #ifndef _DEBUG |
|
59 |
|
60 if (User::CreatorSecureId() != KJavaBackupSecureID) |
|
61 { |
|
62 ELOG(EJavaConverters, |
|
63 "ConvertJavaAppsL: Mismatch in secure ID, only java backup can launch this exe."); |
|
64 User::Leave(KErrPermissionDenied); |
|
65 } |
|
66 #endif |
|
67 |
|
68 RFs fs; |
|
69 User::LeaveIfError(fs.Connect()); |
|
70 CleanupClosePushL(fs); |
|
71 |
|
72 CActiveScheduler* as = new(ELeave) CActiveScheduler(); |
|
73 |
|
74 // Install active scheduler |
|
75 CActiveScheduler::Install(as); |
|
76 CleanupStack::PushL(as); |
|
77 |
|
78 // Setup and start the MIDlet conversion |
|
79 CRestoreConvertMIDlet* si = CRestoreConvertMIDlet::NewLC(fs); |
|
80 |
|
81 LOG(EJavaConverters, EInfo, "RestoreConvertJavaAppsL: Call CRestoreConvertMIDlet::Start()"); |
|
82 |
|
83 si->Start(); |
|
84 |
|
85 // Start active scheduler, starts conversion |
|
86 LOG(EJavaConverters, EInfo, "RestoreConvertJavaAppsL: Starting CActiveScheduler"); |
|
87 CActiveScheduler::Start(); |
|
88 |
|
89 LOG(EJavaConverters, EInfo, "RestoreConvertJavaAppsL: Cleaning up"); |
|
90 |
|
91 CleanupStack::PopAndDestroy(si); |
|
92 CleanupStack::PopAndDestroy(as); |
|
93 CleanupStack::PopAndDestroy(&fs); // close connection to file server |
|
94 |
|
95 return; |
|
96 } |
|
97 |
|
98 |
|
99 /** |
|
100 * Create cleanup stack and run the javarestoreconverter code inside TRAP |
|
101 * harness to log unexpected leaves. |
|
102 */ |
|
103 TInt E32Main() |
|
104 { |
|
105 CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
|
106 |
|
107 TRAPD(err, RestoreConvertJavaAppsL()); |
|
108 if (err != KErrNone) |
|
109 { |
|
110 ELOG1(EJavaConverters, "RestoreConvertJavaAppsL:Main error %d", err); |
|
111 } |
|
112 |
|
113 delete cleanupStack; |
|
114 return err; |
|
115 } |