examples/Telephony/ETel3rdPartyExample/IncomingCalls/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 
00025 CFlightModeInfo* CFlightModeInfo::NewL(MExecAsync* aController)
00026         {
00027         CFlightModeInfo* self = new(ELeave) CFlightModeInfo(aController);
00028         CleanupStack::PushL(self);
00029         self->ConstructL();
00030         CleanupStack::Pop(self);
00031         return self;
00032         }
00033 
00038 CFlightModeInfo::~CFlightModeInfo()
00039         {
00040         Cancel();
00041         }
00042 
00046 void CFlightModeInfo::DoStartRequestL()
00047         {
00048         iRequestNotify = EFalse;
00049         
00050         // Retrieves the current flight mode status.
00051         iTelephony->GetFlightMode(iStatus, iFlightModeV1Pckg);
00052         SetActive();
00053         }
00054 
00061 CFlightModeInfo::CFlightModeInfo(MExecAsync* aController)
00062         : CISVAPIAsync(aController, KFlightModeInfo)
00063         , iFlightModeV1Pckg(iFlightModeV1)
00064         {
00065         // Empty method
00066         }
00067 
00071 void CFlightModeInfo::ConstructL()
00072         {
00073         // Empty method
00074         }
00075 
00079 void CFlightModeInfo::RunL()
00080         {
00081         if(iStatus != KErrNone)
00082                 {
00083                 iConsole->Printf(KError);
00084                 
00085                 // Print the error status code
00086                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00087                 }
00088         else
00089                 {
00090                 if (iRequestNotify)
00091                 {
00092                 iConsole->Printf(_L("~*THIS IS A NOTIFICATION*~\n"));
00093                 }
00094                 switch (iFlightModeV1.iFlightModeStatus)
00095                         {
00096                 case CTelephony::EFlightModeOff:
00097                         iConsole->Printf(_L("FlightStatus Off, you can make a calls!\n"));
00098                         ExampleComplete();
00099                         break;
00100                 case CTelephony::EFlightModeOn:
00101                         iConsole->Printf(_L("FlightStatus On, you cannot make calls!\n"));
00102                         RequestNotificationL();
00103                         break;
00104                 default:
00105                         iConsole->Printf(KError);
00106                         }
00107                 }
00108         }
00109 
00113 void CFlightModeInfo::DoRequestNotificationL()
00114         {
00115         // Panic if this object is already performing an asynchronous operation.
00116         // Application will panic if you call SetActive() on an already active object.
00117         _LIT( KNotifyPanic, "CFlightModeInfo Notify Method" );
00118         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00119         iRequestNotify = ETrue;
00120         
00121         // Registers interest in receiving change notifications for events.
00122         iTelephony->NotifyChange(       iStatus,
00123                                                                 CTelephony::EFlightModeChange,
00124                                                                 iFlightModeV1Pckg );
00125         SetActive();
00126         }
00127 
00131 void CFlightModeInfo::DoCancel()
00132         {
00133         // Cancels an outstanding asynchronous request.
00134         iTelephony->CancelAsync(CTelephony::EFlightModeChangeCancel);
00135         }

Generated by  doxygen 1.6.2