src/hbservers/hbthemeserver/hbthemeserver_generic.cpp
changeset 3 11d3954df52a
parent 2 06ff229162e9
child 5 627c4a0fd0e7
equal deleted inserted replaced
2:06ff229162e9 3:11d3954df52a
    77   \fn HbThemeServerPrivate::HbThemeServerPrivate()
    77   \fn HbThemeServerPrivate::HbThemeServerPrivate()
    78   Constructor
    78   Constructor
    79   \a parent
    79   \a parent
    80 */
    80 */
    81 #ifdef QT_DEBUG
    81 #ifdef QT_DEBUG
    82 HbThemeServerPrivate::HbThemeServerPrivate(QWidget *parent): QMainWindow(parent), server(new QLocalServer(this))
    82 HbThemeServerPrivate::HbThemeServerPrivate(QWidget *parent)
       
    83     : QMainWindow(parent), server(new QLocalServer(this))
    83 #else
    84 #else
    84 HbThemeServerPrivate::HbThemeServerPrivate(): server(new QLocalServer(this))
    85 HbThemeServerPrivate::HbThemeServerPrivate(): server(new QLocalServer(this))
    85 #endif
    86 #endif
    86 {
    87 {
    87     iThemeSelectionClient = 0;
    88     iThemeSelectionClient = 0;
    88     sessionList.clear();
    89     sessionList.clear();
    89 #ifdef QT_DEBUG
    90 #ifdef QT_DEBUG
    90     setWindowTitle("Theme Server");
    91     setWindowTitle("Theme Server");
    91     setCentralWidget(&statusLabel);
    92     setCentralWidget(&statusLabel);
    92 #endif
    93 #endif
    93 	// renderMode set to SW mode by default
    94     renderMode = ESWRendering;
    94 	renderMode = ESWRendering;
       
    95     // Using QScopedPointer so that it deallocates memory
       
    96     // when std::badalloc exception occurs.
       
    97     QScopedPointer <HbIconDataCache> tempIconCache(new HbIconDataCache());
    95     QScopedPointer <HbIconDataCache> tempIconCache(new HbIconDataCache());
    98     QScopedPointer <HbCache> tempCssCache(new HbCache());
    96     QScopedPointer <HbCache> tempCssCache(new HbCache());
    99     iconCache = tempIconCache.take();
    97     iconCache = tempIconCache.take();
   100     cssCache = tempCssCache.take();
    98     cssCache = tempCssCache.take();
   101     setMaxGpuCacheSize(GPU_CACHE_SIZE);
    99     setMaxGpuCacheSize(GPU_CACHE_SIZE);
   109   Destructor
   107   Destructor
   110 */
   108 */
   111 HbThemeServerPrivate::~HbThemeServerPrivate()
   109 HbThemeServerPrivate::~HbThemeServerPrivate()
   112 {
   110 {
   113     server->close();
   111     server->close();
   114     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.
   112     // QLocalServer should be deleted first before deleting Server data
       
   113     // so all sessions will be cleaned up first.
       
   114     delete server;
   115     delete iconCache;
   115     delete iconCache;
   116     delete cssCache;
   116     delete cssCache;
   117 }
   117 }
   118 
   118 
   119 /*!
   119 /*!
   165   \fn HbThemeServerPrivate::insertIconCacheItem()
   165   \fn HbThemeServerPrivate::insertIconCacheItem()
   166   Insert item into the icon cache
   166   Insert item into the icon cache
   167   \a key denotes the unique identifier for the cache item that is to be inserted into the cache.
   167   \a key denotes the unique identifier for the cache item that is to be inserted into the cache.
   168   \a item denotes the cache item that is to be inserted
   168   \a item denotes the cache item that is to be inserted
   169 */
   169 */
   170 bool HbThemeServerPrivate::insertIconCacheItem(const HbIconKey &key,  HbIconCacheItem *item)
   170 bool HbThemeServerPrivate::insertIconCacheItem(const HbIconKey &key, HbIconCacheItem *item)
   171 {
   171 {
   172     return (iconCache->insert(key, item));
   172     return (iconCache->insert(key, item));
   173 }
   173 }
   174 
   174 
   175 /*!
   175 /*!
   176   \fn HbThemeServerPrivate::insertCssCacheItem()
   176   \fn HbThemeServerPrivate::insertCssCacheItem()
   177   Insert item into the css cache
   177   Insert item into the css cache
   178   \a key denotes the unique identifier for the cache item that is to be inserted into the cache.
   178   \a key denotes the unique identifier for the cache item that is to be inserted into the cache.
   179   \a item denotes the cache item that is to be inserted
   179   \a item denotes the cache item that is to be inserted
   180 */
   180 */
   181 bool HbThemeServerPrivate::insertCssCacheItem(const QString &key,  HbCacheItem *item)
   181 bool HbThemeServerPrivate::insertCssCacheItem(const QString &key, HbCacheItem *item)
   182 {
   182 {
   183     return (cssCache->insert(key, item));
   183     return (cssCache->insert(key, item));
   184 }
   184 }
   185 
   185 
   186 /*!
   186 /*!
   329 
   329 
   330         return;
   330         return;
   331     }
   331     }
   332 
   332 
   333     // Else delete only specified files
   333     // Else delete only specified files
   334     for (int i=0; i<fileNames.count();i++) {
   334     for (int i = 0; i < fileNames.count(); i++) {
   335         QString filename = fileNames.at(i);
   335         QString filename = fileNames.at(i);
   336 
   336 
   337         // Stylesheet
   337         // Stylesheet
   338         if (themePriorityItems.contains(filename)) {
   338         if (themePriorityItems.contains(filename)) {
   339             cssCache->cacheHandle().remove(filename);
   339             cssCache->cacheHandle().remove(filename);
   349             break;
   349             break;
   350         }
   350         }
   351 
   351 
   352         // Icon
   352         // Icon
   353         QVector<const HbIconKey *> keys = iconCache->getKeys(filename);
   353         QVector<const HbIconKey *> keys = iconCache->getKeys(filename);
   354         for (int j = 0; j<keys.count();j++) {
   354         for (int j = 0; j < keys.count(); j++) {
   355             HbThemeServerSession *session;
   355             HbThemeServerSession *session;
   356             foreach(session, sessionList) {
   356             foreach(session, sessionList) {
   357                 session->removeSessionIconItem(*keys.at(j));
   357                 session->removeSessionIconItem(*keys.at(j));
   358             }
   358             }
   359             iconCache->remove(*keys.at(j),false);
   359             iconCache->remove(*keys.at(j), false);
   360         }
   360         }
   361     }
   361     }
   362 }
   362 }
   363 
   363 
   364 /*!
   364 /*!
   431 }
   431 }
   432 
   432 
   433 void HbThemeServerPrivate::clienDisconnected()
   433 void HbThemeServerPrivate::clienDisconnected()
   434 {
   434 {
   435 #ifdef THEME_SERVER_TRACES
   435 #ifdef THEME_SERVER_TRACES
   436     qDebug()<<"Total No of Connection after deletion = "<<sessionList.count();
   436     qDebug() << "Total No of Connection after deletion = " << sessionList.count();
   437 #endif
   437 #endif
   438 
   438 
   439     // Quit the server if no more clients connected
   439     // Quit the server if no more clients connected
   440     if (!HbThemeServerApplication::Options::persistent && sessionList.isEmpty()) {
   440     if (!HbThemeServerApplication::Options::persistent && sessionList.isEmpty()) {
   441 #ifdef THEME_SERVER_TRACES
   441 #ifdef THEME_SERVER_TRACES
   552   \class HbThemeServerSession
   552   \class HbThemeServerSession
   553   \brief HbThemeServerSession implements the sessions associated with the server.
   553   \brief HbThemeServerSession implements the sessions associated with the server.
   554   The Theme server maintains a list of sessions, each session corresponding to a client.
   554   The Theme server maintains a list of sessions, each session corresponding to a client.
   555   Each session in turn is responsible for keeping track of client specific resources.
   555   Each session in turn is responsible for keeping track of client specific resources.
   556   In case of Icon caching, a session maintains a list of Icon keys.
   556   In case of Icon caching, a session maintains a list of Icon keys.
   557   A  key is added to the list only if the corresponding cache item has been successfully inserted into cache
   557   A  key is added to the list only if the corresponding cache item
   558   or if a previously cached icon is requested and successfully found in the cache.
   558   has been successfully inserted into cache or if a previously cached icon
       
   559   is requested and successfully found in the cache.
   559   In case of client crash or graceful exit of client, the server goes through its list of sessions,
   560   In case of client crash or graceful exit of client, the server goes through its list of sessions,
   560   finds the session corresponding to the client, removes the session from its session list and deletes the session.
   561   finds the session corresponding to the client, removes the session from its session list and
       
   562   deletes the session.
   561   In the session destructor, the session specific resources are cleaned up.
   563   In the session destructor, the session specific resources are cleaned up.
   562   In case of icon caching, the list of icon keys is traversed and a remove operation is performed on the cache
   564   In case of icon caching, the list of icon keys is traversed and a remove operation is
   563   items corresponding to these keys. On removal, the items reference count is decremented and in case the
   565   performed on the cache items corresponding to these keys.
       
   566   On removal, the items reference count is decremented and in case the
   564   reference count becomes 0, the cache item instance gets added to the back of the LRU list.
   567   reference count becomes 0, the cache item instance gets added to the back of the LRU list.
   565 
   568 
   566 */
   569 */
   567 
   570 
   568 /*!
   571 /*!
   569   \fn HbThemeServerSession::HbThemeServerSession()
   572   \fn HbThemeServerSession::HbThemeServerSession()
   570   Constructor
   573   Constructor
   571   \a aClientConnection indicates the local socket that is contained within this session
   574   \a aClientConnection indicates the local socket that is contained within this session
   572   \a aServer denotes the handle to the theme server
   575   \a aServer denotes the handle to the theme server
   573 */
   576 */
   574 HbThemeServerSession::HbThemeServerSession(QLocalSocket *aClientConnection, HbThemeServerPrivate *aServer)
   577 HbThemeServerSession::HbThemeServerSession(QLocalSocket *aClientConnection,
       
   578                                            HbThemeServerPrivate *aServer)
   575 {
   579 {
   576     iServer = aServer;
   580     iServer = aServer;
   577     iClientConnection = aClientConnection;
   581     iClientConnection = aClientConnection;
   578     sessionIconData.clear();
   582     sessionIconData.clear();
   579     sessionCssData.clear();
   583     sessionCssData.clear();
   627     qDebug() << Q_FUNC_INFO;
   631     qDebug() << Q_FUNC_INFO;
   628 #endif
   632 #endif
   629     HbSharedIconInfo data;
   633     HbSharedIconInfo data;
   630     data.type = INVALID_FORMAT;
   634     data.type = INVALID_FORMAT;
   631     HbThemeServerRequest requestType;
   635     HbThemeServerRequest requestType;
   632     QByteArray inputByteArray = ((QLocalSocket *)sender())->readAll();
   636     QByteArray inputByteArray = static_cast<QLocalSocket *>(sender())->readAll();
   633     if (inputByteArray.size() > 0) {
   637     if (inputByteArray.size() > 0) {
   634         QDataStream inputDataStream(inputByteArray);
   638         QDataStream inputDataStream(inputByteArray);
   635         int clue;
   639         int clue;
   636         inputDataStream >> clue;
   640         inputDataStream >> clue;
   637         requestType = (HbThemeServerRequest)clue;
   641         requestType = (HbThemeServerRequest)clue;
   642 
   646 
   643 //Debug Code for Test Purpose
   647 //Debug Code for Test Purpose
   644 #ifdef HB_ICON_CACHE_DEBUG
   648 #ifdef HB_ICON_CACHE_DEBUG
   645         QByteArray outputByteArray;
   649         QByteArray outputByteArray;
   646         QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
   650         QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
   647         outputDataStream << (int)requestType;
   651         outputDataStream << int(requestType);
   648 #endif
   652 #endif
   649         switch (requestType) {
   653         switch (requestType) {
   650         case EStyleSheetLookup: {
   654         case EStyleSheetLookup: {
   651             QString fileName;
   655             QString fileName;
   652             int priority;
   656             int priority;
   653             HbLayeredStyleLoader::LayerPriority layerdPriority;
   657             HbLayeredStyleLoader::LayerPriority layerPriority;
   654             inputDataStream >> fileName;
   658             inputDataStream >> fileName;
   655             inputDataStream >> priority;
   659             inputDataStream >> priority;
   656             layerdPriority = (HbLayeredStyleLoader::LayerPriority) priority;
   660             layerPriority = static_cast<HbLayeredStyleLoader::LayerPriority>(priority);
   657             QByteArray output = handleStyleSheetLookup((int) requestType, fileName, layerdPriority);
   661             QByteArray output = handleStyleSheetLookup(int(requestType), fileName, layerPriority);
   658             ((QLocalSocket *)sender())->write(output);
   662             static_cast<QLocalSocket *>(sender())->write(output);
   659             break;
   663             break;
   660         }
   664         }
   661         case EWidgetMLLookup: {
   665         case EWidgetMLLookup: {
   662             QString filename;
   666             QString filename;
   663             QString section;
   667             QString section;
   666             inputDataStream >> filename;
   670             inputDataStream >> filename;
   667             inputDataStream >> layout;
   671             inputDataStream >> layout;
   668             inputDataStream >> section;
   672             inputDataStream >> section;
   669             // handle the shared Widgetml look up.
   673             // handle the shared Widgetml look up.
   670             QByteArray output = iServer->handleSharedWidgetMLLookup(filename, layout, section);
   674             QByteArray output = iServer->handleSharedWidgetMLLookup(filename, layout, section);
   671             ((QLocalSocket *)sender())->write(output);
   675             static_cast<QLocalSocket *>(sender())->write(output);
   672             break;
   676             break;
   673         }
   677         }
   674         case EDeviceProfileOffset: {
   678         case EDeviceProfileOffset: {
   675             int offset = -1;
   679             int offset = -1;
   676             HbDeviceProfileDatabase *deviceProfileDatabase =
   680             HbDeviceProfileDatabase *deviceProfileDatabase =
   682             // offset will be -1 if the deviceProfileDatabase is NULL.
   686             // offset will be -1 if the deviceProfileDatabase is NULL.
   683             QByteArray outputByteArray;
   687             QByteArray outputByteArray;
   684             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
   688             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
   685             outputDataStream << requestType;
   689             outputDataStream << requestType;
   686             outputDataStream << offset;
   690             outputDataStream << offset;
   687             ((QLocalSocket *)sender())->write(outputByteArray);
   691             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
   688             break;
   692             break;
   689         }
   693         }
   690         case EEffectLookupFilePath:
   694         case EEffectLookupFilePath:
   691         case EEffectAdd: {
   695         case EEffectAdd: {
   692             QString fileName;
   696             QString fileName;
   693             inputDataStream >> fileName;
   697             inputDataStream >> fileName;
   694             QByteArray output = iServer->handleSharedEffectAddAndFileLookup((int) requestType, fileName);
   698             QByteArray output = iServer->handleSharedEffectAddAndFileLookup((int) requestType, fileName);
   695             ((QLocalSocket *)sender())->write(output);
   699             static_cast<QLocalSocket *>(sender())->write(output);
   696             break;
   700             break;
   697         }
   701         }
   698         case EThemeSelection: {
   702         case EThemeSelection: {
   699             QString themename;
   703             QString themename;
   700             QLocalSocket *themeSelectionClient = (QLocalSocket *)sender();
   704             QLocalSocket *themeSelectionClient = static_cast<QLocalSocket *>(sender());
   701             inputDataStream >> themename;
   705             inputDataStream >> themename;
   702             iServer->setThemeSelectionClient(themeSelectionClient);
   706             iServer->setThemeSelectionClient(themeSelectionClient);
   703             iServer->handleThemeSelection(themename);
   707             iServer->handleThemeSelection(themename);
   704             break;
   708             break;
   705         }
   709         }
   708             inputDataStream >> themedItems;
   712             inputDataStream >> themedItems;
   709             iServer->handleContentUpdate(themedItems);
   713             iServer->handleContentUpdate(themedItems);
   710             HbThemeServerRequest requestType = EThemeContentUpdate;
   714             HbThemeServerRequest requestType = EThemeContentUpdate;
   711             QByteArray block;
   715             QByteArray block;
   712             QDataStream out(&block, QIODevice::WriteOnly);
   716             QDataStream out(&block, QIODevice::WriteOnly);
   713             out << (int)requestType;
   717             out << int(requestType);
   714             out << themedItems;
   718             out << themedItems;
   715             iServer->writeToClients(block);
   719             iServer->writeToClients(block);
   716             break;
   720             break;
   717         }
   721         }
   718         case EThemeServerStop: {
   722         case EThemeServerStop: {
   719             //This segment is used by HbThemeApiWrapperUi.
   723             //This segment is used by HbThemeApiWrapperUi.
   720             //When no HbApplication is open and HbThemeserver has only HbThemeApiWrapperUi as client, making sessionListCount =1
   724             //When no HbApplication is open and
       
   725             // HbThemeserver has only HbThemeApiWrapperUi as client, making sessionListCount =1
   721             //HbThemeserver is closed otherwise warning is shown.
   726             //HbThemeserver is closed otherwise warning is shown.
   722             //QCoreApplication::quit() removes the UI of HbThemeServer. Destructor of HbThemeServer will be called where it was instantiated.
   727             //QCoreApplication::quit() removes the UI of HbThemeServer.
       
   728             // Destructor of HbThemeServer will be called where it was instantiated.
   723             if (iServer->sessionListCount() == 1) {
   729             if (iServer->sessionListCount() == 1) {
   724 #ifdef QT_DEBUG
   730 #ifdef QT_DEBUG
   725                 iServer->close();
   731                 iServer->close();
   726 #endif
   732 #endif
   727                 ((QLocalSocket *)sender())->disconnectFromServer();
   733                 static_cast<QLocalSocket *>(sender())->disconnectFromServer();
   728                 QCoreApplication::quit();
   734                 QCoreApplication::quit();
   729             } else {
   735             } else {
   730                 qWarning() << "Close all HbApplications before closing hbthemeserver!!";
   736                 qWarning() << "Close all HbApplications before closing hbthemeserver!!";
   731             }
   737             }
   732             break;
   738             break;
   748             inputDataStream >> color;
   754             inputDataStream >> color;
   749 
   755 
   750 #ifdef THEME_SERVER_TRACES
   756 #ifdef THEME_SERVER_TRACES
   751             qDebug() << "image req at server: " << filename;
   757             qDebug() << "image req at server: " << filename;
   752 #endif
   758 #endif
   753 			HbIconKey key(filename, size, (Qt::AspectRatioMode)aspectRatioMode, (QIcon::Mode)mode, mirrored, color, iServer->currentRenderingMode());
   759             HbIconKey key(filename, size, static_cast<Qt::AspectRatioMode>(aspectRatioMode),
       
   760                           static_cast<QIcon::Mode>(mode), mirrored, color,
       
   761                           iServer->currentRenderingMode());
   754             QByteArray output = handleIconLookup(key, data, options);
   762             QByteArray output = handleIconLookup(key, data, options);
   755             ((QLocalSocket *)sender())->write(output);
   763             static_cast<QLocalSocket *>(sender())->write(output);
   756             break;
   764             break;
   757         }
   765         }
   758         case EIconDefaultSize:
   766         case EIconDefaultSize:
   759             break; //todo
   767             break; //todo
   760         case EMultiPieceIcon: {
   768         case EMultiPieceIcon: {
   761             HbMultiIconParams frameItemParams;
   769             HbMultiIconParams frameItemParams;
   762             inputDataStream >> frameItemParams.multiPartIconList;
   770             inputDataStream >> frameItemParams.multiPartIconList;
   763             inputDataStream >> frameItemParams.multiPartIconData.multiPartIconId;
   771             inputDataStream >> frameItemParams.multiPartIconData.multiPartIconId;
   764 
   772 
   765             int noOfPieces = 1;
   773             int noOfPieces = 1;
   766             if (frameItemParams.multiPartIconData.multiPartIconId.contains("_3PV", Qt::CaseInsensitive) ||
   774             if (frameItemParams.multiPartIconData.multiPartIconId.contains("_3PV", Qt::CaseInsensitive)
   767                     frameItemParams.multiPartIconData.multiPartIconId.contains("_3PH", Qt::CaseInsensitive)) {
   775                 || frameItemParams.multiPartIconData.multiPartIconId.contains("_3PH", Qt::CaseInsensitive)) {
   768                 noOfPieces = 3;
   776                 noOfPieces = 3;
   769             } else if (frameItemParams.multiPartIconData.multiPartIconId.contains("_9P", Qt::CaseInsensitive)) {
   777             } else if (frameItemParams.multiPartIconData.multiPartIconId.contains("_9P", Qt::CaseInsensitive)) {
   770                 noOfPieces = 9;
   778                 noOfPieces = 9;
   771             }
   779             }
   772 
       
   773             for (int i = 0; i < noOfPieces; i++) {
   780             for (int i = 0; i < noOfPieces; i++) {
   774                 inputDataStream >> frameItemParams.multiPartIconData.sources[i];
   781                 inputDataStream >> frameItemParams.multiPartIconData.sources[i];
   775             }
   782             }
   776 
   783 
   777             for (int i = 0; i < noOfPieces; i++) {
   784             for (int i = 0; i < noOfPieces; i++) {
   790             inputDataStream >> frameItemParams.color;
   797             inputDataStream >> frameItemParams.color;
   791 
   798 
   792 #ifdef THEME_SERVER_TRACES
   799 #ifdef THEME_SERVER_TRACES
   793             qDebug() << "image req at server: " << frameItemParams.multiPartIconList;
   800             qDebug() << "image req at server: " << frameItemParams.multiPartIconList;
   794 #endif
   801 #endif
   795 
   802             int index = frameItemParams.multiPartIconList[0].lastIndexOf('/');
   796             int index = frameItemParams.multiPartIconList[0].lastIndexOf("/");
       
   797             QString iconId = frameItemParams.multiPartIconList[0].left(index + 1);
   803             QString iconId = frameItemParams.multiPartIconList[0].left(index + 1);
   798             HbSharedIconInfo stitchedData;
   804             HbSharedIconInfo stitchedData;
   799             QT_TRY {
   805             QT_TRY {
   800                 iconId.append(frameItemParams.multiPartIconData.multiPartIconId);
   806                 iconId.append(frameItemParams.multiPartIconData.multiPartIconId);
   801                 HbIconKey finalIconKey(iconId, frameItemParams.size,
   807                 HbIconKey finalIconKey(iconId, frameItemParams.size,
   802                                        (Qt::AspectRatioMode)frameItemParams.aspectRatioMode,
   808                     static_cast<Qt::AspectRatioMode>(frameItemParams.aspectRatioMode),
   803                                        (QIcon::Mode)frameItemParams.mode, frameItemParams.mirrored,
   809                     static_cast<QIcon::Mode>(frameItemParams.mode),
   804 									   frameItemParams.color, (HbRenderingMode)frameItemParams.renderMode);
   810                     frameItemParams.mirrored,
       
   811                     frameItemParams.color,
       
   812                     static_cast<HbRenderingMode>(frameItemParams.renderMode));
   805 
   813 
   806                 stitchedData.type = INVALID_FORMAT;
   814                 stitchedData.type = INVALID_FORMAT;
   807 
   815 
   808                 if (!iconInfoFromSingleIcon(finalIconKey, stitchedData)) {
   816                 if (!iconInfoFromSingleIcon(finalIconKey, stitchedData)) {
   809                     iconInfoFromMultiParts(frameItemParams, noOfPieces, finalIconKey, stitchedData);
   817                     iconInfoFromMultiParts(frameItemParams, noOfPieces, finalIconKey, stitchedData);
   816             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
   824             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
   817             HbThemeServerRequest request;
   825             HbThemeServerRequest request;
   818             request = EMultiPieceIcon;
   826             request = EMultiPieceIcon;
   819             fillOutPutDataStream(outputDataStream, stitchedData, request);
   827             fillOutPutDataStream(outputDataStream, stitchedData, request);
   820 #ifdef THEME_SERVER_TRACES
   828 #ifdef THEME_SERVER_TRACES
   821             qDebug() << Q_FUNC_INFO << " offset= " << stitchedData.pixmapData.offset << " format= " << stitchedData.pixmapData.format;
   829             qDebug() << Q_FUNC_INFO << " offset= " << stitchedData.pixmapData.offset
       
   830                      << " format= " << stitchedData.pixmapData.format;
   822             testLabel->setPixmap(QPixmap::fromImage(
   831             testLabel->setPixmap(QPixmap::fromImage(
   823                                      QImage(
   832                 QImage(HbMemoryUtils::getAddress<uchar>(HbMemoryManager::SharedMemory,
   824                                          HbMemoryUtils::getAddress<uchar>(HbMemoryManager::SharedMemory, stitchedData.pixmapData.offset),
   833                                                         stitchedData.pixmapData.offset),
   825                                          stitchedData.pixmapData.width,
   834                        stitchedData.pixmapData.width,
   826                                          stitchedData.pixmapData.height,
   835                        stitchedData.pixmapData.height,
   827                                          stitchedData.pixmapData.format)));
   836                        stitchedData.pixmapData.format)));
   828 #endif
   837 #endif
   829             ((QLocalSocket *)sender())->write(outputByteArray);
   838             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
   830             break;
   839             break;
   831         }
   840         }
   832         case EMultiIcon: {
   841         case EMultiIcon: {
   833             QStringList fileList;
   842             QStringList fileList;
   834             QVector<QSizeF> sizeList;
   843             QVector<QSizeF> sizeList;
   837             int mode;
   846             int mode;
   838             bool mirrored;
   847             bool mirrored;
   839             int options;
   848             int options;
   840             QColor color;
   849             QColor color;
   841             inputDataStream >> fileList;
   850             inputDataStream >> fileList;
   842             for (int i = 0; i < fileList.count(); i++) {
   851             inputDataStream >> sizeList;
   843                 inputDataStream >> size;
       
   844                 sizeList << size;
       
   845             }
       
   846             inputDataStream >> aspectRatioMode;
   852             inputDataStream >> aspectRatioMode;
   847             inputDataStream >> mode;
   853             inputDataStream >> mode;
   848             inputDataStream >> mirrored;
   854             inputDataStream >> mirrored;
   849             inputDataStream >> options;
   855             inputDataStream >> options;
   850             inputDataStream >> color;
   856             inputDataStream >> color;
   851 
   857 
   852 #ifdef THEME_SERVER_TRACES
   858 #ifdef THEME_SERVER_TRACES
   853             qDebug() << "image req at server: " << fileList;
   859             qDebug() << "image req at server: " << fileList;
   854 #endif
   860 #endif
   855             QByteArray output;
   861             QByteArray output;
       
   862             QDataStream outputDataStream(&output, QIODevice::WriteOnly);
       
   863             outputDataStream << (int)requestType; // Put EMultiIcon request type in the beginning
   856             for (int i = 0; i < fileList.count(); i++) {
   864             for (int i = 0; i < fileList.count(); i++) {
   857                 HbIconKey key(fileList[i], sizeList[i],
   865                 HbIconKey key(fileList[i], sizeList[i],
   858                               static_cast<Qt::AspectRatioMode>(aspectRatioMode),
   866                               static_cast<Qt::AspectRatioMode>(aspectRatioMode),
   859 							  static_cast<QIcon::Mode>(mode), mirrored, color, iServer->currentRenderingMode());
   867                               static_cast<QIcon::Mode>(mode), mirrored, color,
       
   868                               iServer->currentRenderingMode());
   860                 output.append(handleIconLookup(key, data, options));
   869                 output.append(handleIconLookup(key, data, options));
   861             }
   870             }
   862 
   871 
   863             ((QLocalSocket *)sender())->write(output);
   872             static_cast<QLocalSocket *>(sender())->write(output);
   864 
       
   865             break;
   873             break;
   866         }
   874         }
   867         case ENotifyForegroundLost: {
   875         case ENotifyForegroundLost: {
   868             //Nothing to do here when the app notifies it's foreground lost event
   876             //Nothing to do here when the app notifies it's foreground lost event
   869             break;
   877             break;
   871         //Debug Code for Test Purpose
   879         //Debug Code for Test Purpose
   872 #ifdef HB_ICON_CACHE_DEBUG
   880 #ifdef HB_ICON_CACHE_DEBUG
   873         case ECacheIconCount: {
   881         case ECacheIconCount: {
   874             int count = iServer->cacheIconCount();
   882             int count = iServer->cacheIconCount();
   875             outputDataStream << count;
   883             outputDataStream << count;
   876             ((QLocalSocket *)sender())->write(outputByteArray);
   884             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
   877             break;
   885             break;
   878         }
   886         }
   879         case ERasterMemLimit: {
   887         case ERasterMemLimit: {
   880             int limit;
   888             int limit;
   881             inputDataStream >> limit;
   889             inputDataStream >> limit;
   889             break;
   897             break;
   890         }
   898         }
   891         case EFreeRasterMem: {
   899         case EFreeRasterMem: {
   892             int freeRastMem = iServer->freeRasterMemory();
   900             int freeRastMem = iServer->freeRasterMemory();
   893             outputDataStream << freeRastMem;
   901             outputDataStream << freeRastMem;
   894             ((QLocalSocket *)sender())->write(outputByteArray);
   902             static_cast<QLocalSocket *>sender())->write(outputByteArray);
   895             break;
   903             break;
   896         }
   904         }
   897         case EFreeVectorMem: {
   905         case EFreeVectorMem: {
   898             int freeVectMem = iServer->freeVectorMemory();
   906             int freeVectMem = iServer->freeVectorMemory();
   899             outputDataStream << freeVectMem;
   907             outputDataStream << freeVectMem;
   900             ((QLocalSocket *)sender())->write(outputByteArray);
   908             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
   901             break;
   909             break;
   902         }
   910         }
   903         case ELastAddedItemMem {
   911         case ELastAddedItemMem {
   904                 int lAddItemMem = iServer->lastAddedItemMem();
   912             int lAddItemMem = iServer->lastAddedItemMem();
   905                 outputDataStream << lAddItemMem;
   913             outputDataStream << lAddItemMem;
   906                 ((QLocalSocket *)sender())->write(outputByteArray);
   914             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
   907                 break;
   915             break;
   908             }
   916         }
   909         case ELastRemovedItemMem {
   917         case ELastRemovedItemMem {
   910                 int lRemItemMem = iServer->lastRemovedItemMem();
   918             int lRemItemMem = iServer->lastRemovedItemMem();
   911                 outputDataStream << lRemItemMem;
   919             outputDataStream << lRemItemMem;
   912                 ((QLocalSocket *)sender())->write(outputByteArray);
   920             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
   913                 break;
   921             break;
   914             }
   922         }
   915         case ELastRemovedItemRefCount: {
   923         case ELastRemovedItemRefCount: {
   916                 int lRemItemRfCnt = iServer->lastRemovedItemRfCount();
   924             int lRemItemRfCnt = iServer->lastRemovedItemRfCount();
   917                 outputDataStream << lRemItemRfCnt;
   925             outputDataStream << lRemItemRfCnt;
   918                 ((QLocalSocket *)sender())->write(outputByteArray);
   926             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
   919                 break;
   927             break;
   920             }
   928         }
   921         case ELastAddedItemRefCount: {
   929         case ELastAddedItemRefCount: {
   922                 int lAddItemRfCnt = iServer->lastAddedRefCount();
   930             int lAddItemRfCnt = iServer->lastAddedRefCount();
   923                 outputDataStream << lAddItemRfCnt;
   931             outputDataStream << lAddItemRfCnt;
   924                 ((QLocalSocket *)sender())->write(outputByteArray);
   932             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
   925                 break;
   933             break;
   926             }
   934         }
   927         case EEnableCache: {
   935         case EEnableCache: {
   928                 int enable ;
   936             int enable ;
   929                 inputDataStream >> enable;
   937             inputDataStream >> enable;
   930                 bool success = iServer->enableCache(enable);
   938             bool success = iServer->enableCache(enable);
   931                 outputDataStream << (int)success;
   939             outputDataStream << (int)success;
   932                 ((QLocalSocket *)sender())->write(outputByteArray);
   940             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
   933                 break;
   941             break;
   934             }
   942         }
   935         case ECacheHit: {
   943         case ECacheHit: {
   936                 int cacheHitCnt = iServer->cacheHitCount();
   944             int cacheHitCnt = iServer->cacheHitCount();
   937                 outputDataStream << cacheHitCnt;
   945             outputDataStream << cacheHitCnt;
   938                 ((QLocalSocket *)sender())->write(outputByteArray);
   946             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
   939                 break;
   947             break;
   940             }
   948         }
   941         case ECacheMiss: {
   949         case ECacheMiss: {
   942                 int cacheMissCnt = iServer->cacheMissCount();
   950             int cacheMissCnt = iServer->cacheMissCount();
   943                 outputDataStream << cacheMissCnt;
   951             outputDataStream << cacheMissCnt;
   944                 ((QLocalSocket *)sender())->write(outputByteArray);
   952             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
   945                 break;
   953             break;
   946             }
   954         }
   947         case ECleanRasterLRUList: {
   955         case ECleanRasterLRUList: {
   948                 iServer->cleanRasterLRUList();
   956             iServer->cleanRasterLRUList();
   949                 break;
   957             break;
   950             }
   958         }
   951         case ECleanVectorLRUList: {
   959         case ECleanVectorLRUList: {
   952                 iServer->cleanVectorLRUList();
   960             iServer->cleanVectorLRUList();
   953                 break;
   961             break;
   954             }
   962         }
   955         case EGpuLruCount: {
   963         case EGpuLruCount: {
   956                 int rasterLruCount = iServer->rasterLruCount();
   964             int rasterLruCount = iServer->rasterLruCount();
   957                 outputDataStream << rasterLruCount;
   965             outputDataStream << rasterLruCount;
   958                 ((QLocalSocket *)sender())->write(outputByteArray);
   966             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
   959                 break;
   967             break;
   960             }
   968         }
   961         case ECpuLruCount: {
   969         case ECpuLruCount: {
   962                 int vectorLruCount = iServer->vectorLruCount();
   970             int vectorLruCount = iServer->vectorLruCount();
   963                 outputDataStream << vectorLruCount;
   971             outputDataStream << vectorLruCount;
   964                 ((QLocalSocket *)sender())->write(outputByteArray);
   972             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
   965                 break;
   973             break;
   966             }
   974         }
   967         case EServerHeap: {
   975         case EServerHeap: {
   968             }
   976         }
   969 #endif
   977 #endif
   970 #ifdef HB_THEME_SERVER_MEMORY_REPORT
   978 #ifdef HB_THEME_SERVER_MEMORY_REPORT
   971         case ECreateMemoryReport: {
   979         case ECreateMemoryReport: {
   972                 GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory);
   980             GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory);
   973                 static_cast<HbSharedMemoryManager *>(manager)->createReport();
   981             static_cast<HbSharedMemoryManager *>(manager)->createReport();
   974                 break;
   982             break;
   975             }
   983         }
   976 #endif
   984 #endif
   977         case EUnloadIcon: {
   985         case EUnloadIcon: {
   978                 QString filename;
   986             QString filename;
   979                 QSizeF size;
   987             QSizeF size;
   980                 int aspectRatioMode;
   988             int aspectRatioMode;
   981                 int mode;
   989             int mode;
   982                 bool mirrored;
   990             bool mirrored;
   983                 int options;
   991             int options;
   984                 QColor color;
   992             QColor color;
   985                 inputDataStream >> filename;
   993             inputDataStream >> filename;
   986                 inputDataStream >> size;
   994             inputDataStream >> size;
   987                 inputDataStream >> aspectRatioMode;
   995             inputDataStream >> aspectRatioMode;
   988                 inputDataStream >> mode;
   996             inputDataStream >> mode;
   989                 inputDataStream >> mirrored;
   997             inputDataStream >> mirrored;
   990                 inputDataStream >> options;
   998             inputDataStream >> options;
   991                 inputDataStream >> color;
   999             inputDataStream >> color;
   992 
  1000 
   993                 HbIconKey key(filename, size, (Qt::AspectRatioMode)aspectRatioMode,
  1001             HbIconKey key(filename, size,
   994 					(QIcon::Mode)mode, mirrored, color, iServer->currentRenderingMode());
  1002                           static_cast<Qt::AspectRatioMode>(aspectRatioMode),
   995                 iServer->removeIconCacheItem(key);
  1003                           static_cast<QIcon::Mode>(mode), mirrored, color,
   996                 sessionIconData.removeOne(key);
  1004                           iServer->currentRenderingMode());
   997                 QByteArray outputByteArray;
  1005             iServer->removeIconCacheItem(key);
   998                 QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
  1006             sessionIconData.removeOne(key);
   999                 outputDataStream << (int)requestType;
  1007             QByteArray outputByteArray;
  1000                 ((QLocalSocket *)sender())->write(outputByteArray);
  1008             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
  1001                 break;
  1009             outputDataStream << int(requestType);
  1002             }
  1010             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
       
  1011             break;
       
  1012         }
  1003         case EFreeSharedMem: {
  1013         case EFreeSharedMem: {
  1004             int freeSharedMem = iServer->freeSharedMemory();
  1014             int freeSharedMem = iServer->freeSharedMemory();
  1005             QByteArray outputByteArray;
  1015             QByteArray outputByteArray;
  1006             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
  1016             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
  1007             outputDataStream << requestType;
  1017             outputDataStream << requestType;
  1008             outputDataStream << freeSharedMem;
  1018             outputDataStream << freeSharedMem;
  1009             ((QLocalSocket *)sender())->write(outputByteArray);
  1019             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
  1010             break;
  1020             break;
  1011         }
  1021         }
  1012         case EAllocatedSharedMem: {
  1022         case EAllocatedSharedMem: {
  1013             int allocatedSharedMem = iServer->allocatedSharedMemory();
  1023             int allocatedSharedMem = iServer->allocatedSharedMemory();
  1014             QByteArray outputByteArray;
  1024             QByteArray outputByteArray;
  1015             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
  1025             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
  1016             outputDataStream << requestType;
  1026             outputDataStream << requestType;
  1017             outputDataStream << allocatedSharedMem;
  1027             outputDataStream << allocatedSharedMem;
  1018             ((QLocalSocket *)sender())->write(outputByteArray);
  1028             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
  1019             break;
  1029             break;
  1020         }
  1030         }
  1021 
       
  1022         case ETypefaceOffset: {
  1031         case ETypefaceOffset: {
  1023             int offset = -1;
  1032             int offset = -1;
  1024             HbTypefaceInfoDatabase *typefaceDatabase =
  1033             HbTypefaceInfoDatabase *typefaceDatabase =
  1025                 HbTypefaceInfoDatabase::instance(HbMemoryManager::SharedMemory);
  1034                 HbTypefaceInfoDatabase::instance(HbMemoryManager::SharedMemory);
  1026 
  1035 
  1030             // offset will be -1 if the typefaceDatabase is NULL.
  1039             // offset will be -1 if the typefaceDatabase is NULL.
  1031             QByteArray outputByteArray;
  1040             QByteArray outputByteArray;
  1032             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
  1041             QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
  1033             outputDataStream << requestType;
  1042             outputDataStream << requestType;
  1034             outputDataStream << offset;
  1043             outputDataStream << offset;
  1035             ((QLocalSocket *)sender())->write(outputByteArray);
  1044             static_cast<QLocalSocket *>(sender())->write(outputByteArray);
  1036             break;
  1045             break;
  1037         }
  1046         }
  1038 
       
  1039 
       
  1040         default:
  1047         default:
  1041             break;
  1048             break;
  1042         }
  1049         }
  1043     }
  1050     }
  1044 }
  1051 }
  1050 
  1057 
  1051 bool HbThemeServerSession::iconInfoFromSingleIcon(HbIconKey key,
  1058 bool HbThemeServerSession::iconInfoFromSingleIcon(HbIconKey key,
  1052         HbSharedIconInfo &stitchedData)
  1059         HbSharedIconInfo &stitchedData)
  1053 {
  1060 {
  1054     stitchedData.type = INVALID_FORMAT;
  1061     stitchedData.type = INVALID_FORMAT;
  1055     HbIconCacheItem * cacheItem = iServer->iconCacheItem(key);
  1062     HbIconCacheItem *cacheItem = iServer->iconCacheItem(key);
  1056     if (cacheItem) {
  1063     if (cacheItem) {
  1057         getDataFromCacheItem(cacheItem, stitchedData);
  1064         getDataFromCacheItem(cacheItem, stitchedData);
  1058         return true;
  1065         return true;
  1059     }
  1066     }
  1060     return false;
  1067     return false;
  1063 /*!
  1070 /*!
  1064   \fn HbThemeServerSession::createCacheItemData()
  1071   \fn HbThemeServerSession::createCacheItemData()
  1065   Creates a cacheItem of the given key and insert the item in to the list
  1072   Creates a cacheItem of the given key and insert the item in to the list
  1066   else free the data allocated for the cache..
  1073   else free the data allocated for the cache..
  1067 */
  1074 */
  1068 bool HbThemeServerSession::createCacheItemData(HbIconKey key, int options , HbSharedIconInfo &data)
  1075 bool HbThemeServerSession::createCacheItemData(HbIconKey key, int options, HbSharedIconInfo &data)
  1069 {
  1076 {
  1070     HbIconCacheItem * cacheItemOfPiece = iServer->iconCacheItem(key);
  1077     HbIconCacheItem *cacheItemOfPiece = iServer->iconCacheItem(key);
  1071     if (cacheItemOfPiece) {
  1078     if (cacheItemOfPiece) {
  1072         return true;
  1079         return true;
  1073     }
  1080     }
  1074 
  1081 
  1075     QScopedPointer <HbIconCacheItem> tempIconCacheItem;
  1082     QScopedPointer<HbIconCacheItem> tempIconCacheItem;
  1076     bool insertKeyIntoSessionList = false;
  1083     bool insertKeyIntoSessionList = false;
  1077     data.type = INVALID_FORMAT;
  1084     data.type = INVALID_FORMAT;
  1078     QString format = HbThemeServerUtils::formatFromPath(key.filename);
  1085     QString format = HbThemeServerUtils::formatFromPath(key.filename);
  1079 
  1086 
  1080     tempIconCacheItem.reset(HbIconCacheItemCreator::createCacheItem(key,
  1087     tempIconCacheItem.reset(HbIconCacheItemCreator::createCacheItem(key,
  1081                             (HbIconLoader::IconLoaderOptions)options,
  1088                             static_cast<HbIconLoader::IconLoaderOptions>(options),
  1082                             format,
  1089                             format, iServer->currentRenderingMode(), false));
  1083 							iServer->currentRenderingMode(),
       
  1084                             false));
       
  1085     cacheItemOfPiece = tempIconCacheItem.data();
  1090     cacheItemOfPiece = tempIconCacheItem.data();
  1086     if (cacheItemOfPiece) {
  1091     if (cacheItemOfPiece) {
  1087         getDataFromCacheItem(cacheItemOfPiece, data);
  1092         getDataFromCacheItem(cacheItemOfPiece, data);
  1088         if (data.type != INVALID_FORMAT) {
  1093         if (data.type != INVALID_FORMAT) {
  1089             insertKeyIntoSessionList = iServer->insertIconCacheItem(key, cacheItemOfPiece);
  1094             insertKeyIntoSessionList = iServer->insertIconCacheItem(key, cacheItemOfPiece);
  1103   Creates a consolidated icon of the available piece iconInfo.
  1108   Creates a consolidated icon of the available piece iconInfo.
  1104 */
  1109 */
  1105 bool HbThemeServerSession::createStichedIconInfoOfParts(QVector<HbSharedIconInfo> dataForParts, HbMultiIconParams params,
  1110 bool HbThemeServerSession::createStichedIconInfoOfParts(QVector<HbSharedIconInfo> dataForParts, HbMultiIconParams params,
  1106         HbIconKey &finalIconKey, HbSharedIconInfo &stitchedData)
  1111         HbIconKey &finalIconKey, HbSharedIconInfo &stitchedData)
  1107 {
  1112 {
  1108     HbIconCacheItem * cacheItem = iServer->iconCacheItem(finalIconKey);
  1113     HbIconCacheItem *cacheItem = iServer->iconCacheItem(finalIconKey);
  1109     if (cacheItem) {
  1114     if (cacheItem) {
  1110         return true;
  1115         return true;
  1111     }
  1116     }
  1112     bool insertKeyIntoSessionList = false;
  1117     bool insertKeyIntoSessionList = false;
  1113     stitchedData.type = INVALID_FORMAT;
  1118     stitchedData.type = INVALID_FORMAT;
  1114     QString format = HbThemeServerUtils::formatFromPath(params.multiPartIconList[0]);
  1119     QString format = HbThemeServerUtils::formatFromPath(params.multiPartIconList[0]);
  1115 
  1120 
  1116     QScopedPointer <HbPixmapIconProcessor> tempIconProcessor(new HbPixmapIconProcessor(finalIconKey,
  1121     QScopedPointer<HbPixmapIconProcessor> tempIconProcessor(new HbPixmapIconProcessor(finalIconKey,
  1117                                                 static_cast<HbIconLoader::IconLoaderOptions>(params.options), format));
  1122                                                 static_cast<HbIconLoader::IconLoaderOptions>(params.options), format));
  1118     HbPixmapIconProcessor * rasterIcon = tempIconProcessor.data();
  1123     HbPixmapIconProcessor *rasterIcon = tempIconProcessor.data();
  1119     rasterIcon->createMultiPieceIconData(dataForParts, params);
  1124     rasterIcon->createMultiPieceIconData(dataForParts, params);
  1120 
  1125 
  1121     QScopedPointer <HbIconCacheItem> tempIconCacheItem;
  1126     QScopedPointer <HbIconCacheItem> tempIconCacheItem;
  1122     tempIconCacheItem.reset(HbIconCacheItemCreator::createCacheItem(finalIconKey,
  1127     tempIconCacheItem.reset(HbIconCacheItemCreator::createCacheItem(finalIconKey,
  1123                                     static_cast<HbIconLoader::IconLoaderOptions>(params.options), format, iServer->currentRenderingMode(),false));
  1128                                     static_cast<HbIconLoader::IconLoaderOptions>(params.options), format, iServer->currentRenderingMode(),false));
  1151 {
  1156 {
  1152     QVector<HbIconKey> keysInserted;
  1157     QVector<HbIconKey> keysInserted;
  1153     QVector<HbSharedIconInfo>  dataForParts;
  1158     QVector<HbSharedIconInfo>  dataForParts;
  1154     bool insertKeyIntoSessionList = false;
  1159     bool insertKeyIntoSessionList = false;
  1155     bool failedToCreateParts = false;
  1160     bool failedToCreateParts = false;
  1156     QString format;
       
  1157     try {
  1161     try {
  1158         for (int i = 0; i < noOfPieces; i++) {
  1162         for (int i = 0; i < noOfPieces; i++) {
  1159             HbSharedIconInfo data;
  1163             HbSharedIconInfo data;
  1160             bool iconPieceMirrored = false;
  1164             bool iconPieceMirrored = false;
  1161             HbIconKey key(params.multiPartIconList.at(i), params.multiPartIconData.pixmapSizes[i],
  1165             HbIconKey key(params.multiPartIconList.at(i), params.multiPartIconData.pixmapSizes[i],
  1162                           static_cast<Qt::AspectRatioMode>(stichedKey.aspectRatioMode),
  1166                           static_cast<Qt::AspectRatioMode>(stichedKey.aspectRatioMode),
  1163 						  static_cast<QIcon::Mode>(stichedKey.mode), iconPieceMirrored, stichedKey.color,stichedKey.renderMode );
  1167                           static_cast<QIcon::Mode>(stichedKey.mode),
       
  1168                           iconPieceMirrored, stichedKey.color, stichedKey.renderMode);
  1164             insertKeyIntoSessionList = iconInfoFromSingleIcon(key, data);
  1169             insertKeyIntoSessionList = iconInfoFromSingleIcon(key, data);
  1165             if (!insertKeyIntoSessionList) {
  1170             if (!insertKeyIntoSessionList) {
  1166                 insertKeyIntoSessionList = createCacheItemData(key, params.options, data);
  1171                 insertKeyIntoSessionList = createCacheItemData(key, params.options, data);
  1167             }
  1172             }
  1168             if ((data.type == INVALID_FORMAT) || (!insertKeyIntoSessionList)) {
  1173             if ((data.type == INVALID_FORMAT) || !insertKeyIntoSessionList) {
  1169                 failedToCreateParts = true;
  1174                 failedToCreateParts = true;
  1170                 break;
  1175                 break;
  1171             } else {
  1176             } else {
  1172                 //The session will only keep track of icons that were either successfully found or were
  1177                 //The session will only keep track of icons that were either successfully found or were
  1173                 //successfully inserted in the cache.
  1178                 //successfully inserted in the cache.
  1178         }//end of for
  1183         }//end of for
  1179     } catch(std::exception &) {
  1184     } catch(std::exception &) {
  1180         failedToCreateParts = true;
  1185         failedToCreateParts = true;
  1181     }
  1186     }
  1182 
  1187 
  1183     if ((failedToCreateParts) || (dataForParts.count() != noOfPieces) || (!insertKeyIntoSessionList)) {
  1188     if (failedToCreateParts || (dataForParts.count() != noOfPieces)
  1184         //atLeast one of the icon did'nt get constructed , so move the cached piece icons to unused state and return
  1189         || !insertKeyIntoSessionList) {
       
  1190         //atLeast one of the icon did'nt get constructed ,
       
  1191         //so move the cached piece icons to unused state and return
  1185         for (int i = 0; i < keysInserted.count(); i++) {
  1192         for (int i = 0; i < keysInserted.count(); i++) {
  1186             sessionIconData.removeOne(keysInserted.at(i));
  1193             sessionIconData.removeOne(keysInserted.at(i));
  1187         }
  1194         }
  1188         dataForParts.clear();
  1195         dataForParts.clear();
  1189         stitchedData.type = INVALID_FORMAT;
  1196         stitchedData.type = INVALID_FORMAT;
  1267 
  1274 
  1268 /*!
  1275 /*!
  1269   \fn HbThemeServerSession::fillOutPutDataStream()
  1276   \fn HbThemeServerSession::fillOutPutDataStream()
  1270   Fills the Output data stream with the sharedIconInfo data.
  1277   Fills the Output data stream with the sharedIconInfo data.
  1271 */
  1278 */
  1272 void HbThemeServerSession::fillOutPutDataStream(QDataStream &outputDataStream, HbSharedIconInfo &data, HbThemeServerRequest request)
  1279 void HbThemeServerSession::fillOutPutDataStream(QDataStream &outputDataStream,
  1273 {
  1280                                                 HbSharedIconInfo &data,
  1274     outputDataStream << (int)request;
  1281                                                 HbThemeServerRequest request)
  1275     outputDataStream << (int)data.type;
  1282 {
       
  1283     outputDataStream << int(request);
       
  1284     outputDataStream << int(data.type);
  1276 
  1285 
  1277     switch (data.type) {
  1286     switch (data.type) {
  1278     case OTHER_SUPPORTED_FORMATS:
  1287     case OTHER_SUPPORTED_FORMATS:
  1279         outputDataStream << data.pixmapData.offset;
  1288         outputDataStream << data.pixmapData.offset;
  1280         outputDataStream << data.pixmapData.width;
  1289         outputDataStream << data.pixmapData.width;
  1281         outputDataStream << data.pixmapData.height;
  1290         outputDataStream << data.pixmapData.height;
  1282         outputDataStream << data.pixmapData.defaultWidth;
  1291         outputDataStream << data.pixmapData.defaultWidth;
  1283         outputDataStream << data.pixmapData.defaultHeight;
  1292         outputDataStream << data.pixmapData.defaultHeight;
  1284         outputDataStream << (int)data.pixmapData.format;
  1293         outputDataStream << int(data.pixmapData.format);
  1285         break;
  1294         break;
  1286         /*case SVG:*/
  1295         /*case SVG:*/
  1287     case PIC: {
  1296     case PIC: {
  1288         outputDataStream << data.picData.offset;
  1297         outputDataStream << data.picData.offset;
  1289         outputDataStream << data.picData.dataSize;
  1298         outputDataStream << data.picData.dataSize;
  1308 
  1317 
  1309 /*!
  1318 /*!
  1310   \fn HbThemeServerSession::getDataFromCacheItem()
  1319   \fn HbThemeServerSession::getDataFromCacheItem()
  1311   Gets data from the cache Item.
  1320   Gets data from the cache Item.
  1312 */
  1321 */
  1313 void HbThemeServerSession::getDataFromCacheItem(HbIconCacheItem* cacheItem, HbSharedIconInfo &data) const
  1322 void HbThemeServerSession::getDataFromCacheItem(HbIconCacheItem* cacheItem,
       
  1323                                                 HbSharedIconInfo &data) const
  1314 {
  1324 {
  1315     if (cacheItem) {
  1325     if (cacheItem) {
  1316         if (cacheItem->rasterIconData.type != INVALID_FORMAT) {
  1326         if (cacheItem->rasterIconData.type != INVALID_FORMAT) {
  1317             data = cacheItem->rasterIconData;
  1327             data = cacheItem->rasterIconData;
  1318         } else if (cacheItem->vectorIconData.type != INVALID_FORMAT) {
  1328         } else if (cacheItem->vectorIconData.type != INVALID_FORMAT) {
  1326 }
  1336 }
  1327 
  1337 
  1328 /**
  1338 /**
  1329  * HbThemeServerPrivate::handleSharedWidgetMLLookup()
  1339  * HbThemeServerPrivate::handleSharedWidgetMLLookup()
  1330  */
  1340  */
  1331 QByteArray HbThemeServerPrivate::handleSharedWidgetMLLookup(const QString &fileName, const QString &layout, const QString &section)
  1341 QByteArray HbThemeServerPrivate::handleSharedWidgetMLLookup(const QString &fileName,
       
  1342                                                             const QString &layout,
       
  1343                                                             const QString &section)
  1332 {
  1344 {
  1333     int offset = HbThemeServerUtils::getSharedLayoutDefinition(fileName, layout, section);
  1345     int offset = HbThemeServerUtils::getSharedLayoutDefinition(fileName, layout, section);
  1334     QByteArray outputByteArray;
  1346     QByteArray outputByteArray;
  1335     QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
  1347     QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
  1336     HbThemeServerRequest request;
  1348     HbThemeServerRequest request;
  1341 }
  1353 }
  1342 
  1354 
  1343 /**
  1355 /**
  1344  * HbThemeServerPrivate::handleSharedEffectAddAndFileLookup()
  1356  * HbThemeServerPrivate::handleSharedEffectAddAndFileLookup()
  1345  */
  1357  */
  1346 QByteArray HbThemeServerPrivate::handleSharedEffectAddAndFileLookup(int request, const QString &fileName)
  1358 QByteArray HbThemeServerPrivate::handleSharedEffectAddAndFileLookup(int request,
       
  1359                                                                     const QString &fileName)
  1347 {
  1360 {
  1348     int offset = HbThemeServerUtils::getSharedEffect(fileName);
  1361     int offset = HbThemeServerUtils::getSharedEffect(fileName);
  1349     QByteArray outputByteArray;
  1362     QByteArray outputByteArray;
  1350     QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
  1363     QDataStream outputDataStream(&outputByteArray, QIODevice::WriteOnly);
  1351     outputDataStream << request;
  1364     outputDataStream << request;
  1354 }
  1367 }
  1355 
  1368 
  1356 /**
  1369 /**
  1357  * HbThemeServerSession::handleStyleSheetLookup()
  1370  * HbThemeServerSession::handleStyleSheetLookup()
  1358  */
  1371  */
  1359 QByteArray HbThemeServerSession::handleStyleSheetLookup(int request, const QString &fileName, HbLayeredStyleLoader::LayerPriority priority)
  1372 QByteArray HbThemeServerSession::handleStyleSheetLookup(int request,
       
  1373     const QString &fileName, HbLayeredStyleLoader::LayerPriority priority)
  1360 {
  1374 {
  1361     int offset = -1;
  1375     int offset = -1;
  1362     HbCacheItem* cssItem = iServer->cssCacheItem(fileName);
  1376     HbCacheItem* cssItem = iServer->cssCacheItem(fileName);
  1363     bool insertKeyIntoSessionList = false;
  1377     bool insertKeyIntoSessionList = false;
  1364     if (cssItem) {
  1378     if (cssItem) {
  1371             offset = HbThemeServerUtils::getSharedStylesheet(fileName, priority, &inSharedCache);
  1385             offset = HbThemeServerUtils::getSharedStylesheet(fileName, priority, &inSharedCache);
  1372             if (!inSharedCache) {
  1386             if (!inSharedCache) {
  1373                 if (offset >= 0) {
  1387                 if (offset >= 0) {
  1374                     HbCacheItem *cssItem = new HbCacheItem(offset, 0, fileName);
  1388                     HbCacheItem *cssItem = new HbCacheItem(offset, 0, fileName);
  1375                     insertKeyIntoSessionList = iServer->insertCssCacheItem(fileName, cssItem);
  1389                     insertKeyIntoSessionList = iServer->insertCssCacheItem(fileName, cssItem);
  1376                     if (priority == HbLayeredStyleLoader::Priority_Core && cssItem->refCount == 1) {
  1390                     if (priority == HbLayeredStyleLoader::Priority_Core
       
  1391                         && cssItem->refCount == 1) {
  1377                         // This will make sure the requested stylesheet will always remain
  1392                         // This will make sure the requested stylesheet will always remain
  1378                         // in the primary and secondary cache.
  1393                         // in the primary and secondary cache.
  1379                         cssItem->incrementRefCount();
  1394                         cssItem->incrementRefCount();
  1380                     }
  1395                     }
  1381                     if (priority == HbLayeredStyleLoader::Priority_Theme && cssItem->refCount == 1) {
  1396                     if (priority == HbLayeredStyleLoader::Priority_Theme
  1382                         iServer->themePriorityItems.insert(fileName,cssItem);
  1397                         && cssItem->refCount == 1) {
       
  1398                         iServer->themePriorityItems.insert(fileName, cssItem);
  1383                     }
  1399                     }
  1384                     break;
  1400                     break;
  1385                 } else if (offset == OUT_OF_MEMORY_ERROR && tryAgain == false) {
  1401                 } else if (offset == OUT_OF_MEMORY_ERROR && tryAgain == false) {
  1386                     iServer->doCleanup();
  1402                     iServer->doCleanup();
  1387                     tryAgain = true;
  1403                     tryAgain = true;
  1411 }
  1427 }
  1412 
  1428 
  1413 /**
  1429 /**
  1414  * HbThemeServerSession::handleIconLookup()
  1430  * HbThemeServerSession::handleIconLookup()
  1415  */
  1431  */
  1416 QByteArray HbThemeServerSession::handleIconLookup(const HbIconKey &key, HbSharedIconInfo &data, int options)
  1432 QByteArray HbThemeServerSession::handleIconLookup(const HbIconKey &key, HbSharedIconInfo &data,
       
  1433                                                   int options)
  1417 {
  1434 {
  1418     bool insertKeyIntoSessionList = false;
  1435     bool insertKeyIntoSessionList = false;
  1419     HbIconCacheItem * cacheItem = iServer->iconCacheItem(key);
  1436     HbIconCacheItem * cacheItem = iServer->iconCacheItem(key);
  1420     QScopedPointer <HbIconCacheItem> tempIconCacheItem;
  1437     QScopedPointer <HbIconCacheItem> tempIconCacheItem;
  1421 
  1438