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 "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: HtiFileHlp implementation. This exe is used for file operations |
|
15 * to TCB folders (requiring capability ALL). |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "../../symbian_version.hrh" |
|
22 #include <e32std.h> |
|
23 #include <swi/sisregistrysession.h> |
|
24 |
|
25 // CONSTANTS |
|
26 _LIT( KTcbHlpName, "HtiTcbHlp" ); |
|
27 |
|
28 _LIT( KCmdAppRegInfo, "AppRegInfo"); |
|
29 _LIT( KCmdAppRegInfo_Add, "add" ); |
|
30 _LIT( KCmdAppRegInfo_Remove, "remove" ); |
|
31 |
|
32 _LIT( KDelimiter, "|" ); |
|
33 // MACROS |
|
34 |
|
35 // LOCAL CONSTANTS AND MACROS |
|
36 |
|
37 // MODULE DATA STRUCTURES |
|
38 |
|
39 // LOCAL FUNCTION PROTOTYPES |
|
40 |
|
41 // FORWARD DECLARATIONS |
|
42 |
|
43 // ============================ LOCAL FUNCTIONS =============================== |
|
44 |
|
45 #if ( SYMBIAN_VERSION_SUPPORT >= SYMBIAN_4 ) |
|
46 LOCAL_C void HandleAppRegFileInfoL(const TDesC& aAppRegFile, TBool aAdded) |
|
47 { |
|
48 Swi::RSisRegistrySession regSession; |
|
49 User::LeaveIfError( regSession.Connect() ); |
|
50 CleanupClosePushL( regSession ); |
|
51 if(aAdded) |
|
52 { |
|
53 regSession.AddAppRegInfoL(aAppRegFile); |
|
54 } |
|
55 else |
|
56 { |
|
57 regSession.RemoveAppRegInfoL(aAppRegFile); |
|
58 } |
|
59 CleanupStack::PopAndDestroy(1); |
|
60 } |
|
61 #endif |
|
62 |
|
63 LOCAL_C TInt StartL() |
|
64 { |
|
65 TInt cmdLen = User::CommandLineLength(); |
|
66 |
|
67 HBufC* cmdLine = HBufC::NewLC( cmdLen ); |
|
68 TPtr ptCmdLine = cmdLine->Des(); |
|
69 User::CommandLine( ptCmdLine ); |
|
70 |
|
71 TInt paramStart = 0; |
|
72 TInt paramEnd = 0; |
|
73 |
|
74 // Take first parameter (the command) |
|
75 paramEnd = cmdLine->Find( KDelimiter ); |
|
76 if ( paramEnd <= paramStart ) |
|
77 { |
|
78 User::Leave( KErrArgument ); |
|
79 } |
|
80 TPtrC cmd = cmdLine->Mid( paramStart, paramEnd - paramStart ); |
|
81 |
|
82 if(cmd == KCmdAppRegInfo) |
|
83 { |
|
84 #if ( SYMBIAN_VERSION_SUPPORT >= SYMBIAN_4 ) |
|
85 // Take the next parameter either until next delimiter or |
|
86 // the rest of the command line. |
|
87 paramStart = paramEnd + 1; |
|
88 paramEnd = cmdLine->Mid( paramStart ).Find( KDelimiter ) + paramStart; |
|
89 if ( paramEnd < paramStart ) |
|
90 { |
|
91 // No delimiter found - this is the last parameter |
|
92 paramEnd = cmdLen; |
|
93 } |
|
94 |
|
95 TPtrC param1 = cmdLine->Mid( paramStart, paramEnd - paramStart ); |
|
96 |
|
97 paramStart = paramEnd + 1; |
|
98 if ( paramStart >= cmdLen ) |
|
99 { |
|
100 User::Leave( KErrArgument ); |
|
101 } |
|
102 |
|
103 if ( param1 == KCmdAppRegInfo_Add ) |
|
104 { |
|
105 TPtrC param2 = cmdLine->Mid( paramStart ); |
|
106 HandleAppRegFileInfoL( param2, ETrue ); |
|
107 } |
|
108 else if ( param1 == KCmdAppRegInfo_Remove ) |
|
109 { |
|
110 TPtrC param2 = cmdLine->Mid( paramStart ); |
|
111 HandleAppRegFileInfoL( param2, EFalse ); |
|
112 } |
|
113 else |
|
114 { |
|
115 User::Leave( KErrArgument ); |
|
116 } |
|
117 #endif |
|
118 } |
|
119 else |
|
120 { |
|
121 User::Leave( KErrArgument ); |
|
122 } |
|
123 |
|
124 CleanupStack::PopAndDestroy(); // cmdLine |
|
125 |
|
126 return KErrNone; |
|
127 } |
|
128 |
|
129 GLDEF_C TInt E32Main() |
|
130 { |
|
131 __UHEAP_MARK; |
|
132 |
|
133 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
134 CActiveScheduler* scheduler = new ( ELeave ) CActiveScheduler; |
|
135 CActiveScheduler::Install( scheduler ); |
|
136 |
|
137 User::RenameThread( KTcbHlpName ); |
|
138 |
|
139 TRAPD( error, StartL() ); |
|
140 |
|
141 delete scheduler; |
|
142 delete cleanup; |
|
143 __UHEAP_MARKEND; |
|
144 |
|
145 //__ASSERT_ALWAYS( !error, User::Panic( KTcbHlpName, error ) ); |
|
146 return error; |
|
147 } |
|
148 |
|
149 |
|
150 // End of File |
|