How to detect profile
Article Metadata
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;
}


(no comments yet)