×
Namespaces

Variants
Actions
Revision as of 08:02, 22 December 2011 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

扩展皮肤API

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

代码示例
文章
翻译:
hoolee
最后由 hamishwillee 在 22 Dec 2011 编辑
  • 详细描述

这个API并非公开SDK的一部分,可以在这里找到SDK API Plug-in

  • 用例

改变当前主题

收到主题内容,配置的改变通知

获得皮肤包信息

删除皮肤,复制拷贝皮肤

设置桌面

  • 示例代码

头文件

#include <AknSSrvClient.h>
#include <AknsPkgID.h>
#include <AknsItemDef.h>
#include <AknsItemID.h>
#include <AknsSrvSkinInformationPkg.h>
#include <EIKENV.H>
#include <centralrepository.h>
#include <AknSkinsInternalCRKeys.h>
  • 需要的库链接
aknskinsrv.lib centralrepository.lib
  • 需要能的能力
CAPABILITY WriteDeviceData


先与skin服务连接

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

虚函数

{
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(""));
}

下列代码列出了当前主题:

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

下列代码改变了主题

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);
}
  • 示例程序

File:ExtSkins.zip

This page was last modified on 22 December 2011, at 08:02.
92 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.

×