情景模式引擎 API

来源:互联网 发布:在端口 连接失败 编辑:程序博客网 时间:2024/05/20 06:37

Profiles Engine API


Reviewer Approved    
Note!
This API is not part of the public SDK. It can be found in the SDK API Plug-in.
非标准API


ProfileEngine API's are mainly used to get the list of available profiles on the mobile, get the information about the active profile,
to get information of the profile change, set a profile and related information about it.

ProfileEngine API主要用来得到可用情景模式列表,得到当前情景模式的信息,得到情景模式变化的信息,设置一个情景模式及相关的信息

Header files
#include <mprofileengine.h>
#include <mprofilesnamesarray.h>
#include <mprofile.h>
#include <mprofilename.h>
#include <mprofiletones.h>

Link against
profileeng.lib

Capabilities required for activating new profile: WriteDeviceData

Use cases
These API's are used to show the Profiles. Also used to retrieve information of the currently Active Profile,its Id, Ringtone, MessageAlertTone.
They can also be used to set a particular Profile active.

这些API用来显示情景模式,而且用来获取当前情景模式的信息,他的ID、铃声、消息提示铃声,他们也可以用来设置一个特定的情景模式。

Example code
Before using the API's first we create an instance of MProfileEngine using "CreateProfileEngineL()" API
在使用这个API之前,我们首先要使用"CreateProfileEngineL创建一个MProfileEngine

MProfileEngine* lProfileEngine = CreateProfileEngineL();

Free the resources using "Release()" API
用Release()资源释放资源

lProfileEngine->Release();

or alternatively first Push it onto CleanupStack and then PopAndDestroy()
或者用清理栈

CleanupReleasePushL( *lProfileEngine );
....
CleanupStack::PopAndDestroy();

The following code snippet is used to get the available profiles on the phone.
下列代码片段得到当前可用的情景模式

MProfilesNamesArray* profilesNamesArray =
                       lProfileEngine->ProfilesNamesArrayLC();
TInt lCount = profilesNamesArray->MdcaCount();
 
for(TInt i=0;i<lCount;i++)
    {
    TBuf<20> lName;
    lName= profilesNamesArray->ProfileName(i)->Name();
    CEikonEnv::Static()->AlertWin(_L("Available Profiles:"),lName);
    lName.Zero();
    }
 
CleanupStack::PopAndDestroy(profilesNamesArray);

The following code snippet is used to list the details of the Active profile and its properties like Profile Name, Id, etc.,
下面的代码片段用来列出当前情景模式和他的属性如:名称、ID、等等

MProfile* lProfile =  lProfileEngine->ActiveProfileL();
CleanupReleasePushL( *lProfile );
 
const MProfileName& lMProfileName = lProfile->ProfileName();
TBuf<10> lProfileName = lMProfileName.Name();
CEikonEnv::Static()->AlertWin(_L("Profile Name:"),lProfileName);
 
TInt lId = lMProfileName.Id();
TBuf<10> lProfileId;
lProfileId.AppendNum(lId);
CEikonEnv::Static()->AlertWin(_L("its Profile Id:"),lProfileId);
 
const MProfileTones& lMProfileTones = lProfile->ProfileTones();
TBuf<255> lProfileTone1 = lMProfileTones.RingingTone1();
CEikonEnv::Static()->AlertWin(_L("Profile Ringtone1:"), lProfileTone1);
 
TBuf<255> lProfileMsgalrt = lMProfileTones.MessageAlertTone();
CEikonEnv::Static()->AlertWin(_L("ProfileMsgAlrtToneName:"),lProfileMsgalrt);
 
CleanupStack::PopAndDestroy();

The following code snippet is used to set the Profile:
We pass the Id of the Profile Name to set the Profile active.

下列代码片段用来设置情景模式,我们传入情景模式的ID来设置为活动的。

lProfileEngine->SetActiveProfileL(0);

The following link is useful in getting notifications of profile change:Profile Change

Example project
ProfileEngine_SampleCode 

 

原创粉丝点击