|
1 /* |
|
2 * Copyright (c) 2007 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: Server session for BS engine |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "bsserver.h" |
|
21 #include "bsengine.h" |
|
22 #include "bsengineglobals.h" |
|
23 |
|
24 #include "bsserversession.h" |
|
25 #include "bspanic.h" |
|
26 #include "bsdebug.h" |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ======================= |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CBSServerSession::NewL |
|
32 // Two-phased constructor. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CBSServerSession* CBSServerSession::NewL( CBSServer* aServer ) |
|
36 { |
|
37 CBSServerSession* self = CBSServerSession::NewLC( aServer ); |
|
38 CleanupStack::Pop( self ) ; |
|
39 return self; |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CBSServerSession::NewLC |
|
44 // Two-phased constructor. |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CBSServerSession* CBSServerSession::NewLC( CBSServer* aServer ) |
|
48 { |
|
49 CBSServerSession* self = new ( ELeave ) CBSServerSession(aServer); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL( ) ; |
|
52 return self; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CBSServerSession::~CBSServerSession |
|
57 // Destructor. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CBSServerSession::~CBSServerSession() |
|
61 { |
|
62 if ( iBSServer ) |
|
63 { |
|
64 iBSServer->Engine().RemoveAppRecord( iAppUid ); |
|
65 iBSServer->DecrementSessions( ); |
|
66 } |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CBSServerSession::ReadTextL |
|
71 // |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 HBufC8* CBSServerSession::ReadTextLC( const RMessage2& aMessage, TInt aSlot ) |
|
75 { |
|
76 TInt length = aMessage.GetDesMaxLength( aSlot ); |
|
77 HBufC8* result = HBufC8::NewLC( length ); |
|
78 TPtr8 ptr(result->Des( )); |
|
79 User::LeaveIfError( aMessage.Read( aSlot, ptr ) ); |
|
80 |
|
81 DEBUG(("ReadTextL slot (%d) - %S", aSlot, result)); |
|
82 return result; |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CBSServerSession::ServiceL |
|
87 // Handle client requests. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CBSServerSession::ServiceL( const RMessage2& aMessage ) |
|
91 { |
|
92 DEBUG(("CBSServerSession::ServiceL")); |
|
93 HBufC8* state(NULL); |
|
94 TInt result(0); |
|
95 switch ( aMessage.Function( ) ) |
|
96 { |
|
97 case EBSEngineInitialize: |
|
98 iAppUid = TUid::Uid( aMessage.Int0( ) ); |
|
99 DEBUG(("EBSEngineInitialize %x", iAppUid.iUid)); |
|
100 aMessage.Complete( EBSEngineCommandWasConsumed ); |
|
101 break; |
|
102 case EBSEngineHandleActivationEvent: |
|
103 state = ReadTextLC( aMessage, 0 ); |
|
104 DEBUG(("EBSEngineHandleActivationEvent 0x%X, %S, 0x%X", |
|
105 iAppUid.iUid, state, aMessage.Int1() )); |
|
106 result = iBSServer->Engine(). |
|
107 HandleActivationEventL( iAppUid, *state, aMessage.Int1( ) ); |
|
108 CleanupStack::PopAndDestroy( state ); |
|
109 aMessage.Complete( result ); |
|
110 break; |
|
111 case EBSEngineHandleBackCommand: |
|
112 state = ReadTextLC( aMessage, 0 ); |
|
113 |
|
114 DEBUG(("EBSEngineHandleBackCommand 0x%X, %S", |
|
115 iAppUid.iUid, state)); |
|
116 result = iBSServer->Engine(). |
|
117 HandleBackEventL( iAppUid, *state, aMessage.Int1( ) ); |
|
118 CleanupStack::PopAndDestroy( state ); |
|
119 aMessage.Complete( result ); |
|
120 break; |
|
121 default: |
|
122 TBSEnginePanic tmp = EBSEngineBadRequest; |
|
123 iBSServer->PanicClient( aMessage, tmp ); |
|
124 break; |
|
125 } |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CBSServerSession::CBSServerSession |
|
130 // C++ default constructor can NOT contain any code, that |
|
131 // might leave. |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 CBSServerSession::CBSServerSession( CBSServer* aServer ) : |
|
135 CSession2() |
|
136 { |
|
137 iBSServer = aServer; |
|
138 iBSServer->IncrementSessions( ); |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CBSServerSession::ConstructL |
|
143 // Symbian 2nd phase constructor can leave. |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 void CBSServerSession::ConstructL() |
|
147 { |
|
148 DEBUG(("CBSServerSession::ConstructL")); |
|
149 |
|
150 } |
|
151 |
|
152 // End of File |