telephonyutils/etel3rdpartyapi/ExampleApps/AutoDTMFDialler/CFlightModeInfo.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "CFlightModeInfo.h"
       
    17 
       
    18 /**
       
    19 Factory constructor.
       
    20 @param  aController Pointer to MExecAsync object passed to constructor of
       
    21                     CISVAPIBase
       
    22 @return             Instance of CFlightModeInfo class
       
    23 */
       
    24 CFlightModeInfo* CFlightModeInfo::NewL(MExecAsync* aController)
       
    25 	{
       
    26 	CFlightModeInfo* self = new(ELeave) CFlightModeInfo(aController);
       
    27 	CleanupStack::PushL(self);
       
    28 	self->ConstructL();
       
    29 	CleanupStack::Pop(self);
       
    30 	return self;
       
    31 	}
       
    32 
       
    33 /**
       
    34 Destructor.
       
    35 Calls Cancel() to cancel outstanding requests.
       
    36 */
       
    37 CFlightModeInfo::~CFlightModeInfo()
       
    38 	{
       
    39 	Cancel();
       
    40 	}
       
    41 
       
    42 /**
       
    43 Gets the flight mode status and stores it in the iFlightModeV1Pckg.
       
    44 */
       
    45 void CFlightModeInfo::DoStartRequestL()
       
    46 	{
       
    47 	// Retrieves the current flight mode status
       
    48 	iTelephony->GetFlightMode(iStatus, iFlightModeV1Pckg);
       
    49 	SetActive();
       
    50 	}
       
    51 
       
    52 /**
       
    53 Constructor called by CFlightModeInfo::NewL().
       
    54 @param aController Pointer to an MExecAsync object passed to constructor of CISVAPIBase
       
    55 */
       
    56 CFlightModeInfo::CFlightModeInfo(MExecAsync* aController)
       
    57 	: CISVAPIAsync(aController, KFlightModeInfo),
       
    58 	  iFlightModeV1Pckg(iFlightModeV1)
       
    59 	{
       
    60 	// Empty method
       
    61 	}
       
    62 
       
    63 /**
       
    64 Second phase constructor. Currently empty.
       
    65 */
       
    66 void CFlightModeInfo::ConstructL()
       
    67 	{
       
    68 	// Empty method
       
    69 	}
       
    70 
       
    71 /**
       
    72 Checks the status of the active object and displays the flight mode
       
    73 status is there is no error.
       
    74 */
       
    75 void CFlightModeInfo::RunL()
       
    76 	{
       
    77 	if(iStatus != KErrNone)
       
    78 		{
       
    79 		iConsole->Printf(KError);
       
    80 		
       
    81 		// Print error status code
       
    82 		iConsole->Printf(_L("%d\n"), iStatus.Int());
       
    83 		}
       
    84 	else
       
    85 		{
       
    86 		if(iRequestNotify)
       
    87 			{
       
    88 			iConsole->ClearScreen();
       
    89 			iConsole->Printf(_L("*~This is a notifcation\n~*"));
       
    90 			}
       
    91 		switch (iFlightModeV1.iFlightModeStatus)
       
    92 			{
       
    93 		case CTelephony::EFlightModeOff:
       
    94 			iConsole->Printf(_L("Flight Status is Off, you can make a call!\n"));
       
    95 			ExampleComplete();
       
    96 			break;
       
    97 		case CTelephony::EFlightModeOn:
       
    98 			iConsole->Printf(_L("Flight Status is On, you can't make a call!\n"));
       
    99 			ExampleNotify();
       
   100 			break;
       
   101 		default:
       
   102 			iConsole->Printf(KError);
       
   103 			}
       
   104 		}
       
   105 	}
       
   106 
       
   107 /**
       
   108 Requests to receive notifications of changes to the flight mode.
       
   109 */
       
   110 void CFlightModeInfo::DoRequestNotificationL()
       
   111 	{
       
   112 	// Panic if this object is already performing an asynchronous operation.
       
   113 	// Application will panic if you call SetActive() on an already active 
       
   114 	// object.
       
   115 	_LIT( KNotifyPanic, "CFlightModeInfo Notify Method" );
       
   116 	__ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
       
   117 	iRequestNotify = ETrue;
       
   118 
       
   119 	// Notify if there is any change to line status
       
   120 	iTelephony->NotifyChange(	iStatus,
       
   121 								CTelephony::EFlightModeChange,
       
   122 								iFlightModeV1Pckg );
       
   123 	SetActive();
       
   124 	}
       
   125 
       
   126 /**
       
   127 Cancels asynchronous request to CTelephony::GetFlightMode()
       
   128 */
       
   129 void CFlightModeInfo::DoCancel()
       
   130 	{
       
   131 	// Cancels an outstanding asynchronous request.
       
   132 	iTelephony->CancelAsync(CTelephony::EFlightModeChangeCancel);
       
   133 	}
       
   134