×
Namespaces

Variants
Actions
(Difference between revisions)

Extended Skins API

From Nokia Developer Wiki
Jump to: navigation, search
lenclud (Talk | contribs)
m
linxin79 (Talk | contribs)
Line 43: Line 43:
 
<code cpp>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(""));
 
}</code>
 
}</code>
 
'''The following code displays current active theme details:'''
 
'''The following code displays current active theme details:'''
Line 58: Line 58:
 
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&lt; 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 &lt; 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&lt;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();
 
}</code>
 
}</code>
Line 94: Line 94:
 
{
 
{
 
StoreCurrentSkinIdL();
 
StoreCurrentSkinIdL();
CArrayPtr&lt; CAknsSrvSkinInformationPkg &gt;* skinInfoArray = iSkinSrvSession.EnumerateSkinPackagesL();
+
CArrayPtr&lt; 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 &lt; skinInfoArray->Count(); i++ )
 
{
 
{
TAknsPkgID pkgId = skinInfoArray-&gt;At(i)-&gt;PID();
+
TAknsPkgID pkgId = skinInfoArray->At(i)->PID();
 
if ( pkgId&nbsp;!= iOriginalSkinPid )
 
if ( pkgId&nbsp;!= iOriginalSkinPid )
 
{
 
{
TBuf&lt;100&gt; lName = skinInfoArray-&gt;At(i)-&gt;Name();
+
TBuf&lt;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 );
Line 116: Line 116:
 
}
 
}
 
}
 
}
skinInfoArray-&gt;ResetAndDestroy();
+
skinInfoArray->ResetAndDestroy();
 
CleanupStack::PopAndDestroy();
 
CleanupStack::PopAndDestroy();
 
}</code><code cpp>void CNotifyEngine::StoreCurrentSkinIdL()
 
}</code><code cpp>void CNotifyEngine::StoreCurrentSkinIdL()
Line 122: Line 122:
 
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
Line 131: Line 131:
 
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  

Revision as of 04:24, 14 July 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 <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()&nbsp;;
}


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&lt; CAknsSrvSkinInformationPkg >* skinInfoArray = iSkinSrvSession.EnumerateSkinPackagesL();
CleanupStack::PushL( skinInfoArray );
TInt retValue( KErrNone );
if ( skinInfoArray->Count() > 0 )
{
for (TInt i=0; i &lt; skinInfoArray->Count(); i++ )
{
TAknsPkgID pkgId = skinInfoArray->At(i)->PID();
if ( pkgId == cpkgId )
{
TBuf&lt;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&lt; CAknsSrvSkinInformationPkg >* skinInfoArray = iSkinSrvSession.EnumerateSkinPackagesL();
CleanupStack::PushL( skinInfoArray );
TInt retValue( KErrNone );
if ( skinInfoArray->Count() > 0 )
{
for (TInt i=0; i &lt; skinInfoArray->Count(); i++ )
{
TAknsPkgID pkgId = skinInfoArray->At(i)->PID();
if ( pkgId&nbsp;!= iOriginalSkinPid )
{
TBuf&lt;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

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

Related topics

127 page views in the last 30 days.
×