Enabling and disabling keypad lock using Symbian C++
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|write your reason here}}.
Article Metadata
Code Example
Source file: Media:ExampleStub CS000932.zip Media:CS000932 Enabling and disabling keypad lock.diff.zip
Tested with
Devices(s): Nokia N95 8GB
Compatibility
Platform(s): S60 3rd Edition, MR
Article
Keywords: RAknKeyLock, RAknKeyLock::IsKeyLockEnabled(), RAknKeyLock::EnableKeyLock(), RAknKeyLock::EnableWithoutNote(), RAknKeyLock::DisableKeyLock(), RAknKeyLock::DisableWithoutNote(), RAknKeyLock::EnableAutoLockEmulation()
Created: tapla
(23 Apr 2008)
Last edited: hamishwillee
(10 May 2012)
Contents |
Overview
This code snippet demonstrates the following use cases regarding enabling and disabling keypad lock:
- Offering the user to enable the key lock.
- Enabling the key lock and showing a notification ("Keypad locked" or similar).
- Enabling the key lock without showing a notification.
- Disabling the key lock and showing a notification ("Keypad unlocked" or similar).
- Disabling the key lock without showing a notification.
- Locking the device keys similarly to device lock (unlocking requires a lock code).
This snippet can be self-signed.
MMP file
The following libraries are required:
LIBRARY avkon.lib
Source file
#include <aknkeylock.h> // RAknKeyLock
RAknKeyLock keyLock;
// Connect to the notifier server so that key lock state notifications can be
// displayed
User::LeaveIfError(keyLock.Connect());
// USE CASE 1
// If the key lock is not enabled, ask the user whether it should be
if (!keyLock.IsKeyLockEnabled())
{
keyLock.OfferKeyLock();
}
// USE CASE 2
// If the key lock is not enabled, enable it and show a notification
if (!keyLock.IsKeyLockEnabled())
{
keyLock.EnableKeyLock();
}
// USE CASE 3
// If the key lock is not enabled, enable it without showing a notification
if (!keyLock.IsKeyLockEnabled())
{
keyLock.EnableWithoutNote();
}
// USE CASE 4
// If the key lock is enabled, disable it and show a notification
if (keyLock.IsKeyLockEnabled())
{
keyLock.DisableKeyLock();
}
// USE CASE 5
// If the key lock is enabled, disable it without showing a notification
if (keyLock.IsKeyLockEnabled())
{
keyLock.DisableWithoutNote();
}
// USE CASE 6
// Lock the device keys similarly to device lock (unlocking requires a lock
// code)
keyLock.EnableAutoLockEmulation();
// Close the session with the notifier server
keyLock.Close();
Supplementary material
- You can test the keypad lock features in action in a simple, executable application into which this code snippet has been patched. The application is available for download at: Media:ExampleStub CS000932.zip
- You can examine all the changes that are required to implement keypad lock handling in an application. The changes are provided in unified diff and color-coded diff formats: Media:CS000932 Enabling and disabling keypad lock.diff.zip
- For general information on applying the patch, see Using Diffs.
- For unpatched stub applications, see Example stub.


(no comments yet)