author | Fionntina Carville <fionntinac@symbian.org> |
Fri, 12 Nov 2010 18:52:18 +0000 | |
branch | RCL_3 |
changeset 69 | a2232ad2df6d |
parent 67 | 756ad29ed18e |
permissions | -rw-r--r-- |
54 | 1 |
/* |
2 |
* Copyright (c) 2007-2010 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: Class for file server service. |
|
15 |
* |
|
67
756ad29ed18e
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
16 |
* Copyright © 2007 Nokia. All rights reserved. |
756ad29ed18e
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
17 |
* This material, including documentation and any related computer |
756ad29ed18e
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
18 |
* programs, is protected by copyright controlled by Nokia. All |
756ad29ed18e
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
19 |
* rights are reserved. Copying, including reproducing, storing, |
756ad29ed18e
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
20 |
* adapting or translating, any or all of this material requires the |
756ad29ed18e
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
21 |
* prior written consent of Nokia. This material also contains |
756ad29ed18e
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
22 |
* confidential information which may not be disclosed to others |
756ad29ed18e
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
23 |
* without the prior written consent of Nokia. |
756ad29ed18e
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
24 |
|
756ad29ed18e
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
25 |
* |
756ad29ed18e
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
26 |
* |
756ad29ed18e
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
27 |
* |
54 | 28 |
*/ |
29 |
||
30 |
||
31 |
// INCLUDE FILES |
|
32 |
#include "CamNewFileService.h" |
|
33 |
#include "CNewFileServiceBase.h" |
|
34 |
||
35 |
#include "CamSettingsModel.h" |
|
36 |
#include <f32file.h> |
|
37 |
#include <eikenv.h> |
|
38 |
#include <eikappui.h> |
|
39 |
#include <eikapp.h> |
|
40 |
#include <AiwGenericParam.h> |
|
41 |
||
42 |
#include "CamAppUi.h" |
|
43 |
||
44 |
#include "CamUtility.h" |
|
45 |
#include "CamAppController.h" |
|
46 |
||
47 |
// FORWARD DECLARATIONS |
|
48 |
||
49 |
// ========================= MEMBER FUNCTIONS ================================ |
|
50 |
||
51 |
// --------------------------------------------------------------------------- |
|
52 |
// CCamNewFileService::NewL |
|
53 |
// Constructor |
|
54 |
// --------------------------------------------------------------------------- |
|
55 |
// |
|
56 |
CCamNewFileService* CCamNewFileService::NewL() |
|
57 |
{ |
|
58 |
return new( ELeave ) CCamNewFileService; |
|
59 |
} |
|
60 |
||
61 |
// --------------------------------------------------------------------------- |
|
62 |
// CCamNewFileService::~CCamNewFileService |
|
63 |
// Destructor |
|
64 |
// --------------------------------------------------------------------------- |
|
65 |
// |
|
66 |
CCamNewFileService::~CCamNewFileService() |
|
67 |
{ |
|
68 |
PRINT( _L("Camera => ~CCamNewFileService") ); |
|
69 |
if ( !iCompleted && iObserver ) |
|
70 |
{ |
|
71 |
TRAP_IGNORE( iObserver->HandleCompletedNewServiceL( EFalse ) ); |
|
72 |
} |
|
73 |
CCamAppUi* appUi = static_cast< CCamAppUi* >( CEikonEnv::Static()->EikAppUi() ); |
|
74 |
if ( appUi ) |
|
75 |
{ |
|
76 |
// Tell appui 'this' is not valid MCamEmbeddedObserver pointer anymore |
|
77 |
appUi->SetEmbeddedObserver( NULL ); |
|
78 |
} |
|
79 |
PRINT( _L("Camera <= ~CCamNewFileService") ); |
|
80 |
} |
|
81 |
||
82 |
// --------------------------------------------------------------------------- |
|
83 |
// CCamNewFileService::HandleNewFileL |
|
84 |
// Receive message from service to record new files |
|
85 |
// --------------------------------------------------------------------------- |
|
86 |
// |
|
87 |
void CCamNewFileService::HandleNewFileL( MNewFileServiceObserver* /*aObserver*/, |
|
88 |
RFile& /*aFile*/, |
|
89 |
TNewServiceFileType /*aType*/ ) |
|
90 |
{ |
|
91 |
||
92 |
||
93 |
} |
|
94 |
||
95 |
// --------------------------------------------------------------------------- |
|
96 |
// CCamNewFileService::HandleNewFileL |
|
97 |
// Receive message from service to record new files |
|
98 |
// --------------------------------------------------------------------------- |
|
99 |
// |
|
100 |
void CCamNewFileService::HandleNewFileL( MNewFileServiceObserver* aObserver, |
|
101 |
CDesCArray& aFilenameArray, |
|
102 |
TNewServiceFileType aType, |
|
103 |
TBool /*aMultipleFiles*/ ) |
|
104 |
{ |
|
105 |
PRINT( _L("Camera: CCamNewFileService::HandleNewFileL()") ); |
|
106 |
||
107 |
iCompleted = EFalse; |
|
108 |
||
109 |
if( aType != ENewFileServiceImage && aType != ENewFileServiceVideo ) |
|
110 |
{ |
|
111 |
aObserver->HandleCompletedNewServiceL( EFalse ); |
|
112 |
return; |
|
113 |
} |
|
114 |
||
115 |
iObserver = aObserver; |
|
116 |
||
117 |
||
118 |
TInt mode = KErrNone; |
|
119 |
||
120 |
switch ( aType ) |
|
121 |
{ |
|
122 |
case ENewFileServiceImage: |
|
123 |
mode = ECamControllerImage; |
|
124 |
break; |
|
125 |
case ENewFileServiceVideo: |
|
126 |
mode = ECamControllerVideo; |
|
127 |
break; |
|
128 |
default: |
|
129 |
break; |
|
130 |
} |
|
131 |
||
132 |
iCamFilenameArray = &aFilenameArray; |
|
133 |
||
134 |
CAiwGenericParamList* ParamList = GenericParams(); |
|
135 |
TInt resolutionsAvailable = ParamList->Count(EGenericParamResolution); |
|
136 |
// set the default requested resolution as 0*0, which is later on |
|
137 |
// interpreted as the default embedded quality. |
|
138 |
TSize requestedResolution(0,0); |
|
139 |
if ( resolutionsAvailable > 0 ) |
|
140 |
{ |
|
141 |
TInt index = 0; |
|
142 |
const TAiwGenericParam* firstReso = ParamList->FindFirst( index, EGenericParamResolution ); |
|
143 |
if ( KErrNotFound != index ) |
|
144 |
{ |
|
145 |
TPtrC8 resData = firstReso->Value().AsData();//&firstReso->Value().AsData(); |
|
146 |
TBuf8<sizeof(TSize)> bufRes; |
|
147 |
if ( resData.Length() > sizeof(TSize) ) User::Leave( KErrArgument ); |
|
148 |
bufRes.Copy(resData); |
|
149 |
TDes8& rText = bufRes; |
|
150 |
TPckgBuf<TSize>* ptr = |
|
151 |
static_cast<TPckgBuf<TSize>*>( &rText ); |
|
152 |
if( !ptr ) User::Leave( KErrNotSupported ); |
|
153 |
TSize& params( (*ptr)() ); |
|
154 |
requestedResolution.SetSize( params.iWidth, params.iHeight ); |
|
155 |
PRINT2( _L("Camera: CCamNewFileService::HandleNewFileL() - Requested resolution: %d * %d"), requestedResolution.iWidth, requestedResolution.iHeight ); |
|
156 |
} |
|
157 |
} |
|
158 |
||
159 |
CCamAppUi * appUi = |
|
160 |
static_cast< CCamAppUi* >( CEikonEnv::Static()->EikAppUi() ); |
|
161 |
appUi->SetRequestedNewFileResolution(requestedResolution); |
|
162 |
appUi->StartAsServerAppL( this, mode ); // 'this' is used for MCamEmbeddedObserver pointer |
|
163 |
} |
|
164 |
||
165 |
// --------------------------------------------------------------------------- |
|
166 |
// CCamNewFileService::ServiceCompleteL |
|
167 |
// Receive message from service that file service has completed |
|
168 |
// and can be closed |
|
169 |
// --------------------------------------------------------------------------- |
|
170 |
// |
|
171 |
void CCamNewFileService::ServiceCompleteL() |
|
172 |
{ |
|
173 |
PRINT( _L("Camcorder: CCamNewFileService::ServiceCompleteL()") ); |
|
174 |
iCompleted = ETrue; |
|
175 |
||
176 |
CEikonEnv::Static()->EikAppUi()->HandleCommandL( EEikCmdExit ); |
|
177 |
} |
|
178 |
||
179 |
// --------------------------------------------------------------------------- |
|
180 |
// CCamNewFileService::FileCompleteL |
|
181 |
// Receive command from application that file named aName has been captured. |
|
182 |
// (image or video) |
|
183 |
// --------------------------------------------------------------------------- |
|
184 |
// |
|
185 |
void |
|
186 |
CCamNewFileService::FileCompleteL( const TDesC& aName ) |
|
187 |
{ |
|
188 |
PRINT( _L("Camcorder: CCamNewFileService::FileCompleteL()") ); |
|
189 |
if( iCamFilenameArray != NULL ) |
|
190 |
{ |
|
191 |
iCamFilenameArray->AppendL( aName ); |
|
192 |
} |
|
193 |
||
194 |
iCompleted = ETrue; |
|
195 |
iObserver->HandleCompletedNewServiceL( ETrue ); |
|
196 |
||
197 |
||
198 |
} |
|
199 |
// --------------------------------------------------------------------------- |
|
200 |
// CCamNewFileService::AbortL |
|
201 |
// Receive command from application that file service must be aborted |
|
202 |
// --------------------------------------------------------------------------- |
|
203 |
// |
|
204 |
void CCamNewFileService::AbortL() |
|
205 |
{ |
|
206 |
PRINT( _L("Camcorder => CCamNewFileService::AbortL()") ); |
|
207 |
if( !iCompleted ) |
|
208 |
{ |
|
209 |
iCompleted = ETrue; |
|
210 |
iObserver->HandleCompletedNewServiceL( EFalse ); |
|
211 |
} |
|
212 |
PRINT( _L("Camcorder <= CCamNewFileService::AbortL()") ); |
|
213 |
} |
|
214 |
||
215 |
// End of File |