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 00017 #include "CFlightModeInfo.h" 00018 00026 CFlightModeInfo* CFlightModeInfo::NewL(MExecAsync* aController) 00027 { 00028 CFlightModeInfo* self = new(ELeave) CFlightModeInfo(aController); 00029 CleanupStack::PushL(self); 00030 self->ConstructL(); 00031 CleanupStack::Pop(self); 00032 return self; 00033 } 00034 00039 CFlightModeInfo::~CFlightModeInfo() 00040 { 00041 Cancel(); 00042 } 00043 00047 void CFlightModeInfo::DoStartRequestL() 00048 { 00049 // Retrieves the current flight mode status. 00050 iTelephony->GetFlightMode(iStatus, iFlightModeV1Pckg); 00051 SetActive(); 00052 } 00053 00060 CFlightModeInfo::CFlightModeInfo(MExecAsync* aController) 00061 : CISVAPIAsync(aController, KFlightModeInfo), 00062 iFlightModeV1Pckg(iFlightModeV1) 00063 { 00064 // Empty method 00065 } 00066 00070 void CFlightModeInfo::ConstructL() 00071 { 00072 // Empty method 00073 } 00074 00078 void CFlightModeInfo::RunL() 00079 { 00080 if(iStatus != KErrNone) 00081 { 00082 iConsole->Printf(KError); 00083 00084 // Print the error status code 00085 iConsole->Printf(_L("%d\n"), iStatus.Int()); 00086 } 00087 else 00088 { 00089 switch (iFlightModeV1.iFlightModeStatus) 00090 { 00091 case CTelephony::EFlightModeOff: 00092 iConsole->Printf(_L("Flight Status is Off, you can make a call!\n")); 00093 ExampleComplete(); 00094 break; 00095 case CTelephony::EFlightModeOn: 00096 iConsole->Printf(_L("Flight Status is On, you can't make a call!\n")); 00097 User::After(5000000); 00098 AppTerminate(); 00099 break; 00100 } 00101 } 00102 } 00103 00107 void CFlightModeInfo::DoRequestNotificationL() 00108 { 00109 // Panic if this object is already performing an asynchronous operation. 00110 // Application will panic if you call SetActive() on an already active object. 00111 _LIT( KNotifyPanic, "CFlightModeInfo Notify Method" ); 00112 __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 )); 00113 iRequestNotify = ETrue; 00114 00115 // Registers interest in receiving change notifications for events 00116 iTelephony->NotifyChange( iStatus, 00117 CTelephony::EFlightModeChange, 00118 iFlightModeV1Pckg ); 00119 SetActive(); 00120 } 00121 00125 void CFlightModeInfo::DoCancel() 00126 { 00127 // Cancels an outstanding asynchronous request. 00128 iTelephony->CancelAsync(CTelephony::EFlightModeChangeCancel); 00129 }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.