×
Namespaces

Variants
Actions
(Difference between revisions)

Extended Skins API

From Nokia Developer Wiki
Jump to: navigation, search
kiran10182 (Talk | contribs)
m (fixed minor typos)
lenclud (Talk | contribs)
Line 21: Line 21:
  
 
'''Header files'''
 
'''Header files'''
<pre>#include &lt;AknSSrvClient.h&gt;
+
<code cpp>#include &lt;AknSSrvClient.h&gt;
 
#include &lt;AknsPkgID.h&gt;
 
#include &lt;AknsPkgID.h&gt;
 
#include &lt;AknsItemDef.h&gt;
 
#include &lt;AknsItemDef.h&gt;
Line 28: Line 28:
 
#include &lt;EIKENV.H&gt;
 
#include &lt;EIKENV.H&gt;
 
#include &lt;centralrepository.h&gt;
 
#include &lt;centralrepository.h&gt;
#include &lt;AknSkinsInternalCRKeys.h&gt;</pre>
+
#include &lt;AknSkinsInternalCRKeys.h&gt;</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
Line 39: Line 39:
 
// to recieve notifications of skin change
 
// to recieve notifications of skin change
 
iSkinSrvSession.EnableSkinChangeNotify()&nbsp;;
 
iSkinSrvSession.EnableSkinChangeNotify()&nbsp;;
}</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()-&gt;InfoWinL(_L("Skin Content Changed"),_L(""));
Line 52: Line 52:
 
{
 
{
 
CEikonEnv::Static()-&gt;InfoWinL(_L("Skin Package Changed"),_L(""));
 
CEikonEnv::Static()-&gt;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;
Line 89: Line 89:
 
skinInfoArray-&gt;ResetAndDestroy();
 
skinInfoArray-&gt;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();
Line 118: Line 118:
 
skinInfoArray-&gt;ResetAndDestroy();
 
skinInfoArray-&gt;ResetAndDestroy();
 
CleanupStack::PopAndDestroy();
 
CleanupStack::PopAndDestroy();
}</pre><pre>void CNotifyEngine::StoreCurrentSkinIdL()
+
}</code><code cpp>void CNotifyEngine::StoreCurrentSkinIdL()
 
{
 
{
 
TAknsPkgIDBuf pidBuf;
 
TAknsPkgIDBuf pidBuf;
Line 126: Line 126:
 
// 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;
Line 135: Line 135:
 
// 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>
  

Revision as of 11:54, 29 May 2009


Template:NoteS

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

Template:NoteE Extended Skins API provides classes to change active, to get skin package information.

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 &lt;AknSSrvClient.h&gt;
#include &lt;AknsPkgID.h&gt;
#include &lt;AknsItemDef.h&gt;
#include &lt;AknsItemID.h&gt;
#include &lt;AknsSrvSkinInformationPkg.h&gt;
#include &lt;EIKENV.H&gt;
#include &lt;centralrepository.h&gt;
#include &lt;AknSkinsInternalCRKeys.h&gt;


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()&nbsp;;
}


Virtual functions

void CNotifyEngine::SkinContentChanged()
{
CEikonEnv::Static()-&gt;InfoWinL(_L("Skin Content Changed"),_L(""));
}
void CNotifyEngine::SkinConfigurationChanged(const TAknsSkinStatusConfigurationChangeReason aReason )
{
CEikonEnv::Static()-&gt;InfoWinL(_L("Skin Configuration Changed"),_L(""));
}
void CNotifyEngine::SkinPackageChanged(const TAknsSkinStatusPackageChangeReason aReason)
{
CEikonEnv::Static()-&gt;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-&gt;Get( KPslnActiveSkinUid, cidBuf );
TAknsPkgID cpkgId;
cpkgId.SetFromDesL( cidBuf );
CleanupStack::PopAndDestroy(repository);
CArrayPtr&lt; CAknsSrvSkinInformationPkg &gt;* skinInfoArray = iSkinSrvSession.EnumerateSkinPackagesL();
CleanupStack::PushL( skinInfoArray );
TInt retValue( KErrNone );
if ( skinInfoArray-&gt;Count() &gt; 0 )
{
for (TInt i=0; i &lt; skinInfoArray-&gt;Count(); i++ )
{
TAknsPkgID pkgId = skinInfoArray-&gt;At(i)-&gt;PID();
if ( pkgId == cpkgId )
{
TBuf&lt;128&gt; lBuf = skinInfoArray-&gt;At(i)-&gt;Name();
CEikonEnv::Static()-&gt;InfoWinL(_L("Skin Name"),lBuf);
lBuf.Zero();
lBuf = skinInfoArray-&gt;At(i)-&gt;FullName();
CEikonEnv::Static()-&gt;InfoWinL(_L("Skin Path"),lBuf);
lBuf.Zero();
lBuf = skinInfoArray-&gt;At(i)-&gt;Directory();
CEikonEnv::Static()-&gt;InfoWinL(_L("Skin Directory"),lBuf);
lBuf.Zero();
lBuf = skinInfoArray-&gt;At(i)-&gt;IniFileDirectory();
CEikonEnv::Static()-&gt;InfoWinL(_L("Skin IniFile Directory"),lBuf);
break;
}
}
}
skinInfoArray-&gt;ResetAndDestroy();
CleanupStack::PopAndDestroy();
}

The following code changes the active theme:

void CNotifyEngine::ActivateSkinL()
{
StoreCurrentSkinIdL();
CArrayPtr&lt; CAknsSrvSkinInformationPkg &gt;* skinInfoArray = iSkinSrvSession.EnumerateSkinPackagesL();
CleanupStack::PushL( skinInfoArray );
TInt retValue( KErrNone );
if ( skinInfoArray-&gt;Count() &gt; 0 )
{
for (TInt i=0; i &lt; skinInfoArray-&gt;Count(); i++ )
{
TAknsPkgID pkgId = skinInfoArray-&gt;At(i)-&gt;PID();
if ( pkgId&nbsp;!= iOriginalSkinPid )
{
TBuf&lt;100&gt; lName = skinInfoArray-&gt;At(i)-&gt;Name();
CEikonEnv::Static()-&gt;InfoWinL(_L("New Skin Name"),lName);
//Activate a complete skin package at once.
retValue = iSkinSrvSession.SetAllDefinitionSets( pkgId );
if ( retValue == KErrNone )
{
SetNewSkinIdL( pkgId );
}
break;
}
}
}
skinInfoArray-&gt;ResetAndDestroy();
CleanupStack::PopAndDestroy();
}
void CNotifyEngine::StoreCurrentSkinIdL()
{
TAknsPkgIDBuf pidBuf;
CRepository* repository = CRepository::NewLC( KCRUidPersonalisation );
TInt retVal = repository-&gt;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-&gt;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

http://wiki.forum.nokia.com/index.php/Image:ExtSkins.zip

215 page views in the last 30 days.
×