|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Implements CNcdSendHttpRequestOperationProxy |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdsendhttprequestoperationproxy.h" |
|
20 |
|
21 #include <s32strm.h> |
|
22 |
|
23 #include "ncdsendhttprequestoperationobserver.h" |
|
24 #include "ncdoperationproxyremovehandler.h" |
|
25 #include "catalogsclientserver.h" |
|
26 #include "catalogsutils.h" |
|
27 |
|
28 #include "catalogsdebug.h" |
|
29 |
|
30 // ======== MEMBER FUNCTIONS ======== |
|
31 |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CNcdSendHttpRequestOperationProxy* CNcdSendHttpRequestOperationProxy::NewLC( |
|
38 MCatalogsClientServer& aSession, |
|
39 TInt aHandle, |
|
40 MNcdOperationProxyRemoveHandler& aRemoveHandler, |
|
41 CNcdNodeManagerProxy& aNodeManager, |
|
42 MNcdSendHttpRequestOperationObserver& aObserver ) |
|
43 { |
|
44 CNcdSendHttpRequestOperationProxy* self = |
|
45 new( ELeave ) CNcdSendHttpRequestOperationProxy( aObserver ); |
|
46 |
|
47 self->AddRef(); |
|
48 CleanupReleasePushL( *self ); |
|
49 self->ConstructL( |
|
50 aSession, |
|
51 aHandle, |
|
52 aRemoveHandler, |
|
53 aNodeManager ); |
|
54 return self; |
|
55 } |
|
56 |
|
57 |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 HBufC8* CNcdSendHttpRequestOperationProxy::ResponseL() const |
|
64 { |
|
65 DLTRACEIN(("")); |
|
66 |
|
67 if ( OperationStateL() != MNcdOperation::EStateComplete ) |
|
68 { |
|
69 DLERROR(("Operation has not completed yet, leaving with KErrNotReady")); |
|
70 User::Leave( KErrNotReady ); |
|
71 } |
|
72 |
|
73 HBufC8* data = NULL; |
|
74 User::LeaveIfError( ClientServerSession().SendSyncAlloc( |
|
75 ENCDOperationFunctionGetData, |
|
76 KNullDesC8(), |
|
77 data, |
|
78 Handle(), |
|
79 0 ) ); |
|
80 |
|
81 if ( !data ) |
|
82 { |
|
83 DLERROR(("No data, leaving with KErrCorrupt")); |
|
84 User::Leave( KErrCorrupt ); |
|
85 } |
|
86 |
|
87 return data; |
|
88 } |
|
89 |
|
90 |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // From MNcdOperation |
|
94 // Operation type getter |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 TNcdInterfaceId CNcdSendHttpRequestOperationProxy::OperationType() const |
|
98 { |
|
99 return static_cast<TNcdInterfaceId>( |
|
100 MNcdSendHttpRequestOperation::KInterfaceUid ); |
|
101 } |
|
102 |
|
103 |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // Constructor |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 CNcdSendHttpRequestOperationProxy::CNcdSendHttpRequestOperationProxy( |
|
110 MNcdSendHttpRequestOperationObserver& aObserver ) |
|
111 : CNcdOperation< MNcdSendHttpRequestOperation >( NULL ), |
|
112 iObserver( aObserver ) |
|
113 { |
|
114 } |
|
115 |
|
116 |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // Destructor |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 CNcdSendHttpRequestOperationProxy::~CNcdSendHttpRequestOperationProxy() |
|
123 { |
|
124 DLTRACEIN(( "this: %X", this )); |
|
125 |
|
126 if ( iRemoveHandler ) |
|
127 { |
|
128 iRemoveHandler->RemoveOperationProxy( *this ); |
|
129 } |
|
130 |
|
131 DLTRACEOUT(( "" )); |
|
132 } |
|
133 |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // ConstructL |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 void CNcdSendHttpRequestOperationProxy::ConstructL( |
|
140 MCatalogsClientServer& aSession, |
|
141 TInt aHandle, |
|
142 MNcdOperationProxyRemoveHandler& aRemoveHandler, |
|
143 CNcdNodeManagerProxy& aNodeManager ) |
|
144 { |
|
145 DLTRACEIN( ( "this: %X", this ) ); |
|
146 CNcdBaseOperationProxy::ConstructL( |
|
147 aSession, |
|
148 aHandle, |
|
149 &aRemoveHandler, |
|
150 NULL, |
|
151 &aNodeManager ); |
|
152 } |
|
153 |
|
154 |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // Handle progress callback |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 void CNcdSendHttpRequestOperationProxy::ProgressCallback() |
|
161 { |
|
162 DLTRACEIN( ( "this: %X", this ) ); |
|
163 TNcdSendableProgress& sendableProgress( SendableProgress() ); |
|
164 TNcdProgress progress( sendableProgress.iProgress, |
|
165 sendableProgress.iMaxProgress ); |
|
166 |
|
167 DLTRACE(("Progress: %d/%d", sendableProgress.iProgress, |
|
168 sendableProgress.iMaxProgress )); |
|
169 |
|
170 AddRef(); |
|
171 DLTRACE(("Calling observer")); |
|
172 iObserver.Progress( *this, progress ); |
|
173 |
|
174 Release(); |
|
175 |
|
176 } |
|
177 |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // Handle query received callback |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 void CNcdSendHttpRequestOperationProxy::QueryReceivedCallback( CNcdQuery* /*aQuery*/ ) |
|
184 { |
|
185 DLTRACEIN( ( "" ) ); |
|
186 } |
|
187 |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // Handle operation complete |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CNcdSendHttpRequestOperationProxy::CompleteCallback( TInt aError ) |
|
194 { |
|
195 DLTRACEIN( ( "Error: %d, this: %X", aError, this ) ); |
|
196 AddRef(); |
|
197 |
|
198 // Iterate backwards in case observers want to remove themselves |
|
199 iObserver.OperationComplete( *this, aError ); |
|
200 |
|
201 DLTRACE(("Observers handled, this: %X", this)); |
|
202 Release(); |
|
203 } |
|
204 |