|
1 /* |
|
2 * Copyright (c) 2008-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: |
|
15 * This file defines a parser and console commands for the reference Application Manager |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 exampleCode |
|
24 */ |
|
25 |
|
26 #ifndef COMMAND_H |
|
27 #define COMAMND_H |
|
28 |
|
29 #include <e32base.h> |
|
30 #include <f32file.h> |
|
31 #include <bacline.h> |
|
32 |
|
33 namespace Usif |
|
34 { |
|
35 class CComponentFilter; |
|
36 |
|
37 /** |
|
38 The CConsoleCommand class defines a pure virtual interface for console commands. |
|
39 Each software management operation provided by the Reference Application Manager |
|
40 must implement this interface. |
|
41 */ |
|
42 class CConsoleCommand: public CBase |
|
43 { |
|
44 public: |
|
45 /** |
|
46 Returns the name of the command. The CCommandLineParser class uses this method |
|
47 to find an appropriate command object whilst parsing the console input. |
|
48 */ |
|
49 virtual const TDesC& Name() = 0; |
|
50 |
|
51 /** |
|
52 CCommandLineParser uses this method to hand over the recognition of command's options |
|
53 to an appropriate command object. |
|
54 |
|
55 @param aName The name of an option. |
|
56 @param aValues The values of option's parameters. |
|
57 */ |
|
58 virtual void OptionHandlerL(const TPtrC& aName, const RArray<TPtrC>& aValues) = 0; |
|
59 |
|
60 /** |
|
61 CCommandLineParser uses this method to execute a command. |
|
62 |
|
63 @param aConsole The console the command writes its output to. |
|
64 */ |
|
65 virtual void ExecuteL(CConsoleBase& aConsole) = 0; |
|
66 |
|
67 virtual ~CConsoleCommand(); |
|
68 |
|
69 protected: |
|
70 CConsoleCommand(); |
|
71 CConsoleCommand(const CConsoleCommand&); |
|
72 CConsoleCommand& operator=(const CConsoleCommand&); |
|
73 }; |
|
74 |
|
75 /** |
|
76 A 'list' command. It displays to the user a list of installed software components. |
|
77 Please @see appmanager.cpp for the list of supported filtering options. |
|
78 */ |
|
79 class CListCommand: public CConsoleCommand |
|
80 { |
|
81 public: |
|
82 static CListCommand* NewLC(); |
|
83 |
|
84 // Implement CConsoleCommand |
|
85 virtual const TDesC& Name(); |
|
86 virtual void OptionHandlerL(const TPtrC& aName, const RArray<TPtrC>& aValues); |
|
87 virtual void ExecuteL(CConsoleBase& aConsole); |
|
88 virtual ~CListCommand(); |
|
89 |
|
90 private: |
|
91 CListCommand(); |
|
92 CComponentFilter* iFilter; |
|
93 TLanguage iLocale; |
|
94 TBool iScomoStateSet; |
|
95 }; |
|
96 |
|
97 /** |
|
98 A 'delete' command. It deletes a component specified by id from the system. The id of a component |
|
99 to be deleted can be retrieved with the aid of the 'list' command. |
|
100 */ |
|
101 class CDeleteCommand: public CConsoleCommand |
|
102 { |
|
103 public: |
|
104 static CDeleteCommand* NewLC(); |
|
105 |
|
106 // Implement CConsoleCommand |
|
107 virtual const TDesC& Name(); |
|
108 virtual void OptionHandlerL(const TPtrC& aName, const RArray<TPtrC>& aValues); |
|
109 virtual void ExecuteL(CConsoleBase& aConsole); |
|
110 virtual ~CDeleteCommand(); |
|
111 |
|
112 private: |
|
113 CDeleteCommand(); |
|
114 |
|
115 enum { EInvalidComponentId = -1 }; |
|
116 TInt iComponentId; |
|
117 }; |
|
118 |
|
119 /** |
|
120 A user input parser. The Reference Application Manager uses this class to recognize |
|
121 and execute console commands entred by the user. A command must be registered with |
|
122 the RegisterCommandL() method so the parser may use it. |
|
123 The parser uses the CCommandLineArguments class to read user input from the console. |
|
124 */ |
|
125 class CCommandLineParser: public CBase |
|
126 { |
|
127 public: |
|
128 /** |
|
129 Creates a new instance of the Parser. |
|
130 */ |
|
131 static CCommandLineParser* NewLC(); |
|
132 |
|
133 /** |
|
134 Registers a command to the parser. |
|
135 |
|
136 @param aCommand A command to be registered. |
|
137 */ |
|
138 void RegisterCommandL(CConsoleCommand& aCommand); |
|
139 |
|
140 /** |
|
141 Parses user input from the console and returns a command that has been found. |
|
142 */ |
|
143 CConsoleCommand& ParseL(); |
|
144 |
|
145 virtual ~CCommandLineParser(); |
|
146 |
|
147 private: |
|
148 CCommandLineParser(); |
|
149 CCommandLineParser(const CCommandLineParser&); |
|
150 CCommandLineParser& operator=(const CCommandLineParser&); |
|
151 |
|
152 CCommandLineArguments* iCmdLineArgs; |
|
153 RPointerArray<CConsoleCommand> iCommands; |
|
154 }; |
|
155 } |
|
156 |
|
157 #endif // COMAMND_H |