Phone Security Code Tutorial

This tutorial describes how to set the security code in a Symbian platform device.

A security code controls access to the phone and can take a number of forms, such as a phone password, or SIM PIN number. Phone security functions use an RMobilePhone::TMobilePhoneSecurityCode flag to specify the type of the code.

Phone security code example

The following code takes the parameters for old and new password values, and changes the phone password.

The code assumes iMobilePhone is an RMobilePhone object.

void CClass::SetPasswordL(const TDesC& aOldPassword, const TDesC& aNewPassword)
    {
    TUint32 securityCaps;
    User::LeaveIfError(iMobilePhone.GetSecurityCaps(securityCaps));

    if (securityCaps & RMobilePhone::KCapsLockPhone)
        {
        RMobilePhone::TMobilePhonePasswordChangeV1 passwordChange;
        passwordChange.iOldPassword = aOldPassword;
        passwordChange.iNewPassword = aNewPassword;
        RMobilePhone::TMobilePhoneSecurityCode securityCode = RMobilePhone::ESecurityCodePhonePassword;
        TRequestStatus status;
        iMobilePhone.ChangeSecurityCode(status, securityCode, passwordChange);
        User::WaitForRequest(status);
        User::LeaveIfError(status.Int());
        }
    }