|
1 /* |
|
2 * Copyright (c) 2006 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: Contains MNcdNode interface |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdserverreportmanagerproxy.h" |
|
20 |
|
21 #include <s32mem.h> |
|
22 |
|
23 #include "catalogsinterfaceidentifier.h" |
|
24 #include "catalogsclientserver.h" |
|
25 #include "catalogsconstants.h" |
|
26 #include "ncdproviderproxy.h" |
|
27 #include "ncdnodeproxy.h" |
|
28 #include "ncdnodeidentifier.h" |
|
29 #include "ncdoperationmanagerproxy.h" |
|
30 #include "ncdserverreportoperationproxy.h" |
|
31 #include "catalogsdebug.h" |
|
32 |
|
33 |
|
34 CNcdServerReportManagerProxy* CNcdServerReportManagerProxy::NewL( MCatalogsClientServer& aSession, |
|
35 TInt aHandle, |
|
36 CNcdProviderProxy& aProvider ) |
|
37 { |
|
38 CNcdServerReportManagerProxy* self = |
|
39 CNcdServerReportManagerProxy::NewLC( aSession, aHandle, aProvider ); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 |
|
45 CNcdServerReportManagerProxy* CNcdServerReportManagerProxy::NewLC( MCatalogsClientServer& aSession, |
|
46 TInt aHandle, |
|
47 CNcdProviderProxy& aProvider ) |
|
48 { |
|
49 CNcdServerReportManagerProxy* self = |
|
50 new( ELeave ) CNcdServerReportManagerProxy( aSession, aHandle, aProvider ); |
|
51 // Using PushL because the object does not have any references yet |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 return self; |
|
55 } |
|
56 |
|
57 |
|
58 CNcdServerReportManagerProxy::CNcdServerReportManagerProxy( MCatalogsClientServer& aSession, |
|
59 TInt aHandle, |
|
60 CNcdProviderProxy& aProvider ) |
|
61 : CNcdInterfaceBaseProxy( aSession, aHandle, &aProvider ), |
|
62 iProvider( aProvider ) |
|
63 { |
|
64 |
|
65 } |
|
66 |
|
67 |
|
68 void CNcdServerReportManagerProxy::ConstructL() |
|
69 { |
|
70 DLTRACEIN(("")); |
|
71 |
|
72 // Register the interface |
|
73 MNcdServerReportManager* mgr( this ); |
|
74 AddInterfaceL( |
|
75 CCatalogsInterfaceIdentifier::NewL( mgr, |
|
76 this, |
|
77 MNcdServerReportManager::KInterfaceUid ) ); |
|
78 } |
|
79 |
|
80 |
|
81 CNcdServerReportManagerProxy::~CNcdServerReportManagerProxy() |
|
82 { |
|
83 // Remove interfaces implemented by this class from the interface list. |
|
84 // So, the interface list is up to date when this class object is deleted. |
|
85 RemoveInterface( MNcdServerReportManager::KInterfaceUid ); |
|
86 } |
|
87 |
|
88 |
|
89 void CNcdServerReportManagerProxy::NodeSetAsInstalledL( CNcdNodeProxy& aNode, TInt aErrorCode ) |
|
90 { |
|
91 CBufBase* buf = CBufFlat::NewL( KBufExpandSize ); |
|
92 CleanupStack::PushL( buf ); |
|
93 RBufWriteStream stream( *buf ); |
|
94 CleanupClosePushL( stream ); |
|
95 |
|
96 stream.WriteInt32L( aErrorCode ); |
|
97 aNode.NodeIdentifier().ExternalizeL( stream ); |
|
98 |
|
99 CleanupStack::PopAndDestroy( &stream ); |
|
100 TPtrC8 ptr = buf->Ptr( 0 ); |
|
101 |
|
102 TInt tmp( 0 ); |
|
103 TInt error = |
|
104 ClientServerSession(). |
|
105 SendSync( NcdNodeFunctionIds::ENcdServerReportManagerNodeSetAsInstalled, |
|
106 ptr, |
|
107 tmp, |
|
108 Handle() ); |
|
109 User::LeaveIfError( error ); |
|
110 |
|
111 CleanupStack::PopAndDestroy( buf ); |
|
112 } |
|
113 |
|
114 |
|
115 void CNcdServerReportManagerProxy::SetReportingMethodL( const MNcdServerReportManager::TReportingMethod& aMethod ) |
|
116 { |
|
117 DLTRACEIN(("")); |
|
118 |
|
119 CBufBase* buf = CBufFlat::NewL( KBufExpandSize ); |
|
120 CleanupStack::PushL( buf ); |
|
121 RBufWriteStream stream( *buf ); |
|
122 CleanupClosePushL( stream ); |
|
123 |
|
124 stream.WriteInt32L( aMethod ); |
|
125 |
|
126 CleanupStack::PopAndDestroy( &stream ); |
|
127 TPtrC8 ptr = buf->Ptr( 0 ); |
|
128 |
|
129 TInt tmp( 0 ); |
|
130 TInt error = |
|
131 ClientServerSession(). |
|
132 SendSync( NcdNodeFunctionIds::ENcdServerReportManagerSetReportingMethod, |
|
133 ptr, |
|
134 tmp, |
|
135 Handle() ); |
|
136 User::LeaveIfError( error ); |
|
137 |
|
138 CleanupStack::PopAndDestroy( buf ); |
|
139 } |
|
140 |
|
141 |
|
142 MNcdServerReportManager::TReportingMethod CNcdServerReportManagerProxy::ReportingMethodL() const |
|
143 { |
|
144 DLTRACEIN(("")); |
|
145 |
|
146 TInt method( MNcdServerReportManager::EReportingBackground ); |
|
147 |
|
148 TInt error = |
|
149 ClientServerSession(). |
|
150 SendSync( NcdNodeFunctionIds::ENcdServerReportManagerReportingMethod, |
|
151 KNullDesC, |
|
152 method, |
|
153 Handle() ); |
|
154 User::LeaveIfError( error ); |
|
155 |
|
156 MNcdServerReportManager::TReportingMethod retMethod( |
|
157 static_cast<MNcdServerReportManager::TReportingMethod>( method ) ); |
|
158 |
|
159 return retMethod; |
|
160 } |
|
161 |
|
162 |
|
163 void CNcdServerReportManagerProxy::SetReportingStyleL( const MNcdServerReportManager::TReportingStyle& aStyle ) |
|
164 { |
|
165 DLTRACEIN(("")); |
|
166 |
|
167 CBufBase* buf = CBufFlat::NewL( KBufExpandSize ); |
|
168 CleanupStack::PushL( buf ); |
|
169 RBufWriteStream stream( *buf ); |
|
170 CleanupClosePushL( stream ); |
|
171 |
|
172 stream.WriteInt32L( aStyle ); |
|
173 |
|
174 CleanupStack::PopAndDestroy( &stream ); |
|
175 TPtrC8 ptr = buf->Ptr( 0 ); |
|
176 |
|
177 TInt tmp( 0 ); |
|
178 TInt error = |
|
179 ClientServerSession(). |
|
180 SendSync( NcdNodeFunctionIds::ENcdServerReportManagerSetReportingStyle, |
|
181 ptr, |
|
182 tmp, |
|
183 Handle() ); |
|
184 User::LeaveIfError( error ); |
|
185 |
|
186 CleanupStack::PopAndDestroy( buf ); |
|
187 } |
|
188 |
|
189 |
|
190 MNcdServerReportManager::TReportingStyle CNcdServerReportManagerProxy::ReportingStyleL() const |
|
191 { |
|
192 DLTRACEIN(("")); |
|
193 |
|
194 TInt style( MNcdServerReportManager::EReportingStyleGeneral ); |
|
195 |
|
196 TInt error = |
|
197 ClientServerSession(). |
|
198 SendSync( NcdNodeFunctionIds::ENcdServerReportManagerReportingStyle, |
|
199 KNullDesC, |
|
200 style, |
|
201 Handle() ); |
|
202 User::LeaveIfError( error ); |
|
203 |
|
204 MNcdServerReportManager::TReportingStyle retStyle( |
|
205 static_cast<MNcdServerReportManager::TReportingStyle>( style ) ); |
|
206 |
|
207 return retStyle; |
|
208 } |
|
209 |
|
210 |
|
211 MNcdServerReportOperation* CNcdServerReportManagerProxy::SendL( MNcdServerReportOperationObserver& aObserver ) |
|
212 { |
|
213 DLTRACEIN(("")); |
|
214 |
|
215 // Create operation |
|
216 |
|
217 // This class does not need to observe the operation itself. |
|
218 // It is up to the called to observe the progress. |
|
219 // So, just set the given observer directly for the operation. |
|
220 CNcdServerReportOperationProxy* op( NULL ); |
|
221 |
|
222 if ( ReportingMethodL() == MNcdServerReportManager::EReportingManaged ) |
|
223 { |
|
224 DLINFO(("Reporting method managed, create operation.")); |
|
225 op = Provider().OperationManager().CreateServerReportOperationL( aObserver ); |
|
226 } |
|
227 |
|
228 DLTRACEOUT(("")); |
|
229 |
|
230 return op; |
|
231 } |
|
232 |
|
233 |
|
234 CNcdProviderProxy& CNcdServerReportManagerProxy::Provider() |
|
235 { |
|
236 return iProvider; |
|
237 } |
|
238 |