How to check if the phone is in offline mode
Article Metadata
There's a CenRep key KCoreAppUIsNetworkConnectionAllowed that can be used for detecting off-line mode.
#include <CoreApplicationUIsSDKCRKeys.h>To ask one time:
TInt aOfflineModeOff(0);
// Connecting and initialization:
CRepository* repository = CRepository::NewL(KCRUidCoreApplicationUIs);
// Check offline mode on or not.
if (repository->Get(KCoreAppUIsNetworkConnectionAllowed, aOfflineModeOff) == KErrNone)
{
// Do something based on the aOfflineModeOff value
}
delete repository;
You might want to order notifications about the changes:
iRepository = CRepository::NewL(KCRUidCoreApplicationUIs);
iCenRepNotifyHandler =
CCenRepNotifyHandler::NewL(*this, *iRepository,
CCenRepNotifyHandler::EIntKey, KCoreAppUIsNetworkConnectionAllowed);
iCenRepNotifyHandler->StartListeningL();
void CThisClass::HandleNotifyInt(
TUint32 aId,
TInt aNewValue )
{
if (aId == KCoreAppUIsNetworkConnectionAllowed)
{
// Do something based on the aNewValue
}
}
// Remeber to delete created objects in the destructor
S60 3rd, FP1
Another way to query the profile is to use the Profiles Engine Wrapper API:
#include <proengfactory.h>
#include <mproengengine.h>
MProEngEngine* engine = ProEngFactory::NewEngineLC();
TInt profileId = engine->ActiveProfileId();
if (profileId == 5) //offline
{
//…
}
CleanupStack::PopAndDestroy(); //engine


(no comments yet)