sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32cons.h>
|
sl@0
|
20 |
#include <bacline.h>
|
sl@0
|
21 |
#include <keytool.rsg>
|
sl@0
|
22 |
|
sl@0
|
23 |
#include "keytool_utils.h"
|
sl@0
|
24 |
#include "keytool_defs.h"
|
sl@0
|
25 |
#include "keytool_controller.h"
|
sl@0
|
26 |
#include "keytool_view_imp.h"
|
sl@0
|
27 |
#include "keytool_commands.h"
|
sl@0
|
28 |
#include "keytoolfileview.h"
|
sl@0
|
29 |
|
sl@0
|
30 |
|
sl@0
|
31 |
// Boiler plate
|
sl@0
|
32 |
_LIT(KShortName, "Nokia KeyTool");
|
sl@0
|
33 |
_LIT(KName, "Nokia KeyStore Manipulation Tool");
|
sl@0
|
34 |
_LIT(KCopyright, "Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.");
|
sl@0
|
35 |
|
sl@0
|
36 |
_LIT(KNewLine, "\n");
|
sl@0
|
37 |
|
sl@0
|
38 |
_LIT(KDone, "Press any key to continue... \n");
|
sl@0
|
39 |
|
sl@0
|
40 |
// Keytool command line parameters
|
sl@0
|
41 |
_LIT(KList, "-list");
|
sl@0
|
42 |
_LIT(KListShort, "-l");
|
sl@0
|
43 |
|
sl@0
|
44 |
_LIT(KListStores, "-liststores");
|
sl@0
|
45 |
_LIT(KListStoresShort, "-ls");
|
sl@0
|
46 |
|
sl@0
|
47 |
_LIT(KImport, "-import");
|
sl@0
|
48 |
_LIT(KImportShort, "-i");
|
sl@0
|
49 |
|
sl@0
|
50 |
|
sl@0
|
51 |
_LIT(KRemove, "-remove");
|
sl@0
|
52 |
_LIT(KRemoveShort, "-r");
|
sl@0
|
53 |
|
sl@0
|
54 |
_LIT(KHelp, "-help");
|
sl@0
|
55 |
_LIT(KHelpShort, "-h");
|
sl@0
|
56 |
|
sl@0
|
57 |
_LIT(KSetUser, "-setuser");
|
sl@0
|
58 |
_LIT(KSetUserShort, "-s");
|
sl@0
|
59 |
|
sl@0
|
60 |
_LIT(KSetAllUsers, "-setallusers");
|
sl@0
|
61 |
_LIT(KSetAllUsersShort, "-a");
|
sl@0
|
62 |
|
sl@0
|
63 |
_LIT(KSetManager, "-setmanager");
|
sl@0
|
64 |
_LIT(KSetManagerShort, "-m");
|
sl@0
|
65 |
|
sl@0
|
66 |
_LIT(KRemoveUser, "-removeuser");
|
sl@0
|
67 |
_LIT(KRemoveUserShort, "-ru");
|
sl@0
|
68 |
|
sl@0
|
69 |
// Command parameters
|
sl@0
|
70 |
_LIT(KLabel, "-label");
|
sl@0
|
71 |
_LIT(KKeyUsage, "-usage");
|
sl@0
|
72 |
_LIT(KAccess, "-access");
|
sl@0
|
73 |
|
sl@0
|
74 |
_LIT(KStore, "-store");
|
sl@0
|
75 |
|
sl@0
|
76 |
//_LIT(KExpiry, "-expiry"); // Functionality not present at the moment...
|
sl@0
|
77 |
_LIT(KDetails, "-details");
|
sl@0
|
78 |
_LIT(KDetailsShort, "-d");
|
sl@0
|
79 |
|
sl@0
|
80 |
_LIT(KPageWise, "-page");
|
sl@0
|
81 |
_LIT(KPageWiseShort, "-p");
|
sl@0
|
82 |
|
sl@0
|
83 |
#ifdef KEYTOOL
|
sl@0
|
84 |
_LIT(KMigrateStore, "-migratestore");
|
sl@0
|
85 |
_LIT(KNewFileName, "-new");
|
sl@0
|
86 |
_LIT(KAuthExpression, "-expr");
|
sl@0
|
87 |
_LIT(KFreshness, "-freshness");
|
sl@0
|
88 |
#endif // KEYTOOL
|
sl@0
|
89 |
|
sl@0
|
90 |
const TInt KMaxArgs = 10;
|
sl@0
|
91 |
|
sl@0
|
92 |
/**
|
sl@0
|
93 |
* Displays tool name and copyright informations.
|
sl@0
|
94 |
*/
|
sl@0
|
95 |
LOCAL_D void BoilerPlateL(CConsoleBase* console)
|
sl@0
|
96 |
{
|
sl@0
|
97 |
console->Printf(KNewLine);
|
sl@0
|
98 |
console->Printf(KName);
|
sl@0
|
99 |
console->Printf(KNewLine);
|
sl@0
|
100 |
console->Printf(KCopyright);
|
sl@0
|
101 |
console->Printf(KNewLine);
|
sl@0
|
102 |
console->Printf(KNewLine);
|
sl@0
|
103 |
}
|
sl@0
|
104 |
|
sl@0
|
105 |
|
sl@0
|
106 |
LOCAL_D TBool VerifyCommand(const TDesC& aCommand, TInt& aCmdNum, TInt& aCmdCount)
|
sl@0
|
107 |
{
|
sl@0
|
108 |
if ((aCmdNum != -1) && (aCommand[0] == '-'))
|
sl@0
|
109 |
{
|
sl@0
|
110 |
aCmdNum = KeyToolDefController::KUsageCommand;
|
sl@0
|
111 |
aCmdCount = KMaxArgs;
|
sl@0
|
112 |
return 1;
|
sl@0
|
113 |
}
|
sl@0
|
114 |
if (aCommand.CompareF(KList) == 0 || aCommand.Compare(KListShort) == 0)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
aCmdNum = KeyToolDefController::KListCommand;
|
sl@0
|
117 |
}
|
sl@0
|
118 |
else if (aCommand.CompareF(KListStores) == 0 || aCommand.Compare(KListStoresShort) == 0)
|
sl@0
|
119 |
{
|
sl@0
|
120 |
aCmdNum = KeyToolDefController::KListStoresCommand;
|
sl@0
|
121 |
}
|
sl@0
|
122 |
else if (aCommand.CompareF(KImport) == 0 || aCommand.Compare(KImportShort) == 0)
|
sl@0
|
123 |
{
|
sl@0
|
124 |
aCmdNum = KeyToolDefController::KImportCommand;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
else if (aCommand.CompareF(KRemove) == 0 || aCommand.Compare(KRemoveShort) == 0)
|
sl@0
|
127 |
{
|
sl@0
|
128 |
aCmdNum = KeyToolDefController::KRemoveCommand;
|
sl@0
|
129 |
}
|
sl@0
|
130 |
else if (aCommand.CompareF(KSetUser) == 0 || aCommand.Compare(KSetUserShort) == 0)
|
sl@0
|
131 |
{
|
sl@0
|
132 |
aCmdNum = KeyToolDefController::KSetUserCommand;
|
sl@0
|
133 |
}
|
sl@0
|
134 |
else if (aCommand.CompareF(KSetManager) == 0 || aCommand.Compare(KSetManagerShort) == 0)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
aCmdNum = KeyToolDefController::KSetManagerCommand;
|
sl@0
|
137 |
}
|
sl@0
|
138 |
else if (aCommand.CompareF(KRemoveUser) == 0 || aCommand.Compare(KRemoveUserShort) == 0)
|
sl@0
|
139 |
{
|
sl@0
|
140 |
aCmdNum = KeyToolDefController::KRemoveUserCommand;
|
sl@0
|
141 |
}
|
sl@0
|
142 |
else if (aCommand.CompareF(KSetAllUsers) == 0 || aCommand.Compare(KSetAllUsersShort) == 0)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
aCmdNum = KeyToolDefController::KSetAllUsersCommand;
|
sl@0
|
145 |
}
|
sl@0
|
146 |
|
sl@0
|
147 |
#ifdef KEYTOOL
|
sl@0
|
148 |
else if ( aCommand.CompareF(KMigrateStore) == 0 )
|
sl@0
|
149 |
{
|
sl@0
|
150 |
aCmdNum = KeyToolDefController::KMigrateStore;
|
sl@0
|
151 |
}
|
sl@0
|
152 |
#endif // KEYTOOL
|
sl@0
|
153 |
|
sl@0
|
154 |
else
|
sl@0
|
155 |
{
|
sl@0
|
156 |
return 0;
|
sl@0
|
157 |
}
|
sl@0
|
158 |
|
sl@0
|
159 |
return 1;
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
|
sl@0
|
163 |
/**
|
sl@0
|
164 |
* Parses the command line and given control to the handler to deal with the request.
|
sl@0
|
165 |
*/
|
sl@0
|
166 |
LOCAL_D void DoMainL()
|
sl@0
|
167 |
{
|
sl@0
|
168 |
TBool interactiveMode = ETrue;
|
sl@0
|
169 |
|
sl@0
|
170 |
RFs fs;
|
sl@0
|
171 |
User::LeaveIfError(fs.Connect());
|
sl@0
|
172 |
CleanupClosePushL(fs);
|
sl@0
|
173 |
|
sl@0
|
174 |
CConsoleBase* console = Console::NewL(KShortName, TSize(KConsFullScreen, KConsFullScreen));
|
sl@0
|
175 |
CleanupStack::PushL(console);
|
sl@0
|
176 |
CCommandLineArguments* cmdArgs = CCommandLineArguments::NewLC();
|
sl@0
|
177 |
TInt cmdArgsCount = cmdArgs->Count();
|
sl@0
|
178 |
|
sl@0
|
179 |
RFile file;
|
sl@0
|
180 |
// command: keytool inputfile outputfile
|
sl@0
|
181 |
if (cmdArgsCount == 3)
|
sl@0
|
182 |
{
|
sl@0
|
183 |
if (KeyToolUtils::DoesFileExistsL(fs,cmdArgs->Arg(1)))
|
sl@0
|
184 |
{
|
sl@0
|
185 |
interactiveMode = EFalse;
|
sl@0
|
186 |
TInt error = file.Open(fs, cmdArgs->Arg(1), EFileRead|EFileShareAny);
|
sl@0
|
187 |
file.Close();
|
sl@0
|
188 |
|
sl@0
|
189 |
TInt error1 = file.Replace(fs, cmdArgs->Arg(2), EFileWrite|EFileShareExclusive);
|
sl@0
|
190 |
CleanupClosePushL(file);
|
sl@0
|
191 |
// If the input file doesn't exist or not able to create outputfile
|
sl@0
|
192 |
// switch to Interactive mode
|
sl@0
|
193 |
if (error != KErrNone || error1 != KErrNone)
|
sl@0
|
194 |
{
|
sl@0
|
195 |
CleanupStack::PopAndDestroy(&file);
|
sl@0
|
196 |
interactiveMode = ETrue;
|
sl@0
|
197 |
}
|
sl@0
|
198 |
}
|
sl@0
|
199 |
}
|
sl@0
|
200 |
|
sl@0
|
201 |
CKeytoolConsoleView* view = CKeytoolConsoleView::NewLC(*console);
|
sl@0
|
202 |
CKeyToolController* controller = CKeyToolController::NewLC(*view);
|
sl@0
|
203 |
CArrayFixFlat<TPtrC>* args = new (ELeave) CArrayFixFlat<TPtrC> (10);
|
sl@0
|
204 |
CleanupStack::PushL(args);
|
sl@0
|
205 |
CKeytoolFileView* view1 = NULL;
|
sl@0
|
206 |
|
sl@0
|
207 |
TInt cmdCount = 0;
|
sl@0
|
208 |
if (interactiveMode)
|
sl@0
|
209 |
{
|
sl@0
|
210 |
KeyToolUtils::SetConsole(console);
|
sl@0
|
211 |
BoilerPlateL(console);
|
sl@0
|
212 |
for (TInt i = 0; i < cmdArgsCount; i++)
|
sl@0
|
213 |
{
|
sl@0
|
214 |
args->AppendL(cmdArgs->Arg(i));
|
sl@0
|
215 |
}
|
sl@0
|
216 |
// In Interactive mode by default we can execute 1 command only.
|
sl@0
|
217 |
cmdCount = 1;
|
sl@0
|
218 |
}
|
sl@0
|
219 |
else
|
sl@0
|
220 |
{
|
sl@0
|
221 |
CleanupStack::PopAndDestroy(3, view); // args, controller, view
|
sl@0
|
222 |
KeyToolUtils::SetFile(&file);
|
sl@0
|
223 |
view1 = CKeytoolFileView::NewLC(cmdArgs->Arg(1));
|
sl@0
|
224 |
cmdCount = view1->SplitFileInputToArrayL();
|
sl@0
|
225 |
}
|
sl@0
|
226 |
|
sl@0
|
227 |
for (TInt j = 0; j < cmdCount; j++)
|
sl@0
|
228 |
{
|
sl@0
|
229 |
if (!interactiveMode)
|
sl@0
|
230 |
{
|
sl@0
|
231 |
controller = CKeyToolController::NewLC(*view1);
|
sl@0
|
232 |
args = view1->ReadArrayArgumentsLC(j);
|
sl@0
|
233 |
}
|
sl@0
|
234 |
|
sl@0
|
235 |
CKeyToolParameters* params = CKeyToolParameters::NewLC();
|
sl@0
|
236 |
|
sl@0
|
237 |
TInt command = -1;
|
sl@0
|
238 |
TInt i = -1;
|
sl@0
|
239 |
|
sl@0
|
240 |
TInt argsCount = args->Count();
|
sl@0
|
241 |
while (i < (argsCount-1))
|
sl@0
|
242 |
{
|
sl@0
|
243 |
i++;
|
sl@0
|
244 |
|
sl@0
|
245 |
if ((args->At(i).CompareF(KDetails)==0)|| (args->At(i).Compare(KDetailsShort)==0))
|
sl@0
|
246 |
{
|
sl@0
|
247 |
params->iIsDetailed = ETrue;
|
sl@0
|
248 |
continue;
|
sl@0
|
249 |
}
|
sl@0
|
250 |
|
sl@0
|
251 |
if (args->At(i).CompareF(KPageWise)==0 || (args->At(i).Compare(KPageWiseShort)==0))
|
sl@0
|
252 |
{
|
sl@0
|
253 |
params->iPageWise = ETrue;
|
sl@0
|
254 |
continue;
|
sl@0
|
255 |
}
|
sl@0
|
256 |
|
sl@0
|
257 |
TDesC& commd = args->At(i);
|
sl@0
|
258 |
if (VerifyCommand(commd, command, i))
|
sl@0
|
259 |
{
|
sl@0
|
260 |
if (commd.CompareF(KSetAllUsers) == 0 || commd.Compare(KSetAllUsersShort) == 0 ||
|
sl@0
|
261 |
commd.CompareF(KRemoveUser) == 0 || commd.Compare(KRemoveUserShort) == 0 ||
|
sl@0
|
262 |
commd.CompareF(KSetManager) == 0 || commd.Compare(KSetManagerShort) == 0 )
|
sl@0
|
263 |
{
|
sl@0
|
264 |
i++;
|
sl@0
|
265 |
if (args->At(i)[0] == '-' || args->At(i).Left(2) == _L("0x"))
|
sl@0
|
266 |
{
|
sl@0
|
267 |
i = argsCount;
|
sl@0
|
268 |
command = KeyToolDefController::KUsageCommand;
|
sl@0
|
269 |
}
|
sl@0
|
270 |
else
|
sl@0
|
271 |
{
|
sl@0
|
272 |
i--;
|
sl@0
|
273 |
}
|
sl@0
|
274 |
}
|
sl@0
|
275 |
if (commd.CompareF(KSetAllUsers) == 0 || commd.Compare(KSetAllUsersShort) == 0)
|
sl@0
|
276 |
{
|
sl@0
|
277 |
params->iPolicy = CKeyToolParameters::ESetAllUsersPolicy;
|
sl@0
|
278 |
params->iIsDetailed = ETrue;
|
sl@0
|
279 |
}
|
sl@0
|
280 |
if (commd.CompareF(KRemoveUser) == 0 || commd.Compare(KRemoveUserShort) == 0)
|
sl@0
|
281 |
{
|
sl@0
|
282 |
params->iPolicy = CKeyToolParameters::ERemoveUserPolicy;
|
sl@0
|
283 |
params->iIsDetailed = ETrue;
|
sl@0
|
284 |
}
|
sl@0
|
285 |
if (commd.CompareF(KSetManager) == 0 || commd.Compare(KSetManagerShort) == 0)
|
sl@0
|
286 |
{
|
sl@0
|
287 |
params->iPolicy = CKeyToolParameters::ESetManagerPolicy;
|
sl@0
|
288 |
params->iIsDetailed = ETrue;
|
sl@0
|
289 |
}
|
sl@0
|
290 |
if (commd.CompareF(KSetUser) == 0 || commd.Compare(KSetUserShort) == 0)
|
sl@0
|
291 |
{
|
sl@0
|
292 |
params->iPolicy = CKeyToolParameters::ESetUserPolicy;
|
sl@0
|
293 |
i++;
|
sl@0
|
294 |
if (i >= argsCount || args->At(i)[0] == '-' || args->At(i).Left(2) != _L("0x"))
|
sl@0
|
295 |
{
|
sl@0
|
296 |
i = argsCount;
|
sl@0
|
297 |
command = KeyToolDefController::KUsageCommand;
|
sl@0
|
298 |
}
|
sl@0
|
299 |
else
|
sl@0
|
300 |
{
|
sl@0
|
301 |
TUid app;
|
sl@0
|
302 |
TLex lex(args->At(i).Mid(2));
|
sl@0
|
303 |
TUint uid =0;
|
sl@0
|
304 |
TInt err = lex.Val(uid, EHex);
|
sl@0
|
305 |
if (err == KErrNone)
|
sl@0
|
306 |
{
|
sl@0
|
307 |
app = TUid::Uid(uid);
|
sl@0
|
308 |
}
|
sl@0
|
309 |
params->iUIDs.Append(app);
|
sl@0
|
310 |
params->iIsDetailed = ETrue;
|
sl@0
|
311 |
}
|
sl@0
|
312 |
}
|
sl@0
|
313 |
|
sl@0
|
314 |
#ifdef KEYTOOL
|
sl@0
|
315 |
if(commd.CompareF(KMigrateStore) == 0 )
|
sl@0
|
316 |
{
|
sl@0
|
317 |
int mandatoryParams = 2;
|
sl@0
|
318 |
if(argsCount-1 >= ++i)
|
sl@0
|
319 |
{
|
sl@0
|
320 |
params->iOldKeyFile = args->At(i).AllocL();
|
sl@0
|
321 |
}
|
sl@0
|
322 |
else
|
sl@0
|
323 |
{
|
sl@0
|
324 |
controller->DisplayLocalisedMsgL(R_KEYTOOL_USAGE_OLDKEY_ABSENT);
|
sl@0
|
325 |
--mandatoryParams;
|
sl@0
|
326 |
}
|
sl@0
|
327 |
if(argsCount-1 >= ++i)
|
sl@0
|
328 |
{
|
sl@0
|
329 |
params->iPassphrase = args->At(i).AllocL();
|
sl@0
|
330 |
}
|
sl@0
|
331 |
else
|
sl@0
|
332 |
{
|
sl@0
|
333 |
controller->DisplayLocalisedMsgL(R_KEYTOOL_USAGE_PASSPHRASE_ABSENT);
|
sl@0
|
334 |
--mandatoryParams;
|
sl@0
|
335 |
}
|
sl@0
|
336 |
|
sl@0
|
337 |
if( mandatoryParams != 2 )
|
sl@0
|
338 |
{
|
sl@0
|
339 |
command = KeyToolDefController::KUsageCommand;
|
sl@0
|
340 |
}
|
sl@0
|
341 |
else
|
sl@0
|
342 |
{
|
sl@0
|
343 |
TInt count = args->Count();
|
sl@0
|
344 |
|
sl@0
|
345 |
while(++i < count )
|
sl@0
|
346 |
{
|
sl@0
|
347 |
TDesC& commd = args->At(i);
|
sl@0
|
348 |
if(commd.CompareF(KNewFileName) == 0 && argsCount-1 >= ++i)
|
sl@0
|
349 |
{
|
sl@0
|
350 |
delete params->iNewKeyFile;
|
sl@0
|
351 |
params->iNewKeyFile=NULL;
|
sl@0
|
352 |
params->iNewKeyFile = args->At(i++).AllocL();
|
sl@0
|
353 |
}
|
sl@0
|
354 |
else if(commd.CompareF(KAuthExpression) == 0 && argsCount-1 >= ++i )
|
sl@0
|
355 |
{
|
sl@0
|
356 |
params->iAuthExpression = args->At(i++).AllocL();
|
sl@0
|
357 |
}
|
sl@0
|
358 |
else if(commd.CompareF(KFreshness) == 0 && argsCount-1 >= ++i )
|
sl@0
|
359 |
{
|
sl@0
|
360 |
TLex lex(args->At(i++));
|
sl@0
|
361 |
TInt err = lex.Val(params->iFreshness);
|
sl@0
|
362 |
}
|
sl@0
|
363 |
} // while
|
sl@0
|
364 |
} // if(mandatoryParams == 0)
|
sl@0
|
365 |
} // if
|
sl@0
|
366 |
|
sl@0
|
367 |
#endif // KEYTOOL
|
sl@0
|
368 |
continue;
|
sl@0
|
369 |
}
|
sl@0
|
370 |
|
sl@0
|
371 |
TDesC& cmd = args->At(i);
|
sl@0
|
372 |
if (cmd.CompareF(KHelp) == 0 || cmd.Compare(KHelpShort) == 0 ||
|
sl@0
|
373 |
cmd.CompareF(KLabel) == 0 || cmd.CompareF(KKeyUsage) == 0 ||
|
sl@0
|
374 |
cmd.CompareF(KStore) == 0 || cmd.CompareF(KAccess) == 0)
|
sl@0
|
375 |
{
|
sl@0
|
376 |
i++;
|
sl@0
|
377 |
if (i >= argsCount || args->At(i)[0] == '-')
|
sl@0
|
378 |
{
|
sl@0
|
379 |
i = argsCount;
|
sl@0
|
380 |
command = KeyToolDefController::KUsageCommand;
|
sl@0
|
381 |
}
|
sl@0
|
382 |
else if (cmd.CompareF(KHelp) == 0 || cmd.Compare(KHelpShort) == 0)
|
sl@0
|
383 |
{
|
sl@0
|
384 |
params->iDefault = args->At(i).AllocL();
|
sl@0
|
385 |
i = argsCount;
|
sl@0
|
386 |
}
|
sl@0
|
387 |
else if (cmd.CompareF(KLabel) == 0)
|
sl@0
|
388 |
{
|
sl@0
|
389 |
params->iLabel = args->At(i).AllocL();
|
sl@0
|
390 |
}
|
sl@0
|
391 |
else if (cmd.CompareF(KKeyUsage) == 0)
|
sl@0
|
392 |
{
|
sl@0
|
393 |
params->iUsage = KeyToolUtils::ParseKeyUsage(args->At(i));
|
sl@0
|
394 |
}
|
sl@0
|
395 |
else if (cmd.CompareF(KStore) == 0)
|
sl@0
|
396 |
{
|
sl@0
|
397 |
TLex parser(args->At(i));
|
sl@0
|
398 |
TInt err = parser.Val(params->iKeystoreIndex);
|
sl@0
|
399 |
params->iIsDetailed = ETrue;
|
sl@0
|
400 |
}
|
sl@0
|
401 |
else if (cmd.CompareF(KAccess) == 0)
|
sl@0
|
402 |
{
|
sl@0
|
403 |
params->iAccess = KeyToolUtils::ParseKeyAccess(args->At(i));
|
sl@0
|
404 |
}
|
sl@0
|
405 |
else
|
sl@0
|
406 |
{
|
sl@0
|
407 |
// no action required
|
sl@0
|
408 |
}
|
sl@0
|
409 |
continue;
|
sl@0
|
410 |
}
|
sl@0
|
411 |
|
sl@0
|
412 |
if (i!=0)
|
sl@0
|
413 |
{
|
sl@0
|
414 |
if (args->At(i)[0] == '-')
|
sl@0
|
415 |
{
|
sl@0
|
416 |
i = argsCount;
|
sl@0
|
417 |
command = KeyToolDefController::KUsageCommand;
|
sl@0
|
418 |
continue;
|
sl@0
|
419 |
}
|
sl@0
|
420 |
delete params->iDefault;
|
sl@0
|
421 |
params->iDefault = NULL;
|
sl@0
|
422 |
params->iDefault = args->At(i).AllocL();
|
sl@0
|
423 |
}
|
sl@0
|
424 |
}
|
sl@0
|
425 |
|
sl@0
|
426 |
|
sl@0
|
427 |
if (command != -1)
|
sl@0
|
428 |
{
|
sl@0
|
429 |
TRAP_IGNORE(controller->HandleCommandL(command, params));
|
sl@0
|
430 |
}
|
sl@0
|
431 |
else
|
sl@0
|
432 |
{
|
sl@0
|
433 |
controller->HandleCommandL(KeyToolDefController::KUsageCommand, params);
|
sl@0
|
434 |
}
|
sl@0
|
435 |
|
sl@0
|
436 |
CleanupStack::PopAndDestroy(3, controller); // params, args, controller
|
sl@0
|
437 |
}
|
sl@0
|
438 |
if (interactiveMode)
|
sl@0
|
439 |
{
|
sl@0
|
440 |
CleanupStack::PopAndDestroy(view);
|
sl@0
|
441 |
// We are done!
|
sl@0
|
442 |
console->Printf(KNewLine);
|
sl@0
|
443 |
console->Printf(KDone);
|
sl@0
|
444 |
console->Getch();
|
sl@0
|
445 |
}
|
sl@0
|
446 |
else
|
sl@0
|
447 |
{
|
sl@0
|
448 |
CleanupStack::PopAndDestroy(2, &file); //view1 and file
|
sl@0
|
449 |
}
|
sl@0
|
450 |
CleanupStack::PopAndDestroy(3, &fs); //cmdArgs, console, fs
|
sl@0
|
451 |
}
|
sl@0
|
452 |
|
sl@0
|
453 |
|
sl@0
|
454 |
GLDEF_C TInt E32Main() // main function called by E32
|
sl@0
|
455 |
{
|
sl@0
|
456 |
__UHEAP_MARK;
|
sl@0
|
457 |
CTrapCleanup* cleanup=CTrapCleanup::New();
|
sl@0
|
458 |
|
sl@0
|
459 |
TRAP_IGNORE(DoMainL());
|
sl@0
|
460 |
|
sl@0
|
461 |
delete cleanup;
|
sl@0
|
462 |
__UHEAP_MARKEND;
|
sl@0
|
463 |
return 0;
|
sl@0
|
464 |
}
|
sl@0
|
465 |
|