1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbServers module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 |
|
26 #ifndef HBTHEMESERVERSYMBIAN_P_H |
|
27 #define HBTHEMESERVERSYMBIAN_P_H |
|
28 |
|
29 #include <QFile> |
|
30 #include <QColor> |
|
31 #include <QHash> |
|
32 #include <QList> |
|
33 #include <QSizeF> |
|
34 #include <QString> |
|
35 #include <QChar> |
|
36 |
|
37 #include "hbthemecommon_p.h" |
|
38 #include "hbthemesymbiancommon_p.h" |
|
39 #include "hbicondatacache_p.h" |
|
40 #include "hbcache_p.h" |
|
41 #include <e32property.h> |
|
42 #include <e32base.h> |
|
43 |
|
44 class HbSymbianThemeServSession; |
|
45 struct HbIconKey; |
|
46 class HbIconSource; |
|
47 class ThemeIndexTables; |
|
48 |
|
49 // reasons for server panic |
|
50 enum TPixmapServPanic{ |
|
51 EBadRequest = 1, |
|
52 EBadDescriptor, |
|
53 EMainSchedulerError, |
|
54 ESvrCreateServer, |
|
55 ESvrStartServer, |
|
56 ECreateTrapCleanup, |
|
57 ENotImplementedYet, |
|
58 }; |
|
59 |
|
60 //********************************** |
|
61 //HbThemeServerSymbian |
|
62 //********************************** |
|
63 /** |
|
64 Our server class - an active object - and therefore derived ultimately from CActive. |
|
65 It accepts requests from client threads and forwards |
|
66 them to the client session to be dealt with. It also handles the creation |
|
67 of the server-side client session. |
|
68 */ |
|
69 class HbThemeServerSymbian : public CServer2 |
|
70 { |
|
71 public: |
|
72 // Creates a new session with the server; the function |
|
73 // implements the pure virtutal function |
|
74 // defined in class CServer2 |
|
75 HbThemeServerSymbian(CActive::TPriority aActiveObjectPriority); |
|
76 static HbThemeServerSymbian * NewL(CActive::TPriority aActiveObjectPriority); |
|
77 ~HbThemeServerSymbian(); |
|
78 CSession2 * NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
|
79 |
|
80 static HbThemeServerSymbian *Instance(); |
|
81 |
|
82 public : |
|
83 // Function to panic the server |
|
84 static void PanicServer(TPixmapServPanic aPanic); |
|
85 bool insertIconCacheItem ( const HbIconKey &key, HbIconCacheItem * item ); |
|
86 HbIconCacheItem * iconCacheItem (const HbIconKey &key, bool isMultiPiece = false); |
|
87 void setMaxGpuCacheSize(int size); |
|
88 void setMaxCpuCacheSize(int size); |
|
89 void CleanupSessionIconItem(HbIconKey key); |
|
90 void clearIconCache(); |
|
91 |
|
92 bool insertCssCacheItem ( const QString& key, HbCacheItem * item ); |
|
93 HbCacheItem * cssCacheItem ( const QString &key); |
|
94 void CleanupSessionCssItem(QString key); |
|
95 void clearCssCache(); |
|
96 |
|
97 void insertIconDefaultSizeCacheItem(const QString &key, const QSizeF &item); |
|
98 QSizeF iconDefaultSizeCacheItem(const QString &key); |
|
99 |
|
100 void doCleanup(); |
|
101 void getThemeIndexTables(ThemeIndexTables &tables); |
|
102 void openCurrentIndexFile(); |
|
103 void resolveCurrentThemeDrive(); |
|
104 |
|
105 //Debug Code for Test Purpose |
|
106 #ifdef HB_ICON_CACHE_DEBUG |
|
107 int cacheIconCount() const; |
|
108 int memorySize(const QString &mem); |
|
109 int freeVectorMemory(); |
|
110 int freeRasterMemory(); |
|
111 int lastAddedRefCount(); |
|
112 int lastAddedItemMem(); |
|
113 int lastRemovedItemMem(); |
|
114 int lastRemovedItemRfCount(); |
|
115 bool enableCache(bool cacheIt); |
|
116 int cacheHitCount(); |
|
117 int cacheMissCount(); |
|
118 int serverHeapSize(); |
|
119 void cleanRasterLRUList(); |
|
120 void cleanVectorLRUList(); |
|
121 int rasterLruCount(); |
|
122 int vectorLruCount(); |
|
123 #endif |
|
124 |
|
125 private: |
|
126 void processThemeIndex(const QString &theme, const QChar drive); |
|
127 QString themeIndexKey(const QString &theme, const QChar drive); |
|
128 void removeOldThemeIndexes(); |
|
129 |
|
130 public: |
|
131 RProperty iThemeProperty; |
|
132 QString iCurrentThemeName; |
|
133 QChar currentThemeDrive; |
|
134 QFile currentIndexfile; |
|
135 private: |
|
136 void ConstructL(); |
|
137 HbIconDataCache * cache; |
|
138 HbCache* cssCache; |
|
139 QHash<QString, QSizeF> iconDefaultSizes; |
|
140 // String key is in format "<drive_capitalized>:<themename>" |
|
141 // E.g. "Z:hbdefault" |
|
142 QMap<QString, int> themeIndexes; |
|
143 QString baseThemeIndexKey; |
|
144 QString lastThemeIndexKey; |
|
145 |
|
146 }; |
|
147 |
|
148 //********************************** |
|
149 //HbSymbianThemeServSession |
|
150 //********************************** |
|
151 /** |
|
152 This class represents a session with the server. |
|
153 Functions are provided to respond appropriately to client messages. |
|
154 */ |
|
155 class HbSymbianThemeServSession : public CSession2 |
|
156 { |
|
157 public: |
|
158 HbSymbianThemeServSession(HbThemeServerSymbian * aServer); |
|
159 ~HbSymbianThemeServSession(); |
|
160 void ServiceL(const RMessage2 & aMessage); |
|
161 void DispatchMessageL(const RMessage2 & aMessage); |
|
162 void GetSharedIconInfoL(const RMessage2 & aMessage); |
|
163 void GetSharedIconDefaultSizeInfoL(const RMessage2 &aMessage); |
|
164 QSizeF RetrieveIconDefaultSize(const QString &filename); |
|
165 void HandleStyleSheetLookupL(const RMessage2 & aMessage); |
|
166 void HandleWidgetMLLookupL(const RMessage2& aMessage); |
|
167 void HandleDeviceProfilesReqL(const RMessage2& aMessage); |
|
168 void HandleSecondaryCacheOffsetReqL(const RMessage2& aMessage); |
|
169 void HandleEffectAddAndFileLookupL(const RMessage2 &aMessage); |
|
170 void HandleThemeSelectionL(const RMessage2 & aMessage); |
|
171 QColor GetColorFromRgba(TUint32 aRgba, bool aColorFlag); |
|
172 void GetSharedMultiIconInfoL(const RMessage2& aMessage); |
|
173 TMultiIconSymbParams ReadMessageAndRetrieveMultiIconParams(const RMessage2& aMessage); |
|
174 void GetDataFromCacheItem(HbIconCacheItem* cacheItem, HbSharedIconInfo &data) const; |
|
175 void FreeDataFromCacheItem(HbIconCacheItem* cacheItem); |
|
176 bool IconInfoFromSingleIcon(HbIconKey key, HbSharedIconInfo &stitchedData); |
|
177 bool CreateCacheItemData(HbIconKey key, int options, HbSharedIconInfo &data, bool isMultiPiece = false); |
|
178 bool CreateStichedIconInfoOfParts(QVector<HbSharedIconInfo> dataForParts, HbMultiIconParams params, |
|
179 HbIconKey &finalIconKey, HbSharedIconInfo &stitchedData); |
|
180 void IconInfoFromMultiParts(const HbMultiIconParams ¶msCommon, |
|
181 const int noOfPieces, |
|
182 HbIconKey &stichedKey, |
|
183 HbSharedIconInfo &stitchedData); |
|
184 |
|
185 protected: |
|
186 TIconParams ReadMessageAndRetrieveParams (const RMessage2 & aMessage); |
|
187 void PanicClient(const RMessage2 & aMessage, TInt aPanic) const; |
|
188 |
|
189 private: |
|
190 HbThemeServerSymbian *iServer; |
|
191 QList<HbIconKey> sessionData; |
|
192 QList<QString> sessionCssData; |
|
193 }; |
|
194 #endif // HBTHEMESERVERSYMBIAN_P_H |
|