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(); |
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; |
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 |
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. |
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; |