Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Changing the active theme using Symbian C++

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

Article Metadata
Platform(s): S60 3rd Edition
S60 3rd Edition (initial release)
Created: User:Technical writer 2 (19 Oct 2006)
Last edited: lpvalente (26 Jul 2014)


Changing the active theme


The S60 3rd Edition SDK does not provide a way to activate a specific theme from 3rd-party applications.
However, the required API (Skin Server API) is part of the Extensions plug-in package for S60 3rd Edition SDK.


To change the active theme:
1. Connect to Skin Server.  
    #include <AknSSrvClient.h> // link against aknskinsrv.lib
    RAknsSrvSession skinsSession;
    User::LeaveIfError( skinsSession.Connect( this ) );
    CleanupClosePushL( skinsSession );
2. Fetch the package ID of the current skin.
    #include <centralrepository.h> // link against centralrepository.lib
    #include <AknSkinsInternalCRKeys.h>
    void CMyThemeManager::StoreCurrentSkinIdL()
        TAknsPkgIDBuf pidBuf;       
        CRepository* repository = CRepository::NewL(KCRUidPersonalisation );               
        TInt retVal = repository->Get( KPslnActiveSkinUid, pidBuf );
        delete repository;
        repository = NULL;
        iOriginalSkinPid.SetFromDesL( pidBuf ); // iOriginalSkinPid is of type TAknsPkgID
3. Get a list of installed skin packages.
    CArrayPtr<CAknsSrvSkinInformationPkg>* skinInfoArray =
    CleanupStack::PushL( skinInfoArray );
4. Go through installed packages and switch to the first available new skin.
    TInt retValue( KErrNone );
    if ( skinInfoArray->Count() > 0 )
        for ( TInt i = 0; i < skinInfoArray->Count(); i++ )
            TAknsPkgID pkgId = skinInfoArray->At( i )->PID();
            if ( pkgId != iOriginalSkinPid )
                // Activates a complete skin package
                retValue = skinsSession.SetAllDefinitionSets( pkgId );
                if ( retValue == KErrNone )
                    SetNewSkinIdL( pkgId );
5. Save the new skin package ID in Central Repository.
    void CMyThemeManager::SetNewSkinIdL( TAknsPkgID aPkgId )
        TAknsPkgIDBuf pidBuf;       
        aPkgId.CopyToDes( pidBuf );
        CRepository* repository = CRepository::NewL( KCRUidPersonalisation );               
        TInt retVal = repository->Set( KPslnActiveSkinUid, pidBuf );   
        // KPslnActiveSkinLocation value needs to be updated
        // if the new skin resides on memory card and the
        // previous one resided in phone memory (and vice versa)   
        delete repository;
        repository = NULL;

This page was last modified on 26 July 2014, at 23:28.
43 page views in the last 30 days.