×
Namespaces

Variants
Actions

Archived:Notification of a change in the Active Profile Ringtone using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: 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|user=~~~~|write your reason here}}.

Article Metadata
Code ExampleTested with
Devices(s): All devices
Compatibility
Platform(s): S60 3rd Edition, MR
S60 3rd Edition (initial release)
Article
Created: User:Technical writer 1 (17 Oct 2007)
Last edited: hamishwillee (01 Jul 2012)

Overview

Profiles Engine API, part of the Extension plug-in package for S60 3rd Edition, MR, provides the class CProfileChangeNotifyHandler that can be used to get a notification for activation of a new profile and modifications of current active profile settings.

See also How to get notification of profile change

Description

Header files:

 #include <CProfileChangeNotifyHandler.h>
 #include <MProfileChangeObserver.h>
 #include <MProfileEngine.h>  // link against profileeng.lib
 #include <MProfile.h>
 #include <MProfileTones.h>

Derive a class from MProfileChangeObserver and implement a pure virtual function HandleActiveProfileEventL() in order to get notifications.

Create an instance of CProfileChangeNotifyHandler class in the ConstructL() of this class:

 CProfileChangeNotifyHandler* iHandler = 
     CProfileChangeNotifyHandler::NewL( this );

First, store the ring tone from the active profile in a descriptor. Whenever a change notification for the active profile comes in, re-retrieve the ring tone and compare it with the old value.

The following code is used to get the active profile ring tone:

 MProfileEngine* profileEngine = CreateProfileEngineL();
 CleanupReleasePushL(*profileEngine);
 MProfile* activProfile = 
     profileEngine->ActiveProfileL();
 const MProfileTones& activeProfileTone = 
     activProfile->ProfileTones();
 // iCurrentRingTone is of type TFileName
 iCurrentRingTone = activeProfileTone.RingingTone1(); 
 CleanupStack::PopAndDestroy(); // profileEngine

Implementation of HandleActiveProfileEventL():

 HandleActiveProfileEventL( TProfileEvent aProfileEvent, 
                            TInt aProfileId )
   {
   switch(aProfileEvent)
     {
     case EProfileActiveProfileModified:
       {
       // Active profile settings are modified
       MProfileEngine* profileEngineNew =
           CreateProfileEngineL();
       CleanupReleasePushL(*profileEngineNew);
       MProfile* activeProfileNew = 
           profileEngineNew->ActiveProfileL();
       const MProfileTones& activeProfileToneNew = 
           activeProfileNew->ProfileTones();
       TFileName ringToneNew = 
           activeProfileToneNew.RingingTone1();
       TBool ringToneChanged = 
           iCurrentRingTone.operator!=(ringToneNew);
 
       if( ringToneChanged )
         {
         // Active profile ring tone changed
         iCurrentRingTone = ringToneNew;
         }
       else
         {
         // Some other profile settings have changed
         }
       CleanupStack::PopAndDestroy(); // profileEngineNew
       break;
       }
     default:
       break;
     }
   }

File:NotifyProfileRingtoneChange.zip

This page was last modified on 1 July 2012, at 11:29.
36 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.

×