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: Active object that checks if files have been deleted outside camera |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CamFileCheckAo.h" |
|
21 #include "camlogging.h" |
|
22 |
|
23 // ============================ MEMBER FUNCTIONS =============================== |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // CCamFileCheckAo::CCamFileCheckAo |
|
27 // C++ constructor |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CCamFileCheckAo::CCamFileCheckAo( CCamAppController& aController, MCamFileCheckObserver& aObserver ) |
|
31 :CActive( EPriorityStandard ), iController( aController ), iObserver( aObserver ) |
|
32 { |
|
33 } |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CCamFileCheckAo::~CCamFileCheckAo |
|
37 // Destructor |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CCamFileCheckAo::~CCamFileCheckAo() |
|
41 { |
|
42 PRINT( _L("Camera => CCamFileCheckAo::~CCamFileCheckAo()") ); |
|
43 Cancel(); |
|
44 PRINT( _L("Camera <= CCamFileCheckAo::~CCamFileCheckAo()") ); |
|
45 } |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CCamFileCheckAo::NewL |
|
50 // Two-phased constructor. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CCamFileCheckAo* CCamFileCheckAo::NewL( CCamAppController& aController, MCamFileCheckObserver& aObserver ) |
|
54 { |
|
55 CCamFileCheckAo* self = new( ELeave ) CCamFileCheckAo( aController, aObserver ); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 CleanupStack::Pop( self ); |
|
59 |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CCamFileCheckAo::ConstructL |
|
65 // 2nd phase construction |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CCamFileCheckAo::ConstructL() |
|
69 { |
|
70 CActiveScheduler::Add( this ); |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CCamFileCheckAo::DoCancel |
|
75 // Cancels the active object |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void CCamFileCheckAo::DoCancel() |
|
79 { |
|
80 PRINT( _L("Camera => CCamFileCheckAo::DoCancel()") ); |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CCamFileCheckAo::RunL |
|
85 // Check existance of next file in burstcapturearray. |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void CCamFileCheckAo::RunL() |
|
89 { |
|
90 PRINT1( _L("Camera => CCamFileCheckAo::RunL() findex=%d"), iFileIndex ) |
|
91 |
|
92 //Check to prevent crash. Some items from array might have been deleted |
|
93 //before this object have been activated...Or by different thread, active object and so on... |
|
94 if ( iFileIndex < iArray->Count() && iFileIndex >= 0 ) |
|
95 { |
|
96 if ( !BaflUtils::FileExists( iFs, iArray->FileName( iFileIndex ) ) |
|
97 && iArray->FileName( iFileIndex ) != KNullDesC ) |
|
98 { |
|
99 PRINT1( _L("Camera <> CCamFileCheckAo::RunL: File %s didn't exist"),iArray->FileName( iFileIndex ).Ptr() ) |
|
100 iArray->SetDeleted( iFileIndex, ETrue ); |
|
101 iFileCount--; |
|
102 |
|
103 // Avoid instant view switch from postcapture |
|
104 // to precapture when the file was deleted |
|
105 // in Photos or File Manager while camera |
|
106 // postcapture view was in background. |
|
107 User::After( 150000 ); |
|
108 } |
|
109 } |
|
110 else |
|
111 { |
|
112 PRINT( _L("Camera <> CCamFileCheckAo::RunL emptyrun") ) |
|
113 iFileIndex = iArray->Count(); |
|
114 iFileCount = iFileIndex; |
|
115 iEmptyRun=ETrue; |
|
116 } |
|
117 |
|
118 if( iFileIndex > 0 && iFileCount > 0 ) |
|
119 { |
|
120 if( iEmptyRun ) |
|
121 { |
|
122 if( iFileIndex > iFileCount) |
|
123 { |
|
124 iFileIndex = iFileCount; |
|
125 } |
|
126 else |
|
127 { |
|
128 iFileIndex--; |
|
129 } |
|
130 } |
|
131 else |
|
132 { |
|
133 iFileIndex--; |
|
134 } |
|
135 PRINT( _L("Camera <> CCamFileCheckAo::RunL: Set active again.") ) |
|
136 StartRequest(); |
|
137 } |
|
138 else |
|
139 { |
|
140 //File check is complete. Don't set active anymore. |
|
141 //Inform observer about result. |
|
142 TRAPD( err, iObserver.FileCheckingCompleteL( iFileCount, KErrNone ) ); |
|
143 if( err != KErrNone ) |
|
144 { |
|
145 User::Leave( err ); |
|
146 } |
|
147 } |
|
148 } |
|
149 |
|
150 |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CCamFileCheckAo::Start |
|
154 // Initializes starting index and set active.. |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void CCamFileCheckAo::Start() |
|
158 { |
|
159 PRINT( _L("Camera => CCamFileCheckAo::Start()") ); |
|
160 iArray = iController.BurstCaptureArray(); |
|
161 iFileCount = iArray->Count(); |
|
162 iFileIndex = iFileCount; |
|
163 iFs = CEikonEnv::Static()->FsSession(); |
|
164 |
|
165 StartRequest(); |
|
166 PRINT( _L("Camera <= CCamFileCheckAo::Start()") ); |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CCamFileCheckAo::StartRequest |
|
171 // Set active and starts new request immediately |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 void CCamFileCheckAo::StartRequest() |
|
175 { |
|
176 iEmptyRun = EFalse; |
|
177 SetActive(); |
|
178 TRequestStatus* statusPtr = &iStatus; |
|
179 User::RequestComplete( statusPtr, KErrNone ); |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CCamFileCheckAo::RunError |
|
184 // Called when an error has occurred. |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 TInt CCamFileCheckAo::RunError( TInt aError ) |
|
188 { |
|
189 PRINT( _L("Camera => CCamFileCheckAo::RunError()") ); |
|
190 |
|
191 TRAP_IGNORE( iObserver.FileCheckingCompleteL( 0, aError ) ) |
|
192 PRINT( _L("Camera <= CCamFileCheckAo::RunError()") ); |
|
193 return KErrNone; |
|
194 } |
|
195 |
|
196 // End of File |
|