|
1 /* |
|
2 * Copyright (c) 2004 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: Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "CTcWatcherSession.h" |
|
19 #include "CTcWatcherServer.h" |
|
20 #include "CTcCoroner.h" |
|
21 #include "CTcGrimreaper.h" |
|
22 #include "WatcherConstants.h" |
|
23 |
|
24 CTcWatcherSession* CTcWatcherSession::NewL( |
|
25 #ifndef __IPC_V2_PRESENT__ |
|
26 RThread& aClient, |
|
27 #endif |
|
28 CTcWatcherServer* aServer ) |
|
29 { |
|
30 CTcWatcherSession* self = |
|
31 #ifdef __IPC_V2_PRESENT__ |
|
32 new( ELeave ) CTcWatcherSession; |
|
33 #else |
|
34 new( ELeave ) CTcWatcherSession( aClient ); |
|
35 #endif |
|
36 |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL( aServer ); |
|
39 CleanupStack::Pop(); |
|
40 |
|
41 return self; |
|
42 } |
|
43 |
|
44 CTcWatcherSession::~CTcWatcherSession() |
|
45 { |
|
46 delete iCoroner; |
|
47 delete iGrimreaper; |
|
48 iWatcherServer->SessionRemoved(); |
|
49 } |
|
50 |
|
51 CTcWatcherSession::CTcWatcherSession() |
|
52 { |
|
53 } |
|
54 |
|
55 void CTcWatcherSession::ConstructL( CTcWatcherServer* aServer ) |
|
56 { |
|
57 #ifndef __IPC_V2_PRESENT__ |
|
58 CreateL( *aServer ); |
|
59 #endif |
|
60 |
|
61 iWatcherServer = aServer; |
|
62 iWatcherServer->SessionAdded(); |
|
63 } |
|
64 |
|
65 #ifdef __IPC_V2_PRESENT__ |
|
66 void CTcWatcherSession::ServiceL( const RMessage2& aMessage ) |
|
67 #else |
|
68 void CTcWatcherSession::ServiceL( const RMessage& aMessage ) |
|
69 #endif |
|
70 { |
|
71 // Any leaves from this function will be catched by the Active Scheduler |
|
72 // and forwarded to CTcWatcher::RunError(). |
|
73 |
|
74 // Check for session related requests |
|
75 TInt status( KErrNone ); |
|
76 switch( aMessage.Function() ) |
|
77 { |
|
78 case ECloseSession: |
|
79 { |
|
80 // Session destruction is handled |
|
81 // by the client-server framework. |
|
82 delete iCoroner; |
|
83 iCoroner = NULL; |
|
84 delete iGrimreaper; |
|
85 iGrimreaper = NULL; |
|
86 break; |
|
87 } |
|
88 case EConfigAndStart: |
|
89 { |
|
90 RThread clientThread; |
|
91 #ifdef __IPC_V2_PRESENT__ |
|
92 aMessage.Client( clientThread ); |
|
93 CleanupClosePushL( clientThread ); |
|
94 |
|
95 aMessage.ReadL( 0, iAppName ); |
|
96 iCoroner = CTcCoroner::NewL( clientThread, iAppName, *iWatcherServer ); |
|
97 iGrimreaper = CTcGrimreaper::NewL( clientThread, aMessage.Int1() ); |
|
98 CleanupStack::PopAndDestroy(); |
|
99 #else |
|
100 aMessage.ReadL( aMessage.Ptr0(), iAppName ); |
|
101 iCoroner = CTcCoroner::NewL( Client(), iAppName, *iWatcherServer ); |
|
102 iGrimreaper = CTcGrimreaper::NewL( Client(), aMessage.Int1() ); |
|
103 #endif |
|
104 break; |
|
105 } |
|
106 case EPing: |
|
107 { |
|
108 iGrimreaper->NotYet(); |
|
109 break; |
|
110 } |
|
111 default: |
|
112 { |
|
113 // Unknown request |
|
114 status = KErrUnknown; |
|
115 } |
|
116 } |
|
117 |
|
118 aMessage.Complete( status ); |
|
119 } |