|
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: This file contains the header file of the CAtsLogger |
|
15 * class. |
|
16 * |
|
17 */ |
|
18 |
|
19 // Include Files |
|
20 |
|
21 #include "stfsystemtestlibplugin.h" // Cstfsystemtestlibplugin |
|
22 #include "stfsystemtestlibplugin.pan" // panic codes |
|
23 #include "AppInstall.h" |
|
24 _LIT(KSTFRunProgram,"RUN_PROGRAM"); |
|
25 _LIT(KSTFKillProgram,"KILL_PROGRAM"); |
|
26 _LIT(KSTFInstallSIS,"InstallSis"); |
|
27 _LIT(KSTFUnInstallSIS,"UnInstallSis"); |
|
28 // Member Functions |
|
29 |
|
30 EXPORT_C Cstfsystemtestlibplugin* LibEntryL() |
|
31 { |
|
32 Cstfsystemtestlibplugin* self=Cstfsystemtestlibplugin::NewL(); |
|
33 return self; |
|
34 } |
|
35 |
|
36 Cstfsystemtestlibplugin* Cstfsystemtestlibplugin::NewL() |
|
37 { |
|
38 Cstfsystemtestlibplugin* self = new (ELeave) Cstfsystemtestlibplugin; |
|
39 CleanupStack::PushL(self); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop(self); |
|
42 return self; |
|
43 } |
|
44 |
|
45 Cstfsystemtestlibplugin::Cstfsystemtestlibplugin() |
|
46 // note, CBase initialises all member variables to zero |
|
47 { |
|
48 } |
|
49 |
|
50 void Cstfsystemtestlibplugin::ConstructL() |
|
51 { |
|
52 } |
|
53 |
|
54 Cstfsystemtestlibplugin::~Cstfsystemtestlibplugin() |
|
55 { |
|
56 |
|
57 } |
|
58 |
|
59 |
|
60 |
|
61 EXPORT_C TBool Cstfsystemtestlibplugin::IsCommandSupported(const TDesC& aCommand) |
|
62 { |
|
63 TBool result=EFalse; |
|
64 if(aCommand==KSTFRunProgram) |
|
65 { |
|
66 result=ETrue; |
|
67 } |
|
68 else if(aCommand==KSTFKillProgram) |
|
69 { |
|
70 result=ETrue; |
|
71 } |
|
72 |
|
73 else if(aCommand==KSTFInstallSIS) |
|
74 { |
|
75 result=ETrue; |
|
76 } |
|
77 else if(aCommand==KSTFUnInstallSIS) |
|
78 { |
|
79 result=ETrue; |
|
80 } |
|
81 |
|
82 |
|
83 return result; |
|
84 } |
|
85 EXPORT_C TInt Cstfsystemtestlibplugin::ExecuteCommandL(const TDesC& aCommandLine) |
|
86 { |
|
87 TInt result=KErrNone; |
|
88 TLex lex(aCommandLine); |
|
89 TPtrC token(lex.NextToken()); |
|
90 if(token.CompareF(KSTFRunProgram) == 0) |
|
91 { |
|
92 RProcess process; |
|
93 TPtrC filename(lex.NextToken()); |
|
94 TPtrC para(lex.NextToken()); |
|
95 TInt err=process.Create(filename, para); |
|
96 if (err == KErrNone) |
|
97 { |
|
98 CleanupClosePushL(process); |
|
99 TRequestStatus status; |
|
100 process.Rendezvous(status); |
|
101 if (status == KRequestPending) |
|
102 { |
|
103 process.Resume(); |
|
104 User::WaitForRequest(status); |
|
105 } |
|
106 else |
|
107 { |
|
108 process.RendezvousCancel(status); |
|
109 process.Kill(0); |
|
110 |
|
111 } |
|
112 CleanupStack::PopAndDestroy(); |
|
113 } |
|
114 else |
|
115 { |
|
116 |
|
117 } |
|
118 } |
|
119 else if(token.CompareF(KSTFKillProgram) == 0) |
|
120 { |
|
121 |
|
122 |
|
123 TBuf<100> execute; |
|
124 execute.Append(lex.NextToken()); |
|
125 execute.TrimAll(); |
|
126 execute.Append(_L("*")); |
|
127 |
|
128 TFindProcess processFinder(execute); |
|
129 |
|
130 TFullName result; |
|
131 TInt err=processFinder.Next(result); |
|
132 if( err == KErrNone) |
|
133 { |
|
134 |
|
135 RProcess processHandle; |
|
136 User::LeaveIfError(processHandle.Open ( processFinder, EOwnerThread)); |
|
137 processHandle.Kill(KErrNone); |
|
138 processHandle.Close(); |
|
139 } |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 } |
|
145 else if(token.CompareF(KSTFInstallSIS) == 0) |
|
146 { |
|
147 TPtrC sisname(lex.NextToken()); |
|
148 result=CAppInstall::Install(sisname); |
|
149 } |
|
150 else if(token.CompareF(KSTFUnInstallSIS) == 0) |
|
151 { |
|
152 TPtrC uid(lex.NextToken()); |
|
153 result=CAppInstall::Uninstall(uid); |
|
154 } |
|
155 return result; |
|
156 } |