src/hbservers/hbthemeserver/hbthemeserver_symbian.cpp
changeset 28 b7da29130b0e
parent 23 e6ad4ef83b23
child 30 80e4d18b72f5
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
   193     : CServer2( aActiveObjectPriority ), iWatcher(0)
   193     : CServer2( aActiveObjectPriority ), iWatcher(0)
   194 {
   194 {
   195     // Set up the listener to listen for Publish events
   195     // Set up the listener to listen for Publish events
   196     TRAPD(err, iListener = CHbThemeChangeNotificationListener::NewL(*this));
   196     TRAPD(err, iListener = CHbThemeChangeNotificationListener::NewL(*this));
   197     if (err) {
   197     if (err) {
   198         qWarning( "HbThemeServerPrivate::HbThemeServerPrivate: CHbThemeChangeNotificationListener::NewL failed = %d", err );
   198         THEME_GENERIC_DEBUG() << Q_FUNC_INFO << "CHbThemeChangeNotificationListener::NewL failed. Error code:" << err;
   199     } else {
   199     } else {
   200         TRAPD(err, iListener->startListeningL());
   200         TRAPD(err, iListener->startListeningL());
   201         if (err) {
   201         if (err) {
   202              qWarning( "HbThemeServerPrivate::HbThemeServerPrivate: iListener->startListening failed = %d", err );
   202              THEME_GENERIC_DEBUG() << Q_FUNC_INFO << "iListener->startListening failed. Error code:" << err;
   203          }
   203          }
   204     }    
   204     }    
   205 }
   205 }
   206 
   206 
   207 /**
   207 /**
   234         indexFileName.append(iCurrentThemePath);
   234         indexFileName.append(iCurrentThemePath);
   235         indexFileName.append("/index.theme");
   235         indexFileName.append("/index.theme");
   236         
   236         
   237         QFile currentIndexfile(indexFileName);
   237         QFile currentIndexfile(indexFileName);
   238         if(!currentIndexfile.open(QIODevice::ReadOnly)) {
   238         if(!currentIndexfile.open(QIODevice::ReadOnly)) {
   239             qWarning()<< "HbSymbianThemeServer: No Index file found in the new theme, How did this happen ??";
   239             THEME_GENERIC_DEBUG()<< Q_FUNC_INFO << "No Index file found in the new theme.";
   240             return false;
   240             return false;
   241         } else {
   241         } else {
   242             currentIndexfile.close();
   242             currentIndexfile.close();
   243             if (!iWatcher) {
   243             if (!iWatcher) {
   244                 // Set up the file watcher for active theme changes
   244                 // Set up the file watcher for active theme changes
   267 
   267 
   268     QDir path(cleanThemeName);
   268     QDir path(cleanThemeName);
   269     iCurrentThemeName = path.dirName();
   269     iCurrentThemeName = path.dirName();
   270     iCurrentThemePath = path.absolutePath();
   270     iCurrentThemePath = path.absolutePath();
   271 
   271 
   272     #ifdef THEME_INDEX_TRACES
   272     THEME_INDEX_DEBUG() << Q_FUNC_INFO << "Theme change request, new theme =" << cleanThemeName.toUtf8();
   273     qDebug() << "ThemeIndex: theme change request, new theme =" << cleanThemeName.toUtf8();
       
   274     #endif
       
   275 
       
   276 
   273 
   277     // Clear cached icons and session data
   274     // Clear cached icons and session data
   278     clearIconCache();
   275     clearIconCache();
   279     iSessionIter.SetToFirst();
   276     iSessionIter.SetToFirst();
   280     while(iSessionIter) {
   277     while(iSessionIter) {
   290 /**
   287 /**
   291 Creates a new session with the server.
   288 Creates a new session with the server.
   292 */
   289 */
   293 CSession2* HbThemeServerPrivate::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const
   290 CSession2* HbThemeServerPrivate::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const
   294 {
   291 {
   295 #ifdef THEME_SERVER_TRACES
   292     THEME_GENERIC_DEBUG() << "entering" << Q_FUNC_INFO;
   296     qDebug() << "HbThemeServerPrivate::NewSessionL: entered";
       
   297 #endif
       
   298     // Check that the version is OK
   293     // Check that the version is OK
   299     TVersion v(KThemeServerMajorVersionNumber, KThemeServerMinorVersionNumber, KThemeServerBuildVersionNumber);
   294     TVersion v(KThemeServerMajorVersionNumber, KThemeServerMinorVersionNumber, KThemeServerBuildVersionNumber);
   300     if (!User::QueryVersionSupported(v, aVersion))
   295     if (!User::QueryVersionSupported(v, aVersion))
   301         User::Leave(KErrNotSupported);
   296         User::Leave(KErrNotSupported);
   302     // Create the session.
   297     // Create the session.
   655 /**
   650 /**
   656 Services a client request.
   651 Services a client request.
   657 */
   652 */
   658 void HbThemeServerSession::ServiceL(const RMessage2& aMessage)
   653 void HbThemeServerSession::ServiceL(const RMessage2& aMessage)
   659 {
   654 {
   660 #ifdef THEME_SERVER_TRACES
   655     THEME_GENERIC_DEBUG() << "entered" << Q_FUNC_INFO << "with function:" << aMessage.Function();
   661     qDebug() << "Just entered HbThemeServerSession::ServiceL";
       
   662 #endif
       
   663 
   656 
   664     TRAPD(err, DispatchMessageL(aMessage));
   657     TRAPD(err, DispatchMessageL(aMessage));
   665     aMessage.Complete(err);
   658     aMessage.Complete(err);
   666 
   659     THEME_GENERIC_DEBUG() << "completed" << Q_FUNC_INFO << "with error code" + err;
   667 #ifdef THEME_SERVER_TRACES
       
   668     QString er;
       
   669     er.setNum(err);
       
   670     qDebug() << "completed DispatchMessageL error code is " + er;
       
   671 #endif
       
   672 
       
   673 }
   660 }
   674 
   661 
   675 /**
   662 /**
   676 Called by ServiceL()
   663 Called by ServiceL()
   677 
   664 
   678 It tests the function code and then delegates to
   665 It tests the function code and then delegates to
   679 the appropriate function.
   666 the appropriate function.
   680 */
   667 */
   681 void HbThemeServerSession::DispatchMessageL(const RMessage2& aMessage)
   668 void HbThemeServerSession::DispatchMessageL(const RMessage2& aMessage)
   682 {
   669 {
   683 #ifdef THEME_SERVER_TRACES
       
   684     qDebug() << "Just entered HbThemeServerSession::DispatchMessageL";
       
   685 #endif
       
   686 
       
   687     switch (aMessage.Function()) {
   670     switch (aMessage.Function()) {
   688     case EStyleSheetLookup:
   671     case EStyleSheetLookup:
   689         HandleStyleSheetLookupL(aMessage);
   672         HandleStyleSheetLookupL(aMessage);
   690         break;
   673         break;
   691     case EWidgetMLLookup:
   674     case EWidgetMLLookup:
   723         unloadMultiIcon(aMessage);
   706         unloadMultiIcon(aMessage);
   724         break;
   707         break;
   725 
   708 
   726     case ENotifyForegroundLost:
   709     case ENotifyForegroundLost:
   727 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
   710 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
   728         freeClientGpuResources();
   711         freeIconResources();
   729 #endif
   712 #endif
   730         break;
   713         break;
   731         //Debug Code for Test Purpose
   714         //Debug Code for Test Purpose
   732 #ifdef HB_ICON_CACHE_DEBUG
   715 #ifdef HB_ICON_CACHE_DEBUG
   733     case ECacheIconCount: {
   716     case ECacheIconCount: {
   926             iServer->setCurrentRenderingMode(ESWRendering );
   909             iServer->setCurrentRenderingMode(ESWRendering );
   927         }
   910         }
   928         iServer->FreeGpuRam(params.bytesToFree, params.useSwRendering);
   911         iServer->FreeGpuRam(params.bytesToFree, params.useSwRendering);
   929         break;
   912         break;
   930     }
   913     }
   931 
       
   932     case ERenderModeSwitch: {
   914     case ERenderModeSwitch: {
   933         TInt mode = 0;
   915         TInt mode = 0;
   934         TPckg<TInt> paramPckg(mode);      
   916         TPckg<TInt> paramPckg(mode);      
   935         aMessage.ReadL(0, paramPckg, 0);
   917         aMessage.ReadL(0, paramPckg, 0);
   936         SwitchRenderingMode((HbRenderingMode)mode);
   918         SwitchRenderingMode((HbRenderingMode)mode);
   952         int allocatedHeapMem = iServer->allocatedHeapMemory();
   934         int allocatedHeapMem = iServer->allocatedHeapMemory();
   953         TPckg<int> out(allocatedHeapMem);
   935         TPckg<int> out(allocatedHeapMem);
   954         aMessage.WriteL(1, out);
   936         aMessage.WriteL(1, out);
   955         break;
   937         break;
   956     }
   938     }
   957 
       
   958     case ETypefaceOffset: {
   939     case ETypefaceOffset: {
   959         HandleTypefaceReqL(aMessage);
   940         HandleTypefaceReqL(aMessage);
   960         break;
   941         break;
   961     }
   942     }
   962     case EMissedHbCssLookup: {
   943     case EMissedHbCssLookup: {
   963         HandleMissedHbCssLookupL(aMessage);
   944         HandleMissedHbCssLookupL(aMessage);
   964         break;
   945         break;
   965     }
   946     }
   966 
       
   967 
       
   968 
       
   969     // This is an example of a request that we know about, but don't support.
       
   970     // We cause KErrNotSupported to be returned to the client.
       
   971     default:
   947     default:
   972         PanicClient(aMessage, EBadRequest);
   948         PanicClient(aMessage, EBadRequest);
   973         break;
   949         break;
   974     }
   950     }
   975 #ifdef THEME_SERVER_TRACES
       
   976     qDebug() << "Leave HbThemeServerSession::DispatchMessageL";
       
   977 #endif
       
   978 }
   951 }
   979 
   952 
   980 void HbThemeServerSession::SwitchRenderingMode(HbRenderingMode aRenderMode)
   953 void HbThemeServerSession::SwitchRenderingMode(HbRenderingMode aRenderMode)
   981 {
   954 {
   982 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
   955 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
   997  * HandleStyleSheetLookupL
   970  * HandleStyleSheetLookupL
   998  */
   971  */
   999 void HbThemeServerSession::HandleStyleSheetLookupL(const RMessage2& aMessage)
   972 void HbThemeServerSession::HandleStyleSheetLookupL(const RMessage2& aMessage)
  1000 {
   973 {
  1001     if (aMessage.GetDesLength(0) == 0) {
   974     if (aMessage.GetDesLength(0) == 0) {
  1002 #ifdef THEME_SERVER_TRACES
   975         THEME_GENERIC_DEBUG() << Q_FUNC_INFO << "no filename given.";
  1003         qDebug() << "Empty Filename";
       
  1004 #endif
       
  1005         return;
   976         return;
  1006     }
   977     }
  1007 
   978 
  1008     TFileName fileName;
   979     TFileName fileName;
  1009     aMessage.ReadL(0, fileName, 0);
   980     aMessage.ReadL(0, fileName, 0);
  1185     }
  1156     }
  1186 #endif
  1157 #endif
  1187     // create dshared pixmap info from HbIconCacheItem
  1158     // create dshared pixmap info from HbIconCacheItem
  1188     TPckg<HbSharedIconInfo> pixdata(data);
  1159     TPckg<HbSharedIconInfo> pixdata(data);
  1189     aMessage.WriteL(1, pixdata);
  1160     aMessage.WriteL(1, pixdata);
  1190 
       
  1191 #ifdef THEME_SERVER_TRACES
       
  1192     qDebug() << "Completed  aMessage.WriteL";
       
  1193 #endif
       
  1194 }
  1161 }
  1195 
  1162 
  1196 /**
  1163 /**
  1197  * Panics the client
  1164  * Panics the client
  1198  */
  1165  */
  1351         if (!format.isEmpty()) {
  1318         if (!format.isEmpty()) {
  1352             // try search for icon in software mode if the icon is not of type nvg
  1319             // try search for icon in software mode if the icon is not of type nvg
  1353             // currently only nvg type is used to create RSgImage
  1320             // currently only nvg type is used to create RSgImage
  1354             if (format != HbIconCacheItemCreator::KNvg) {            
  1321             if (format != HbIconCacheItemCreator::KNvg) {            
  1355                 HbIconKey newKey(key);
  1322                 HbIconKey newKey(key);
  1356                 key.renderMode = ESWRendering;
  1323                 newKey.renderMode = ESWRendering;
  1357                 cacheItem = iServer->iconCacheItem(newKey);
  1324                 cacheItem = iServer->iconCacheItem(newKey);
  1358                 if (cacheItem) {
  1325                 if (cacheItem) {
  1359                     key.renderMode = ESWRendering;
  1326                     key.renderMode = ESWRendering;
  1360                 }
  1327                 }
  1361             }
  1328             }
  1797     }
  1764     }
  1798 #endif
  1765 #endif
  1799 }
  1766 }
  1800 
  1767 
  1801 /**
  1768 /**
       
  1769 freeIconResources - unloads all the resources in the session
       
  1770 
       
  1771 Iterates all the keys in sessionData and then CleanUpSessionIConItem is called
       
  1772 on that item, which will do the cleanup based on the reference count.
       
  1773 */
       
  1774 void HbThemeServerSession::freeIconResources()
       
  1775 {
       
  1776     QList<HbIconKey> tempSessionData(sessionData);
       
  1777     QList<HbIconKey>::const_iterator itEnd( tempSessionData.constEnd() );
       
  1778     for ( QList<HbIconKey>::const_iterator iter = tempSessionData.constBegin();
       
  1779             iter != itEnd;
       
  1780             ++iter ) {
       
  1781                 
       
  1782         iServer->CleanupSessionIconItem(*iter);
       
  1783         // remove the item in the session data.
       
  1784         sessionData.removeOne(*iter);
       
  1785                
       
  1786     }
       
  1787 }
       
  1788 
       
  1789 
       
  1790 
       
  1791 
       
  1792 /**
  1802  * HbThemeServerSession::ClearSessionData
  1793  * HbThemeServerSession::ClearSessionData
  1803  *
  1794  *
  1804  * Clears the session data list. Items in the server should be deleted before clearing.
  1795  * Clears the session data list. Items in the server should be deleted before clearing.
  1805  */
  1796  */
  1806 void HbThemeServerSession::ClearSessionData()
  1797 void HbThemeServerSession::ClearSessionData()