×
Namespaces

Variants
Actions
(Difference between revisions)

Extended Skins API

From Nokia Developer Wiki
Jump to: navigation, search
kiran10182 (Talk | contribs)
m (fixed minor typos)
hamishwillee (Talk | contribs)
m (Text replace - "Category:Symbian" to "")
 
(18 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:Symbian C++]][[Category:S60]][[Category:Code Examples]][[Category:UI]][[Category:Themes]]
+
[[Category:Symbian C++]][[Category:Code Examples]][[Category:UI]][[Category:Themes]]
__NOEDITSECTION__ __NOTOC__
+
{{ArticleMetaData <!-- v1.1 -->
{{NoteS}}
+
|sourcecode= [[Media:ExtSkins.zip]]
:This API is not part of the public SDK. It can be found in the [[SDK API Plug-in]].  
+
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
{{NoteE}}
+
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
Extended Skins API provides classes to change active, to get skin package information.
+
|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 ==
  
Line 21: Line 40:
  
 
'''Header files'''
 
'''Header files'''
<pre>#include &lt;AknSSrvClient.h&gt;
+
<code cpp>#include <AknSSrvClient.h>
#include &lt;AknsPkgID.h&gt;
+
#include <AknsPkgID.h>
#include &lt;AknsItemDef.h&gt;
+
#include <AknsItemDef.h>
#include &lt;AknsItemID.h&gt;
+
#include <AknsItemID.h>
#include &lt;AknsSrvSkinInformationPkg.h&gt;
+
#include <AknsSrvSkinInformationPkg.h>
#include &lt;EIKENV.H&gt;
+
#include <EIKENV.H>
#include &lt;centralrepository.h&gt;
+
#include <centralrepository.h>
#include &lt;AknSkinsInternalCRKeys.h&gt;</pre>
+
#include <AknSkinsInternalCRKeys.h></code>
 
<br>'''Libraries Used'''
 
<br>'''Libraries Used'''
<pre>aknskinsrv.lib centralrepository.lib</pre>
+
<code cpp>aknskinsrv.lib centralrepository.lib</code>
<br>'''Capability required'''<pre>CAPABILITY WriteDeviceData</pre>
+
<br>'''Capability required'''<code cpp>CAPABILITY WriteDeviceData</code>
 
<br>'''First connect to the skin server:'''
 
<br>'''First connect to the skin server:'''
<pre>void CNotifyEngine::ConstructL()
+
<code cpp>void CNotifyEngine::ConstructL()
 
{
 
{
 
//connect to skin server
 
//connect to skin server
 
User::LeaveIfError( iSkinSrvSession.Connect( this ) );
 
User::LeaveIfError( iSkinSrvSession.Connect( this ) );
 
// to recieve notifications of skin change
 
// to recieve notifications of skin change
iSkinSrvSession.EnableSkinChangeNotify()&nbsp;;
+
iSkinSrvSession.EnableSkinChangeNotify();
}</pre>
+
}</code>
 
<br>'''Virtual functions'''
 
<br>'''Virtual functions'''
<pre>void CNotifyEngine::SkinContentChanged()
+
<code cpp>void CNotifyEngine::SkinContentChanged()
 
{
 
{
CEikonEnv::Static()-&gt;InfoWinL(_L("Skin Content Changed"),_L(""));
+
CEikonEnv::Static()->InfoWinL(_L("Skin Content Changed"),_L(""));
 
}
 
}
 
void CNotifyEngine::SkinConfigurationChanged(const TAknsSkinStatusConfigurationChangeReason aReason )
 
void CNotifyEngine::SkinConfigurationChanged(const TAknsSkinStatusConfigurationChangeReason aReason )
 
{  
 
{  
CEikonEnv::Static()-&gt;InfoWinL(_L("Skin Configuration Changed"),_L(""));
+
CEikonEnv::Static()->InfoWinL(_L("Skin Configuration Changed"),_L(""));
 
}
 
}
 
void CNotifyEngine::SkinPackageChanged(const TAknsSkinStatusPackageChangeReason aReason)
 
void CNotifyEngine::SkinPackageChanged(const TAknsSkinStatusPackageChangeReason aReason)
 
{
 
{
CEikonEnv::Static()-&gt;InfoWinL(_L("Skin Package Changed"),_L(""));
+
CEikonEnv::Static()->InfoWinL(_L("Skin Package Changed"),_L(""));
}</pre>
+
}</code>
 
'''The following code displays current active theme details:'''
 
'''The following code displays current active theme details:'''
<pre>void CNotifyEngine::SkinNameL()
+
<code cpp>void CNotifyEngine::SkinNameL()
 
{
 
{
 
TAknsPkgIDBuf cidBuf;
 
TAknsPkgIDBuf cidBuf;
 
CRepository* repository = CRepository::NewLC( KCRUidPersonalisation );
 
CRepository* repository = CRepository::NewLC( KCRUidPersonalisation );
TInt retVal = repository-&gt;Get( KPslnActiveSkinUid, cidBuf );
+
TInt retVal = repository->Get( KPslnActiveSkinUid, cidBuf );
 
TAknsPkgID cpkgId;
 
TAknsPkgID cpkgId;
 
cpkgId.SetFromDesL( cidBuf );
 
cpkgId.SetFromDesL( cidBuf );
 
CleanupStack::PopAndDestroy(repository);
 
CleanupStack::PopAndDestroy(repository);
CArrayPtr&lt; CAknsSrvSkinInformationPkg &gt;* skinInfoArray = iSkinSrvSession.EnumerateSkinPackagesL();
+
CArrayPtr< CAknsSrvSkinInformationPkg >* skinInfoArray = iSkinSrvSession.EnumerateSkinPackagesL();
 
CleanupStack::PushL( skinInfoArray );
 
CleanupStack::PushL( skinInfoArray );
 
TInt retValue( KErrNone );
 
TInt retValue( KErrNone );
if ( skinInfoArray-&gt;Count() &gt; 0 )
+
if ( skinInfoArray->Count() > 0 )
{
+
    {
for (TInt i=0; i &lt; skinInfoArray-&gt;Count(); i++ )
+
    for (TInt i=0; i < skinInfoArray->Count(); i++ )
{
+
        {
TAknsPkgID pkgId = skinInfoArray-&gt;At(i)-&gt;PID();
+
        TAknsPkgID pkgId = skinInfoArray->At(i)->PID();
if ( pkgId == cpkgId )
+
        if ( pkgId == cpkgId )
{
+
            {
TBuf&lt;128&gt; lBuf = skinInfoArray-&gt;At(i)-&gt;Name();
+
            TBuf<128> lBuf = skinInfoArray->At(i)->Name();
CEikonEnv::Static()-&gt;InfoWinL(_L("Skin Name"),lBuf);
+
            CEikonEnv::Static()->InfoWinL(_L("Skin Name"),lBuf);
lBuf.Zero();
+
            lBuf.Zero();
lBuf = skinInfoArray-&gt;At(i)-&gt;FullName();
+
            lBuf = skinInfoArray->At(i)->FullName();
CEikonEnv::Static()-&gt;InfoWinL(_L("Skin Path"),lBuf);
+
            CEikonEnv::Static()->InfoWinL(_L("Skin Path"),lBuf);
lBuf.Zero();
+
            lBuf.Zero();
lBuf = skinInfoArray-&gt;At(i)-&gt;Directory();
+
            lBuf = skinInfoArray->At(i)->Directory();
CEikonEnv::Static()-&gt;InfoWinL(_L("Skin Directory"),lBuf);
+
            CEikonEnv::Static()->InfoWinL(_L("Skin Directory"),lBuf);
lBuf.Zero();
+
            lBuf.Zero();
lBuf = skinInfoArray-&gt;At(i)-&gt;IniFileDirectory();
+
            lBuf = skinInfoArray->At(i)->IniFileDirectory();
CEikonEnv::Static()-&gt;InfoWinL(_L("Skin IniFile Directory"),lBuf);
+
            CEikonEnv::Static()->InfoWinL(_L("Skin IniFile Directory"),lBuf);
break;
+
            break;
}
+
            }
}
+
        }
}
+
    }
skinInfoArray-&gt;ResetAndDestroy();
+
skinInfoArray->ResetAndDestroy();
 
CleanupStack::PopAndDestroy();
 
CleanupStack::PopAndDestroy();
}</pre>
+
}</code>
 
'''The following code changes the active theme:'''
 
'''The following code changes the active theme:'''
<pre>void CNotifyEngine::ActivateSkinL()
+
<code cpp>void CNotifyEngine::ActivateSkinL()
 
{
 
{
 
StoreCurrentSkinIdL();
 
StoreCurrentSkinIdL();
CArrayPtr&lt; CAknsSrvSkinInformationPkg &gt;* skinInfoArray = iSkinSrvSession.EnumerateSkinPackagesL();
+
CArrayPtr< CAknsSrvSkinInformationPkg >* skinInfoArray = iSkinSrvSession.EnumerateSkinPackagesL();
 
CleanupStack::PushL( skinInfoArray );
 
CleanupStack::PushL( skinInfoArray );
 
TInt retValue( KErrNone );
 
TInt retValue( KErrNone );
if ( skinInfoArray-&gt;Count() &gt; 0 )
+
if ( skinInfoArray->Count() > 0 )
{
+
    {
for (TInt i=0; i &lt; skinInfoArray-&gt;Count(); i++ )
+
    for (TInt i=0; i < skinInfoArray->Count(); i++ )
{
+
        {
TAknsPkgID pkgId = skinInfoArray-&gt;At(i)-&gt;PID();
+
        TAknsPkgID pkgId = skinInfoArray->At(i)->PID();
if ( pkgId&nbsp;!= iOriginalSkinPid )
+
        if ( pkgId != iOriginalSkinPid )
{
+
            {
TBuf&lt;100&gt; lName = skinInfoArray-&gt;At(i)-&gt;Name();
+
            TBuf<100> lName = skinInfoArray->At(i)->Name();
CEikonEnv::Static()-&gt;InfoWinL(_L("New Skin Name"),lName);
+
            CEikonEnv::Static()->InfoWinL(_L("New Skin Name"),lName);
//Activate a complete skin package at once.
+
            //Activate a complete skin package at once.
retValue = iSkinSrvSession.SetAllDefinitionSets( pkgId );
+
            retValue = iSkinSrvSession.SetAllDefinitionSets( pkgId );
if ( retValue == KErrNone )
+
            if ( retValue == KErrNone )
{
+
                {
SetNewSkinIdL( pkgId );
+
                SetNewSkinIdL( pkgId );
}
+
                }
break;
+
            break;
}
+
            }
}
+
        }
}
+
    }
skinInfoArray-&gt;ResetAndDestroy();
+
skinInfoArray->ResetAndDestroy();
 
CleanupStack::PopAndDestroy();
 
CleanupStack::PopAndDestroy();
}</pre><pre>void CNotifyEngine::StoreCurrentSkinIdL()
+
}</code><code cpp>void CNotifyEngine::StoreCurrentSkinIdL()
 
{
 
{
 
TAknsPkgIDBuf pidBuf;
 
TAknsPkgIDBuf pidBuf;
 
CRepository* repository = CRepository::NewLC( KCRUidPersonalisation );
 
CRepository* repository = CRepository::NewLC( KCRUidPersonalisation );
TInt retVal = repository-&gt;Get( KPslnActiveSkinUid, pidBuf );
+
TInt retVal = repository->Get( KPslnActiveSkinUid, pidBuf );
 
CleanupStack::PopAndDestroy(repository);
 
CleanupStack::PopAndDestroy(repository);
 
// iOriginalSkinPid is of type TAknsPkgID
 
// iOriginalSkinPid is of type TAknsPkgID
 
iOriginalSkinPid.SetFromDesL( pidBuf );
 
iOriginalSkinPid.SetFromDesL( pidBuf );
}</pre><pre>void CNotifyEngine::SetNewSkinIdL( TAknsPkgID aPkgId )
+
}</code><code cpp>void CNotifyEngine::SetNewSkinIdL( TAknsPkgID aPkgId )
 
{
 
{
 
TAknsPkgIDBuf pidBuf;
 
TAknsPkgIDBuf pidBuf;
 
aPkgId.CopyToDes( pidBuf );
 
aPkgId.CopyToDes( pidBuf );
 
CRepository* repository = CRepository::NewLC( KCRUidPersonalisation );
 
CRepository* repository = CRepository::NewLC( KCRUidPersonalisation );
TInt retVal = repository-&gt;Set( KPslnActiveSkinUid, pidBuf );
+
TInt retVal = repository->Set( KPslnActiveSkinUid, pidBuf );
 
// KPslnActiveSkinLocation has to be changed also
 
// KPslnActiveSkinLocation has to be changed also
 
// if new skin resides on mmc whereas old one resided in phone memory  
 
// if new skin resides on mmc whereas old one resided in phone memory  
 
CleanupStack::PopAndDestroy(repository);
 
CleanupStack::PopAndDestroy(repository);
}</pre>
+
}</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 04: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 04:33.
208 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.

×