1 /* |
|
2 * Copyright (c) 2006 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: Stores a single slide |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDES |
|
23 #include "SlideshowSlide.h" |
|
24 #include "SlideshowSlideLoader.h" |
|
25 #include "SlideshowPluginUtils.h" |
|
26 |
|
27 // Creator |
|
28 CSlideshowSlide* CSlideshowSlide::NewL(TDesC& aFileName, TBool aIsOnMC) |
|
29 { |
|
30 CSlideshowSlide* self = new (ELeave) CSlideshowSlide(aIsOnMC); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(aFileName); |
|
33 CleanupStack::Pop(self); |
|
34 return self; |
|
35 } |
|
36 |
|
37 // Destructor |
|
38 CSlideshowSlide::~CSlideshowSlide() |
|
39 { |
|
40 ReleaseImage(); |
|
41 delete iSlideLoader; |
|
42 delete iFileName; |
|
43 } |
|
44 |
|
45 |
|
46 // Default C'tor |
|
47 CSlideshowSlide::CSlideshowSlide(TBool aIsOnMC) |
|
48 : iFlags(SSS_NONE) |
|
49 { |
|
50 if (aIsOnMC) |
|
51 { |
|
52 iFlags |= SSS_ISONMC; |
|
53 } |
|
54 } |
|
55 |
|
56 // is decoding in progress |
|
57 TBool CSlideshowSlide::IsDecodingInProgress() |
|
58 { |
|
59 if(iSlideLoader->IsActive()) |
|
60 { |
|
61 return ETrue; |
|
62 } |
|
63 return EFalse; |
|
64 } |
|
65 // Could not decode the file |
|
66 TBool CSlideshowSlide::CouldNotDecodeFile() |
|
67 { |
|
68 if (iFlags & SSS_DECODEFAILED) |
|
69 { |
|
70 return ETrue; |
|
71 } |
|
72 return EFalse; |
|
73 } |
|
74 // Two-phase constructor |
|
75 void CSlideshowSlide::ConstructL(TDesC& aFileName) |
|
76 { |
|
77 // Allocate space for the filename and save it |
|
78 iFileName = HBufC::NewL(aFileName.Length()); |
|
79 *iFileName = aFileName; |
|
80 iSlideLoader = CSlideshowSlideLoader::NewL(this); |
|
81 } |
|
82 // Prepares the slide (loads image) |
|
83 void CSlideshowSlide::PrepareSlideL(const TSize& aTargetSize) |
|
84 { |
|
85 if (iFlags & SSS_IMAGELOADED) |
|
86 { |
|
87 return; |
|
88 } |
|
89 if( iSlideLoader->IsActive()) |
|
90 { |
|
91 // slide is being decoded ... should wait .. dont call LoadSlideL here |
|
92 // should not come here.. |
|
93 return; |
|
94 } |
|
95 iSlideLoader->LoadSlideL(*iFileName, aTargetSize); |
|
96 } |
|
97 |
|
98 // Is slide decoded completely |
|
99 TBool CSlideshowSlide::IsSlideDecoded() |
|
100 { |
|
101 if (iFlags & SSS_IMAGELOADED) |
|
102 { |
|
103 return ETrue; |
|
104 } |
|
105 return EFalse; |
|
106 } |
|
107 // Releases the slide's image |
|
108 void CSlideshowSlide::ReleaseImage() |
|
109 { |
|
110 // if decoding is in progress... at any cost dont delete the image before Canceling the decoding |
|
111 if(IsDecodingInProgress()) |
|
112 { |
|
113 iSlideLoader->Cancel(); |
|
114 } |
|
115 else if(iImage ) |
|
116 { |
|
117 delete iImage; |
|
118 iImage = NULL; |
|
119 } |
|
120 //image deleted, revert back to not decoded state |
|
121 iFlags &= ~(SSS_IMAGELOADED); |
|
122 } |
|
123 // End of File |
|