Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How to detect profile

From Wiki
Jump to: navigation, search
Article Metadata
Article
Created: rihoe (14 Sep 2007)
Last edited: hamishwillee (26 Jul 2012)

This sample shows how to detect if the user has selected silent profile (in Symbian 3rd edition and in older models)

TBool CheckIfSilentMode()
{
#ifdef __SERIES60_3X__
TBool inSilentMode=EFalse;
 
CRepository* cr = CRepository::NewLC( KCRUidProfileEngine );
TInt value;
// Get the ID of the currently active profile:
/*
* 0 = General profile (default value)<br>
* 1 = Silent profile<br>
* 2 = Meeting profile<br>
* 3 = Outdoor profile<br>
* 4 = Pager profile<br>
* 5 = Off-line profile<br>
* 6 = Drive profile<br>
*/

cr->Get( KProEngActiveProfile, value ) ;
if(value==1||value==2)
inSilentMode=ETrue;
cr->Get( KProEngActiveRingingType, value );
if(value==4) //silent
inSilentMode=ETrue;
CleanupStack::PopAndDestroy( cr );
 
#else
_LIT(KProfileDatabase,"c:\\system\\Apps\\profileApp\\dbProfile.db");
_LIT(KProfileLookup,"ProfileLookup");
_LIT(KProfileStore,"ProfileStore");
 
CPermanentFileStore* fstore =
CPermanentFileStore::OpenLC(CEikonEnv::Static()->FsSession(),
KProfileDatabase,EFileRead);
RDbStoreDatabase database;
database.OpenL(fstore,fstore->Root());
RDbTable table;
 
table.Open(database, KProfileLookup);
TBool foundactive = EFalse;
TInt prfindex=0;
while (table.NextL() && !foundactive)
{
table.GetL();
if (!table.IsColNull(6) && (table.ColInt16(6) != 0) )
{
foundactive = ETrue;
prfindex = table.ColInt16(1);
}
}
table.Close();
 
TBuf<20> tablestr;
tablestr.Format(_L("PRF%d"),prfindex);
table.Open(database,tablestr);
 
// first record, field 3 holds call alert
// a value of 4 means silent mode
table.FirstL();
table.GetL();
TInt value;
value = table.ColInt16(3);
inSilentMode = (value == 4);
table.Close();
 
database.Close();
CleanupStack::PopAndDestroy(fstore);
#endif
return inSilentMode;
}

Related Links

This page was last modified on 26 July 2012, at 03:12.
44 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.

×