|
1 /* |
|
2 * Copyright (c) 2008-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: |
|
13 * |
|
14 * Description: CGlxImageViewerManager implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "glximageviewermanager.h" |
|
20 |
|
21 #include <glxtracer.h> |
|
22 |
|
23 #include <f32file.h> |
|
24 |
|
25 CGlxImageViewerManager* singleInstance = NULL; /// The singleton instance |
|
26 |
|
27 EXPORT_C CGlxImageViewerManager* CGlxImageViewerManager::InstanceL() |
|
28 { |
|
29 TRACER("CGlxImageViewerManager::InstanceL()"); |
|
30 if ( NULL != singleInstance ) |
|
31 { |
|
32 singleInstance->IncrementRefCount(); |
|
33 } |
|
34 else |
|
35 { |
|
36 singleInstance = CGlxImageViewerManager::NewLC(); |
|
37 CleanupStack::Pop( singleInstance ); |
|
38 } |
|
39 |
|
40 return singleInstance; |
|
41 } |
|
42 |
|
43 EXPORT_C void CGlxImageViewerManager::DeleteInstance() |
|
44 { |
|
45 TRACER("CGlxImageViewerManager::DeleteInstance()"); |
|
46 iRefCount--; |
|
47 |
|
48 if (0 == iRefCount) |
|
49 { |
|
50 delete this; |
|
51 } |
|
52 } |
|
53 |
|
54 CGlxImageViewerManager::CGlxImageViewerManager() |
|
55 : iRefCount(0), iImageUri(NULL), iFile(NULL), iIsPrivate(EFalse) |
|
56 { |
|
57 TRACER("CGlxImageViewerManager::CGlxImageViewerManager()"); |
|
58 // No implementation required |
|
59 } |
|
60 |
|
61 CGlxImageViewerManager::~CGlxImageViewerManager() |
|
62 { |
|
63 TRACER("CGlxImageViewerManager::~CGlxImageViewerManager()"); |
|
64 delete iImageUri; |
|
65 |
|
66 if( iFile ) |
|
67 { |
|
68 iFile->Close(); |
|
69 } |
|
70 } |
|
71 |
|
72 CGlxImageViewerManager* CGlxImageViewerManager::NewLC() |
|
73 { |
|
74 TRACER("CGlxImageViewerManager::NewLC()"); |
|
75 CGlxImageViewerManager* self = new (ELeave) CGlxImageViewerManager(); |
|
76 CleanupStack::PushL(self); |
|
77 self->ConstructL(); |
|
78 return self; |
|
79 } |
|
80 |
|
81 CGlxImageViewerManager* CGlxImageViewerManager::NewL() |
|
82 { |
|
83 TRACER("CGlxImageViewerManager::NewLC()"); |
|
84 CGlxImageViewerManager* self = CGlxImageViewerManager::NewLC(); |
|
85 CleanupStack::Pop(); // self; |
|
86 return self; |
|
87 } |
|
88 |
|
89 void CGlxImageViewerManager::ConstructL() |
|
90 { |
|
91 TRACER("CGlxImageViewerManager::ConstructL()"); |
|
92 IncrementRefCount(); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // SetImageUri |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C void CGlxImageViewerManager::SetImageUriL(const TDesC& aFileName) |
|
100 { |
|
101 TRACER("void CGlxImageViewerManager::SetImageUriL()"); |
|
102 if ( iImageUri ) |
|
103 { |
|
104 delete iImageUri; |
|
105 iImageUri = NULL; |
|
106 } |
|
107 iImageUri = aFileName.AllocL(); |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // Reset |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 EXPORT_C void CGlxImageViewerManager::Reset() |
|
115 { |
|
116 TRACER("void CGlxImageViewerManager::Reset()"); |
|
117 if( iFile ) |
|
118 { |
|
119 iFile->Close(); |
|
120 } |
|
121 delete iFile; |
|
122 |
|
123 if ( iImageUri ) |
|
124 { |
|
125 delete iImageUri; |
|
126 iImageUri = NULL; |
|
127 } |
|
128 iIsPrivate = EFalse; |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // SetImageFileHandleL |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 EXPORT_C void CGlxImageViewerManager::SetImageFileHandleL(const RFile& aFileHandle) |
|
136 { |
|
137 TRACER("void CGlxImageViewerManager::SetImageFileHandleL()"); |
|
138 _LIT( KPrivateFolder, "\\Private\\" ); // Platsec private folder |
|
139 TFileName filePath; |
|
140 User::LeaveIfError( aFileHandle.FullName( filePath ) ); |
|
141 SetImageUriL( filePath ); |
|
142 TParsePtrC parse( filePath ); |
|
143 if( parse.PathPresent() && |
|
144 parse.Path().Length() > KPrivateFolder().Length() && |
|
145 parse.Path().Left( KPrivateFolder().Length() ).CompareF( KPrivateFolder ) == 0 ) |
|
146 { |
|
147 // File is in private folder; duplicate file handle |
|
148 iFile = new (ELeave) RFile64; |
|
149 User::LeaveIfError( iFile->Duplicate( aFileHandle ) ); |
|
150 iIsPrivate = ETrue; |
|
151 } |
|
152 } |