examples/Telephony/ETel3rdPartyExample/AutoDTMFDialler/CFlightModeInfo.cpp

00001 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
00002 // All rights reserved.
00003 // This component and the accompanying materials are made available
00004 // under the terms of "Eclipse Public License v1.0"
00005 // which accompanies this distribution, and is available
00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00007 //
00008 // Initial Contributors:
00009 // Nokia Corporation - initial contribution.
00010 //
00011 // Contributors:
00012 //
00013 // Description:
00014 //
00015 
00016 #include "CFlightModeInfo.h"
00017 
00024 CFlightModeInfo* CFlightModeInfo::NewL(MExecAsync* aController)
00025         {
00026         CFlightModeInfo* self = new(ELeave) CFlightModeInfo(aController);
00027         CleanupStack::PushL(self);
00028         self->ConstructL();
00029         CleanupStack::Pop(self);
00030         return self;
00031         }
00032 
00037 CFlightModeInfo::~CFlightModeInfo()
00038         {
00039         Cancel();
00040         }
00041 
00045 void CFlightModeInfo::DoStartRequestL()
00046         {
00047         // Retrieves the current flight mode status
00048         iTelephony->GetFlightMode(iStatus, iFlightModeV1Pckg);
00049         SetActive();
00050         }
00051 
00056 CFlightModeInfo::CFlightModeInfo(MExecAsync* aController)
00057         : CISVAPIAsync(aController, KFlightModeInfo),
00058           iFlightModeV1Pckg(iFlightModeV1)
00059         {
00060         // Empty method
00061         }
00062 
00066 void CFlightModeInfo::ConstructL()
00067         {
00068         // Empty method
00069         }
00070 
00075 void CFlightModeInfo::RunL()
00076         {
00077         if(iStatus != KErrNone)
00078                 {
00079                 iConsole->Printf(KError);
00080                 
00081                 // Print error status code
00082                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00083                 }
00084         else
00085                 {
00086                 if(iRequestNotify)
00087                         {
00088                         iConsole->ClearScreen();
00089                         iConsole->Printf(_L("*~This is a notifcation\n~*"));
00090                         }
00091                 switch (iFlightModeV1.iFlightModeStatus)
00092                         {
00093                 case CTelephony::EFlightModeOff:
00094                         iConsole->Printf(_L("Flight Status is Off, you can make a call!\n"));
00095                         ExampleComplete();
00096                         break;
00097                 case CTelephony::EFlightModeOn:
00098                         iConsole->Printf(_L("Flight Status is On, you can't make a call!\n"));
00099                         ExampleNotify();
00100                         break;
00101                 default:
00102                         iConsole->Printf(KError);
00103                         }
00104                 }
00105         }
00106 
00110 void CFlightModeInfo::DoRequestNotificationL()
00111         {
00112         // Panic if this object is already performing an asynchronous operation.
00113         // Application will panic if you call SetActive() on an already active 
00114         // object.
00115         _LIT( KNotifyPanic, "CFlightModeInfo Notify Method" );
00116         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00117         iRequestNotify = ETrue;
00118 
00119         // Notify if there is any change to line status
00120         iTelephony->NotifyChange(       iStatus,
00121                                                                 CTelephony::EFlightModeChange,
00122                                                                 iFlightModeV1Pckg );
00123         SetActive();
00124         }
00125 
00129 void CFlightModeInfo::DoCancel()
00130         {
00131         // Cancels an outstanding asynchronous request.
00132         iTelephony->CancelAsync(CTelephony::EFlightModeChangeCancel);
00133         }
00134 

Generated by  doxygen 1.6.2