src/hbservers/hbthemeserver/hbthemeserver_generic.cpp
changeset 3 11d3954df52a
parent 2 06ff229162e9
child 5 627c4a0fd0e7
--- a/src/hbservers/hbthemeserver/hbthemeserver_generic.cpp	Fri May 14 16:09:54 2010 +0300
+++ b/src/hbservers/hbthemeserver/hbthemeserver_generic.cpp	Thu May 27 13:10:59 2010 +0300
@@ -79,7 +79,8 @@
   \a parent
 */
 #ifdef QT_DEBUG
-HbThemeServerPrivate::HbThemeServerPrivate(QWidget *parent): QMainWindow(parent), server(new QLocalServer(this))
+HbThemeServerPrivate::HbThemeServerPrivate(QWidget *parent)
+    : QMainWindow(parent), server(new QLocalServer(this))
 #else
 HbThemeServerPrivate::HbThemeServerPrivate(): server(new QLocalServer(this))
 #endif
@@ -90,10 +91,7 @@
     setWindowTitle("Theme Server");
     setCentralWidget(&statusLabel);
 #endif
-	// renderMode set to SW mode by default
-	renderMode = ESWRendering;
-    // Using QScopedPointer so that it deallocates memory
-    // when std::badalloc exception occurs.
+    renderMode = ESWRendering;
     QScopedPointer <HbIconDataCache> tempIconCache(new HbIconDataCache());
     QScopedPointer <HbCache> tempCssCache(new HbCache());
     iconCache = tempIconCache.take();
@@ -111,7 +109,9 @@
 HbThemeServerPrivate::~HbThemeServerPrivate()
 {
     server->close();
-    delete server; // Order of Deletion needs to be maintain ,as the QLocalServer should delete first before deleting Server data so All sessions will be cleanup first.
+    // QLocalServer should be deleted first before deleting Server data
+    // so all sessions will be cleaned up first.
+    delete server;
     delete iconCache;
     delete cssCache;
 }
@@ -167,7 +167,7 @@
   \a key denotes the unique identifier for the cache item that is to be inserted into the cache.
   \a item denotes the cache item that is to be inserted
 */
-bool HbThemeServerPrivate::insertIconCacheItem(const HbIconKey &key,  HbIconCacheItem *item)
+bool HbThemeServerPrivate::insertIconCacheItem(const HbIconKey &key, HbIconCacheItem *item)
 {
     return (iconCache->insert(key, item));
 }
@@ -178,7 +178,7 @@
   \a key denotes the unique identifier for the cache item that is to be inserted into the cache.
   \a item denotes the cache item that is to be inserted
 */
-bool HbThemeServerPrivate::insertCssCacheItem(const QString &key,  HbCacheItem *item)
+bool HbThemeServerPrivate::insertCssCacheItem(const QString &key, HbCacheItem *item)
 {
     return (cssCache->insert(key, item));
 }
@@ -331,7 +331,7 @@
     }
 
     // Else delete only specified files
-    for (int i=0; i<fileNames.count();i++) {
+    for (int i = 0; i < fileNames.count(); i++) {
         QString filename = fileNames.at(i);
 
         // Stylesheet
@@ -351,12 +351,12 @@
 
         // Icon
         QVector<const HbIconKey *> keys = iconCache->getKeys(filename);
-        for (int j = 0; j<keys.count();j++) {
+        for (int j = 0; j < keys.count(); j++) {
             HbThemeServerSession *session;
             foreach(session, sessionList) {
                 session->removeSessionIconItem(*keys.at(j));
             }
-            iconCache->remove(*keys.at(j),false);
+            iconCache->remove(*keys.at(j), false);
         }
     }
 }
@@ -433,7 +433,7 @@
 void HbThemeServerPrivate::clienDisconnected()
 {
 #ifdef THEME_SERVER_TRACES
-    qDebug()<<"Total No of Connection after deletion = "<<sessionList.count();
+    qDebug() << "Total No of Connection after deletion = " << sessionList.count();
 #endif
 
     // Quit the server if no more clients connected
@@ -554,13 +554,16 @@
   The Theme server maintains a list of sessions, each session corresponding to a client.
   Each session in turn is responsible for keeping track of client specific resources.
   In case of Icon caching, a session maintains a list of Icon keys.
-  A  key is added to the list only if the corresponding cache item has been successfully inserted into cache
-  or if a previously cached icon is requested and successfully found in the cache.
+  A  key is added to the list only if the corresponding cache item
+  has been successfully inserted into cache or if a previously cached icon
+  is requested and successfully found in the cache.
   In case of client crash or graceful exit of client, the server goes through its list of sessions,
-  finds the session corresponding to the client, removes the session from its session list and deletes the session.
+  finds the session corresponding to the client, removes the session from its session list and
+  deletes the session.
   In the session destructor, the session specific resources are cleaned up.
-  In case of icon caching, the list of icon keys is traversed and a remove operation is performed on the cache
-  items corresponding to these keys. On removal, the items reference count is decremented and in case the
+  In case of icon caching, the list of icon keys is traversed and a remove operation is
+  performed on the cache items corresponding to these keys.
+  On removal, the items reference count is decremented and in case the
   reference count becomes 0, the cache item instance gets added to the back of the LRU list.
 
 */
@@ -571,7 +574,8 @@
   \a aClientConnection indicates the local socket that is contained within this session
   \a aServer denotes the handle to the theme server
 */
-HbThemeServerSession::HbThemeServerSession(QLocalSocket *aClientConnection, HbThemeServerPrivate *aServer)
+HbThemeServerSession::HbThemeServerSession(QLocalSocket *aClientConnection,
+                                           HbThemeServerPrivate *aServer)
 {
     iServer = aServer;
     iClientConnection = aClientConnection;
@@ -629,7 +633,7 @@
     HbSharedIconInfo data;
     data.type = INVALID_FORMAT;
     HbThemeServerRequest requestType;
-    QByteArray inputByteArray = ((QLocalSocket *)sender())->readAll();
+    QByteArray inputByteArray = static_cast<QLocalSocket *>(sender())->readAll();
     if (inputByteArray.size() > 0) {
         QDataStream inputDataStream(inputByteArray);
         int clue;
@@ -644,18 +648,18 @@
 #ifdef HB_ICON_CACHE_DEBUG
         QByteArray outputByteArray;
         QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
-        outputDataStream << (int)requestType;
+        outputDataStream << int(requestType);
 #endif
         switch (requestType) {
         case EStyleSheetLookup: {
             QString fileName;
             int priority;
-            HbLayeredStyleLoader::LayerPriority layerdPriority;
+            HbLayeredStyleLoader::LayerPriority layerPriority;
             inputDataStream >> fileName;
             inputDataStream >> priority;
-            layerdPriority = (HbLayeredStyleLoader::LayerPriority) priority;
-            QByteArray output = handleStyleSheetLookup((int) requestType, fileName, layerdPriority);
-            ((QLocalSocket *)sender())->write(output);
+            layerPriority = static_cast<HbLayeredStyleLoader::LayerPriority>(priority);
+            QByteArray output = handleStyleSheetLookup(int(requestType), fileName, layerPriority);
+            static_cast<QLocalSocket *>(sender())->write(output);
             break;
         }
         case EWidgetMLLookup: {
@@ -668,7 +672,7 @@
             inputDataStream >> section;
             // handle the shared Widgetml look up.
             QByteArray output = iServer->handleSharedWidgetMLLookup(filename, layout, section);
-            ((QLocalSocket *)sender())->write(output);
+            static_cast<QLocalSocket *>(sender())->write(output);
             break;
         }
         case EDeviceProfileOffset: {
@@ -684,7 +688,7 @@
             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
             outputDataStream << requestType;
             outputDataStream << offset;
-            ((QLocalSocket *)sender())->write(outputByteArray);
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
             break;
         }
         case EEffectLookupFilePath:
@@ -692,12 +696,12 @@
             QString fileName;
             inputDataStream >> fileName;
             QByteArray output = iServer->handleSharedEffectAddAndFileLookup((int) requestType, fileName);
-            ((QLocalSocket *)sender())->write(output);
+            static_cast<QLocalSocket *>(sender())->write(output);
             break;
         }
         case EThemeSelection: {
             QString themename;
-            QLocalSocket *themeSelectionClient = (QLocalSocket *)sender();
+            QLocalSocket *themeSelectionClient = static_cast<QLocalSocket *>(sender());
             inputDataStream >> themename;
             iServer->setThemeSelectionClient(themeSelectionClient);
             iServer->handleThemeSelection(themename);
@@ -710,21 +714,23 @@
             HbThemeServerRequest requestType = EThemeContentUpdate;
             QByteArray block;
             QDataStream out(&block, QIODevice::WriteOnly);
-            out << (int)requestType;
+            out << int(requestType);
             out << themedItems;
             iServer->writeToClients(block);
             break;
         }
         case EThemeServerStop: {
             //This segment is used by HbThemeApiWrapperUi.
-            //When no HbApplication is open and HbThemeserver has only HbThemeApiWrapperUi as client, making sessionListCount =1
+            //When no HbApplication is open and
+            // HbThemeserver has only HbThemeApiWrapperUi as client, making sessionListCount =1
             //HbThemeserver is closed otherwise warning is shown.
-            //QCoreApplication::quit() removes the UI of HbThemeServer. Destructor of HbThemeServer will be called where it was instantiated.
+            //QCoreApplication::quit() removes the UI of HbThemeServer.
+            // Destructor of HbThemeServer will be called where it was instantiated.
             if (iServer->sessionListCount() == 1) {
 #ifdef QT_DEBUG
                 iServer->close();
 #endif
-                ((QLocalSocket *)sender())->disconnectFromServer();
+                static_cast<QLocalSocket *>(sender())->disconnectFromServer();
                 QCoreApplication::quit();
             } else {
                 qWarning() << "Close all HbApplications before closing hbthemeserver!!";
@@ -750,9 +756,11 @@
 #ifdef THEME_SERVER_TRACES
             qDebug() << "image req at server: " << filename;
 #endif
-			HbIconKey key(filename, size, (Qt::AspectRatioMode)aspectRatioMode, (QIcon::Mode)mode, mirrored, color, iServer->currentRenderingMode());
+            HbIconKey key(filename, size, static_cast<Qt::AspectRatioMode>(aspectRatioMode),
+                          static_cast<QIcon::Mode>(mode), mirrored, color,
+                          iServer->currentRenderingMode());
             QByteArray output = handleIconLookup(key, data, options);
-            ((QLocalSocket *)sender())->write(output);
+            static_cast<QLocalSocket *>(sender())->write(output);
             break;
         }
         case EIconDefaultSize:
@@ -763,13 +771,12 @@
             inputDataStream >> frameItemParams.multiPartIconData.multiPartIconId;
 
             int noOfPieces = 1;
-            if (frameItemParams.multiPartIconData.multiPartIconId.contains("_3PV", Qt::CaseInsensitive) ||
-                    frameItemParams.multiPartIconData.multiPartIconId.contains("_3PH", Qt::CaseInsensitive)) {
+            if (frameItemParams.multiPartIconData.multiPartIconId.contains("_3PV", Qt::CaseInsensitive)
+                || frameItemParams.multiPartIconData.multiPartIconId.contains("_3PH", Qt::CaseInsensitive)) {
                 noOfPieces = 3;
             } else if (frameItemParams.multiPartIconData.multiPartIconId.contains("_9P", Qt::CaseInsensitive)) {
                 noOfPieces = 9;
             }
-
             for (int i = 0; i < noOfPieces; i++) {
                 inputDataStream >> frameItemParams.multiPartIconData.sources[i];
             }
@@ -792,16 +799,17 @@
 #ifdef THEME_SERVER_TRACES
             qDebug() << "image req at server: " << frameItemParams.multiPartIconList;
 #endif
-
-            int index = frameItemParams.multiPartIconList[0].lastIndexOf("/");
+            int index = frameItemParams.multiPartIconList[0].lastIndexOf('/');
             QString iconId = frameItemParams.multiPartIconList[0].left(index + 1);
             HbSharedIconInfo stitchedData;
             QT_TRY {
                 iconId.append(frameItemParams.multiPartIconData.multiPartIconId);
                 HbIconKey finalIconKey(iconId, frameItemParams.size,
-                                       (Qt::AspectRatioMode)frameItemParams.aspectRatioMode,
-                                       (QIcon::Mode)frameItemParams.mode, frameItemParams.mirrored,
-									   frameItemParams.color, (HbRenderingMode)frameItemParams.renderMode);
+                    static_cast<Qt::AspectRatioMode>(frameItemParams.aspectRatioMode),
+                    static_cast<QIcon::Mode>(frameItemParams.mode),
+                    frameItemParams.mirrored,
+                    frameItemParams.color,
+                    static_cast<HbRenderingMode>(frameItemParams.renderMode));
 
                 stitchedData.type = INVALID_FORMAT;
 
@@ -818,15 +826,16 @@
             request = EMultiPieceIcon;
             fillOutPutDataStream(outputDataStream, stitchedData, request);
 #ifdef THEME_SERVER_TRACES
-            qDebug() << Q_FUNC_INFO << " offset= " << stitchedData.pixmapData.offset << " format= " << stitchedData.pixmapData.format;
+            qDebug() << Q_FUNC_INFO << " offset= " << stitchedData.pixmapData.offset
+                     << " format= " << stitchedData.pixmapData.format;
             testLabel->setPixmap(QPixmap::fromImage(
-                                     QImage(
-                                         HbMemoryUtils::getAddress<uchar>(HbMemoryManager::SharedMemory, stitchedData.pixmapData.offset),
-                                         stitchedData.pixmapData.width,
-                                         stitchedData.pixmapData.height,
-                                         stitchedData.pixmapData.format)));
+                QImage(HbMemoryUtils::getAddress<uchar>(HbMemoryManager::SharedMemory,
+                                                        stitchedData.pixmapData.offset),
+                       stitchedData.pixmapData.width,
+                       stitchedData.pixmapData.height,
+                       stitchedData.pixmapData.format)));
 #endif
-            ((QLocalSocket *)sender())->write(outputByteArray);
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
             break;
         }
         case EMultiIcon: {
@@ -839,10 +848,7 @@
             int options;
             QColor color;
             inputDataStream >> fileList;
-            for (int i = 0; i < fileList.count(); i++) {
-                inputDataStream >> size;
-                sizeList << size;
-            }
+            inputDataStream >> sizeList;
             inputDataStream >> aspectRatioMode;
             inputDataStream >> mode;
             inputDataStream >> mirrored;
@@ -853,15 +859,17 @@
             qDebug() << "image req at server: " << fileList;
 #endif
             QByteArray output;
+            QDataStream outputDataStream(&output, QIODevice::WriteOnly);
+            outputDataStream << (int)requestType; // Put EMultiIcon request type in the beginning
             for (int i = 0; i < fileList.count(); i++) {
                 HbIconKey key(fileList[i], sizeList[i],
                               static_cast<Qt::AspectRatioMode>(aspectRatioMode),
-							  static_cast<QIcon::Mode>(mode), mirrored, color, iServer->currentRenderingMode());
+                              static_cast<QIcon::Mode>(mode), mirrored, color,
+                              iServer->currentRenderingMode());
                 output.append(handleIconLookup(key, data, options));
             }
 
-            ((QLocalSocket *)sender())->write(output);
-
+            static_cast<QLocalSocket *>(sender())->write(output);
             break;
         }
         case ENotifyForegroundLost: {
@@ -873,7 +881,7 @@
         case ECacheIconCount: {
             int count = iServer->cacheIconCount();
             outputDataStream << count;
-            ((QLocalSocket *)sender())->write(outputByteArray);
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
             break;
         }
         case ERasterMemLimit: {
@@ -891,122 +899,124 @@
         case EFreeRasterMem: {
             int freeRastMem = iServer->freeRasterMemory();
             outputDataStream << freeRastMem;
-            ((QLocalSocket *)sender())->write(outputByteArray);
+            static_cast<QLocalSocket *>sender())->write(outputByteArray);
             break;
         }
         case EFreeVectorMem: {
             int freeVectMem = iServer->freeVectorMemory();
             outputDataStream << freeVectMem;
-            ((QLocalSocket *)sender())->write(outputByteArray);
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
             break;
         }
         case ELastAddedItemMem {
-                int lAddItemMem = iServer->lastAddedItemMem();
-                outputDataStream << lAddItemMem;
-                ((QLocalSocket *)sender())->write(outputByteArray);
-                break;
-            }
+            int lAddItemMem = iServer->lastAddedItemMem();
+            outputDataStream << lAddItemMem;
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
+            break;
+        }
         case ELastRemovedItemMem {
-                int lRemItemMem = iServer->lastRemovedItemMem();
-                outputDataStream << lRemItemMem;
-                ((QLocalSocket *)sender())->write(outputByteArray);
-                break;
-            }
+            int lRemItemMem = iServer->lastRemovedItemMem();
+            outputDataStream << lRemItemMem;
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
+            break;
+        }
         case ELastRemovedItemRefCount: {
-                int lRemItemRfCnt = iServer->lastRemovedItemRfCount();
-                outputDataStream << lRemItemRfCnt;
-                ((QLocalSocket *)sender())->write(outputByteArray);
-                break;
-            }
+            int lRemItemRfCnt = iServer->lastRemovedItemRfCount();
+            outputDataStream << lRemItemRfCnt;
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
+            break;
+        }
         case ELastAddedItemRefCount: {
-                int lAddItemRfCnt = iServer->lastAddedRefCount();
-                outputDataStream << lAddItemRfCnt;
-                ((QLocalSocket *)sender())->write(outputByteArray);
-                break;
-            }
+            int lAddItemRfCnt = iServer->lastAddedRefCount();
+            outputDataStream << lAddItemRfCnt;
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
+            break;
+        }
         case EEnableCache: {
-                int enable ;
-                inputDataStream >> enable;
-                bool success = iServer->enableCache(enable);
-                outputDataStream << (int)success;
-                ((QLocalSocket *)sender())->write(outputByteArray);
-                break;
-            }
+            int enable ;
+            inputDataStream >> enable;
+            bool success = iServer->enableCache(enable);
+            outputDataStream << (int)success;
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
+            break;
+        }
         case ECacheHit: {
-                int cacheHitCnt = iServer->cacheHitCount();
-                outputDataStream << cacheHitCnt;
-                ((QLocalSocket *)sender())->write(outputByteArray);
-                break;
-            }
+            int cacheHitCnt = iServer->cacheHitCount();
+            outputDataStream << cacheHitCnt;
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
+            break;
+        }
         case ECacheMiss: {
-                int cacheMissCnt = iServer->cacheMissCount();
-                outputDataStream << cacheMissCnt;
-                ((QLocalSocket *)sender())->write(outputByteArray);
-                break;
-            }
+            int cacheMissCnt = iServer->cacheMissCount();
+            outputDataStream << cacheMissCnt;
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
+            break;
+        }
         case ECleanRasterLRUList: {
-                iServer->cleanRasterLRUList();
-                break;
-            }
+            iServer->cleanRasterLRUList();
+            break;
+        }
         case ECleanVectorLRUList: {
-                iServer->cleanVectorLRUList();
-                break;
-            }
+            iServer->cleanVectorLRUList();
+            break;
+        }
         case EGpuLruCount: {
-                int rasterLruCount = iServer->rasterLruCount();
-                outputDataStream << rasterLruCount;
-                ((QLocalSocket *)sender())->write(outputByteArray);
-                break;
-            }
+            int rasterLruCount = iServer->rasterLruCount();
+            outputDataStream << rasterLruCount;
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
+            break;
+        }
         case ECpuLruCount: {
-                int vectorLruCount = iServer->vectorLruCount();
-                outputDataStream << vectorLruCount;
-                ((QLocalSocket *)sender())->write(outputByteArray);
-                break;
-            }
+            int vectorLruCount = iServer->vectorLruCount();
+            outputDataStream << vectorLruCount;
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
+            break;
+        }
         case EServerHeap: {
-            }
+        }
 #endif
 #ifdef HB_THEME_SERVER_MEMORY_REPORT
         case ECreateMemoryReport: {
-                GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory);
-                static_cast<HbSharedMemoryManager *>(manager)->createReport();
-                break;
-            }
+            GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory);
+            static_cast<HbSharedMemoryManager *>(manager)->createReport();
+            break;
+        }
 #endif
         case EUnloadIcon: {
-                QString filename;
-                QSizeF size;
-                int aspectRatioMode;
-                int mode;
-                bool mirrored;
-                int options;
-                QColor color;
-                inputDataStream >> filename;
-                inputDataStream >> size;
-                inputDataStream >> aspectRatioMode;
-                inputDataStream >> mode;
-                inputDataStream >> mirrored;
-                inputDataStream >> options;
-                inputDataStream >> color;
+            QString filename;
+            QSizeF size;
+            int aspectRatioMode;
+            int mode;
+            bool mirrored;
+            int options;
+            QColor color;
+            inputDataStream >> filename;
+            inputDataStream >> size;
+            inputDataStream >> aspectRatioMode;
+            inputDataStream >> mode;
+            inputDataStream >> mirrored;
+            inputDataStream >> options;
+            inputDataStream >> color;
 
-                HbIconKey key(filename, size, (Qt::AspectRatioMode)aspectRatioMode,
-					(QIcon::Mode)mode, mirrored, color, iServer->currentRenderingMode());
-                iServer->removeIconCacheItem(key);
-                sessionIconData.removeOne(key);
-                QByteArray outputByteArray;
-                QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
-                outputDataStream << (int)requestType;
-                ((QLocalSocket *)sender())->write(outputByteArray);
-                break;
-            }
+            HbIconKey key(filename, size,
+                          static_cast<Qt::AspectRatioMode>(aspectRatioMode),
+                          static_cast<QIcon::Mode>(mode), mirrored, color,
+                          iServer->currentRenderingMode());
+            iServer->removeIconCacheItem(key);
+            sessionIconData.removeOne(key);
+            QByteArray outputByteArray;
+            QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
+            outputDataStream << int(requestType);
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
+            break;
+        }
         case EFreeSharedMem: {
             int freeSharedMem = iServer->freeSharedMemory();
             QByteArray outputByteArray;
             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
             outputDataStream << requestType;
             outputDataStream << freeSharedMem;
-            ((QLocalSocket *)sender())->write(outputByteArray);
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
             break;
         }
         case EAllocatedSharedMem: {
@@ -1015,10 +1025,9 @@
             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
             outputDataStream << requestType;
             outputDataStream << allocatedSharedMem;
-            ((QLocalSocket *)sender())->write(outputByteArray);
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
             break;
         }
-
         case ETypefaceOffset: {
             int offset = -1;
             HbTypefaceInfoDatabase *typefaceDatabase =
@@ -1032,11 +1041,9 @@
             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
             outputDataStream << requestType;
             outputDataStream << offset;
-            ((QLocalSocket *)sender())->write(outputByteArray);
+            static_cast<QLocalSocket *>(sender())->write(outputByteArray);
             break;
         }
-
-
         default:
             break;
         }
@@ -1052,7 +1059,7 @@
         HbSharedIconInfo &stitchedData)
 {
     stitchedData.type = INVALID_FORMAT;
-    HbIconCacheItem * cacheItem = iServer->iconCacheItem(key);
+    HbIconCacheItem *cacheItem = iServer->iconCacheItem(key);
     if (cacheItem) {
         getDataFromCacheItem(cacheItem, stitchedData);
         return true;
@@ -1065,23 +1072,21 @@
   Creates a cacheItem of the given key and insert the item in to the list
   else free the data allocated for the cache..
 */
-bool HbThemeServerSession::createCacheItemData(HbIconKey key, int options , HbSharedIconInfo &data)
+bool HbThemeServerSession::createCacheItemData(HbIconKey key, int options, HbSharedIconInfo &data)
 {
-    HbIconCacheItem * cacheItemOfPiece = iServer->iconCacheItem(key);
+    HbIconCacheItem *cacheItemOfPiece = iServer->iconCacheItem(key);
     if (cacheItemOfPiece) {
         return true;
     }
 
-    QScopedPointer <HbIconCacheItem> tempIconCacheItem;
+    QScopedPointer<HbIconCacheItem> tempIconCacheItem;
     bool insertKeyIntoSessionList = false;
     data.type = INVALID_FORMAT;
     QString format = HbThemeServerUtils::formatFromPath(key.filename);
 
     tempIconCacheItem.reset(HbIconCacheItemCreator::createCacheItem(key,
-                            (HbIconLoader::IconLoaderOptions)options,
-                            format,
-							iServer->currentRenderingMode(),
-                            false));
+                            static_cast<HbIconLoader::IconLoaderOptions>(options),
+                            format, iServer->currentRenderingMode(), false));
     cacheItemOfPiece = tempIconCacheItem.data();
     if (cacheItemOfPiece) {
         getDataFromCacheItem(cacheItemOfPiece, data);
@@ -1105,7 +1110,7 @@
 bool HbThemeServerSession::createStichedIconInfoOfParts(QVector<HbSharedIconInfo> dataForParts, HbMultiIconParams params,
         HbIconKey &finalIconKey, HbSharedIconInfo &stitchedData)
 {
-    HbIconCacheItem * cacheItem = iServer->iconCacheItem(finalIconKey);
+    HbIconCacheItem *cacheItem = iServer->iconCacheItem(finalIconKey);
     if (cacheItem) {
         return true;
     }
@@ -1113,9 +1118,9 @@
     stitchedData.type = INVALID_FORMAT;
     QString format = HbThemeServerUtils::formatFromPath(params.multiPartIconList[0]);
 
-    QScopedPointer <HbPixmapIconProcessor> tempIconProcessor(new HbPixmapIconProcessor(finalIconKey,
+    QScopedPointer<HbPixmapIconProcessor> tempIconProcessor(new HbPixmapIconProcessor(finalIconKey,
                                                 static_cast<HbIconLoader::IconLoaderOptions>(params.options), format));
-    HbPixmapIconProcessor * rasterIcon = tempIconProcessor.data();
+    HbPixmapIconProcessor *rasterIcon = tempIconProcessor.data();
     rasterIcon->createMultiPieceIconData(dataForParts, params);
 
     QScopedPointer <HbIconCacheItem> tempIconCacheItem;
@@ -1153,19 +1158,19 @@
     QVector<HbSharedIconInfo>  dataForParts;
     bool insertKeyIntoSessionList = false;
     bool failedToCreateParts = false;
-    QString format;
     try {
         for (int i = 0; i < noOfPieces; i++) {
             HbSharedIconInfo data;
             bool iconPieceMirrored = false;
             HbIconKey key(params.multiPartIconList.at(i), params.multiPartIconData.pixmapSizes[i],
                           static_cast<Qt::AspectRatioMode>(stichedKey.aspectRatioMode),
-						  static_cast<QIcon::Mode>(stichedKey.mode), iconPieceMirrored, stichedKey.color,stichedKey.renderMode );
+                          static_cast<QIcon::Mode>(stichedKey.mode),
+                          iconPieceMirrored, stichedKey.color, stichedKey.renderMode);
             insertKeyIntoSessionList = iconInfoFromSingleIcon(key, data);
             if (!insertKeyIntoSessionList) {
                 insertKeyIntoSessionList = createCacheItemData(key, params.options, data);
             }
-            if ((data.type == INVALID_FORMAT) || (!insertKeyIntoSessionList)) {
+            if ((data.type == INVALID_FORMAT) || !insertKeyIntoSessionList) {
                 failedToCreateParts = true;
                 break;
             } else {
@@ -1180,8 +1185,10 @@
         failedToCreateParts = true;
     }
 
-    if ((failedToCreateParts) || (dataForParts.count() != noOfPieces) || (!insertKeyIntoSessionList)) {
-        //atLeast one of the icon did'nt get constructed , so move the cached piece icons to unused state and return
+    if (failedToCreateParts || (dataForParts.count() != noOfPieces)
+        || !insertKeyIntoSessionList) {
+        //atLeast one of the icon did'nt get constructed ,
+        //so move the cached piece icons to unused state and return
         for (int i = 0; i < keysInserted.count(); i++) {
             sessionIconData.removeOne(keysInserted.at(i));
         }
@@ -1269,10 +1276,12 @@
   \fn HbThemeServerSession::fillOutPutDataStream()
   Fills the Output data stream with the sharedIconInfo data.
 */
-void HbThemeServerSession::fillOutPutDataStream(QDataStream &outputDataStream, HbSharedIconInfo &data, HbThemeServerRequest request)
+void HbThemeServerSession::fillOutPutDataStream(QDataStream &outputDataStream,
+                                                HbSharedIconInfo &data,
+                                                HbThemeServerRequest request)
 {
-    outputDataStream << (int)request;
-    outputDataStream << (int)data.type;
+    outputDataStream << int(request);
+    outputDataStream << int(data.type);
 
     switch (data.type) {
     case OTHER_SUPPORTED_FORMATS:
@@ -1281,7 +1290,7 @@
         outputDataStream << data.pixmapData.height;
         outputDataStream << data.pixmapData.defaultWidth;
         outputDataStream << data.pixmapData.defaultHeight;
-        outputDataStream << (int)data.pixmapData.format;
+        outputDataStream << int(data.pixmapData.format);
         break;
         /*case SVG:*/
     case PIC: {
@@ -1310,7 +1319,8 @@
   \fn HbThemeServerSession::getDataFromCacheItem()
   Gets data from the cache Item.
 */
-void HbThemeServerSession::getDataFromCacheItem(HbIconCacheItem* cacheItem, HbSharedIconInfo &data) const
+void HbThemeServerSession::getDataFromCacheItem(HbIconCacheItem* cacheItem,
+                                                HbSharedIconInfo &data) const
 {
     if (cacheItem) {
         if (cacheItem->rasterIconData.type != INVALID_FORMAT) {
@@ -1328,7 +1338,9 @@
 /**
  * HbThemeServerPrivate::handleSharedWidgetMLLookup()
  */
-QByteArray HbThemeServerPrivate::handleSharedWidgetMLLookup(const QString &fileName, const QString &layout, const QString &section)
+QByteArray HbThemeServerPrivate::handleSharedWidgetMLLookup(const QString &fileName,
+                                                            const QString &layout,
+                                                            const QString &section)
 {
     int offset = HbThemeServerUtils::getSharedLayoutDefinition(fileName, layout, section);
     QByteArray outputByteArray;
@@ -1343,7 +1355,8 @@
 /**
  * HbThemeServerPrivate::handleSharedEffectAddAndFileLookup()
  */
-QByteArray HbThemeServerPrivate::handleSharedEffectAddAndFileLookup(int request, const QString &fileName)
+QByteArray HbThemeServerPrivate::handleSharedEffectAddAndFileLookup(int request,
+                                                                    const QString &fileName)
 {
     int offset = HbThemeServerUtils::getSharedEffect(fileName);
     QByteArray outputByteArray;
@@ -1356,7 +1369,8 @@
 /**
  * HbThemeServerSession::handleStyleSheetLookup()
  */
-QByteArray HbThemeServerSession::handleStyleSheetLookup(int request, const QString &fileName, HbLayeredStyleLoader::LayerPriority priority)
+QByteArray HbThemeServerSession::handleStyleSheetLookup(int request,
+    const QString &fileName, HbLayeredStyleLoader::LayerPriority priority)
 {
     int offset = -1;
     HbCacheItem* cssItem = iServer->cssCacheItem(fileName);
@@ -1373,13 +1387,15 @@
                 if (offset >= 0) {
                     HbCacheItem *cssItem = new HbCacheItem(offset, 0, fileName);
                     insertKeyIntoSessionList = iServer->insertCssCacheItem(fileName, cssItem);
-                    if (priority == HbLayeredStyleLoader::Priority_Core && cssItem->refCount == 1) {
+                    if (priority == HbLayeredStyleLoader::Priority_Core
+                        && cssItem->refCount == 1) {
                         // This will make sure the requested stylesheet will always remain
                         // in the primary and secondary cache.
                         cssItem->incrementRefCount();
                     }
-                    if (priority == HbLayeredStyleLoader::Priority_Theme && cssItem->refCount == 1) {
-                        iServer->themePriorityItems.insert(fileName,cssItem);
+                    if (priority == HbLayeredStyleLoader::Priority_Theme
+                        && cssItem->refCount == 1) {
+                        iServer->themePriorityItems.insert(fileName, cssItem);
                     }
                     break;
                 } else if (offset == OUT_OF_MEMORY_ERROR && tryAgain == false) {
@@ -1413,7 +1429,8 @@
 /**
  * HbThemeServerSession::handleIconLookup()
  */
-QByteArray HbThemeServerSession::handleIconLookup(const HbIconKey &key, HbSharedIconInfo &data, int options)
+QByteArray HbThemeServerSession::handleIconLookup(const HbIconKey &key, HbSharedIconInfo &data,
+                                                  int options)
 {
     bool insertKeyIntoSessionList = false;
     HbIconCacheItem * cacheItem = iServer->iconCacheItem(key);