|
1 /* |
|
2 * Copyright (c) 2002-2005 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: |
|
15 * WV engine pure data API |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 // INCLUDE FILES |
|
23 #include <e32std.h> |
|
24 |
|
25 #include "impspurecli.h" |
|
26 #include "impspurehandler.h" |
|
27 #include "impserrors.h" |
|
28 #include "impsdataaccessor.h" |
|
29 #include "impscdatautils.h" |
|
30 #include "impsutils.h" |
|
31 |
|
32 // MACROS |
|
33 #ifndef _DEBUG |
|
34 #define _NO_IMPS_LOGGING_ |
|
35 #endif |
|
36 |
|
37 // ================= MEMBER FUNCTIONS ======================= |
|
38 |
|
39 // ---------------------------------------------------------------------------- |
|
40 // CImpsPureHandler2::CImpsPureHandler2 |
|
41 // ---------------------------------------------------------------------------- |
|
42 CImpsPureHandler2::CImpsPureHandler2( |
|
43 TInt aPriority, |
|
44 RImpsPureClient2& aClient ) : |
|
45 // The base class adds this to the scheduler |
|
46 CImpsHandler2( aPriority, aClient) |
|
47 { |
|
48 } |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // CImpsPureHandler2::NewL |
|
52 // ---------------------------------------------------------------------------- |
|
53 CImpsPureHandler2* CImpsPureHandler2::NewL( |
|
54 RImpsPureClient2& aClient, |
|
55 TInt aPriority ) |
|
56 { |
|
57 |
|
58 // Perform the construction. |
|
59 CImpsPureHandler2* self = new (ELeave) |
|
60 CImpsPureHandler2( aPriority, aClient); |
|
61 |
|
62 CleanupStack::PushL( self ); |
|
63 self->CImpsHandler2::ConstructL(); |
|
64 CleanupStack::Pop( self ); |
|
65 return self; |
|
66 } |
|
67 |
|
68 // ---------------------------------------------------------------------------- |
|
69 // CImpsPureHandler2::~CImpsPureHandler2() |
|
70 // ---------------------------------------------------------------------------- |
|
71 CImpsPureHandler2::~CImpsPureHandler2() |
|
72 { |
|
73 } |
|
74 |
|
75 // ---------------------------------------------------------------------------- |
|
76 // CImpsPureHandler2::HandleEventL() |
|
77 // ---------------------------------------------------------------------------- |
|
78 void CImpsPureHandler2::HandleEventL( CImpsFields* aErrorFields ) |
|
79 { |
|
80 // get the event data from server thread. |
|
81 SImpsEventData* event = (SImpsEventData*)iEventData.Ptr(); |
|
82 TImpsMessageType msgType = (TImpsMessageType)event->iMessageType; |
|
83 |
|
84 #ifndef _NO_IMPS_LOGGING_ |
|
85 CImpsClientLogger::Log(_L("CImpsPureHandler::HandleEventL opid=%d cli=%d"), |
|
86 event->iOpCode, (TInt)&iClient ); |
|
87 #endif |
|
88 if ( msgType != EImpsPureData ) |
|
89 { |
|
90 HandleErrorEventL( event->iOpCode, event->iStatus, aErrorFields ); |
|
91 } |
|
92 // Call regular observer |
|
93 // iStatus is error code or message size |
|
94 else if ( iStatus >= 0 ) |
|
95 { |
|
96 HandlePureEventL( ); |
|
97 } |
|
98 } |
|
99 |
|
100 // ---------------------------------------------------------------------------- |
|
101 // CImpsPureHandler2::HandlePureEventL() |
|
102 // ---------------------------------------------------------------------------- |
|
103 void CImpsPureHandler2::HandlePureEventL( ) |
|
104 { |
|
105 SImpsEventData* event = (SImpsEventData*)iEventData.Ptr(); |
|
106 RImpsPureClient2& client = (RImpsPureClient2&)iClient; |
|
107 MImpsPureHandler2* handler = client.Handler(); |
|
108 |
|
109 // Check request message type |
|
110 TInt myType = event->iMessageType; |
|
111 |
|
112 CImpsDataAccessor* myAccess = CImpsDataAccessor::NewLC( iFields ); // << |
|
113 CImpsKey* myKey = CImpsKey::NewLC(); // <<< myKey |
|
114 |
|
115 switch ( myType ) |
|
116 { |
|
117 case EImpsStatus: |
|
118 case EImpsPureData: |
|
119 { |
|
120 if ( !handler ) |
|
121 { |
|
122 #ifndef _NO_IMPS_LOGGING_ |
|
123 CImpsClientLogger::Log(_L("CImpsPureHandler2:HandlePureEventL: NO HANDLER opid=%d cli=%d h=%d"), |
|
124 event->iOpCode, (TInt)&iClient, (TInt)this ); |
|
125 #endif |
|
126 break; |
|
127 } |
|
128 TPtrC8 pureData; |
|
129 pureData.Set( KNullDesC8 ); |
|
130 |
|
131 TImpsCDataUtils::AddValuesFromArrayL( |
|
132 myKey, |
|
133 KTransContentElements, |
|
134 sizeof( KTransContentElements ) / |
|
135 sizeof( KTransContentElements[0] ) ); |
|
136 myKey->AddL( CREATEKEY( EImpsKeyPureData, 0 ) ); |
|
137 TDesC8* temp = NULL; |
|
138 if( myAccess->RestoreDesc8L( myKey, temp ) ) |
|
139 pureData.Set( *temp ); |
|
140 |
|
141 #ifndef _NO_IMPS_LOGGING_ |
|
142 CImpsClientLogger::Log(_L("CImpsPureHandler2:HandlePureEventL: calls HandlePureDataL opid=%d cli=%d h=%d"), |
|
143 event->iOpCode, (TInt)&iClient, (TInt)this ); |
|
144 #endif |
|
145 |
|
146 // Call API observer method |
|
147 TInt err( KErrNone ); |
|
148 TRAP( err, handler->HandlePureDataL( event->iOpCode, pureData, *iClient.CspIdentifier() )); |
|
149 } |
|
150 break; |
|
151 default: // responses |
|
152 __ASSERT_DEBUG( 0 == 1, |
|
153 User::Panic( KImpsPanicCategory, |
|
154 EImpsCorrupted ) ); |
|
155 User::Leave( KErrNotSupported ); |
|
156 break; |
|
157 } // switch |
|
158 CleanupStack::PopAndDestroy(2); // myKey, myAccess |
|
159 } |
|
160 |
|
161 // End of File |
|
162 |