|
1 // client.cpp |
|
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 #include <fshell/iocli.h> |
|
14 #include "clientserver.h" |
|
15 #include <e32math.h> |
|
16 |
|
17 |
|
18 #ifndef EKA2 |
|
19 |
|
20 // |
|
21 // TServerStart. |
|
22 // |
|
23 |
|
24 TServerStart::TServerStart(TRequestStatus& aStatus) |
|
25 : iId(RThread().Id()), iStatus(&aStatus) |
|
26 { |
|
27 aStatus = KRequestPending; |
|
28 } |
|
29 |
|
30 TPtrC TServerStart::AsCommand() const |
|
31 { |
|
32 return TPtrC(reinterpret_cast<const TText*>(this),sizeof(TServerStart)/sizeof(TText)); |
|
33 } |
|
34 |
|
35 #endif |
|
36 |
|
37 |
|
38 // |
|
39 // Statics. |
|
40 // |
|
41 |
|
42 static TInt StartServer() |
|
43 { |
|
44 #ifdef EKA2 |
|
45 const TUidType serverUid(KNullUid, KNullUid, KServerUid3); |
|
46 RProcess server; |
|
47 TInt r = server.Create(KIoServerName, KNullDesC, serverUid); |
|
48 if (r != KErrNone) |
|
49 { |
|
50 return r; |
|
51 } |
|
52 TRequestStatus stat; |
|
53 server.Rendezvous(stat); |
|
54 if (stat != KRequestPending) |
|
55 { |
|
56 server.Kill(0); |
|
57 } |
|
58 else |
|
59 { |
|
60 server.Resume(); |
|
61 } |
|
62 User::WaitForRequest(stat); // wait for start or death |
|
63 r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int(); |
|
64 server.Close(); |
|
65 return r; |
|
66 #else |
|
67 TRequestStatus started; |
|
68 TServerStart start(started); |
|
69 const TUidType serverUid(KNullUid, KNullUid, KServerUid3); |
|
70 #ifdef __WINS__ |
|
71 RLibrary lib; |
|
72 TInt r = lib.Load(KIoServerName, serverUid); |
|
73 if (r != KErrNone) |
|
74 { |
|
75 return r; |
|
76 } |
|
77 TLibraryFunction ordinal1 = lib.Lookup(1); |
|
78 TThreadFunction serverFunc = reinterpret_cast<TThreadFunction>(ordinal1()); |
|
79 TName name(KIoServerName); |
|
80 name.AppendNum(Math::Random(), EHex); |
|
81 RThread server; |
|
82 r=server.Create(name, serverFunc, |
|
83 KIoStackSize, |
|
84 &start, &lib, NULL, |
|
85 KIoInitHeapSize, KIoMaxHeapSize, EOwnerProcess); |
|
86 lib.Close(); |
|
87 #else |
|
88 RProcess server; |
|
89 TInt r=server.Create(KIoServerName, start.AsCommand(), serverUid); |
|
90 #endif |
|
91 if (r != KErrNone) |
|
92 { |
|
93 return r; |
|
94 } |
|
95 TRequestStatus died; |
|
96 server.Logon(died); |
|
97 if (died != KRequestPending) |
|
98 { |
|
99 User::WaitForRequest(died); |
|
100 server.Kill(0); |
|
101 server.Close(); |
|
102 return died.Int(); |
|
103 } |
|
104 server.Resume(); |
|
105 User::WaitForRequest(started, died); |
|
106 if (started == KRequestPending) |
|
107 { |
|
108 server.Close(); |
|
109 return died.Int(); |
|
110 } |
|
111 server.LogonCancel(died); |
|
112 server.Close(); |
|
113 User::WaitForRequest(died); |
|
114 return KErrNone; |
|
115 #endif // EKA2 |
|
116 } |
|
117 |
|
118 #ifndef EKA2 |
|
119 TInt E32Dll(TDllReason) |
|
120 { |
|
121 return 0; |
|
122 } |
|
123 #endif |
|
124 |
|
125 |
|
126 // |
|
127 // RIoSession. |
|
128 // |
|
129 |
|
130 EXPORT_C TInt RIoSession::Connect() |
|
131 { |
|
132 TInt retry = 2; |
|
133 for (;;) |
|
134 { |
|
135 TInt r = CreateSession(KIoServerName, TVersion(0,0,0)); |
|
136 if ((r != KErrNotFound) && (r != KErrServerTerminated)) |
|
137 { |
|
138 return r; |
|
139 } |
|
140 if (--retry == 0) |
|
141 { |
|
142 return r; |
|
143 } |
|
144 r = StartServer(); |
|
145 if ((r != KErrNone) && (r != KErrAlreadyExists)) |
|
146 { |
|
147 return r; |
|
148 } |
|
149 } |
|
150 } |
|
151 |
|
152 EXPORT_C void RIoSession::ConnectL() |
|
153 { |
|
154 User::LeaveIfError(Connect()); |
|
155 } |
|
156 |
|
157 EXPORT_C TInt RIoSession::SetObjectName(TInt aHandle, const TDesC& aName) |
|
158 { |
|
159 #ifdef EKA2 |
|
160 return SendReceive(EIoSetObjectName, TIpcArgs(aHandle, &aName)); |
|
161 #else |
|
162 TInt p[4]; |
|
163 p[0] = aHandle; |
|
164 p[1] = (TInt)&aName; |
|
165 return SendReceive(EIoSetObjectName, &p[0]); |
|
166 #endif |
|
167 } |
|
168 |
|
169 EXPORT_C void RIoSession::SetObjectNameL(TInt aHandle, const TDesC& aName) |
|
170 { |
|
171 User::LeaveIfError(SetObjectName(aHandle, aName)); |
|
172 } |
|
173 |
|
174 EXPORT_C TInt RIoSession::FindFirstHandle(RIoHandle::TType aType, const TDesC& aMatchString, TInt& aFoundHandle, TName& aName) |
|
175 { |
|
176 #ifdef EKA2 |
|
177 TPckg<TInt> foundBuf(aFoundHandle); |
|
178 return SendReceive(EIoFindFirstHandle, TIpcArgs(aType, &aMatchString, &foundBuf, &aName)); |
|
179 #else |
|
180 TInt p[4]; |
|
181 p[0] = aType; |
|
182 p[1] = &aMatchString; |
|
183 p[2] = &aFoundHandle; |
|
184 p[3] = &aName; |
|
185 return SendReceive(EIoFindFirstHandle, &p[0]); |
|
186 #endif |
|
187 } |
|
188 |
|
189 EXPORT_C TInt RIoSession::FindNextHandle(TInt& aFoundHandle, TName& aName) |
|
190 { |
|
191 #ifdef EKA2 |
|
192 TPckg<TInt> foundBuf(aFoundHandle); |
|
193 return SendReceive(EIoFindNextHandle, TIpcArgs(&foundBuf, &aName)); |
|
194 #else |
|
195 TInt p[4]; |
|
196 p[0] = &aFoundHandle; |
|
197 p[1] = &aName; |
|
198 return SendReceive(EIoFindNextHandle, &p[0]); |
|
199 #endif |
|
200 } |
|
201 |
|
202 |
|
203 // |
|
204 // RIoHandle. |
|
205 // |
|
206 |
|
207 EXPORT_C TInt RIoHandle::OpenFoundHandle(RIoSession& aSession, TInt aFoundHandle) |
|
208 { |
|
209 #ifdef EKA2 |
|
210 return CreateSubSession(aSession, EIoOpenFoundHandle, TIpcArgs(aFoundHandle)); |
|
211 #else |
|
212 TInt p[4]; |
|
213 p[0] = aFoundHandle; |
|
214 return CreateSubSession(aSession, EIoOpenFoundHandle, &p[0]); |
|
215 #endif |
|
216 } |
|
217 |
|
218 EXPORT_C void RIoHandle::OpenFoundHandleL(RIoSession& aSession, TInt aFoundHandle) |
|
219 { |
|
220 User::LeaveIfError(OpenFoundHandle(aSession, aFoundHandle)); |
|
221 } |
|
222 |
|
223 EXPORT_C void RIoHandle::Close() |
|
224 { |
|
225 CloseSubSession(EIoHandleClose); |
|
226 } |
|
227 |
|
228 EXPORT_C TInt RIoHandle::IsType(TType aType) const |
|
229 { |
|
230 #ifdef EKA2 |
|
231 return SendReceive(EIoHandleIsType, TIpcArgs(aType)); |
|
232 #else |
|
233 TInt p[4]; |
|
234 p[0] = (TInt)aType; |
|
235 return SendReceive(EIoHandleIsType, &p[0]); |
|
236 #endif |
|
237 |
|
238 } |
|
239 |
|
240 EXPORT_C TBool RIoHandle::IsTypeL(TType aType) const |
|
241 { |
|
242 return User::LeaveIfError(IsType(aType)); |
|
243 } |
|
244 |
|
245 EXPORT_C TInt RIoHandle::ObjectName(TDes& aName) const |
|
246 { |
|
247 #ifdef EKA2 |
|
248 return SendReceive(EIoHandleGetName, TIpcArgs(&aName)); |
|
249 #else |
|
250 TInt p[4]; |
|
251 p[0] = &aName; |
|
252 return SendReceive(EIoHandleGetName, &p[0]); |
|
253 #endif |
|
254 } |
|
255 |
|
256 EXPORT_C void RIoHandle::ObjectNameL(TDes& aName) const |
|
257 { |
|
258 User::LeaveIfError(ObjectName(aName)); |
|
259 } |
|
260 |
|
261 EXPORT_C TInt RIoHandle::Equals(const RIoHandle& aNother) const |
|
262 { |
|
263 #ifdef EKA2 |
|
264 return SendReceive(EIoHandleEquals, TIpcArgs(aNother.SubSessionHandle())); |
|
265 #else |
|
266 TInt p[4]; |
|
267 p[0] = (TInt)aNother.SubSessionHandle(); |
|
268 return SendReceive(EIoHandleEquals, &p[0]); |
|
269 #endif |
|
270 } |
|
271 |
|
272 EXPORT_C TBool RIoHandle::EqualsL(const RIoHandle& aNother) const |
|
273 { |
|
274 return User::LeaveIfError(Equals(aNother)); |
|
275 } |
|
276 |
|
277 EXPORT_C RIoSession RIoHandle::Session() const |
|
278 { |
|
279 RSessionBase session = RSubSessionBase::Session(); |
|
280 return static_cast<RIoSession&>(session); |
|
281 } |
|
282 |
|
283 |
|
284 // |
|
285 // RIoReadWriteHandle. |
|
286 // |
|
287 |
|
288 EXPORT_C TInt RIoReadWriteHandle::SetMode(TMode aMode) |
|
289 { |
|
290 #ifdef EKA2 |
|
291 return SendReceive(EIoSetReadWriteMode, TIpcArgs(aMode)); |
|
292 #else |
|
293 TInt p[4]; |
|
294 p[0] = (TInt)aMode; |
|
295 return SendReceive(EIoSetReadWriteMode, &p[0]); |
|
296 #endif |
|
297 } |
|
298 |
|
299 EXPORT_C void RIoReadWriteHandle::SetModeL(TMode aMode) |
|
300 { |
|
301 User::LeaveIfError(SetMode(aMode)); |
|
302 } |
|
303 |
|
304 EXPORT_C TInt RIoReadWriteHandle::SetOwner(TThreadId aOwningThread) |
|
305 { |
|
306 #ifdef EKA2 |
|
307 return SendReceive(EIoHandleSetOwner, TIpcArgs(aOwningThread)); |
|
308 #else |
|
309 TInt p[4]; |
|
310 p[0] = aOwningThread; |
|
311 return SendReceive(EIoHandleSetOwner, &p[0]); |
|
312 #endif |
|
313 } |
|
314 |
|
315 EXPORT_C void RIoReadWriteHandle::SetOwnerL(TThreadId aOwningThread) |
|
316 { |
|
317 User::LeaveIfError(SetOwner(aOwningThread)); |
|
318 } |
|
319 |
|
320 EXPORT_C TInt RIoReadWriteHandle::SetUnderlyingConsole(RIoConsole& aConsole) |
|
321 { |
|
322 #ifdef EKA2 |
|
323 return SendReceive(EIoHandleSetUnderlyingConsole, TIpcArgs(aConsole.SubSessionHandle())); |
|
324 #else |
|
325 TInt p[4]; |
|
326 p[0] = aConsole.SubSessionHandle(); |
|
327 return SendReceive(EIoHandleSetUnderlyingConsole, &p[0]); |
|
328 #endif |
|
329 } |
|
330 |
|
331 EXPORT_C void RIoReadWriteHandle::SetUnderlyingConsoleL(RIoConsole& aConsole) |
|
332 { |
|
333 User::LeaveIfError(SetUnderlyingConsole(aConsole)); |
|
334 } |
|
335 |
|
336 EXPORT_C TInt RIoReadWriteHandle::AttachedToConsole() const |
|
337 { |
|
338 #ifdef EKA2 |
|
339 return SendReceive(EIoHandleAttachedToConsole); |
|
340 #else |
|
341 return SendReceive(EIoHandleAttachedToConsole, NULL); |
|
342 #endif |
|
343 } |
|
344 |
|
345 EXPORT_C TBool RIoReadWriteHandle::AttachedToConsoleL() const |
|
346 { |
|
347 return User::LeaveIfError(AttachedToConsole()); |
|
348 } |
|
349 |
|
350 // |
|
351 // RIoReadHandle. |
|
352 // |
|
353 |
|
354 EXPORT_C TInt RIoReadHandle::Create(RIoSession& aSession) |
|
355 { |
|
356 #ifdef EKA2 |
|
357 return CreateSubSession(aSession, EIoCreateReader); |
|
358 #else |
|
359 return CreateSubSession(aSession, EIoCreateReader, NULL); |
|
360 #endif |
|
361 } |
|
362 |
|
363 EXPORT_C void RIoReadHandle::CreateL(RIoSession& aSession) |
|
364 { |
|
365 User::LeaveIfError(Create(aSession)); |
|
366 } |
|
367 |
|
368 EXPORT_C TInt RIoReadHandle::Open(RIoSession& aSession) |
|
369 { |
|
370 #ifdef EKA2 |
|
371 return CreateSubSession(aSession, EIoOpenReaderByThreadId); |
|
372 #else |
|
373 return CreateSubSession(aSession, EIoOpenReaderByThreadId, NULL); |
|
374 #endif |
|
375 } |
|
376 |
|
377 EXPORT_C void RIoReadHandle::OpenL(RIoSession& aSession) |
|
378 { |
|
379 User::LeaveIfError(Open(aSession)); |
|
380 } |
|
381 |
|
382 EXPORT_C TInt RIoReadHandle::Open(RIoSession& aSession, TThreadId aThreadId) |
|
383 { |
|
384 TPckgBuf<TThreadId> threadIdPckg(aThreadId); |
|
385 #ifdef EKA2 |
|
386 return CreateSubSession(aSession, EIoOpenReaderByExplicitThreadId, TIpcArgs(&threadIdPckg)); |
|
387 #else |
|
388 TInt p[4]; |
|
389 p[0] = &threadIdPckg; |
|
390 return CreateSubSession(aSession, EIoOpenReaderByExplicitThreadId, &p[0]); |
|
391 #endif |
|
392 } |
|
393 |
|
394 EXPORT_C void RIoReadHandle::OpenL(RIoSession& aSession, TThreadId aThreadId) |
|
395 { |
|
396 User::LeaveIfError(Open(aSession, aThreadId)); |
|
397 } |
|
398 |
|
399 EXPORT_C TInt RIoReadHandle::Duplicate(RIoReadHandle& aReadHandle) |
|
400 { |
|
401 #ifdef EKA2 |
|
402 return SendReceive(EIoDuplicateReader, TIpcArgs(aReadHandle.SubSessionHandle())); |
|
403 #else |
|
404 TInt p[4]; |
|
405 p[0] = aReadHandle.SubSessionHandle(); |
|
406 return SendReceive(EIoDuplicateReader, &p[0]); |
|
407 #endif |
|
408 } |
|
409 |
|
410 EXPORT_C void RIoReadHandle::DuplicateL(RIoReadHandle& aReadHandle) |
|
411 { |
|
412 User::LeaveIfError(Duplicate(aReadHandle)); |
|
413 } |
|
414 |
|
415 EXPORT_C TInt RIoReadHandle::DuplicateHandleFromThread(TThreadId aThreadId) |
|
416 { |
|
417 return SendReceive(EIoDuplicateReaderHandleFromThread, TIpcArgs(TUint(aThreadId))); |
|
418 } |
|
419 |
|
420 EXPORT_C TInt RIoReadHandle::SetReadMode(TReadMode aMode) |
|
421 { |
|
422 #ifdef EKA2 |
|
423 return SendReceive(EIoSetReadMode, TIpcArgs(aMode)); |
|
424 #else |
|
425 TInt p[4]; |
|
426 p[0] = (TInt)aMode; |
|
427 return SendReceive(EIoSetReadMode, &p[0]); |
|
428 #endif |
|
429 } |
|
430 |
|
431 EXPORT_C void RIoReadHandle::SetReadModeL(TReadMode aMode) |
|
432 { |
|
433 User::LeaveIfError(SetReadMode(aMode)); |
|
434 } |
|
435 |
|
436 EXPORT_C TInt RIoReadHandle::SetToForeground() |
|
437 { |
|
438 #ifdef EKA2 |
|
439 return SendReceive(EIoSetReaderToForeground); |
|
440 #else |
|
441 return SendReceive(EIoSetReaderToForeground, NULL); |
|
442 #endif |
|
443 } |
|
444 |
|
445 EXPORT_C void RIoReadHandle::SetToForegroundL() |
|
446 { |
|
447 User::LeaveIfError(SetToForeground()); |
|
448 } |
|
449 |
|
450 EXPORT_C TInt RIoReadHandle::Read(TDes& aDes) |
|
451 { |
|
452 #ifdef EKA2 |
|
453 return SendReceive(EIoRead, TIpcArgs(&aDes)); |
|
454 #else |
|
455 TInt p[4]; |
|
456 p[0] = (TInt)&aDes; |
|
457 return SendReceive(EIoRead, &p[0]); |
|
458 #endif |
|
459 } |
|
460 |
|
461 EXPORT_C void RIoReadHandle::ReadL(TDes& aDes) |
|
462 { |
|
463 User::LeaveIfError(Read(aDes)); |
|
464 } |
|
465 |
|
466 EXPORT_C void RIoReadHandle::Read(TDes& aDes, TRequestStatus& aStatus) |
|
467 { |
|
468 #ifdef EKA2 |
|
469 return SendReceive(EIoRead, TIpcArgs(&aDes), aStatus); |
|
470 #else |
|
471 TInt p[4]; |
|
472 p[0] = (TInt)&aDes; |
|
473 SendReceive(EIoRead, &p[0], aStatus); |
|
474 #endif |
|
475 } |
|
476 |
|
477 EXPORT_C TInt RIoReadHandle::SetLineSeparator(const TDesC& aSeparator) |
|
478 { |
|
479 #ifdef EKA2 |
|
480 return SendReceive(EIoSetLineSeparator, TIpcArgs(&aSeparator)); |
|
481 #else |
|
482 TInt p[4]; |
|
483 p[0] = (TInt)&aSeparator; |
|
484 return SendReceive(EIoSetLineSeparator, &p[0]); |
|
485 #endif |
|
486 } |
|
487 |
|
488 EXPORT_C void RIoReadHandle::SetLineSeparatorL(const TDesC& aSeparator) |
|
489 { |
|
490 User::LeaveIfError(SetLineSeparator(aSeparator)); |
|
491 } |
|
492 |
|
493 EXPORT_C void RIoReadHandle::ReadCancel() |
|
494 { |
|
495 #ifdef EKA2 |
|
496 SendReceive(EIoReadCancel); |
|
497 #else |
|
498 SendReceive(EIoReadCancel, NULL); |
|
499 #endif |
|
500 } |
|
501 |
|
502 EXPORT_C TInt RIoReadHandle::IsForeground() const |
|
503 { |
|
504 #ifdef EKA2 |
|
505 return SendReceive(EIoIsForegroundReader); |
|
506 #else |
|
507 return SendReceive(EIoIsForegroundReader, NULL); |
|
508 #endif |
|
509 } |
|
510 |
|
511 EXPORT_C TBool RIoReadHandle::IsForegroundL() const |
|
512 { |
|
513 return User::LeaveIfError(IsForeground()); |
|
514 } |
|
515 |
|
516 EXPORT_C void RIoReadHandle::NotifyChange(TPckgBuf<TUint>& aChangeType, TRequestStatus& aStatus) |
|
517 { |
|
518 #ifdef EKA2 |
|
519 SendReceive(EIoReadHandleNotifyChange, TIpcArgs(&aChangeType), aStatus); |
|
520 #else |
|
521 TInt p[4]; |
|
522 p[0] = (TInt)&aChangeType;; |
|
523 SendReceive(EIoReadHandleNotifyChange, &p[0], aStatus); |
|
524 #endif |
|
525 } |
|
526 |
|
527 EXPORT_C void RIoReadHandle::CancelNotifyChange() |
|
528 { |
|
529 SendReceive(EIoReadHandleCancelNotifyChange); |
|
530 } |
|
531 |
|
532 |
|
533 // |
|
534 // RIoConsoleReadHandle. |
|
535 // |
|
536 |
|
537 EXPORT_C RIoConsoleReadHandle::RIoConsoleReadHandle() |
|
538 { |
|
539 } |
|
540 |
|
541 EXPORT_C RIoConsoleReadHandle::RIoConsoleReadHandle(RIoReadHandle& aHandle) |
|
542 { |
|
543 *(RIoReadHandle*)this = aHandle; // Take a bit-wise copy of the base class. |
|
544 } |
|
545 |
|
546 EXPORT_C RIoConsoleReadHandle RIoConsoleReadHandle::operator=(RIoReadHandle& aHandle) |
|
547 { |
|
548 *(RIoReadHandle*)this = aHandle; // Take a bit-wise copy of the base class. |
|
549 return *this; |
|
550 } |
|
551 |
|
552 EXPORT_C TUint RIoConsoleReadHandle::ReadKey() |
|
553 { |
|
554 TRequestStatus status; |
|
555 WaitForKey(status); |
|
556 User::WaitForRequest(status); |
|
557 if (status.Int()) |
|
558 { |
|
559 return EKeyNull; |
|
560 } |
|
561 return KeyCode(); |
|
562 } |
|
563 |
|
564 EXPORT_C void RIoConsoleReadHandle::WaitForKey(TRequestStatus& aStatus) |
|
565 { |
|
566 #ifdef EKA2 |
|
567 return SendReceive(EIoConsoleWaitForKey, TIpcArgs(&iKeyBuf), aStatus); |
|
568 #else |
|
569 TInt p[4]; |
|
570 p[0] = (TInt)&iKeyBuf; |
|
571 SendReceive(EIoConsoleWaitForKey, &p[0], aStatus); |
|
572 #endif |
|
573 } |
|
574 |
|
575 EXPORT_C void RIoConsoleReadHandle::WaitForKeyCancel() |
|
576 { |
|
577 #ifdef EKA2 |
|
578 SendReceive(EIoConsoleWaitForKeyCancel); |
|
579 #else |
|
580 SendReceive(EIoConsoleWaitForKeyCancel, NULL); |
|
581 #endif |
|
582 } |
|
583 |
|
584 EXPORT_C TUint RIoConsoleReadHandle::KeyCode() const |
|
585 { |
|
586 return iKeyBuf().iKeyCode; |
|
587 } |
|
588 |
|
589 EXPORT_C TUint RIoConsoleReadHandle::KeyModifiers() const |
|
590 { |
|
591 return iKeyBuf().iModifiers; |
|
592 } |
|
593 |
|
594 EXPORT_C TInt RIoConsoleReadHandle::CaptureKey(TUint aKeyCode, TUint aModifierMask, TUint aModifiers) |
|
595 { |
|
596 #ifdef EKA2 |
|
597 return SendReceive(EIoConsoleCaptureKey, TIpcArgs(aKeyCode, aModifierMask, aModifiers)); |
|
598 #else |
|
599 TInt p[4]; |
|
600 p[0] = aKeyCode; |
|
601 p[1] = aModifierMask; |
|
602 p[2] = aModifiers; |
|
603 return SendReceive(EIoConsoleCaptureKey, &p[0]); |
|
604 #endif |
|
605 } |
|
606 |
|
607 EXPORT_C void RIoConsoleReadHandle::CaptureKeyL(TUint aKeyCode, TUint aModifierMask, TUint aModifiers) |
|
608 { |
|
609 User::LeaveIfError(CaptureKey(aKeyCode, aModifierMask, aModifiers)); |
|
610 } |
|
611 |
|
612 EXPORT_C TInt RIoConsoleReadHandle::CancelCaptureKey(TUint aKeyCode, TUint aModifierMask, TUint aModifiers) |
|
613 { |
|
614 #ifdef EKA2 |
|
615 return SendReceive(EIoConsoleCancelCaptureKey, TIpcArgs(aKeyCode, aModifierMask, aModifiers)); |
|
616 #else |
|
617 TInt p[4]; |
|
618 p[0] = aKeyCode; |
|
619 p[1] = aModifierMask; |
|
620 p[2] = aModifiers; |
|
621 return SendReceive(EIoConsoleCancelCaptureKey, &p[0]); |
|
622 #endif |
|
623 } |
|
624 |
|
625 EXPORT_C TInt RIoConsoleReadHandle::CaptureAllKeys() |
|
626 { |
|
627 #ifdef EKA2 |
|
628 return SendReceive(EIoConsoleCaptureAllKeys); |
|
629 #else |
|
630 return SendReceive(EIoConsoleCaptureAllKeys, NULL); |
|
631 #endif |
|
632 } |
|
633 |
|
634 EXPORT_C void RIoConsoleReadHandle::CaptureAllKeysL() |
|
635 { |
|
636 User::LeaveIfError(CaptureAllKeys()); |
|
637 } |
|
638 |
|
639 EXPORT_C TInt RIoConsoleReadHandle::CancelCaptureAllKeys() |
|
640 { |
|
641 #ifdef EKA2 |
|
642 return SendReceive(EIoConsoleCancelCaptureAllKeys); |
|
643 #else |
|
644 return SendReceive(EIoConsoleCancelCaptureAllKeys, NULL); |
|
645 #endif |
|
646 } |
|
647 |
|
648 |
|
649 // |
|
650 // RIoWriteHandle. |
|
651 // |
|
652 |
|
653 EXPORT_C TInt RIoWriteHandle::Create(RIoSession& aSession) |
|
654 { |
|
655 #ifdef EKA2 |
|
656 return CreateSubSession(aSession, EIoCreateWriter); |
|
657 #else |
|
658 return CreateSubSession(aSession, EIoCreateWriter, NULL); |
|
659 #endif |
|
660 } |
|
661 |
|
662 EXPORT_C void RIoWriteHandle::CreateL(RIoSession& aSession) |
|
663 { |
|
664 User::LeaveIfError(Create(aSession)); |
|
665 } |
|
666 |
|
667 EXPORT_C TInt RIoWriteHandle::Open(RIoSession& aSession) |
|
668 { |
|
669 #ifdef EKA2 |
|
670 return CreateSubSession(aSession, EIoOpenWriterByThreadId); |
|
671 #else |
|
672 return CreateSubSession(aSession, EIoOpenWriterByThreadId, NULL); |
|
673 #endif |
|
674 } |
|
675 |
|
676 EXPORT_C void RIoWriteHandle::OpenL(RIoSession& aSession) |
|
677 { |
|
678 User::LeaveIfError(Open(aSession)); |
|
679 } |
|
680 |
|
681 EXPORT_C TInt RIoWriteHandle::Open(RIoSession& aSession, TThreadId aThreadId) |
|
682 { |
|
683 TPckgBuf<TThreadId> threadIdPckg(aThreadId); |
|
684 #ifdef EKA2 |
|
685 return CreateSubSession(aSession, EIoOpenWriterByExplicitThreadId, TIpcArgs(&threadIdPckg)); |
|
686 #else |
|
687 TInt p[4]; |
|
688 p[0] = &threadIdPckg; |
|
689 return CreateSubSession(aSession, EIoOpenWriterByExplicitThreadId, &p[0]); |
|
690 #endif |
|
691 } |
|
692 |
|
693 EXPORT_C void RIoWriteHandle::OpenL(RIoSession& aSession, TThreadId aThreadId) |
|
694 { |
|
695 User::LeaveIfError(Open(aSession, aThreadId)); |
|
696 } |
|
697 |
|
698 EXPORT_C TInt RIoWriteHandle::Duplicate(RIoWriteHandle& aWriteHandle) |
|
699 { |
|
700 #ifdef EKA2 |
|
701 return SendReceive(EIoDuplicateWriter, TIpcArgs(aWriteHandle.SubSessionHandle())); |
|
702 #else |
|
703 TInt p[4]; |
|
704 p[0] = aWriteHandle.SubSessionHandle(); |
|
705 return SendReceive(EIoDuplicateWriter, &p[0]); |
|
706 #endif |
|
707 } |
|
708 |
|
709 EXPORT_C void RIoWriteHandle::DuplicateL(RIoWriteHandle& aWriteHandle) |
|
710 { |
|
711 User::LeaveIfError(Duplicate(aWriteHandle)); |
|
712 } |
|
713 |
|
714 EXPORT_C TInt RIoWriteHandle::DuplicateHandleFromThread(TThreadId aThreadId) |
|
715 { |
|
716 return SendReceive(EIoDuplicateWriterHandleFromThread, TIpcArgs(TUint(aThreadId))); |
|
717 } |
|
718 |
|
719 EXPORT_C TInt RIoWriteHandle::Write(const TDesC& aDes) |
|
720 { |
|
721 #ifdef EKA2 |
|
722 return SendReceive(EIoWrite, TIpcArgs(&aDes)); |
|
723 #else |
|
724 TInt p[4]; |
|
725 p[0] = (TInt)&aDes; |
|
726 return SendReceive(EIoWrite, &p[0]); |
|
727 #endif |
|
728 } |
|
729 |
|
730 EXPORT_C void RIoWriteHandle::WriteL(const TDesC& aDes) |
|
731 { |
|
732 User::LeaveIfError(Write(aDes)); |
|
733 } |
|
734 |
|
735 EXPORT_C void RIoWriteHandle::Write(const TDesC& aDes, TRequestStatus& aStatus) |
|
736 { |
|
737 #ifdef EKA2 |
|
738 return SendReceive(EIoWrite, TIpcArgs(&aDes), aStatus); |
|
739 #else |
|
740 TInt p[4]; |
|
741 p[0] = (TInt)&aDes; |
|
742 SendReceive(EIoWrite, &p[0], aStatus); |
|
743 #endif |
|
744 } |
|
745 |
|
746 EXPORT_C void RIoWriteHandle::WriteCancel() |
|
747 { |
|
748 #ifdef EKA2 |
|
749 SendReceive(EIoWriteCancel); |
|
750 #else |
|
751 SendReceive(EIoWriteCancel, NULL); |
|
752 #endif |
|
753 } |
|
754 |
|
755 |
|
756 // |
|
757 // RIoConsoleWriteHandle. |
|
758 // |
|
759 |
|
760 EXPORT_C RIoConsoleWriteHandle::RIoConsoleWriteHandle() |
|
761 { |
|
762 } |
|
763 |
|
764 EXPORT_C RIoConsoleWriteHandle::RIoConsoleWriteHandle(RIoWriteHandle& aHandle) |
|
765 { |
|
766 *(RIoWriteHandle*)this = aHandle; // Take a bit-wise copy of the base class. |
|
767 } |
|
768 |
|
769 EXPORT_C RIoConsoleWriteHandle RIoConsoleWriteHandle::operator=(RIoWriteHandle& aHandle) |
|
770 { |
|
771 *(RIoWriteHandle*)this = aHandle; // Take a bit-wise copy of the base class. |
|
772 return *this; |
|
773 } |
|
774 |
|
775 EXPORT_C TInt RIoConsoleWriteHandle::GetCursorPos(TPoint& aPos) const |
|
776 { |
|
777 TPckg<TPoint> posPckg(aPos); |
|
778 #ifdef EKA2 |
|
779 TInt err = SendReceive(EIoConsoleCursorPos, TIpcArgs(&posPckg)); |
|
780 #else |
|
781 TInt p[4]; |
|
782 p[0] = (TInt)&posPckg; |
|
783 TInt err = SendReceive(EIoConsoleCursorPos, &p[0]); |
|
784 #endif |
|
785 return err; |
|
786 } |
|
787 |
|
788 EXPORT_C TPoint RIoConsoleWriteHandle::GetCursorPosL() const |
|
789 { |
|
790 TPoint pos; |
|
791 User::LeaveIfError(GetCursorPos(pos)); |
|
792 return pos; |
|
793 } |
|
794 |
|
795 EXPORT_C TInt RIoConsoleWriteHandle::SetCursorPosAbs(const TPoint& aPoint) |
|
796 { |
|
797 TPckg<TPoint> posPckg(aPoint); |
|
798 #ifdef EKA2 |
|
799 return SendReceive(EIoConsoleSetCursorPosAbs, TIpcArgs(&posPckg)); |
|
800 #else |
|
801 TInt p[4]; |
|
802 p[0] = (TInt)&posPckg; |
|
803 return SendReceive(EIoConsoleSetCursorPosAbs, &p[0]); |
|
804 #endif |
|
805 } |
|
806 |
|
807 EXPORT_C void RIoConsoleWriteHandle::SetCursorPosAbsL(const TPoint& aPos) |
|
808 { |
|
809 User::LeaveIfError(SetCursorPosAbs(aPos)); |
|
810 } |
|
811 |
|
812 EXPORT_C TInt RIoConsoleWriteHandle::SetCursorPosRel(const TPoint& aPoint) |
|
813 { |
|
814 TPckg<TPoint> posPckg(aPoint); |
|
815 #ifdef EKA2 |
|
816 return SendReceive(EIoConsoleSetCursorPosRel, TIpcArgs(&posPckg)); |
|
817 #else |
|
818 TInt p[4]; |
|
819 p[0] = (TInt)&posPckg; |
|
820 return SendReceive(EIoConsoleSetCursorPosRel, &p[0]); |
|
821 #endif |
|
822 } |
|
823 |
|
824 EXPORT_C void RIoConsoleWriteHandle::SetCursorPosRelL(const TPoint& aPos) |
|
825 { |
|
826 User::LeaveIfError(SetCursorPosRel(aPos)); |
|
827 } |
|
828 |
|
829 EXPORT_C TInt RIoConsoleWriteHandle::SetCursorHeight(TInt aPercentage) |
|
830 { |
|
831 #ifdef EKA2 |
|
832 return SendReceive(EIoConsoleSetCursorHeight, TIpcArgs(aPercentage)); |
|
833 #else |
|
834 TInt p[4]; |
|
835 p[0] = aPercentage; |
|
836 return SendReceive(EIoConsoleSetCursorHeight, &p[0]); |
|
837 #endif |
|
838 } |
|
839 |
|
840 EXPORT_C void RIoConsoleWriteHandle::SetCursorHeightL(TInt aPercentage) |
|
841 { |
|
842 User::LeaveIfError(SetCursorHeight(aPercentage)); |
|
843 } |
|
844 |
|
845 EXPORT_C TInt RIoConsoleWriteHandle::SetTitle(const TDesC& aTitle) |
|
846 { |
|
847 #ifdef EKA2 |
|
848 return SendReceive(EIoConsoleSetTitle, TIpcArgs(&aTitle)); |
|
849 #else |
|
850 TInt p[4]; |
|
851 p[0] = (TInt)&aTitle; |
|
852 return SendReceive(EIoConsoleSetTitle, &p[0]); |
|
853 #endif |
|
854 } |
|
855 |
|
856 EXPORT_C void RIoConsoleWriteHandle::SetTitleL(const TDesC& aTitle) |
|
857 { |
|
858 User::LeaveIfError(SetTitle(aTitle)); |
|
859 } |
|
860 |
|
861 EXPORT_C TInt RIoConsoleWriteHandle::ClearScreen() |
|
862 { |
|
863 #ifdef EKA2 |
|
864 return SendReceive(EIoConsoleClearScreen); |
|
865 #else |
|
866 return SendReceive(EIoConsoleClearScreen, NULL); |
|
867 #endif |
|
868 } |
|
869 |
|
870 EXPORT_C void RIoConsoleWriteHandle::ClearScreenL() |
|
871 { |
|
872 User::LeaveIfError(ClearScreen()); |
|
873 } |
|
874 |
|
875 EXPORT_C TInt RIoConsoleWriteHandle::ClearToEndOfLine() |
|
876 { |
|
877 #ifdef EKA2 |
|
878 return SendReceive(EIoConsoleClearToEndOfLine); |
|
879 #else |
|
880 return SendReceive(EIoConsoleClearToEndOfLine, NULL); |
|
881 #endif |
|
882 } |
|
883 |
|
884 EXPORT_C void RIoConsoleWriteHandle::ClearToEndOfLineL() |
|
885 { |
|
886 User::LeaveIfError(ClearToEndOfLine()); |
|
887 } |
|
888 |
|
889 EXPORT_C TInt RIoConsoleWriteHandle::GetScreenSize(TSize& aSize) const |
|
890 { |
|
891 TPckg<TSize> sizePckg(aSize); |
|
892 #ifdef EKA2 |
|
893 TInt err = SendReceive(EIoConsoleScreenSize, TIpcArgs(&sizePckg)); |
|
894 #else |
|
895 TInt p[4]; |
|
896 p[0] = (TInt)&sizePckg; |
|
897 TInt err = SendReceive(EIoConsoleScreenSize, &p[0]); |
|
898 #endif |
|
899 return err; |
|
900 } |
|
901 |
|
902 EXPORT_C TSize RIoConsoleWriteHandle::GetScreenSizeL() const |
|
903 { |
|
904 TSize size; |
|
905 User::LeaveIfError(GetScreenSize(size)); |
|
906 return size; |
|
907 } |
|
908 |
|
909 EXPORT_C TInt RIoConsoleWriteHandle::SetAttributes(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor) |
|
910 { |
|
911 #ifdef EKA2 |
|
912 TInt err = SendReceive(EIoConsoleSetAttributes, TIpcArgs(aAttributes, aForegroundColor, aBackgroundColor)); |
|
913 #else |
|
914 TInt p[4]; |
|
915 p[0] = aAttributes; |
|
916 p[1] = aForegroundColor; |
|
917 p[2] = aBackgroundColor; |
|
918 TInt err = SendReceive(EIoConsoleSetAttributes, &p[0]); |
|
919 #endif |
|
920 return err; |
|
921 } |
|
922 |
|
923 EXPORT_C void RIoConsoleWriteHandle::SetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor) |
|
924 { |
|
925 User::LeaveIfError(SetAttributes(aAttributes, aForegroundColor, aBackgroundColor)); |
|
926 } |
|
927 |
|
928 EXPORT_C TInt RIoConsoleWriteHandle::SetAttributes(const ConsoleAttributes::TAttributes& aAttributes) |
|
929 { |
|
930 return SetAttributes(aAttributes.iAttributes, aAttributes.iForegroundColor, aAttributes.iBackgroundColor); |
|
931 } |
|
932 |
|
933 EXPORT_C TInt RIoConsoleWriteHandle::SetIsStdErr(TBool aFlag) |
|
934 { |
|
935 return SendReceive(EIoSetIsStdErr, TIpcArgs(aFlag)); |
|
936 } |
|
937 |
|
938 |
|
939 // |
|
940 // RIoEndPoint. |
|
941 // |
|
942 |
|
943 EXPORT_C TInt RIoEndPoint::Attach(RIoReadHandle& aReader, TReadMode aMode) |
|
944 { |
|
945 #ifdef EKA2 |
|
946 return SendReceive(EIoEndPointAttachReader, TIpcArgs(aReader.SubSessionHandle(), aMode)); |
|
947 #else |
|
948 TInt p[4]; |
|
949 p[0] = (TInt)aReader.SubSessionHandle(); |
|
950 p[1] = aMode; |
|
951 return SendReceive(EIoEndPointAttachReader, &p[0]); |
|
952 #endif |
|
953 } |
|
954 |
|
955 EXPORT_C void RIoEndPoint::AttachL(RIoReadHandle& aReader, TReadMode aMode) |
|
956 { |
|
957 User::LeaveIfError(Attach(aReader, aMode)); |
|
958 } |
|
959 |
|
960 EXPORT_C TInt RIoEndPoint::Attach(RIoWriteHandle& aWriter) |
|
961 { |
|
962 #ifdef EKA2 |
|
963 return SendReceive(EIoEndPointAttachWriter, TIpcArgs(aWriter.SubSessionHandle())); |
|
964 #else |
|
965 TInt p[4]; |
|
966 p[0] = (TInt)aWriter.SubSessionHandle(); |
|
967 return SendReceive(EIoEndPointAttachWriter, &p[0]); |
|
968 #endif |
|
969 } |
|
970 |
|
971 EXPORT_C void RIoEndPoint::AttachL(RIoWriteHandle& aWriter) |
|
972 { |
|
973 User::LeaveIfError(Attach(aWriter)); |
|
974 } |
|
975 |
|
976 EXPORT_C TInt RIoEndPoint::SetForegroundReadHandle(RIoReadHandle& aReader) |
|
977 { |
|
978 #ifdef EKA2 |
|
979 return SendReceive(EIoEndPointSetForegroundReadHandle, TIpcArgs(aReader.SubSessionHandle())); |
|
980 #else |
|
981 TInt p[4]; |
|
982 p[0] = (TInt)aReader.SubSessionHandle(); |
|
983 return SendReceive(EIoEndPointSetForegroundReadHandle, &p[0]); |
|
984 #endif |
|
985 } |
|
986 |
|
987 EXPORT_C void RIoEndPoint::SetForegroundReadHandleL(RIoReadHandle& aReader) |
|
988 { |
|
989 User::LeaveIfError(SetForegroundReadHandle(aReader)); |
|
990 } |
|
991 |
|
992 EXPORT_C RIoEndPoint::RIoEndPoint() |
|
993 { |
|
994 } |
|
995 |
|
996 |
|
997 // |
|
998 // RIoPipe. |
|
999 // |
|
1000 |
|
1001 EXPORT_C TInt RIoPipe::Create(RIoSession& aSession) |
|
1002 { |
|
1003 #ifdef EKA2 |
|
1004 return CreateSubSession(aSession, EIoCreatePipe); |
|
1005 #else |
|
1006 return CreateSubSession(aSession, EIoCreatePipe, NULL); |
|
1007 #endif |
|
1008 } |
|
1009 |
|
1010 EXPORT_C void RIoPipe::CreateL(RIoSession& aSession) |
|
1011 { |
|
1012 User::LeaveIfError(Create(aSession)); |
|
1013 } |
|
1014 |
|
1015 // |
|
1016 // RIoConsole. |
|
1017 // |
|
1018 |
|
1019 EXPORT_C TInt RIoConsole::Create(RIoSession& aSession, const TDesC& aTitle, const TSize& aSize, TUint aOptions) |
|
1020 { |
|
1021 return Create(aSession, KNullDesC, aTitle, aSize, aOptions); |
|
1022 } |
|
1023 |
|
1024 EXPORT_C void RIoConsole::CreateL(RIoSession& aSession, const TDesC& aTitle, const TSize& aSize, TUint aOptions) |
|
1025 { |
|
1026 User::LeaveIfError(Create(aSession, aTitle, aSize, aOptions)); |
|
1027 } |
|
1028 |
|
1029 EXPORT_C TInt RIoConsole::Create(RIoSession& aSession, const TDesC& aImplementation, const TDesC& aTitle, const TSize& aSize, TUint aOptions) |
|
1030 { |
|
1031 TConsoleCreateParams params; |
|
1032 params.iSize = aSize; |
|
1033 params.iUnderlyingConsoleHandle = KNullHandle; |
|
1034 params.iOptions = aOptions; |
|
1035 TPckg<TConsoleCreateParams> paramsPckg(params); |
|
1036 #ifdef EKA2 |
|
1037 return CreateSubSession(aSession, EIoCreateConsole, TIpcArgs(&aTitle, ¶msPckg, &aImplementation)); |
|
1038 #else |
|
1039 TInt p[4]; |
|
1040 p[0] = (TInt)&aTitle; |
|
1041 p[1] = (TInt)¶msPckg; |
|
1042 p[2] = (TInt)&aImplementation; |
|
1043 return CreateSubSession(aSession, EIoCreateConsole, &p[0]); |
|
1044 #endif |
|
1045 } |
|
1046 |
|
1047 EXPORT_C TInt RIoConsole::Create(RIoSession& aSession, const TDesC& aImplementation, RIoConsole& aUnderlyingConsole, const TDesC& aTitle, const TSize& aSize, TUint aOptions) |
|
1048 { |
|
1049 TConsoleCreateParams params; |
|
1050 params.iSize = aSize; |
|
1051 params.iUnderlyingConsoleHandle = aUnderlyingConsole.SubSessionHandle(); |
|
1052 params.iOptions = aOptions; |
|
1053 TPckg<TConsoleCreateParams> paramsPckg(params); |
|
1054 #ifdef EKA2 |
|
1055 return CreateSubSession(aSession, EIoCreateConsole, TIpcArgs(&aTitle, ¶msPckg, &aImplementation)); |
|
1056 #else |
|
1057 TInt p[4]; |
|
1058 p[0] = (TInt)&aTitle; |
|
1059 p[1] = (TInt)¶msPckg; |
|
1060 p[2] = (TInt)&aImplementation; |
|
1061 return CreateSubSession(aSession, EIoCreateConsole, &p[0]); |
|
1062 #endif |
|
1063 } |
|
1064 |
|
1065 EXPORT_C void RIoConsole::CreateL(RIoSession& aSession, const TDesC& aImplementation, const TDesC& aTitle, const TSize& aSize, TUint aOptions) |
|
1066 { |
|
1067 User::LeaveIfError(Create(aSession, aImplementation, aTitle, aSize, aOptions)); |
|
1068 } |
|
1069 |
|
1070 EXPORT_C void RIoConsole::CreateL(RIoSession& aSession, const TDesC& aImplementation, RIoConsole& aUnderlyingConsole, const TDesC& aTitle, const TSize& aSize, TUint aOptions) |
|
1071 { |
|
1072 User::LeaveIfError(Create(aSession, aImplementation, aUnderlyingConsole, aTitle, aSize, aOptions)); |
|
1073 } |
|
1074 |
|
1075 EXPORT_C TInt RIoConsole::Open(RIoSession& aSession, RIoHandle& aHandle) |
|
1076 { |
|
1077 #ifdef EKA2 |
|
1078 return CreateSubSession(aSession, EIoOpenConsole, TIpcArgs(aHandle.SubSessionHandle())); |
|
1079 #else |
|
1080 TInt p[4]; |
|
1081 p[0] = aHandle.SubSessionHandle(); |
|
1082 return CreateSubSession(aSession, EIoOpenConsole, &p[0]); |
|
1083 #endif |
|
1084 } |
|
1085 |
|
1086 EXPORT_C void RIoConsole::OpenL(RIoSession& aSession, RIoHandle& aHandle) |
|
1087 { |
|
1088 User::LeaveIfError(Open(aSession, aHandle)); |
|
1089 } |
|
1090 |
|
1091 EXPORT_C TInt RIoConsole::Implementation(TDes& aDes) const |
|
1092 { |
|
1093 #ifdef EKA2 |
|
1094 return SendReceive(EIoConsoleImplementation, TIpcArgs(&aDes)); |
|
1095 #else |
|
1096 TInt p[4]; |
|
1097 p[0] = (TInt)&aDes; |
|
1098 return SendReceive(EIoConsoleImplementation, &p[0]); |
|
1099 #endif |
|
1100 } |
|
1101 |
|
1102 EXPORT_C void RIoConsole::ImplementationL(TDes& aDes) const |
|
1103 { |
|
1104 User::LeaveIfError(Implementation(aDes)); |
|
1105 } |
|
1106 |
|
1107 // |
|
1108 // RIoPersistentConsole. |
|
1109 // |
|
1110 EXPORT_C TInt RIoPersistentConsole::Create(RIoSession& aSession, const TDesC& aName, const TDesC& aTitle) |
|
1111 { |
|
1112 #ifdef EKA2 |
|
1113 return CreateSubSession(aSession, EIoCreatePersistentConsole, TIpcArgs(&aName, &aTitle)); |
|
1114 #else |
|
1115 TInt p[4]; |
|
1116 p[0] = (TInt)&aName; |
|
1117 p[1] = (TInt)&aTitle; |
|
1118 return CreateSubSession(aSession, EIoCreatePersistentConsole, &p[0]); |
|
1119 #endif |
|
1120 } |
|
1121 |
|
1122 EXPORT_C void RIoPersistentConsole::CreateL(RIoSession& aSession, const TDesC& aName, const TDesC& aTitle) |
|
1123 { |
|
1124 User::LeaveIfError(Create(aSession, aName, aTitle)); |
|
1125 } |
|
1126 |
|
1127 EXPORT_C TInt RIoPersistentConsole::OpenByName(RIoSession& aSession, const TDesC& aName) |
|
1128 { |
|
1129 #ifdef EKA2 |
|
1130 return CreateSubSession(aSession, EIoOpenPersistentConsoleByName, TIpcArgs(&aName)); |
|
1131 #else |
|
1132 TInt p[4]; |
|
1133 p[0] = (TInt)&aTitle; |
|
1134 return CreateSubSession(aSession, EIoOpenPersistentConsoleByName, &p[0]); |
|
1135 #endif |
|
1136 } |
|
1137 |
|
1138 EXPORT_C void RIoPersistentConsole::OpenByNameL(RIoSession& aSession, const TDesC& aName) |
|
1139 { |
|
1140 User::LeaveIfError(OpenByName(aSession, aName)); |
|
1141 } |
|
1142 |
|
1143 EXPORT_C TInt RIoPersistentConsole::AttachReader(RIoEndPoint& aEndPoint, TCloseBehaviour aCloseBehaviour) |
|
1144 { |
|
1145 #ifdef EKA2 |
|
1146 return SendReceive(EIoPersistentConsoleAttachReadEndPoint, TIpcArgs(aEndPoint.SubSessionHandle(), aCloseBehaviour)); |
|
1147 #else |
|
1148 TInt p[4]; |
|
1149 p[0] = aEndPoint.Handle(); |
|
1150 p[1] = aCloseBehaviour; |
|
1151 return SendReceive(EIoPersistentConsoleAttachReadEndPoint, &p[0]); |
|
1152 #endif |
|
1153 |
|
1154 } |
|
1155 |
|
1156 EXPORT_C void RIoPersistentConsole::AttachReaderL(RIoEndPoint& aEndPoint, TCloseBehaviour aCloseBehaviour) |
|
1157 { |
|
1158 User::LeaveIfError(AttachReader(aEndPoint, aCloseBehaviour)); |
|
1159 } |
|
1160 |
|
1161 EXPORT_C void RIoPersistentConsole::DetachReader() |
|
1162 { |
|
1163 #ifdef EKA2 |
|
1164 SendReceive(EIoPersistentConsoleDetachReadEndPoint, TIpcArgs()); |
|
1165 #else |
|
1166 TInt p[4]; |
|
1167 SendReceive(EIoPersistentConsoleDetachReadEndPoint, &p[0]); |
|
1168 #endif |
|
1169 } |
|
1170 |
|
1171 EXPORT_C void RIoPersistentConsole::NotifyReaderDetach(TRequestStatus& aStatus) |
|
1172 { |
|
1173 SendReceive(EIoPersistentConsoleNotifyReadDetach, aStatus); |
|
1174 } |
|
1175 |
|
1176 EXPORT_C void RIoPersistentConsole::CancelNotifyReaderDetach(TRequestStatus& aStatus) |
|
1177 { |
|
1178 #ifdef EKA2 |
|
1179 SendReceive(EIoPersistentConsoleCancelNotifyReadDetach, TIpcArgs(&aStatus)); |
|
1180 #else |
|
1181 TInt p[4]; |
|
1182 p[0] = (TInt)&aStatus; |
|
1183 SendReceive(EIoPersistentConsoleCancelNotifyReadDetach, &p[0]); |
|
1184 #endif |
|
1185 } |
|
1186 |
|
1187 EXPORT_C TInt RIoPersistentConsole::AttachWriter(RIoEndPoint& aEndPoint, TCloseBehaviour aCloseBehaviour) |
|
1188 { |
|
1189 #ifdef EKA2 |
|
1190 return SendReceive(EIoPersistentConsoleAttachWriteEndPoint, TIpcArgs(aEndPoint.SubSessionHandle(), aCloseBehaviour)); |
|
1191 #else |
|
1192 TInt p[4]; |
|
1193 p[0] = aEndPoint.Handle(); |
|
1194 p[1] = aCloseBehaviour; |
|
1195 return SendReceive(EIoPersistentConsoleAttachWriteEndPoint, &p[0]); |
|
1196 #endif |
|
1197 } |
|
1198 |
|
1199 EXPORT_C void RIoPersistentConsole::AttachWriterL(RIoEndPoint& aEndPoint, TCloseBehaviour aCloseBehaviour) |
|
1200 { |
|
1201 User::LeaveIfError(AttachWriter(aEndPoint, aCloseBehaviour)); |
|
1202 } |
|
1203 |
|
1204 EXPORT_C void RIoPersistentConsole::DetachWriter() |
|
1205 { |
|
1206 #ifdef EKA2 |
|
1207 SendReceive(EIoPersistentConsoleDetachWriteEndPoint, TIpcArgs()); |
|
1208 #else |
|
1209 TInt p[4]; |
|
1210 SendReceive(EIoPersistentConsoleDetachWriteEndPoint, &p[0]); |
|
1211 #endif |
|
1212 } |
|
1213 |
|
1214 EXPORT_C void RIoPersistentConsole::NotifyWriterDetach(TRequestStatus& aStatus) |
|
1215 { |
|
1216 SendReceive(EIoPersistentConsoleNotifyWriteDetach, aStatus); |
|
1217 } |
|
1218 |
|
1219 EXPORT_C void RIoPersistentConsole::CancelNotifyWriterDetach(TRequestStatus& aStatus) |
|
1220 { |
|
1221 #ifdef EKA2 |
|
1222 SendReceive(EIoPersistentConsoleCancelNotifyWriteDetach, TIpcArgs(&aStatus)); |
|
1223 #else |
|
1224 TInt p[4]; |
|
1225 p[0] = &aStatus; |
|
1226 SendReceive(EIoPersistentConsoleCancelNotifyWriteDetach, &p[0]); |
|
1227 #endif |
|
1228 } |
|
1229 |
|
1230 EXPORT_C TInt RIoPersistentConsole::GetAttachedReaderAndWriterNames(TName& aReaderName, TName& aWriterName) |
|
1231 { |
|
1232 #ifdef EKA2 |
|
1233 return SendReceive(EIoPersistentConsoleGetAttachedNames, TIpcArgs(&aReaderName, &aWriterName)); |
|
1234 #else |
|
1235 TInt p[4]; |
|
1236 p[0] = &aReaderName; |
|
1237 p[1] = &aWriterName; |
|
1238 return SendReceive(EIoPersistentConsoleGetAttachedNames, &p[0]); |
|
1239 #endif |
|
1240 } |
|
1241 |
|
1242 EXPORT_C void RIoPersistentConsole::GetAttachedReaderAndWriterNamesL(TName& aReaderName, TName& aWriterName) |
|
1243 { |
|
1244 User::LeaveIfError(GetAttachedReaderAndWriterNames(aReaderName, aWriterName)); |
|
1245 } |
|
1246 |
|
1247 EXPORT_C TInt RIoPersistentConsole::GetCreator(TThreadId& aThreadId) |
|
1248 { |
|
1249 TPckg<TThreadId> theadPckg(aThreadId); |
|
1250 #ifdef EKA2 |
|
1251 return SendReceive(EIoPersistentConsoleGetCreatorThreadId, TIpcArgs(&theadPckg)); |
|
1252 #else |
|
1253 TInt p[4]; |
|
1254 p[0] = &theadPckg; |
|
1255 return SendReceive(EIoPersistentConsoleGetCreatorThreadId, &p[0]); |
|
1256 #endif |
|
1257 } |
|
1258 |
|
1259 EXPORT_C TThreadId RIoPersistentConsole::GetCreatorL() |
|
1260 { |
|
1261 TThreadId id; |
|
1262 User::LeaveIfError(GetCreator(id)); |
|
1263 return id; |
|
1264 } |
|
1265 |
|
1266 // |
|
1267 // RIoFile. |
|
1268 // |
|
1269 |
|
1270 EXPORT_C TInt RIoFile::Create(RIoSession& aSession, const TDesC& aFileName, TMode aMode) |
|
1271 { |
|
1272 #ifdef EKA2 |
|
1273 return CreateSubSession(aSession, EIoCreateFile, TIpcArgs(&aFileName, (TInt)aMode)); |
|
1274 #else |
|
1275 TInt p[4]; |
|
1276 p[0] = (TInt)&aFileName; |
|
1277 p[1] = (TInt)aMode; |
|
1278 return CreateSubSession(aSession, EIoCreateFile, &p[0]); |
|
1279 #endif |
|
1280 } |
|
1281 |
|
1282 EXPORT_C void RIoFile::CreateL(RIoSession& aSession, const TDesC& aFileName, TMode aMode) |
|
1283 { |
|
1284 User::LeaveIfError(Create(aSession, aFileName,aMode)); |
|
1285 } |
|
1286 |
|
1287 |
|
1288 // |
|
1289 // RIoNull. |
|
1290 // |
|
1291 |
|
1292 EXPORT_C TInt RIoNull::Create(RIoSession& aSession) |
|
1293 { |
|
1294 #ifdef EKA2 |
|
1295 return CreateSubSession(aSession, EIoCreateNull); |
|
1296 #else |
|
1297 return CreateSubSession(aSession, EIoCreateNull, NULL); |
|
1298 #endif |
|
1299 } |
|
1300 |
|
1301 EXPORT_C void RIoNull::CreateL(RIoSession& aSession) |
|
1302 { |
|
1303 User::LeaveIfError(Create(aSession)); |
|
1304 } |
|
1305 |
|
1306 // |
|
1307 // TIoHandleSet |
|
1308 // |
|
1309 |
|
1310 EXPORT_C TIoHandleSet::TIoHandleSet(RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr) |
|
1311 : iIoSession(aIoSession), iStdin(aStdin), iStdout(aStdout), iStderr(aStderr), iSpare(0) |
|
1312 { |
|
1313 } |
|
1314 |
|
1315 EXPORT_C RIoSession& TIoHandleSet::IoSession() const |
|
1316 { |
|
1317 return iIoSession; |
|
1318 } |
|
1319 |
|
1320 EXPORT_C RIoReadHandle& TIoHandleSet::Stdin() const |
|
1321 { |
|
1322 return iStdin; |
|
1323 } |
|
1324 |
|
1325 EXPORT_C RIoWriteHandle& TIoHandleSet::Stdout() const |
|
1326 { |
|
1327 return iStdout; |
|
1328 } |
|
1329 |
|
1330 EXPORT_C RIoWriteHandle& TIoHandleSet::Stderr() const |
|
1331 { |
|
1332 return iStderr; |
|
1333 } |
|
1334 |