telephonyutils/etel3rdpartyapi/ExampleApps/IncomingCalls/CFlightModeInfo.cpp
author Tom Pritchard <tomp@symbian.org>
Tue, 27 Jul 2010 16:01:31 +0100
branchAT_Test_LTSY
changeset 55 2a8729f72b74
parent 0 3553901f7fa8
child 24 6638e7f4bd8f
permissions -rw-r--r--
Adding pre-configured C-drive image for 9600 baud modem and other changes

// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
//

#include "CFlightModeInfo.h"

/**
Factory constructor.

@param  aController Pointer to MExecAsync object passed to constructor of
                    CISVAPIBase.
@return             Instance of CFlightModeInfo class
*/
CFlightModeInfo* CFlightModeInfo::NewL(MExecAsync* aController)
	{
	CFlightModeInfo* self = new(ELeave) CFlightModeInfo(aController);
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop(self);
	return self;
	}

/**
Destructor.
Calls Cancel() to cancel outstanding requests.
*/
CFlightModeInfo::~CFlightModeInfo()
	{
	Cancel();
	}

/**
Gets the flight mode status and stores it in the iFlightModeV1Pckg.
*/
void CFlightModeInfo::DoStartRequestL()
	{
	iRequestNotify = EFalse;
	
	// Retrieves the current flight mode status.
	iTelephony->GetFlightMode(iStatus, iFlightModeV1Pckg);
	SetActive();
	}

/**
Constructor called by CFlightModeInfo::NewL().

@param aController Pointer to an MExecAsync object passed to constructor of 
                   CISVAPIBase.
*/
CFlightModeInfo::CFlightModeInfo(MExecAsync* aController)
	: CISVAPIAsync(aController, KFlightModeInfo)
	, iFlightModeV1Pckg(iFlightModeV1)
	{
	// Empty method
	}

/**
Second phase constructor.
*/
void CFlightModeInfo::ConstructL()
	{
	// Empty method
	}

/**
Displays the flight mode status if there is no error.
*/
void CFlightModeInfo::RunL()
	{
	if(iStatus != KErrNone)
		{
		iConsole->Printf(KError);
		
		// Print the error status code
		iConsole->Printf(_L("%d\n"), iStatus.Int());
		}
	else
		{
		if (iRequestNotify)
	    	{
	    	iConsole->Printf(_L("~*THIS IS A NOTIFICATION*~\n"));
	    	}
		switch (iFlightModeV1.iFlightModeStatus)
			{
		case CTelephony::EFlightModeOff:
			iConsole->Printf(_L("FlightStatus Off, you can make a calls!\n"));
			ExampleComplete();
			break;
		case CTelephony::EFlightModeOn:
			iConsole->Printf(_L("FlightStatus On, you cannot make calls!\n"));
			RequestNotificationL();
			break;
		default:
			iConsole->Printf(KError);
			}
		}
	}

/**
Requests to receive notifications of change in the flight mode.
*/
void CFlightModeInfo::DoRequestNotificationL()
	{
	// Panic if this object is already performing an asynchronous operation.
	// Application will panic if you call SetActive() on an already active object.
	_LIT( KNotifyPanic, "CFlightModeInfo Notify Method" );
	__ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
	iRequestNotify = ETrue;
	
	// Registers interest in receiving change notifications for events.
	iTelephony->NotifyChange(	iStatus,
								CTelephony::EFlightModeChange,
								iFlightModeV1Pckg );
	SetActive();
	}

/**
Cancels asynchronous request to CTelephony::GetFlightMode().
*/
void CFlightModeInfo::DoCancel()
	{
	// Cancels an outstanding asynchronous request.
	iTelephony->CancelAsync(CTelephony::EFlightModeChangeCancel);
	}