|
1 /* |
|
2 * Copyright (c) 2004,2005 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: Document for SVGT Viewer |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <avkon.hrh> |
|
19 #include <aknnotewrappers.h> |
|
20 #include <AiwGenericParam.h> |
|
21 #include <AiwGenericParam.hrh> |
|
22 |
|
23 #include "SVGTViewerAppAppUi.h" |
|
24 #include "SVGTViewerAppDocument.h" |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CSVGTViewerAppDocument::CSVGTViewerAppDocument |
|
30 // Default Constructor for CSVGTViewerAppDocument. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CSVGTViewerAppDocument::CSVGTViewerAppDocument( |
|
34 CEikApplication& aApp ) : // Reference to application object |
|
35 CAiwGenericParamConsumer( aApp ), |
|
36 iIsFileHandleValid( EFalse ) |
|
37 { |
|
38 // No implementation required |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CSVGTViewerAppDocument::ConstructL |
|
43 // Second Phase constructor for CSVGTViewerAppDocument. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 void CSVGTViewerAppDocument::ConstructL() |
|
47 { |
|
48 iIsFileFullPathValid = EFalse; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CSVGTViewerAppDocument::NewL |
|
53 // Factory function for creation of CSVGTViewerAppDocument. |
|
54 // Returns: CSVGTViewerAppDocument* ; Pointer to created object |
|
55 // Leaves if error occurs during creation. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CSVGTViewerAppDocument* CSVGTViewerAppDocument::NewL( |
|
59 CEikApplication& aApp ) // Reference to application object |
|
60 { |
|
61 CSVGTViewerAppDocument* self = NewLC( aApp ); |
|
62 CleanupStack::Pop( self ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CSVGTViewerAppDocument::NewL |
|
68 // Factory function for creation of CSVGTViewerAppDocument. Also pushes the |
|
69 // object on the cleanup stack. |
|
70 // Returns: CSVGTViewerAppDocument* ; Pointer to created object |
|
71 // Leaves if error occurs during creation. |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CSVGTViewerAppDocument* CSVGTViewerAppDocument::NewLC( |
|
75 CEikApplication& aApp ) // Reference to application object |
|
76 { |
|
77 CSVGTViewerAppDocument* self = new ( ELeave ) |
|
78 CSVGTViewerAppDocument( aApp ); |
|
79 CleanupStack::PushL( self ); |
|
80 self->ConstructL(); |
|
81 return self; |
|
82 } |
|
83 |
|
84 |
|
85 // Destructor |
|
86 CSVGTViewerAppDocument::~CSVGTViewerAppDocument() |
|
87 { |
|
88 // Close the file handle and session |
|
89 iSvgtContentFileHandle.Close(); |
|
90 delete iFileFullPath; |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CSVGTViewerAppDocument::GetSvgtContentFileHandle |
|
95 // This function is a get function to get the file-handle of the file content. |
|
96 // This is used by AppUI. |
|
97 // Returns: File handle of content by reference . |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 RFile& CSVGTViewerAppDocument::GetSvgtContentFileHandle() |
|
101 { |
|
102 return iSvgtContentFileHandle; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CSVGTViewerAppDocument::IsFileHandleValid() |
|
107 // Used by UI class to check if file's handle is valid |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 TBool CSVGTViewerAppDocument::IsFileHandleValid() const |
|
111 { |
|
112 return iIsFileHandleValid; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CSVGTViewerAppDocument::IsFileFullPathAvailable() |
|
117 // Used by UI class to check if file's full-path available. |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 TBool CSVGTViewerAppDocument::IsFileFullPathAvailable() const |
|
121 { |
|
122 return iIsFileFullPathValid; |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CSVGTViewerAppDocument::GetFileFullPath() |
|
127 // Used by UI class to get file's full-path. |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CSVGTViewerAppDocument::GetFileFullPath(TFileName& filename) |
|
131 { |
|
132 if ( iFileFullPath ) |
|
133 { |
|
134 filename = iFileFullPath->Des(); |
|
135 } |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CSVGTViewerAppDocument::GetParentAppUid() |
|
140 // Used by UI class to get parent application's uid. |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 TUid CSVGTViewerAppDocument::GetParentAppUid() const |
|
144 { |
|
145 return iParentUid; |
|
146 } |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CSVGTViewerAppDocument::OpenFileL |
|
149 // Reimplements CAknDocument::OpenFileL inorder to support opening of SVGT |
|
150 // files through doc-handler framework. |
|
151 // Returns: NULL. |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 CFileStore* CSVGTViewerAppDocument::OpenFileL( TBool aDoOpen, // Indicates |
|
155 // Whether doc |
|
156 // is to be |
|
157 // created |
|
158 // or opened. |
|
159 const TDesC& aFilename, // SVGT |
|
160 // Filename |
|
161 RFs& aFs ) // File Srvr |
|
162 // Session |
|
163 { |
|
164 // In this function we store the file-name inside the document. |
|
165 // The opening of the document is performed by AppUI after |
|
166 // initialisation. |
|
167 if ( aDoOpen ) |
|
168 { |
|
169 CSVGTViewerAppAppUi* AppUi = static_cast<CSVGTViewerAppAppUi*>(iAppUi); |
|
170 AppUi->SetAllowMove(0); |
|
171 |
|
172 const CAiwGenericParamList* params = GetInputParameters(); |
|
173 if ( params ) |
|
174 { |
|
175 TInt findIndex; |
|
176 const TAiwGenericParam* param = params->FindFirst(findIndex, |
|
177 EGenericParamAllowMove); |
|
178 |
|
179 if ( param && findIndex != KErrNotFound ) |
|
180 { |
|
181 TInt32 value = 0; |
|
182 param->Value().Get(value); |
|
183 AppUi->SetAllowMove(value); |
|
184 } |
|
185 } |
|
186 |
|
187 // Get Move parameter |
|
188 if ( params && params->Count() ) |
|
189 { |
|
190 TInt index = 0; |
|
191 const TAiwGenericParam* param = NULL; |
|
192 |
|
193 param = params->FindFirst(index, EGenericParamApplication, EVariantTypeTUid); |
|
194 |
|
195 if ( index >= 0 && param ) |
|
196 { |
|
197 param->Value().Get(iParentUid); |
|
198 } |
|
199 } |
|
200 } |
|
201 |
|
202 // Function is called with Full-path. |
|
203 iIsFileFullPathValid = ETrue; |
|
204 // Store the File's fullpath. |
|
205 iFileFullPath = aFilename.AllocL(); |
|
206 |
|
207 // Open File Handle for the file |
|
208 TInt openError = iSvgtContentFileHandle.Open( aFs, aFilename, |
|
209 EFileShareAny ); |
|
210 if ( openError != KErrNone ) |
|
211 { |
|
212 User::Leave( openError ); |
|
213 } |
|
214 iIsFileHandleValid = ETrue; |
|
215 |
|
216 return NULL; |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // CSVGTViewerAppDocument::OpenFileL |
|
221 // Reimplements CAknDocument::OpenFileL inorder to support opening of SVGT |
|
222 // files through doc-handler framework. |
|
223 // Returns: NULL. |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 void CSVGTViewerAppDocument::OpenFileL( |
|
227 CFileStore*& aFileStore, // Pointer to reference of filestore |
|
228 RFile& aFile ) // File handle of content. |
|
229 { |
|
230 // Set the docstore pointer to NULL so that the framework |
|
231 // does not try to open the file by filename |
|
232 aFileStore = NULL; |
|
233 |
|
234 // In this function we store the file-name inside the document. |
|
235 // The opening of the document is performed by AppUI after |
|
236 // initialisation. |
|
237 CSVGTViewerAppAppUi* AppUi = static_cast<CSVGTViewerAppAppUi*>(iAppUi); |
|
238 AppUi->SetAllowMove(0); |
|
239 |
|
240 const CAiwGenericParamList* paramList = GetInputParameters(); |
|
241 if ( paramList ) |
|
242 { |
|
243 TInt findIndex; |
|
244 const TAiwGenericParam* param = paramList->FindFirst(findIndex, |
|
245 EGenericParamAllowMove); |
|
246 |
|
247 if ( param && findIndex != KErrNotFound ) |
|
248 { |
|
249 TInt32 value = 0; |
|
250 param->Value().Get(value); |
|
251 AppUi->SetAllowMove(value); |
|
252 } |
|
253 } |
|
254 |
|
255 |
|
256 if ( paramList && paramList->Count() ) |
|
257 { |
|
258 TInt index = 0; |
|
259 const TAiwGenericParam* param = NULL; |
|
260 param = paramList->FindFirst(index, EGenericParamApplication, EVariantTypeTUid); |
|
261 |
|
262 if ( index >= 0 && param ) |
|
263 { |
|
264 param->Value().Get(iParentUid); |
|
265 } |
|
266 } |
|
267 // Function is not called with Full-path. |
|
268 iIsFileFullPathValid = EFalse; |
|
269 |
|
270 // File-handle is valid |
|
271 iIsFileHandleValid = ETrue; |
|
272 |
|
273 // Make a copy for our use later. |
|
274 iSvgtContentFileHandle.Duplicate( aFile ); |
|
275 |
|
276 // Close the original file handle |
|
277 aFile.Close(); |
|
278 |
|
279 return; |
|
280 } |
|
281 // ----------------------------------------------------------------------------- |
|
282 // CSVGTViewerAppDocument::CreateAppUiL |
|
283 // Called by the framework to create the AppUI. |
|
284 // Returns: CEikAppUi* ; Pointer to the created object. |
|
285 // Leaves if error. |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 CEikAppUi* CSVGTViewerAppDocument::CreateAppUiL() |
|
289 { |
|
290 // Create the application user interface, and return a pointer to it |
|
291 // the framework takes ownership of this object |
|
292 return ( static_cast < CEikAppUi* > |
|
293 ( new ( ELeave ) CSVGTViewerAppAppUi ) ); |
|
294 } |
|
295 |
|
296 // End of File |