|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef MCSSUITEHANDLER_H_ |
|
19 #define MCSSUITEHANDLER_H_ |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <f32file.h> |
|
23 |
|
24 |
|
25 #include "menusvrsuite.h" |
|
26 #include "mcsinstallnotifier.h" |
|
27 #include "menuengoperation.h" |
|
28 #include "mcsmmcobserver.h" |
|
29 #include "mcsfreespaceobserver.h" |
|
30 |
|
31 class CMenuEng; |
|
32 class TMenuItem; |
|
33 |
|
34 /** |
|
35 * Suite Handler. |
|
36 * @lib mcsdrmhandler.lib |
|
37 * @since S60 v5.0 |
|
38 */ |
|
39 NONSHARABLE_CLASS( CMcsSuiteHandler ): |
|
40 public CBase, MMcsInstallListener, MMenuEngOperation, MMcsMmcObserver, |
|
41 MMcsFreeSpaceObserver |
|
42 { |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Two-phased constructor. Leaves on failure. |
|
47 * @return The constructed object. |
|
48 */ |
|
49 static CMcsSuiteHandler* NewL( |
|
50 CMenuEng& aEng, const TDesC& aDirName ); |
|
51 |
|
52 /** |
|
53 * Destructor. |
|
54 * @since S60 v5.0 |
|
55 * @capability None. |
|
56 * @throws None. |
|
57 * @panic None. |
|
58 */ |
|
59 virtual ~CMcsSuiteHandler(); |
|
60 |
|
61 /** |
|
62 * Check if suite of given name is present |
|
63 * in handler. |
|
64 */ |
|
65 TBool HaveSuite(const TDesC& aSuiteName); |
|
66 |
|
67 /** |
|
68 * Get attribute from suite handler. |
|
69 */ |
|
70 void GetAttribute( const TDesC& aSuiteName, const TDesC& aAttrName, |
|
71 TBool& aAttrExists, TDes& aAttrVal ); |
|
72 |
|
73 private: |
|
74 |
|
75 /** |
|
76 * Execute engine operation: |
|
77 * Do the application scan and update menu accordingly. |
|
78 */ |
|
79 void RunMenuEngOperationL(); |
|
80 void CompletedMenuEngOperation( TInt aErr ); |
|
81 /** |
|
82 * Constructor. |
|
83 */ |
|
84 CMcsSuiteHandler( CMenuEng& aEng ); |
|
85 |
|
86 /** |
|
87 * 2nd phase constructor. |
|
88 */ |
|
89 void ConstructL(const TDesC& aDirName); |
|
90 |
|
91 /** |
|
92 * Handle Install Event |
|
93 */ |
|
94 void HandleInstallNotifyL(TInt aEvent); |
|
95 |
|
96 /** |
|
97 * Handle Mmc Event |
|
98 */ |
|
99 void HandleMmcEventL(TInt aEvent); |
|
100 |
|
101 /** |
|
102 * Handle Free Space Event. |
|
103 */ |
|
104 void HandleFreeSpaceEventL(); |
|
105 /** |
|
106 * Lists new suits |
|
107 */ |
|
108 void CheckSuiteDirL(); |
|
109 |
|
110 /** |
|
111 * Add new suits |
|
112 */ |
|
113 void AddNew(); |
|
114 |
|
115 /** |
|
116 * Remove old suits |
|
117 */ |
|
118 void RemoveOld(); |
|
119 |
|
120 /** |
|
121 * Removes not installed suites from content xml file(basically during restore) |
|
122 * @since S60 v5.0. |
|
123 */ |
|
124 void ScanSuitesL(); |
|
125 |
|
126 |
|
127 /** |
|
128 * Check if file is installed |
|
129 */ |
|
130 TBool FileInstalled(const TDesC& aFileName); |
|
131 |
|
132 /** |
|
133 * Check if file was removed from installed file list |
|
134 */ |
|
135 TBool FileUninstalled(const TDesC& aFileName); |
|
136 |
|
137 /** |
|
138 * Check if file need Update |
|
139 * @param aTimestamp - actual timestamp of file |
|
140 */ |
|
141 TBool FileNeedUpdate(const TDesC& aFileName, const TTime& aTimestamp); |
|
142 |
|
143 /** |
|
144 * Validates file extansion |
|
145 */ |
|
146 TBool ValidExtansion(const TDesC& aFileName); |
|
147 |
|
148 /** |
|
149 * Install file with suites |
|
150 */ |
|
151 void InstallFileL(const TDesC& aFileName, const TTime& aTimestam); |
|
152 |
|
153 /** |
|
154 * Removes file with suites |
|
155 */ |
|
156 void UninstallFileL(const TDesC& aFileName); |
|
157 |
|
158 /** |
|
159 * Update file with suites |
|
160 */ |
|
161 void UpdateFileL(const TDesC& aFileName, const TTime& aTimestam); |
|
162 |
|
163 /** |
|
164 * Get suites from a file |
|
165 */ |
|
166 void GetSuitesL(const TDesC& aFileName, RPointerArray<CSuiteObject>& aSuiteArray); |
|
167 |
|
168 /* |
|
169 * Reopen older suite. Used when deleteing suite that was replaced by newer one. |
|
170 */ |
|
171 void ReopenSuiteL(TInt aSuiteArrayPos); |
|
172 |
|
173 /** |
|
174 * Append suite items to array |
|
175 * @since S60 v5.0. |
|
176 * @param aItemArray array to append suite items |
|
177 * @param aAttrName attribute name |
|
178 * @param aAttrValue attribute value |
|
179 */ |
|
180 void GetMenuSuitesL( |
|
181 RArray<TMenuItem>& aItemArray, |
|
182 const TDesC& aAttrName, |
|
183 const TDesC& aAttrValue ); |
|
184 |
|
185 |
|
186 /** |
|
187 * Addes or updates suite |
|
188 */ |
|
189 void AddSuiteL( const TPtrC& aSuiteName ); |
|
190 |
|
191 /** |
|
192 * Removes suite |
|
193 */ |
|
194 void RemoveSuiteFromXmlL( const TPtrC& aSuiteName ); |
|
195 |
|
196 /** |
|
197 * Updates suites in content xml file |
|
198 * @since S60 v5.0. |
|
199 * @param aMcsItems suite items |
|
200 * @param aIndex index of suite item to update |
|
201 */ |
|
202 void UpdateSuiteInXmlL( |
|
203 RArray<TMenuItem> & aMcsItems, |
|
204 TInt aIndex ); |
|
205 |
|
206 /** |
|
207 * Addes suite to main xml file |
|
208 */ |
|
209 void AddSuiteToXmlL( const TPtrC& aSuiteName ); |
|
210 |
|
211 |
|
212 void UpdateItemsL( const RArray<TMenuItem>& aItemArray ); |
|
213 |
|
214 private: // data |
|
215 CMenuEng& iEng ; ///< Engine. Not Own. |
|
216 RFs iFs; ///< File Server. Own. |
|
217 RBuf iDirPath; ///< Path to observerd dir. Own. |
|
218 CDesCArrayFlat* iFileNewList; ///< List of new files in dir. Own. |
|
219 CDesCArrayFlat* iInstalledFileList; ///< List of installed suites. Own. |
|
220 RArray<TTime> iNewTimestamps; ///< List of current files' timestamps. Own. |
|
221 RArray<TTime> iTimestamps; ///< List of files' timestamps when isntalled. Own. |
|
222 CMcsInstallNotifier* iInstallNotifier; ///< Own |
|
223 CMcsMmcObserver* iMmcObserver; |
|
224 CMcsFreeSpaceObserver* iFreeSpaceObserver; /// Free space observer. Own. |
|
225 RMenuSrvSuiteArray iSuites; ///< Suite array. Own. |
|
226 TInt iEvent;/// < last event. Own |
|
227 }; |
|
228 |
|
229 #endif /* MCSSUITEHANDLER_H_ */ |