|
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 of the PhoneClient Messenger interface. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPhCltImageHandlerImplementation.h" |
|
22 |
|
23 #ifdef _DEBUG |
|
24 #define _DxPRINT( x ) RDebug::Print(_L( x ) ); |
|
25 #define _DxPRINT2( x,y ) RDebug::Print(_L( x ), y ); |
|
26 #else |
|
27 #define _DxPRINT(x) |
|
28 #define _DxPRINT2( x,y ) |
|
29 #endif |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CPhCltImageHandlerImplementation::NewL |
|
35 // |
|
36 // Creates Phone Client image handler instance. |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CPhCltImageHandlerImplementation* |
|
40 CPhCltImageHandlerImplementation::NewL() |
|
41 { |
|
42 CPhCltImageHandlerImplementation* self = |
|
43 new (ELeave) CPhCltImageHandlerImplementation(); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop(); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CPhCltImageHandlerImplementation::~CPhCltImageHandlerImplementation |
|
52 // |
|
53 // Destructor. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CPhCltImageHandlerImplementation::~CPhCltImageHandlerImplementation() |
|
57 { |
|
58 iStillHandler.Close(); |
|
59 iServer.Close(); |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CPhCltImageHandlerImplementation::SaveImages |
|
64 // |
|
65 // Saves a number of images to PhoneServer. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 TInt CPhCltImageHandlerImplementation:: |
|
69 SaveImages( CPhCltImageParams& aParams ) |
|
70 { |
|
71 return iStillHandler.SaveImages( aParams ); |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CPhCltImageHandlerImplementation::LoadImages |
|
76 // |
|
77 // Loads a number of images from PhoneServer. |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 TInt CPhCltImageHandlerImplementation:: |
|
81 LoadImages( CPhCltImageParams*& aParams ) |
|
82 { |
|
83 return iStillHandler.LoadImages( aParams ); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CPhCltImageHandlerImplementation::CPhCltImageHandlerImplementation |
|
88 // |
|
89 // C++ constructor. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 CPhCltImageHandlerImplementation::CPhCltImageHandlerImplementation() |
|
93 { |
|
94 } |
|
95 |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CPhCltImageHandlerImplementation::ConstructL |
|
99 // |
|
100 // Symbian 2nd phase constructor can leave. |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CPhCltImageHandlerImplementation::ConstructL() |
|
104 { |
|
105 User::LeaveIfError( iServer.Connect() ); |
|
106 User::LeaveIfError ( iStillHandler.Open( iServer ) ); |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CPhCltImageHandlerImplementation::CPhCltBaseImageParamsL |
|
111 // |
|
112 // Creates Phone Client image handler parameter class instance. |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 CPhCltImageParams* CPhCltImageHandlerImplementation:: |
|
116 CPhCltBaseImageParamsL( const TPhCltImageType aType ) |
|
117 { |
|
118 CPhCltBaseImageParams* param = NULL; |
|
119 switch ( aType ) |
|
120 { |
|
121 case EPhCltTypeVTStill: |
|
122 case EPhCltTypeVTDefault: // <- this returns NULL |
|
123 param = CPhCltExtVTImageParams::NewL( aType ); |
|
124 break; |
|
125 case EPhCltTypeOperatorLogo: |
|
126 param = CPhCltExtOperatorLogoParams::NewL(); |
|
127 break; |
|
128 default: |
|
129 User::Leave( KErrArgument ); |
|
130 break; |
|
131 } |
|
132 return param; |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CPhCltImageHandlerImplementation::OpenDefaultVtImage |
|
137 // |
|
138 // Opens Video telephony default image. |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 TInt CPhCltImageHandlerImplementation::OpenDefaultVtImage( RFile& aFile ) |
|
142 { |
|
143 _DxPRINT("CPhCltImageHandlerImplementation.OpenDefaultVtImage") |
|
144 return OpenVtImageCommon( aFile, ETrue ); |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CPhCltImageHandlerImplementation::SaveVtImageL |
|
149 // ----------------------------------------------------------------------------- |
|
150 void CPhCltImageHandlerImplementation::SaveVtImageL( |
|
151 MPhCltImageObserver& aObserver, |
|
152 const TDesC& aImagePath ) |
|
153 { |
|
154 // new style saving not supported yet |
|
155 User::Leave( KErrNotSupported ); |
|
156 iVtImageSaver = |
|
157 CPhCltImageHandlerImplementation::CVtImageSaver::SaveLD( |
|
158 *this, iStillHandler, aImagePath ); |
|
159 iObserver = &aObserver; |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CPhCltImageHandlerImplementation::CancelSaveVtImage |
|
164 // ----------------------------------------------------------------------------- |
|
165 void CPhCltImageHandlerImplementation::CancelSaveVtImage() |
|
166 { |
|
167 if ( iVtImageSaver ) |
|
168 { |
|
169 iVtImageSaver->Cancel(); |
|
170 iVtImageSaver = NULL; |
|
171 } |
|
172 } |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CPhCltImageHandlerImplementation::OpenVtImageCommon |
|
175 // ----------------------------------------------------------------------------- |
|
176 TInt CPhCltImageHandlerImplementation::OpenVtImageCommon( |
|
177 RFile& aFile, |
|
178 const TBool aDefaultImage ) |
|
179 { |
|
180 _DxPRINT2("CPhCltImageHandlerImplementation.OpenDefaultVtImage default=%d", |
|
181 aDefaultImage) |
|
182 TInt fileServerHandle( 0 ); |
|
183 TInt fileHandle( 0 ); |
|
184 // ensure file handle is not open |
|
185 aFile.Close(); |
|
186 fileServerHandle = iStillHandler.OpenVtImage( fileHandle, aDefaultImage ); |
|
187 _DxPRINT2("CPhCltImageHandlerImplementation.OpenDefaultVtImage fileServerHandle=%d", |
|
188 fileServerHandle ) |
|
189 TInt result( fileServerHandle ); |
|
190 if ( fileServerHandle > 0 ) |
|
191 { |
|
192 result = aFile.AdoptFromServer( fileServerHandle, fileHandle ); |
|
193 } |
|
194 _DxPRINT2("CPhCltImageHandlerImplementation.OpenDefaultVtImage result=%d", |
|
195 result ) |
|
196 return result; |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CPhCltImageHandlerImplementation::OpenVtImage |
|
201 // ----------------------------------------------------------------------------- |
|
202 TInt CPhCltImageHandlerImplementation::OpenVtImage( RFile& aFile ) |
|
203 { |
|
204 return OpenVtImageCommon( aFile, EFalse ); |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // CPhCltImageHandlerImplementation::HandleImageSaveCompleteL |
|
209 // ----------------------------------------------------------------------------- |
|
210 void CPhCltImageHandlerImplementation::HandleImageSaveCompleteL( TInt aResult ) |
|
211 { |
|
212 if ( iObserver ) |
|
213 { |
|
214 iVtImageSaver = NULL; // the saver deletes itself |
|
215 MPhCltImageObserver* obs = iObserver; |
|
216 iObserver = NULL; |
|
217 obs->HandleImageSaveCompleteL( aResult ); |
|
218 } |
|
219 } |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // CPhCltImageHandlerImplementation::CVtImageSaver::SaveLD |
|
223 // ----------------------------------------------------------------------------- |
|
224 CPhCltImageHandlerImplementation::CVtImageSaver* |
|
225 CPhCltImageHandlerImplementation::CVtImageSaver::SaveLD( |
|
226 MPhCltImageObserver& aObserver, |
|
227 RPhCltImageHandler& aHandler, |
|
228 const TDesC& aImagePath ) |
|
229 { |
|
230 CPhCltImageHandlerImplementation::CVtImageSaver* saver = |
|
231 new ( ELeave ) CPhCltImageHandlerImplementation::CVtImageSaver( |
|
232 aObserver, aHandler ); |
|
233 CleanupStack::PushL( saver ); |
|
234 saver->DoSave( aImagePath ); |
|
235 CleanupStack::Pop(); |
|
236 return saver; |
|
237 } |
|
238 |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // CPhCltImageHandlerImplementation::CVtImageSaver::CVtImageSaver |
|
242 // ----------------------------------------------------------------------------- |
|
243 CPhCltImageHandlerImplementation::CVtImageSaver::CVtImageSaver( |
|
244 MPhCltImageObserver& aObserver, |
|
245 RPhCltImageHandler& aHandler ) : CActive( CActive::EPriorityStandard ), |
|
246 iObserver( aObserver), iHandler( aHandler ) |
|
247 { |
|
248 CActiveScheduler::Add( this ); |
|
249 } |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // CPhCltImageHandlerImplementation::CVtImageSaver::~CVtImageSaver |
|
253 // ----------------------------------------------------------------------------- |
|
254 CPhCltImageHandlerImplementation::CVtImageSaver::~CVtImageSaver() |
|
255 { |
|
256 Cancel(); |
|
257 } |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // CPhCltImageHandlerImplementation::CVtImageSaver::DoSave |
|
261 // ----------------------------------------------------------------------------- |
|
262 void CPhCltImageHandlerImplementation::CVtImageSaver::DoSave( |
|
263 const TDesC& aImagePath ) |
|
264 { |
|
265 iHandler.SaveVtImage( iStatus, aImagePath ); |
|
266 } |
|
267 |
|
268 // ----------------------------------------------------------------------------- |
|
269 // CPhCltImageHandlerImplementation::CVtImageSaver::RunL |
|
270 // ----------------------------------------------------------------------------- |
|
271 void CPhCltImageHandlerImplementation::CVtImageSaver::RunL() |
|
272 { |
|
273 MPhCltImageObserver& observer = iObserver; |
|
274 delete this; |
|
275 TRAP_IGNORE( observer.HandleImageSaveCompleteL( iStatus.Int() ) ); |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CPhCltImageHandlerImplementation::CVtImageSaver::DoCancel |
|
280 // ----------------------------------------------------------------------------- |
|
281 void CPhCltImageHandlerImplementation::CVtImageSaver::DoCancel() |
|
282 { |
|
283 iHandler.CancelSaveVtImage(); |
|
284 } |
|
285 |
|
286 // End of File |