|
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: CRedirectServer session |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "javaredirectsession.h" |
|
19 #include "javaredirectconsts.h" |
|
20 #include "javadiagnostic.h" |
|
21 using namespace java::util; |
|
22 |
|
23 |
|
24 CRedirectSession::CRedirectSession(DiagnosticListener& aListener) : mListener(aListener) |
|
25 { |
|
26 } |
|
27 |
|
28 CRedirectSession::~CRedirectSession() |
|
29 { |
|
30 } |
|
31 |
|
32 void CRedirectSession::ServiceL(const RMessage2& aMessage) |
|
33 { |
|
34 TInt function = aMessage.Function(); |
|
35 switch (function) |
|
36 { |
|
37 case ESystemOut: |
|
38 case ESystemErr: |
|
39 case ELog: |
|
40 handleMessageL(aMessage); |
|
41 break; |
|
42 |
|
43 default: |
|
44 break; |
|
45 } |
|
46 aMessage.Complete(KErrNone); |
|
47 } |
|
48 |
|
49 void CRedirectSession::handleMessageL(const RMessage2& aMessage) |
|
50 { |
|
51 TInt len = aMessage.GetDesLengthL(0); |
|
52 |
|
53 RBuf8 data; |
|
54 data.CleanupClosePushL(); |
|
55 data.CreateL(len); |
|
56 aMessage.ReadL(0,data); |
|
57 |
|
58 TInt function = aMessage.Function(); |
|
59 dispatchToListener(function, data); |
|
60 |
|
61 CleanupStack::PopAndDestroy(); |
|
62 } |
|
63 |
|
64 void CRedirectSession::dispatchToListener(TInt aType, const TDesC8& aData) |
|
65 { |
|
66 switch (aType) |
|
67 { |
|
68 case ESystemOut: |
|
69 mListener.systemOut(aData); |
|
70 break; |
|
71 case ESystemErr: |
|
72 mListener.systemErr(aData); |
|
73 break; |
|
74 case ELog: |
|
75 mListener.log(aData); |
|
76 break; |
|
77 default: |
|
78 break; |
|
79 } |
|
80 } |
|
81 |