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 iRequestNotify = EFalse; 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 // Active object completed with no error, therefore, print out the 00090 // flight mode status to the console. 00091 CTelephony::TFlightModeV1 FlightMode = iFlightModeV1; 00092 CTelephony::TFlightModeStatus aFlightModeStatus = FlightMode.iFlightModeStatus; 00093 if (iRequestNotify) 00094 { 00095 iConsole->ClearScreen(); 00096 iConsole->Printf(_L("~*THIS IS A NOTIFICATION*~\n")); 00097 } 00098 switch (aFlightModeStatus) 00099 { 00100 case CTelephony::EFlightModeOff: 00101 iConsole->Printf(_L("Flight Status is Off, Signal Strength can be Monitored!\n")); 00102 ExampleComplete(); 00103 break; 00104 case CTelephony::EFlightModeOn: 00105 iConsole->Printf(_L("Flight Status is On, Signal Strength cannot be Monitored!\n")); 00106 RequestNotificationL(); 00107 ExampleNotify(); 00108 break; 00109 default: 00110 iConsole->Printf(KError); 00111 } 00112 } 00113 } 00114 00118 void CFlightModeInfo::DoRequestNotificationL() 00119 { 00120 // Panic if this object is already performing an asynchronous operation. 00121 // Application will panic if you call SetActive() on an already active object. 00122 _LIT( KNotifyPanic, "CFlightModeInfo Notify Method" ); 00123 __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 )); 00124 iRequestNotify = ETrue; 00125 00126 // Registers interest in receiving change notifications for events. 00127 iTelephony->NotifyChange(iStatus, 00128 CTelephony::EFlightModeChange, 00129 iFlightModeV1Pckg ); 00130 SetActive(); 00131 } 00132 00136 void CFlightModeInfo::DoCancel() 00137 { 00138 // Cancels an outstanding asynchronous request. 00139 iTelephony->CancelAsync(CTelephony::EFlightModeChangeCancel); 00140 }
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.