1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 // System includes |
|
23 #include <eikenv.h> |
|
24 #include <pathinfo.h> |
|
25 #include <eikappui.h> |
|
26 #include <bautils.h> |
|
27 #include <e32math.h> |
|
28 #include <vedcommon.h> |
|
29 |
|
30 // User includes |
|
31 #include "VeiTempMaker.h" |
|
32 #include "VideoEditorCommon.h" |
|
33 #include "VeiSettings.h" |
|
34 #include "VideoEditorDebugUtils.h" |
|
35 |
|
36 |
|
37 EXPORT_C CVeiTempMaker* CVeiTempMaker::NewL() |
|
38 { |
|
39 CVeiTempMaker* self = NewLC(); |
|
40 CleanupStack::Pop(self); |
|
41 return self; |
|
42 } |
|
43 |
|
44 |
|
45 EXPORT_C CVeiTempMaker* CVeiTempMaker::NewLC() |
|
46 { |
|
47 CVeiTempMaker* self = new (ELeave) CVeiTempMaker(); |
|
48 CleanupStack::PushL(self); |
|
49 self->ConstructL(); |
|
50 return self; |
|
51 } |
|
52 |
|
53 void CVeiTempMaker::ConstructL() |
|
54 { |
|
55 } |
|
56 |
|
57 CVeiTempMaker::CVeiTempMaker() |
|
58 { |
|
59 } |
|
60 |
|
61 |
|
62 EXPORT_C CVeiTempMaker::~CVeiTempMaker() |
|
63 { |
|
64 } |
|
65 |
|
66 EXPORT_C void CVeiTempMaker::EmptyTempFolder() const |
|
67 { |
|
68 LOG(KVideoEditorLogFile, "CVeiTempMaker::EmptyTempFolder(): In"); |
|
69 |
|
70 TRAP_IGNORE( DoEmptyTempFolderL() ); |
|
71 |
|
72 LOG(KVideoEditorLogFile, "CVeiTempMaker::EmptyTempFolder(): Out"); |
|
73 } |
|
74 |
|
75 void CVeiTempMaker::DoEmptyTempFolderL() const |
|
76 { |
|
77 LOG(KVideoEditorLogFile, "CVeiTempMaker::DoEmptyTempFolderL(): In"); |
|
78 |
|
79 RFs& fs = CCoeEnv::Static()->FsSession(); |
|
80 |
|
81 CFileMan* fileManager = CFileMan::NewL( fs ); |
|
82 CleanupStack::PushL( fileManager ); |
|
83 |
|
84 TFileName tempDir; |
|
85 // First try to delete from Phone Memory |
|
86 TBool dirExists = GetTempPath( CAknMemorySelectionDialog::EPhoneMemory, tempDir ); |
|
87 if ( dirExists ) |
|
88 { |
|
89 LOGFMT(KVideoEditorLogFile, "\tFolder \"%S\" exists...Deleting...", &tempDir); |
|
90 fileManager->RmDir( tempDir ); |
|
91 } |
|
92 // ..then from MMC |
|
93 dirExists = GetTempPath( CAknMemorySelectionDialog::EMemoryCard, tempDir ); |
|
94 if ( dirExists ) |
|
95 { |
|
96 LOGFMT(KVideoEditorLogFile, "\tFolder \"%S\" exists...Deleting...", &tempDir); |
|
97 fileManager->RmDir( tempDir ); |
|
98 } |
|
99 |
|
100 CleanupStack::PopAndDestroy( fileManager ); |
|
101 |
|
102 LOG(KVideoEditorLogFile, "CVeiTempMaker::DoEmptyTempFolderL(): Out"); |
|
103 } |
|
104 |
|
105 EXPORT_C void CVeiTempMaker::GenerateTempFileName( |
|
106 HBufC& aTempPathAndName, |
|
107 CAknMemorySelectionDialog::TMemory aMemory, |
|
108 TVedVideoFormat aVideoFormat, |
|
109 TBool aExtAMR ) const |
|
110 { |
|
111 LOG(KVideoEditorLogFile, "CVeiTempMaker::GenerateTempFileName(): In"); |
|
112 |
|
113 RFs& fs = CCoeEnv::Static()->FsSession(); |
|
114 |
|
115 |
|
116 // Parse tempPath. MMC or memoryroot |
|
117 TFileName tempPath; |
|
118 RFile temp; |
|
119 // Temp files are processed to \\data\\videos\\[application uid]\\[random name] |
|
120 TBool tempFolderExists = GetTempPath( aMemory, tempPath ); |
|
121 if ( !tempFolderExists ) |
|
122 { |
|
123 fs.MkDirAll( tempPath ); |
|
124 fs.SetAtt( tempPath, KEntryAttHidden, KEntryAttDir ); |
|
125 } |
|
126 |
|
127 TUint32 randomName; |
|
128 |
|
129 randomName = Math::Random(); |
|
130 tempPath.AppendNum( randomName, EHex ); |
|
131 |
|
132 if ( aExtAMR ) |
|
133 { |
|
134 tempPath.Append( KExtAmr ); |
|
135 } |
|
136 else if ( aVideoFormat == EVedVideoFormatMP4 ) |
|
137 { |
|
138 tempPath.Append( KExtMp4 ); |
|
139 } |
|
140 else |
|
141 { |
|
142 tempPath.Append( KExt3gp ); |
|
143 } |
|
144 |
|
145 temp.Create( fs, tempPath, EFileWrite ); |
|
146 temp.Close(); |
|
147 |
|
148 aTempPathAndName = tempPath; |
|
149 |
|
150 LOGFMT(KVideoEditorLogFile, "CVeiTempMaker::GenerateTempFileName(): Out: %S", &tempPath); |
|
151 } |
|
152 |
|
153 TBool CVeiTempMaker::GetTempPath( const CAknMemorySelectionDialog::TMemory& aMemory, TDes& aTempPath ) const |
|
154 { |
|
155 LOG(KVideoEditorLogFile, "CVeiTempMaker::GetTempPath: In"); |
|
156 |
|
157 if ( aMemory == CAknMemorySelectionDialog::EPhoneMemory ) |
|
158 { |
|
159 aTempPath = PathInfo::PhoneMemoryRootPath(); |
|
160 } |
|
161 else |
|
162 { |
|
163 aTempPath = PathInfo::MemoryCardRootPath(); |
|
164 } |
|
165 |
|
166 aTempPath.Append( PathInfo::VideosPath() ); |
|
167 aTempPath.AppendNum( KUidVideoEditor.iUid, EHex ); |
|
168 aTempPath.Append(_L("\\")); |
|
169 |
|
170 LOGFMT(KVideoEditorLogFile, "CVeiTempMaker::GetTempPath: Out: %S", &aTempPath); |
|
171 |
|
172 return BaflUtils::FolderExists( CCoeEnv::Static()->FsSession(), aTempPath ); |
|
173 } |
|
174 |
|
175 /*void CVeiTempMaker::ListFilesL(const TDesC& aFindFromDir, const TDesC& aWriteResultTo) const |
|
176 { |
|
177 LOGFMT(KVideoEditorLogFile, "CVeiTempMaker::ListFiles(): In, aFindFromDir:%S", &aFindFromDir); |
|
178 CDir* dir = NULL; |
|
179 //RFile file; |
|
180 RFs fileSession; |
|
181 |
|
182 TInt err = fileSession.Connect(); |
|
183 |
|
184 // err = file.Replace(fileSession, aWriteResultTo, EFileWrite); |
|
185 |
|
186 |
|
187 CleanupClosePushL(fileSession); |
|
188 //CleanupClosePushL(file); |
|
189 |
|
190 //_LIT8(KNewLine, "\r\n"); |
|
191 //TBuf8<255> buf8; |
|
192 TBuf<KMaxFileName> buf; |
|
193 TFileName fileName; |
|
194 fileName.Append(aFindFromDir); |
|
195 |
|
196 fileSession.GetDir(fileName, KEntryAttNormal, ESortNone, dir); |
|
197 LOG(KVideoEditorLogFile, "CVeiTempMaker::ListFiles(): 2"); |
|
198 if (dir) |
|
199 { |
|
200 CleanupStack::PushL(dir); |
|
201 |
|
202 |
|
203 for(TInt index=0; index < dir->Count(); index++) |
|
204 { |
|
205 LOG(KVideoEditorLogFile, "CVeiTempMaker::ListFiles(): 3 in loop"); |
|
206 |
|
207 //buf8.Copy((*dir)[index].iName); |
|
208 //buf.Copy((*dir)[index].iName); |
|
209 |
|
210 LOG(KVideoEditorLogFile, "CVeiTempMaker::ListFiles(): 4 in loop"); |
|
211 |
|
212 LOGFMT(KVideoEditorLogFile, "%S", &((*dir)[index].iName)); |
|
213 //file.Write(buf8); |
|
214 |
|
215 //file.Write(KNewLine); |
|
216 |
|
217 } |
|
218 CleanupStack::PopAndDestroy( dir ); |
|
219 } |
|
220 LOG(KVideoEditorLogFile, "CVeiTempMaker::ListFiles(): 5"); |
|
221 //CleanupStack::PopAndDestroy( file ); |
|
222 CleanupStack::PopAndDestroy( fileSession ); |
|
223 LOG(KVideoEditorLogFile, "CVeiTempMaker::ListFiles(): Out"); |
|
224 }*/ |
|
225 |
|
226 // End of File |
|