|
1 /* |
|
2 * Copyright (c) 2009 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: Juha Kauppinen, Mika Hokkanen |
|
13 * |
|
14 * Description: Photo Browser |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <aknquerydialog.h> |
|
19 #include <avkon.hrh> |
|
20 #include <BAUTILS.H> |
|
21 #include <stringloader.h> |
|
22 #include <aknnotewrappers.h> |
|
23 |
|
24 /*Imagic RSG file for rss file */ |
|
25 #include <PhotoBrowser.rsg> |
|
26 #include "ImagicUtils.h" |
|
27 #include "Imagic.hrh" |
|
28 |
|
29 CImagicUtils* CImagicUtils::NewL(RFs & aFs) |
|
30 { |
|
31 |
|
32 CImagicUtils* self=new (ELeave) CImagicUtils(aFs); |
|
33 CleanupStack::PushL(self); |
|
34 self->ConstructL(); |
|
35 CleanupStack::Pop(); |
|
36 return self; |
|
37 } |
|
38 |
|
39 CImagicUtils::CImagicUtils(RFs& aFs) |
|
40 : iFs(aFs) |
|
41 { |
|
42 |
|
43 } |
|
44 |
|
45 void CImagicUtils::ConstructL() |
|
46 { |
|
47 //no implementation required. |
|
48 } |
|
49 |
|
50 CImagicUtils::~CImagicUtils() |
|
51 { |
|
52 } |
|
53 |
|
54 void CImagicUtils::DisplayYearAndMonth(TInt aIndex, TDateTime dateTime) |
|
55 { |
|
56 if(iPopUpNote) |
|
57 { |
|
58 delete iPopUpNote; |
|
59 } |
|
60 /* if(iTextResource) |
|
61 { |
|
62 //CleanupStack::PopAndDestroy(iTextResource); |
|
63 delete iTextResource; |
|
64 }*/ |
|
65 |
|
66 iPopUpNote = CAknInfoPopupNoteController::NewL(); |
|
67 TMonth month = dateTime.Month(); |
|
68 TInt year = dateTime.Year(); |
|
69 //Convert int to buf |
|
70 TBuf<10> valToNumBuf; |
|
71 valToNumBuf.Num(year); |
|
72 |
|
73 _LIT(KMonth1, "January "); |
|
74 _LIT(KMonth2, "February "); |
|
75 _LIT(KMonth3, "March "); |
|
76 _LIT(KMonth4, "April "); |
|
77 _LIT(KMonth5, "May "); |
|
78 _LIT(KMonth6, "June "); |
|
79 _LIT(KMonth7, "July "); |
|
80 _LIT(KMonth8, "August "); |
|
81 _LIT(KMonth9, "September "); |
|
82 _LIT(KMonth10, "October "); |
|
83 _LIT(KMonth11, "November "); |
|
84 _LIT(KMonth12, "December "); |
|
85 |
|
86 TBuf<512> text; |
|
87 |
|
88 if(month == EJanuary) {text.Format(KMonth1);text.Append(valToNumBuf);} |
|
89 if(month == EFebruary) {text.Format(KMonth2);text.Append(valToNumBuf);} |
|
90 if(month == EMarch) {text.Format(KMonth3);text.Append(valToNumBuf);} |
|
91 if(month == EApril) {text.Format(KMonth4);text.Append(valToNumBuf);} |
|
92 if(month == EMay) {text.Format(KMonth5);text.Append(valToNumBuf);} |
|
93 if(month == EJune) {text.Format(KMonth6);text.Append(valToNumBuf);} |
|
94 if(month == EJuly) {text.Format(KMonth7);text.Append(valToNumBuf);} |
|
95 if(month == EAugust) {text.Format(KMonth8);text.Append(valToNumBuf);} |
|
96 if(month == ESeptember){text.Format(KMonth9);text.Append(valToNumBuf);} |
|
97 if(month == EOctober) {text.Format(KMonth10);text.Append(valToNumBuf);} |
|
98 if(month == ENovember) {text.Format(KMonth11);text.Append(valToNumBuf);} |
|
99 if(month == EDecember) {text.Format(KMonth12);text.Append(valToNumBuf);} |
|
100 |
|
101 iPopUpNote->SetTextL(text); |
|
102 iPopUpNote->SetTimeDelayBeforeShow(0); |
|
103 iPopUpNote->SetTimePopupInView( 4000 ); |
|
104 iPopUpNote->SetPositionAndAlignment(TPoint(0,0), /*TGulAlignmentValue*/EHLeftVTop); |
|
105 iPopUpNote->ShowInfoPopupNote(); |
|
106 } |
|
107 |
|
108 void CImagicUtils::ExecutePopUpNote(TInt aResourceId, TDes& aFilename, TInt aTime) |
|
109 { |
|
110 if(iPopUpNote) |
|
111 { |
|
112 delete iPopUpNote; |
|
113 } |
|
114 if(iTextResource) |
|
115 { |
|
116 //CleanupStack::PopAndDestroy(iTextResource); |
|
117 delete iTextResource; |
|
118 } |
|
119 |
|
120 iPopUpNote = CAknInfoPopupNoteController::NewL(); |
|
121 //iTextResource = StringLoader::LoadLC( aResourceId ); |
|
122 iTextResource = StringLoader::LoadL( aResourceId ); |
|
123 TBuf<512> text; |
|
124 |
|
125 //text.Format(*textResource); |
|
126 TParse parser; |
|
127 parser.Set(aFilename, NULL, NULL); |
|
128 aFilename = parser.NameAndExt(); |
|
129 text.Format(*iTextResource, &aFilename); |
|
130 |
|
131 iPopUpNote->SetTextL(text); |
|
132 iPopUpNote->SetTimeDelayBeforeShow(0); |
|
133 iPopUpNote->SetTimePopupInView( aTime ); |
|
134 iPopUpNote->SetPositionAndAlignment(TPoint(0,0), /*TGulAlignmentValue*/EHLeftVTop); |
|
135 iPopUpNote->ShowInfoPopupNote(); |
|
136 } |
|
137 |
|
138 void CImagicUtils::ExecutePopUpNote(TInt aResourceId, TInt aTime) |
|
139 { |
|
140 if(iPopUpNote) |
|
141 { |
|
142 delete iPopUpNote; |
|
143 } |
|
144 if(iTextResource) |
|
145 { |
|
146 //CleanupStack::PopAndDestroy(iTextResource); |
|
147 delete iTextResource; |
|
148 } |
|
149 |
|
150 iPopUpNote = CAknInfoPopupNoteController::NewL(); |
|
151 //iTextResource = StringLoader::LoadLC( aResourceId ); |
|
152 iTextResource = StringLoader::LoadL( aResourceId ); |
|
153 TBuf<512> text; |
|
154 |
|
155 //text.Format(*textResource); |
|
156 /* TParse parser; |
|
157 parser.Set(aFilename, NULL, NULL); |
|
158 aFilename = parser.NameAndExt();*/ |
|
159 text.Format(*iTextResource); |
|
160 |
|
161 iPopUpNote->SetTextL(text); |
|
162 iPopUpNote->SetTimeDelayBeforeShow(0); |
|
163 iPopUpNote->SetTimePopupInView( aTime ); |
|
164 iPopUpNote->SetPositionAndAlignment(TPoint(0,0), /*TGulAlignmentValue*/EHLeftVTop); |
|
165 iPopUpNote->ShowInfoPopupNote(); |
|
166 } |
|
167 |
|
168 void CImagicUtils::ExecuteFileScanPopUpNote(TInt aResourceId, TInt aTime) |
|
169 { |
|
170 if(iFileScanPopUpNote) |
|
171 { |
|
172 delete iFileScanPopUpNote; |
|
173 } |
|
174 if(iTextResource) |
|
175 { |
|
176 //CleanupStack::PopAndDestroy(iTextResource); |
|
177 delete iTextResource; |
|
178 } |
|
179 |
|
180 iFileScanPopUpNote = CAknInfoPopupNoteController::NewL(); |
|
181 //iTextResource = StringLoader::LoadLC( aResourceId ); |
|
182 iTextResource = StringLoader::LoadL( aResourceId ); |
|
183 TBuf<512> text; |
|
184 |
|
185 //text.Format(*textResource); |
|
186 /* TParse parser; |
|
187 parser.Set(aFilename, NULL, NULL); |
|
188 aFilename = parser.NameAndExt();*/ |
|
189 text.Format(*iTextResource); |
|
190 |
|
191 iFileScanPopUpNote->SetTextL(text); |
|
192 iFileScanPopUpNote->SetTimeDelayBeforeShow(0); |
|
193 iFileScanPopUpNote->SetTimePopupInView( aTime ); |
|
194 iFileScanPopUpNote->SetPositionAndAlignment(TPoint(0,0), /*TGulAlignmentValue*/EHLeftVTop); |
|
195 iFileScanPopUpNote->ShowInfoPopupNote(); |
|
196 } |
|
197 |
|
198 |
|
199 void CImagicUtils::ExecutePopUpNote(TDes& aFilename, TInt aTime, TBool aAligment) |
|
200 { |
|
201 if(iPopUpNote) |
|
202 { |
|
203 delete iPopUpNote; |
|
204 } |
|
205 |
|
206 iPopUpNote = CAknInfoPopupNoteController::NewL(); |
|
207 |
|
208 /*TBuf<512> text; |
|
209 |
|
210 TParse parser; |
|
211 parser.Set(aFilename, NULL, NULL); |
|
212 aFilename = parser.NameAndExt();*/ |
|
213 |
|
214 iPopUpNote->SetTextL(aFilename); |
|
215 iPopUpNote->SetTimeDelayBeforeShow(0); |
|
216 iPopUpNote->SetTimePopupInView(aTime); |
|
217 iPopUpNote->SetPriority(EPriorityHigh); |
|
218 |
|
219 //if(aAligment) |
|
220 iPopUpNote->SetPositionAndAlignment(TPoint(0,0), EHLeftVTop); |
|
221 /*else |
|
222 iPopUpNote->SetPositionAndAlignment(TPoint(0,0), EHRightVCenter);*/ |
|
223 |
|
224 iPopUpNote->ShowInfoPopupNote(); |
|
225 } |
|
226 |
|
227 /* Show text on Display */ |
|
228 void CImagicUtils::ShowText(const TDesC16& aText, CWindowGc& gc, TRect aRect,const CFont*aFont,TRgb aTransparentBlack, TRgb aTransparentWhite) const |
|
229 { |
|
230 //RDebug::Print(_L("CImagicAppUi::ShowText")); |
|
231 |
|
232 gc.SetPenStyle(CGraphicsContext::ESolidPen);//ESolidPen, ENullPen |
|
233 gc.UseFont(aFont); |
|
234 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
235 |
|
236 gc.SetBrushColor(aTransparentWhite); |
|
237 gc.SetPenColor(aTransparentBlack); |
|
238 |
|
239 TRect rectText(TPoint(0, 0), TPoint(aRect.Width(),aFont->HeightInPixels()+3)); |
|
240 gc.DrawText(aText, rectText, rectText.Height() - aFont->DescentInPixels(), CGraphicsContext::ECenter ); |
|
241 |
|
242 } |
|
243 |
|
244 /* Executing Error Dialog */ |
|
245 void CImagicUtils::ExecuteQueryDialog(TInt /*aError*/,TInt aResourceId) |
|
246 { |
|
247 //if (aError != KErrNone) |
|
248 { |
|
249 CAknQueryDialog* dlg; |
|
250 dlg = new ( ELeave ) CAknQueryDialog(); |
|
251 TInt result = dlg->ExecuteLD( aResourceId ); |
|
252 if(result == KErrNone || result != KErrNone) |
|
253 User::Exit(-1); |
|
254 } |
|
255 } |
|
256 |
|
257 TInt CImagicUtils::ExecuteQueryDialog(TInt aResourceId) |
|
258 { |
|
259 CAknQueryDialog* dlg; |
|
260 dlg = new ( ELeave ) CAknQueryDialog(); |
|
261 TInt result = dlg->ExecuteLD( aResourceId ); |
|
262 return result; |
|
263 } |
|
264 |
|
265 void CImagicUtils::DisplayWaitDialog(TInt aResourceId, TBool aSingular) |
|
266 { |
|
267 //show wait dialog untill engine callback cancells it |
|
268 if(iWaitDialog) |
|
269 { |
|
270 delete iWaitDialog; |
|
271 } |
|
272 iWaitDialog = NULL; |
|
273 iWaitDialog = new(ELeave) CAknWaitDialog(NULL, ETrue); |
|
274 |
|
275 iWaitDialog->SetTextPluralityL(aSingular); |
|
276 iWaitDialog->ExecuteLD( aResourceId ); |
|
277 |
|
278 } |
|
279 |
|
280 void CImagicUtils::ProcessFinishedL() |
|
281 { |
|
282 //iWaitDialog->ProcessFinishedL(); |
|
283 //iWaitDialog = NULL; |
|
284 CancelWaitDialog(); |
|
285 } |
|
286 |
|
287 void CImagicUtils::CancelWaitDialog() |
|
288 { |
|
289 if(iWaitDialog != NULL) |
|
290 { |
|
291 iWaitDialog->ProcessFinishedL(); |
|
292 iWaitDialog = NULL; |
|
293 } |
|
294 } |
|
295 |
|
296 void CImagicUtils::ShowWaitDialog( TInt aResourceId ) |
|
297 { |
|
298 TInt result = 0; |
|
299 //show wait dialog untill engine callback cancells it |
|
300 if(iWaitDialog) |
|
301 { |
|
302 delete iWaitDialog; |
|
303 } |
|
304 iWaitDialog = NULL; |
|
305 iWaitDialog = new(ELeave) CAknWaitDialog(NULL, ETrue); |
|
306 iWaitDialog->ExecuteLD( aResourceId ); |
|
307 |
|
308 |
|
309 } |
|
310 void CImagicUtils::DisplayTNInfoNoteStarted() |
|
311 { |
|
312 ExecuteInternalWaitNote(R_WAIT_NOTE, EFalse); |
|
313 } |
|
314 |
|
315 void CImagicUtils::DisplayTNInfoNoteCompleted() |
|
316 { |
|
317 ExecuteInternalWaitNote(R_WAIT_NOTE_END, EFalse); |
|
318 } |
|
319 |
|
320 void CImagicUtils::ShowInfoNote(TInt aResourceId) |
|
321 { |
|
322 HBufC* textResource = StringLoader::LoadLC( aResourceId ); |
|
323 CAknInformationNote* note = new ( ELeave ) CAknInformationNote(ETrue); |
|
324 TBuf<512> text; |
|
325 text.Format(*textResource); |
|
326 note->ExecuteLD( text ); |
|
327 CleanupStack::PopAndDestroy(textResource); |
|
328 } |
|
329 |
|
330 void CImagicUtils::ShowInfoNote(TInt aResourceId, TDes& aFilename) |
|
331 { |
|
332 HBufC* textResource = StringLoader::LoadLC( aResourceId ); |
|
333 CAknInformationNote* note = new ( ELeave ) CAknInformationNote(ETrue); |
|
334 TBuf<256+50> text; |
|
335 |
|
336 TParse parser; |
|
337 parser.Set(aFilename, NULL, NULL); |
|
338 aFilename = parser.NameAndExt(); |
|
339 |
|
340 text.Format(*textResource, &aFilename); |
|
341 note->ExecuteLD( text ); |
|
342 |
|
343 CleanupStack::PopAndDestroy(textResource); |
|
344 } |
|
345 |
|
346 //Modifies given file name to new with adding counting |
|
347 //number to the end of the file name |
|
348 void CImagicUtils::GetNewFileName( TDes& aFileName ) |
|
349 { |
|
350 TBuf<300> valToNumBuf; |
|
351 TInt tempCounter = 0; |
|
352 TParse parser; |
|
353 TFileName tmpName; |
|
354 TBool result = EFalse; |
|
355 |
|
356 while(1) |
|
357 { |
|
358 tempCounter++; |
|
359 |
|
360 /*Converting from Number to Buffer */ |
|
361 valToNumBuf.Num(tempCounter); |
|
362 |
|
363 /*Parsing file name. */ |
|
364 parser.Set(aFileName, NULL, NULL ); |
|
365 tmpName = parser.DriveAndPath(); |
|
366 tmpName.Append(parser.Name()); |
|
367 |
|
368 /*Appending */ |
|
369 tmpName.Append(_L("_")); |
|
370 tmpName.Append(valToNumBuf); |
|
371 tmpName.Append(_L(".jpg")); |
|
372 |
|
373 /*Checking the existing of file */ |
|
374 result = BaflUtils::FileExists(iFs, tmpName); |
|
375 if(result) |
|
376 { |
|
377 /* File exists continue */ |
|
378 continue; |
|
379 } |
|
380 else |
|
381 { |
|
382 /*File does not found then copy the file and comeout of the loop */ |
|
383 aFileName.Copy(tmpName); |
|
384 break; |
|
385 } |
|
386 |
|
387 } |
|
388 } |
|
389 |
|
390 |
|
391 void CImagicUtils::GetOriginalFileName( TDes& aFileName ) |
|
392 { |
|
393 |
|
394 TParse parser; |
|
395 parser.Set(aFileName, NULL, NULL ); |
|
396 TFileName tmpFileName = parser.Name(); |
|
397 //tmpName.Append(_L("_01.jpg")); |
|
398 |
|
399 |
|
400 TFileName tmpPathName = parser.FullName(); |
|
401 //Delete characters from TN folder after _PAlbTN folder |
|
402 TInt ret = tmpPathName.Find(_L("_PAlbTN\\")); |
|
403 tmpPathName.Delete(ret, tmpPathName.Length()-ret); |
|
404 |
|
405 aFileName = tmpPathName; |
|
406 aFileName.Append(tmpFileName); |
|
407 aFileName.Append(_L(".jpg")); |
|
408 } |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 void CImagicUtils::ExecuteInternalWaitNote(TInt aResourceId,TBool aTextPlurality) |
|
414 { |
|
415 CAknNoteDialog* dlg = new ( ELeave ) CAknNoteDialog(CAknNoteDialog::ENoTone,CAknNoteDialog::ELongTimeout); |
|
416 dlg->PrepareLC( aResourceId ); |
|
417 dlg->SetTextPluralityL(aTextPlurality); |
|
418 |
|
419 // Show the Dialog |
|
420 dlg->RunLD(); |
|
421 } |