|
1 /* |
|
2 * Copyright (c) 2005-2008 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: Provides blid document class methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <sysutil.h> |
|
21 #include <f32file.h> |
|
22 #include <pathinfo.h> |
|
23 #include <driveinfo.h> |
|
24 |
|
25 #include "CBlidDocument.h" |
|
26 #include "CBlidAppUi.h" |
|
27 #include "CBlidEng.h" |
|
28 #include "bliduiconsts.h" |
|
29 |
|
30 // constants |
|
31 const TInt KBytesToWrite = 2*sizeof(TInt); |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 // ---------------------------------------------------------------------------- |
|
35 // CBlidDocument::CBlidDocument |
|
36 // First phase constructor, may not leave |
|
37 // ---------------------------------------------------------------------------- |
|
38 // |
|
39 CBlidDocument::CBlidDocument(CEikApplication& aApp) |
|
40 : CAknDocument(aApp) |
|
41 { |
|
42 } |
|
43 |
|
44 // ---------------------------------------------------------------------------- |
|
45 // CBlidDocument::~CBlidDocument |
|
46 // Destructor, frees allocated resources |
|
47 // ---------------------------------------------------------------------------- |
|
48 // |
|
49 CBlidDocument::~CBlidDocument() |
|
50 { |
|
51 delete iEngine; |
|
52 } |
|
53 |
|
54 // ---------------------------------------------------------------------------- |
|
55 // CBlidDocument::ConstructL |
|
56 // Symbian 2nd phase constructor can leave. |
|
57 // ---------------------------------------------------------------------------- |
|
58 // |
|
59 void CBlidDocument::ConstructL() |
|
60 { |
|
61 CreateEngineL(); |
|
62 } |
|
63 |
|
64 // ---------------------------------------------------------------------------- |
|
65 // CBlidDocument::NewL |
|
66 // Two-phased constructor. |
|
67 // ---------------------------------------------------------------------------- |
|
68 // |
|
69 CBlidDocument* CBlidDocument::NewL( |
|
70 CEikApplication& aApp) // CLocApp reference |
|
71 { |
|
72 CBlidDocument* self = new (ELeave) CBlidDocument( aApp ); |
|
73 CleanupStack::PushL( self ); |
|
74 self->ConstructL(); |
|
75 CleanupStack::Pop( self ); |
|
76 return self; |
|
77 } |
|
78 |
|
79 // ---------------------------------------------------- |
|
80 // CBlidDocument::CreateAppUiL |
|
81 // constructs CBlidAppUi |
|
82 // ---------------------------------------------------- |
|
83 // |
|
84 CEikAppUi* CBlidDocument::CreateAppUiL() |
|
85 { |
|
86 return new (ELeave) CBlidAppUi; |
|
87 } |
|
88 |
|
89 // ---------------------------------------------------------------------------- |
|
90 // CBlidDocument::CreateEngineL |
|
91 // Create instance of CBlidEng |
|
92 // ---------------------------------------------------------------------------- |
|
93 // |
|
94 void CBlidDocument::CreateEngineL() |
|
95 { |
|
96 iEngine = CBlidEng::NewL(); |
|
97 } |
|
98 |
|
99 // ---------------------------------------------------------------------------- |
|
100 // CBlidDocument::Engine |
|
101 // Returns the CBlidEng instance |
|
102 // ---------------------------------------------------------------------------- |
|
103 // |
|
104 CBlidEng* CBlidDocument::Engine() |
|
105 { |
|
106 return iEngine; |
|
107 } |
|
108 |
|
109 // ---------------------------------------------------------------------------- |
|
110 // CBlidDocument::StoreL |
|
111 // Stores the app's document |
|
112 // ---------------------------------------------------------------------------- |
|
113 // |
|
114 void CBlidDocument::StoreL( CStreamStore& aStore, |
|
115 CStreamDictionary& aStreamDic ) const |
|
116 { |
|
117 TStreamId id = iEngine->StoreL( aStore, *EditStore() ); |
|
118 aStreamDic.AssignL( KBlidUI, id ); |
|
119 } |
|
120 |
|
121 // ---------------------------------------------------------------------------- |
|
122 // CBlidDocument::RestoreL |
|
123 // Restore the app's document |
|
124 // ---------------------------------------------------------------------------- |
|
125 // |
|
126 void CBlidDocument::RestoreL( const CStreamStore& aStore, |
|
127 const CStreamDictionary& aStreamDic ) |
|
128 { |
|
129 TStreamId streamId = aStreamDic.At( KBlidUI ); |
|
130 iEngine->RestoreL( aStore, streamId ); |
|
131 SetChanged( EFalse ); |
|
132 } |
|
133 |
|
134 // ---------------------------------------------------------------------------- |
|
135 // CBlidDocument::OpenFileL |
|
136 // Restores the document's state from the specified file |
|
137 // ---------------------------------------------------------------------------- |
|
138 // |
|
139 CFileStore* CBlidDocument::OpenFileL(TBool aDoOpen, |
|
140 const TDesC& aFileName, |
|
141 RFs& aFs) |
|
142 { |
|
143 // changes done for multiple drive support |
|
144 TChar colon = ':'; |
|
145 TFileName wpFileName; |
|
146 wpFileName.Append(PathInfo::PhoneMemoryRootPath()[0]); |
|
147 wpFileName.Append(colon); |
|
148 wpFileName.Append(aFileName); |
|
149 |
|
150 if(!aDoOpen ) |
|
151 { |
|
152 if ( SysUtil::DiskSpaceBelowCriticalLevelL( &aFs, KBytesToWrite, DriveInfo::EDefaultPhoneMemory ) ) |
|
153 { |
|
154 User::Leave(KErrNoMemory); |
|
155 } |
|
156 } |
|
157 return CEikDocument::OpenFileL( aDoOpen, wpFileName, aFs ); |
|
158 } |
|
159 |
|
160 // End of File |