×
Namespaces

Variants
Actions
(Difference between revisions)

Extended Skins API

From Nokia Developer Wiki
Jump to: navigation, search
kiranmudiyam (Talk | contribs)
hamishwillee (Talk | contribs)
m (Text replace - "Category:Symbian" to "")
 
(26 intermediate revisions by 8 users not shown)
Line 1: Line 1:
Extended Skins API provides classes to change active, to get skin package information.
+
[[Category:Symbian C++]][[Category:Code Examples]][[Category:UI]][[Category:Themes]]
 
+
{{ArticleMetaData <!-- v1.1 -->
 +
|sourcecode= [[Media:ExtSkins.zip]]
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= DevCert or Symbian Signed
 +
|capabilities= WriteDeviceData
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|id= <!-- Article Id (Knowledge base articles only) -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20070617
 +
|author= [[User:Ltomuta]]
 +
}}  __NOEDITSECTION__ __NOTOC__
 +
{{Abstract|This article provides code examples showing how to use the Symbian C++ Extended Skins API. This API provides methods to change the active skin, to get skin package information, and to notification of skin changes. }}
 +
{{Note|This API is not part of the public SDK. It can be found in the [[SDK API Plug-in]].}}
 
== Use cases ==
 
== Use cases ==
 
To create new theme.
 
  
 
To change the active theme.
 
To change the active theme.
  
To recieve notifications of change in ckin content, configuration.
+
To receive notifications of change in skin content, configuration.
  
 
To get skin package information.
 
To get skin package information.
Line 17: Line 39:
 
== Example code ==
 
== Example code ==
  
 +
'''Header files'''
 +
<code cpp>#include <AknSSrvClient.h>
 +
#include <AknsPkgID.h>
 +
#include <AknsItemDef.h>
 +
#include <AknsItemID.h>
 +
#include <AknsSrvSkinInformationPkg.h>
 +
#include <EIKENV.H>
 +
#include <centralrepository.h>
 +
#include <AknSkinsInternalCRKeys.h></code>
 +
<br>'''Libraries Used'''
 +
<code cpp>aknskinsrv.lib centralrepository.lib</code>
 +
<br>'''Capability required'''<code cpp>CAPABILITY WriteDeviceData</code>
 +
<br>'''First connect to the skin server:'''
 +
<code cpp>void CNotifyEngine::ConstructL()
 +
{
 +
//connect to skin server
 +
User::LeaveIfError( iSkinSrvSession.Connect( this ) );
 +
// to recieve notifications of skin change
 +
iSkinSrvSession.EnableSkinChangeNotify();
 +
}</code>
 +
<br>'''Virtual functions'''
 +
<code cpp>void CNotifyEngine::SkinContentChanged()
 +
{
 +
CEikonEnv::Static()->InfoWinL(_L("Skin Content Changed"),_L(""));
 +
}
 +
void CNotifyEngine::SkinConfigurationChanged(const TAknsSkinStatusConfigurationChangeReason aReason )
 +
{
 +
CEikonEnv::Static()->InfoWinL(_L("Skin Configuration Changed"),_L(""));
 +
}
 +
void CNotifyEngine::SkinPackageChanged(const TAknsSkinStatusPackageChangeReason aReason)
 +
{
 +
CEikonEnv::Static()->InfoWinL(_L("Skin Package Changed"),_L(""));
 +
}</code>
 +
'''The following code displays current active theme details:'''
 +
<code cpp>void CNotifyEngine::SkinNameL()
 +
{
 +
TAknsPkgIDBuf cidBuf;
 +
CRepository* repository = CRepository::NewLC( KCRUidPersonalisation );
 +
TInt retVal = repository->Get( KPslnActiveSkinUid, cidBuf );
 +
TAknsPkgID cpkgId;
 +
cpkgId.SetFromDesL( cidBuf );
 +
CleanupStack::PopAndDestroy(repository);
 +
CArrayPtr< CAknsSrvSkinInformationPkg >* skinInfoArray = iSkinSrvSession.EnumerateSkinPackagesL();
 +
CleanupStack::PushL( skinInfoArray );
 +
TInt retValue( KErrNone );
 +
if ( skinInfoArray->Count() > 0 )
 +
    {
 +
    for (TInt i=0; i < skinInfoArray->Count(); i++ )
 +
        {
 +
        TAknsPkgID pkgId = skinInfoArray->At(i)->PID();
 +
        if ( pkgId == cpkgId )
 +
            {
 +
            TBuf<128> lBuf = skinInfoArray->At(i)->Name();
 +
            CEikonEnv::Static()->InfoWinL(_L("Skin Name"),lBuf);
 +
            lBuf.Zero();
 +
            lBuf = skinInfoArray->At(i)->FullName();
 +
            CEikonEnv::Static()->InfoWinL(_L("Skin Path"),lBuf);
 +
            lBuf.Zero();
 +
            lBuf = skinInfoArray->At(i)->Directory();
 +
            CEikonEnv::Static()->InfoWinL(_L("Skin Directory"),lBuf);
 +
            lBuf.Zero();
 +
            lBuf = skinInfoArray->At(i)->IniFileDirectory();
 +
            CEikonEnv::Static()->InfoWinL(_L("Skin IniFile Directory"),lBuf);
 +
            break;
 +
            }
 +
        }
 +
    }
 +
skinInfoArray->ResetAndDestroy();
 +
CleanupStack::PopAndDestroy();
 +
}</code>
 +
'''The following code changes the active theme:'''
 +
<code cpp>void CNotifyEngine::ActivateSkinL()
 +
{
 +
StoreCurrentSkinIdL();
 +
CArrayPtr< CAknsSrvSkinInformationPkg >* skinInfoArray = iSkinSrvSession.EnumerateSkinPackagesL();
 +
CleanupStack::PushL( skinInfoArray );
 +
TInt retValue( KErrNone );
 +
if ( skinInfoArray->Count() > 0 )
 +
    {
 +
    for (TInt i=0; i < skinInfoArray->Count(); i++ )
 +
        {
 +
        TAknsPkgID pkgId = skinInfoArray->At(i)->PID();
 +
        if ( pkgId != iOriginalSkinPid )
 +
            {
 +
            TBuf<100> lName = skinInfoArray->At(i)->Name();
 +
            CEikonEnv::Static()->InfoWinL(_L("New Skin Name"),lName);
 +
            //Activate a complete skin package at once.
 +
            retValue = iSkinSrvSession.SetAllDefinitionSets( pkgId );
 +
            if ( retValue == KErrNone )
 +
                {
 +
                SetNewSkinIdL( pkgId );
 +
                }
 +
            break;
 +
            }
 +
        }
 +
    }
 +
skinInfoArray->ResetAndDestroy();
 +
CleanupStack::PopAndDestroy();
 +
}</code><code cpp>void CNotifyEngine::StoreCurrentSkinIdL()
 +
{
 +
TAknsPkgIDBuf pidBuf;
 +
CRepository* repository = CRepository::NewLC( KCRUidPersonalisation );
 +
TInt retVal = repository->Get( KPslnActiveSkinUid, pidBuf );
 +
CleanupStack::PopAndDestroy(repository);
 +
// iOriginalSkinPid is of type TAknsPkgID
 +
iOriginalSkinPid.SetFromDesL( pidBuf );
 +
}</code><code cpp>void CNotifyEngine::SetNewSkinIdL( TAknsPkgID aPkgId )
 +
{
 +
TAknsPkgIDBuf pidBuf;
 +
aPkgId.CopyToDes( pidBuf );
 +
CRepository* repository = CRepository::NewLC( KCRUidPersonalisation );
 +
TInt retVal = repository->Set( KPslnActiveSkinUid, pidBuf );
 +
// KPslnActiveSkinLocation has to be changed also
 +
// if new skin resides on mmc whereas old one resided in phone memory
 +
CleanupStack::PopAndDestroy(repository);
 +
}</code>
 
<br>
 
<br>
  
 
== Sample application ==
 
== Sample application ==
  
http://wiki.forum.nokia.com/index.php/Image:ExtSkins.zip
+
[[File:ExtSkins.zip]]
 +
 
 +
=== Related topics ===
 +
 
 +
* [[How to change the active theme]]
 +
<!-- Translation --> [[zh-hans:扩展皮肤API]]

Latest revision as of 07:33, 30 May 2013

Article Metadata
Code Example
Source file: Media:ExtSkins.zip
Platform Security
Signing Required: DevCert or Symbian Signed
Capabilities: WriteDeviceData
Article
Created: ltomuta (17 Jun 2007)
Last edited: hamishwillee (30 May 2013)

This article provides code examples showing how to use the Symbian C++ Extended Skins API. This API provides methods to change the active skin, to get skin package information, and to notification of skin changes.

Note.pngNote: This API is not part of the public SDK. It can be found in the SDK API Plug-in.

Use cases

To change the active theme.

To receive notifications of change in skin content, configuration.

To get skin package information.

To delete skin, copy skin from one location to another.

To set idle wallpaper.

Example code

Header files

#include <AknSSrvClient.h>
#include <AknsPkgID.h>
#include <AknsItemDef.h>
#include <AknsItemID.h>
#include <AknsSrvSkinInformationPkg.h>
#include <EIKENV.H>
#include <centralrepository.h>
#include <AknSkinsInternalCRKeys.h>


Libraries Used

aknskinsrv.lib centralrepository.lib

Capability required
CAPABILITY WriteDeviceData


First connect to the skin server:

void CNotifyEngine::ConstructL()
{
//connect to skin server
User::LeaveIfError( iSkinSrvSession.Connect( this ) );
// to recieve notifications of skin change
iSkinSrvSession.EnableSkinChangeNotify();
}


Virtual functions

void CNotifyEngine::SkinContentChanged()
{
CEikonEnv::Static()->InfoWinL(_L("Skin Content Changed"),_L(""));
}
void CNotifyEngine::SkinConfigurationChanged(const TAknsSkinStatusConfigurationChangeReason aReason )
{
CEikonEnv::Static()->InfoWinL(_L("Skin Configuration Changed"),_L(""));
}
void CNotifyEngine::SkinPackageChanged(const TAknsSkinStatusPackageChangeReason aReason)
{
CEikonEnv::Static()->InfoWinL(_L("Skin Package Changed"),_L(""));
}

The following code displays current active theme details:

void CNotifyEngine::SkinNameL()
{
TAknsPkgIDBuf cidBuf;
CRepository* repository = CRepository::NewLC( KCRUidPersonalisation );
TInt retVal = repository->Get( KPslnActiveSkinUid, cidBuf );
TAknsPkgID cpkgId;
cpkgId.SetFromDesL( cidBuf );
CleanupStack::PopAndDestroy(repository);
CArrayPtr< CAknsSrvSkinInformationPkg >* skinInfoArray = iSkinSrvSession.EnumerateSkinPackagesL();
CleanupStack::PushL( skinInfoArray );
TInt retValue( KErrNone );
if ( skinInfoArray->Count() > 0 )
{
for (TInt i=0; i < skinInfoArray->Count(); i++ )
{
TAknsPkgID pkgId = skinInfoArray->At(i)->PID();
if ( pkgId == cpkgId )
{
TBuf<128> lBuf = skinInfoArray->At(i)->Name();
CEikonEnv::Static()->InfoWinL(_L("Skin Name"),lBuf);
lBuf.Zero();
lBuf = skinInfoArray->At(i)->FullName();
CEikonEnv::Static()->InfoWinL(_L("Skin Path"),lBuf);
lBuf.Zero();
lBuf = skinInfoArray->At(i)->Directory();
CEikonEnv::Static()->InfoWinL(_L("Skin Directory"),lBuf);
lBuf.Zero();
lBuf = skinInfoArray->At(i)->IniFileDirectory();
CEikonEnv::Static()->InfoWinL(_L("Skin IniFile Directory"),lBuf);
break;
}
}
}
skinInfoArray->ResetAndDestroy();
CleanupStack::PopAndDestroy();
}

The following code changes the active theme:

void CNotifyEngine::ActivateSkinL()
{
StoreCurrentSkinIdL();
CArrayPtr< CAknsSrvSkinInformationPkg >* skinInfoArray = iSkinSrvSession.EnumerateSkinPackagesL();
CleanupStack::PushL( skinInfoArray );
TInt retValue( KErrNone );
if ( skinInfoArray->Count() > 0 )
{
for (TInt i=0; i < skinInfoArray->Count(); i++ )
{
TAknsPkgID pkgId = skinInfoArray->At(i)->PID();
if ( pkgId != iOriginalSkinPid )
{
TBuf<100> lName = skinInfoArray->At(i)->Name();
CEikonEnv::Static()->InfoWinL(_L("New Skin Name"),lName);
//Activate a complete skin package at once.
retValue = iSkinSrvSession.SetAllDefinitionSets( pkgId );
if ( retValue == KErrNone )
{
SetNewSkinIdL( pkgId );
}
break;
}
}
}
skinInfoArray->ResetAndDestroy();
CleanupStack::PopAndDestroy();
}
void CNotifyEngine::StoreCurrentSkinIdL()
{
TAknsPkgIDBuf pidBuf;
CRepository* repository = CRepository::NewLC( KCRUidPersonalisation );
TInt retVal = repository->Get( KPslnActiveSkinUid, pidBuf );
CleanupStack::PopAndDestroy(repository);
// iOriginalSkinPid is of type TAknsPkgID
iOriginalSkinPid.SetFromDesL( pidBuf );
}
void CNotifyEngine::SetNewSkinIdL( TAknsPkgID aPkgId )
{
TAknsPkgIDBuf pidBuf;
aPkgId.CopyToDes( pidBuf );
CRepository* repository = CRepository::NewLC( KCRUidPersonalisation );
TInt retVal = repository->Set( KPslnActiveSkinUid, pidBuf );
// KPslnActiveSkinLocation has to be changed also
// if new skin resides on mmc whereas old one resided in phone memory
CleanupStack::PopAndDestroy(repository);
}


Sample application

File:ExtSkins.zip

Related topics

This page was last modified on 30 May 2013, at 07:33.
248 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×