|
1 // iocli.h |
|
2 // |
|
3 // Copyright (c) 2006 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #ifndef __IOCLI_H__ |
|
14 #define __IOCLI_H__ |
|
15 |
|
16 #include <e32std.h> |
|
17 #include <e32keys.h> |
|
18 #include <fshell/consoleextensions.h> |
|
19 |
|
20 class RIoSession; |
|
21 class RIoConsole; |
|
22 |
|
23 class RIoHandle : public RSubSessionBase |
|
24 { |
|
25 public: |
|
26 enum TType |
|
27 { |
|
28 EReadWriteObject, |
|
29 EReadObject, |
|
30 EWriteObject, |
|
31 EEndPoint, |
|
32 EConsole, |
|
33 EFile, |
|
34 ENull, |
|
35 EPipe, |
|
36 EPersistentConsole, |
|
37 }; |
|
38 public: |
|
39 IMPORT_C TInt OpenFoundHandle(RIoSession& aSession, TInt aFoundHandle); |
|
40 IMPORT_C void OpenFoundHandleL(RIoSession& aSession, TInt aFoundHandle); |
|
41 IMPORT_C void Close(); |
|
42 IMPORT_C TInt IsType(TType aType) const; |
|
43 IMPORT_C TBool IsTypeL(TType aType) const; |
|
44 IMPORT_C TInt ObjectName(TDes& aName) const; |
|
45 IMPORT_C void ObjectNameL(TDes& aName) const; |
|
46 IMPORT_C TInt Equals(const RIoHandle& aNother) const; |
|
47 IMPORT_C TBool EqualsL(const RIoHandle& aNother) const; |
|
48 IMPORT_C RIoSession Session() const; |
|
49 }; |
|
50 |
|
51 class RIoSession : public RSessionBase |
|
52 { |
|
53 public: |
|
54 IMPORT_C TInt Connect(); |
|
55 IMPORT_C void ConnectL(); |
|
56 IMPORT_C TInt SetObjectName(TInt aHandle, const TDesC& aName); |
|
57 IMPORT_C void SetObjectNameL(TInt aHandle, const TDesC& aName); |
|
58 IMPORT_C TInt FindFirstHandle(RIoHandle::TType aType, const TDesC& aMatchString, TInt& aFoundHandle, TName& aName); |
|
59 IMPORT_C TInt FindNextHandle(TInt& aFoundHandle, TName& aName); |
|
60 }; |
|
61 |
|
62 class RIoReadWriteHandle : public RIoHandle |
|
63 { |
|
64 public: |
|
65 enum TMode |
|
66 { |
|
67 EText, |
|
68 EBinary |
|
69 }; |
|
70 public: |
|
71 IMPORT_C TInt SetMode(TMode aMode); |
|
72 IMPORT_C void SetModeL(TMode aMode); |
|
73 IMPORT_C TInt SetOwner(TThreadId aOwningThread); |
|
74 IMPORT_C void SetOwnerL(TThreadId aOwningThread); |
|
75 IMPORT_C TInt SetUnderlyingConsole(RIoConsole& aConsole); |
|
76 IMPORT_C void SetUnderlyingConsoleL(RIoConsole& aConsole); |
|
77 IMPORT_C TInt AttachedToConsole() const; |
|
78 IMPORT_C TBool AttachedToConsoleL() const; |
|
79 }; |
|
80 |
|
81 class RIoReadHandle : public RIoReadWriteHandle |
|
82 { |
|
83 public: |
|
84 enum TReadMode |
|
85 { |
|
86 EFull, |
|
87 ELine, |
|
88 EOneOrMore |
|
89 }; |
|
90 enum TChangeType |
|
91 { |
|
92 EGainedForeground = 0x01, |
|
93 EConsoleSizeChanged = 0x02, |
|
94 }; |
|
95 public: |
|
96 IMPORT_C TInt Create(RIoSession& aSession); |
|
97 IMPORT_C void CreateL(RIoSession& aSession); |
|
98 IMPORT_C TInt Open(RIoSession& aSession); |
|
99 IMPORT_C void OpenL(RIoSession& aSession); |
|
100 IMPORT_C TInt Open(RIoSession& aSession, TThreadId aThreadId); |
|
101 IMPORT_C void OpenL(RIoSession& aSession, TThreadId aThreadId); |
|
102 IMPORT_C TInt Duplicate(RIoReadHandle& aReadHandle); |
|
103 IMPORT_C void DuplicateL(RIoReadHandle& aReadHandle); |
|
104 IMPORT_C TInt DuplicateHandleFromThread(TThreadId aThreadId); |
|
105 |
|
106 IMPORT_C TInt SetReadMode(TReadMode aMode); |
|
107 IMPORT_C void SetReadModeL(TReadMode aMode); |
|
108 IMPORT_C TInt SetToForeground(); |
|
109 IMPORT_C void SetToForegroundL(); |
|
110 IMPORT_C TInt Read(TDes& aDes); |
|
111 IMPORT_C void ReadL(TDes& aDes); |
|
112 IMPORT_C void Read(TDes& aDes, TRequestStatus& aStatus); |
|
113 IMPORT_C TInt SetLineSeparator(const TDesC& aSeparator); |
|
114 IMPORT_C void SetLineSeparatorL(const TDesC& aSeparator); |
|
115 IMPORT_C void ReadCancel(); |
|
116 IMPORT_C TInt IsForeground() const; |
|
117 IMPORT_C TBool IsForegroundL() const; |
|
118 IMPORT_C void NotifyChange(TPckgBuf<TUint>& aChangeType, TRequestStatus& aStatus); |
|
119 IMPORT_C void CancelNotifyChange(); |
|
120 }; |
|
121 |
|
122 class RIoConsoleReadHandle : public RIoReadHandle |
|
123 { |
|
124 public: |
|
125 IMPORT_C RIoConsoleReadHandle(); |
|
126 IMPORT_C RIoConsoleReadHandle(RIoReadHandle& aHandle); |
|
127 IMPORT_C RIoConsoleReadHandle operator=(RIoReadHandle& aHandle); |
|
128 IMPORT_C TUint ReadKey(); |
|
129 IMPORT_C void WaitForKey(TRequestStatus& aStatus); |
|
130 IMPORT_C void WaitForKeyCancel(); |
|
131 IMPORT_C TUint KeyCode() const; |
|
132 IMPORT_C TUint KeyModifiers() const; |
|
133 IMPORT_C TInt CaptureKey(TUint aKeyCode, TUint aModifierMask, TUint aModifiers); |
|
134 IMPORT_C void CaptureKeyL(TUint aKeyCode, TUint aModifierMask, TUint aModifiers); |
|
135 IMPORT_C TInt CancelCaptureKey(TUint aKeyCode, TUint aModifierMask, TUint aModifiers); |
|
136 IMPORT_C TInt CaptureAllKeys(); |
|
137 IMPORT_C void CaptureAllKeysL(); |
|
138 IMPORT_C TInt CancelCaptureAllKeys(); |
|
139 public: |
|
140 class TConsoleKey |
|
141 { |
|
142 public: |
|
143 TUint iKeyCode; |
|
144 TUint iModifiers; |
|
145 }; |
|
146 private: |
|
147 TPckgBuf<TConsoleKey> iKeyBuf; |
|
148 }; |
|
149 |
|
150 class RIoWriteHandle : public RIoReadWriteHandle |
|
151 { |
|
152 public: |
|
153 IMPORT_C TInt Create(RIoSession& aSession); |
|
154 IMPORT_C void CreateL(RIoSession& aSession); |
|
155 IMPORT_C TInt Open(RIoSession& aSession); |
|
156 IMPORT_C void OpenL(RIoSession& aSession); |
|
157 IMPORT_C TInt Open(RIoSession& aSession, TThreadId aThreadId); |
|
158 IMPORT_C void OpenL(RIoSession& aSession, TThreadId aThreadId); |
|
159 IMPORT_C TInt Duplicate(RIoWriteHandle& aWriteHandle); |
|
160 IMPORT_C void DuplicateL(RIoWriteHandle& aWriteHandle); |
|
161 IMPORT_C TInt DuplicateHandleFromThread(TThreadId aThreadId); |
|
162 IMPORT_C TInt Write(const TDesC& aDes); |
|
163 IMPORT_C void WriteL(const TDesC& aDes); |
|
164 IMPORT_C void Write(const TDesC& aDes, TRequestStatus& aStatus); |
|
165 IMPORT_C void WriteCancel(); |
|
166 }; |
|
167 |
|
168 class RIoConsoleWriteHandle : public RIoWriteHandle |
|
169 { |
|
170 public: |
|
171 IMPORT_C RIoConsoleWriteHandle(); |
|
172 IMPORT_C RIoConsoleWriteHandle(RIoWriteHandle& aHandle); |
|
173 IMPORT_C RIoConsoleWriteHandle operator=(RIoWriteHandle& aHandle); |
|
174 IMPORT_C TInt GetCursorPos(TPoint& aPos) const; |
|
175 IMPORT_C TPoint GetCursorPosL() const; |
|
176 IMPORT_C TInt SetCursorPosAbs(const TPoint& aPos); |
|
177 IMPORT_C void SetCursorPosAbsL(const TPoint& aPos); |
|
178 IMPORT_C TInt SetCursorPosRel(const TPoint& aPos); |
|
179 IMPORT_C void SetCursorPosRelL(const TPoint& aPos); |
|
180 IMPORT_C TInt SetCursorHeight(TInt aPercentage); |
|
181 IMPORT_C void SetCursorHeightL(TInt aPercentage); |
|
182 IMPORT_C TInt SetTitle(const TDesC& aTitle); |
|
183 IMPORT_C void SetTitleL(const TDesC& aTitle); |
|
184 IMPORT_C TInt ClearScreen(); |
|
185 IMPORT_C void ClearScreenL(); |
|
186 IMPORT_C TInt ClearToEndOfLine(); |
|
187 IMPORT_C void ClearToEndOfLineL(); |
|
188 IMPORT_C TInt GetScreenSize(TSize& aSize) const; |
|
189 IMPORT_C TSize GetScreenSizeL() const; |
|
190 IMPORT_C TInt SetAttributes(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor = ConsoleAttributes::EUnchanged, ConsoleAttributes::TColor aBackgroundColor = ConsoleAttributes::EUnchanged); |
|
191 IMPORT_C void SetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor = ConsoleAttributes::EUnchanged, ConsoleAttributes::TColor aBackgroundColor = ConsoleAttributes::EUnchanged); |
|
192 IMPORT_C TInt SetAttributes(const ConsoleAttributes::TAttributes& aAttributes); |
|
193 IMPORT_C TInt SetIsStdErr(TBool aFlag); |
|
194 }; |
|
195 |
|
196 class RIoEndPoint : public RIoHandle |
|
197 { |
|
198 public: |
|
199 enum TReadMode |
|
200 { |
|
201 EForeground, |
|
202 EBackground |
|
203 }; |
|
204 public: |
|
205 IMPORT_C TInt Attach(RIoReadHandle& aReader, TReadMode aMode); |
|
206 IMPORT_C void AttachL(RIoReadHandle& aReader, TReadMode aMode); |
|
207 IMPORT_C TInt Attach(RIoWriteHandle& aWriter); |
|
208 IMPORT_C void AttachL(RIoWriteHandle& aWriter); |
|
209 IMPORT_C TInt SetForegroundReadHandle(RIoReadHandle& aReader); |
|
210 IMPORT_C void SetForegroundReadHandleL(RIoReadHandle& aReader); |
|
211 IMPORT_C RIoEndPoint(); |
|
212 }; |
|
213 |
|
214 class RIoPipe : public RIoEndPoint |
|
215 { |
|
216 public: |
|
217 IMPORT_C TInt Create(RIoSession& aSession); |
|
218 IMPORT_C void CreateL(RIoSession& aSession); |
|
219 }; |
|
220 |
|
221 class RIoConsole : public RIoEndPoint |
|
222 { |
|
223 public: |
|
224 enum TOptions |
|
225 { |
|
226 ENormal = 0, |
|
227 ELazyCreate = 0x01, |
|
228 }; |
|
229 public: |
|
230 IMPORT_C TInt Create(RIoSession& aSession, const TDesC& aTitle, const TSize& aSize, TUint aConsoleOptions = ENormal); |
|
231 IMPORT_C void CreateL(RIoSession& aSession, const TDesC& aTitle, const TSize& aSize, TUint aConsoleOptions = ENormal); |
|
232 IMPORT_C TInt Create(RIoSession& aSession, const TDesC& aImplementation, const TDesC& aTitle, const TSize& aSize, TUint aConsoleOptions = ENormal); |
|
233 IMPORT_C TInt Create(RIoSession& aSession, const TDesC& aImplementation, RIoConsole& aUnderlyingConsole, const TDesC& aTitle, const TSize& aSize, TUint aConsoleOptions = ENormal); |
|
234 IMPORT_C void CreateL(RIoSession& aSession, const TDesC& aImplementation, const TDesC& aTitle, const TSize& aSize, TUint aConsoleOptions = ENormal); |
|
235 IMPORT_C void CreateL(RIoSession& aSession, const TDesC& aImplementation, RIoConsole& aUnderlyingConsole, const TDesC& aTitle, const TSize& aSize, TUint aConsoleOptions = ENormal); |
|
236 IMPORT_C TInt Open(RIoSession& aSession, RIoHandle& aHandle); |
|
237 IMPORT_C void OpenL(RIoSession& aSession, RIoHandle& aHandle); |
|
238 IMPORT_C TInt Implementation(TDes& aDes) const; |
|
239 IMPORT_C void ImplementationL(TDes& aDes) const; |
|
240 }; |
|
241 |
|
242 class RIoPersistentConsole : public RIoConsole |
|
243 { |
|
244 public: |
|
245 enum TCloseBehaviour |
|
246 { |
|
247 EDetachOnHandleClose, |
|
248 EKeepAttachedOnHandleClose, |
|
249 }; |
|
250 public: |
|
251 IMPORT_C TInt Create(RIoSession& aSession, const TDesC& aName, const TDesC& aTitle); |
|
252 IMPORT_C void CreateL(RIoSession& aSession, const TDesC& aName, const TDesC& aTitle); |
|
253 |
|
254 IMPORT_C TInt OpenByName(RIoSession& aSession, const TDesC& aName); |
|
255 IMPORT_C void OpenByNameL(RIoSession& aSession, const TDesC& aName); |
|
256 |
|
257 IMPORT_C TInt AttachReader(RIoEndPoint& aEndPoint, TCloseBehaviour aDetachOnClose); |
|
258 IMPORT_C void AttachReaderL(RIoEndPoint& aEndPoint, TCloseBehaviour aDetachOnClose); |
|
259 IMPORT_C void DetachReader(); |
|
260 IMPORT_C void NotifyReaderDetach(TRequestStatus& aStatus); |
|
261 IMPORT_C void CancelNotifyReaderDetach(TRequestStatus& aStatus); |
|
262 |
|
263 IMPORT_C TInt AttachWriter(RIoEndPoint& aEndPoint, TCloseBehaviour aDetachOnClose); |
|
264 IMPORT_C void AttachWriterL(RIoEndPoint& aEndPoint, TCloseBehaviour aDetachOnClose); |
|
265 IMPORT_C void DetachWriter(); |
|
266 IMPORT_C void NotifyWriterDetach(TRequestStatus& aStatus); |
|
267 IMPORT_C void CancelNotifyWriterDetach(TRequestStatus& aStatus); |
|
268 |
|
269 IMPORT_C TInt GetAttachedReaderAndWriterNames(TName& aReaderName, TName& aWriterName); |
|
270 IMPORT_C void GetAttachedReaderAndWriterNamesL(TName& aReaderName, TName& aWriterName); |
|
271 |
|
272 IMPORT_C TInt GetCreator(TThreadId& aThreadId); |
|
273 IMPORT_C TThreadId GetCreatorL(); |
|
274 }; |
|
275 |
|
276 class RIoFile : public RIoEndPoint |
|
277 { |
|
278 public: |
|
279 enum TMode |
|
280 { |
|
281 ERead, |
|
282 EOverwrite, |
|
283 EAppend |
|
284 }; |
|
285 public: |
|
286 IMPORT_C TInt Create(RIoSession& aSession, const TDesC& aFileName, TMode aMode); |
|
287 IMPORT_C void CreateL(RIoSession& aSession, const TDesC& aFileName, TMode aMode); |
|
288 }; |
|
289 |
|
290 class RIoNull : public RIoEndPoint |
|
291 { |
|
292 public: |
|
293 IMPORT_C TInt Create(RIoSession& aSession); |
|
294 IMPORT_C void CreateL(RIoSession& aSession); |
|
295 }; |
|
296 |
|
297 // Convenience class to wrap up a set of stdin, stdout, stderr handles |
|
298 class TIoHandleSet |
|
299 { |
|
300 public: |
|
301 IMPORT_C TIoHandleSet(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr); |
|
302 IMPORT_C RIoSession& IoSession() const; |
|
303 IMPORT_C RIoReadHandle& Stdin() const; |
|
304 IMPORT_C RIoWriteHandle& Stdout() const; |
|
305 IMPORT_C RIoWriteHandle& Stderr() const; |
|
306 private: |
|
307 RIoSession& iIoSession; |
|
308 RIoReadHandle& iStdin; |
|
309 RIoWriteHandle& iStdout; |
|
310 RIoWriteHandle& iStderr; |
|
311 TUint32 iSpare; |
|
312 }; |
|
313 |
|
314 #endif |