examples/Telephony/ETel3rdPartyExample/OutgoingCalls/CGetLockInfo.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 "CGetLockInfo.h"
00017 
00025 CGetLockInfo* CGetLockInfo::NewL(MExecAsync* aController)
00026         {
00027         CGetLockInfo* self = new(ELeave) CGetLockInfo(aController);
00028         CleanupStack::PushL(self);
00029         self->ConstructL();
00030         CleanupStack::Pop(self);
00031         return self;
00032         }
00033 
00038 CGetLockInfo::~CGetLockInfo()
00039         {
00040         Cancel();
00041         }
00042 
00046 void CGetLockInfo::DoStartRequestL()
00047         {
00048         _LIT(KDummyAnswerPanic, "CGetLockInfo Get Method");
00049         __ASSERT_ALWAYS(!IsActive(), User::Panic(KDummyAnswerPanic, 1));
00050         iRequestNotify = EFalse;
00051         CTelephony::TIccLock lockSelect = CTelephony::ELockPin2;
00052         
00053         // Retrieves the state and status of ICC locks 
00054         iTelephony->GetLockInfo(iStatus, lockSelect, iIccLockInfoV1Pckg);
00055         SetActive();
00056         }
00057 
00064 CGetLockInfo::CGetLockInfo(MExecAsync* aController)
00065         : CISVAPIAsync(aController, KLockInfo),
00066           iIccLockInfoV1Pckg(iIccLockInfoV1)
00067         {
00068         // Empty method
00069         }
00070 
00074 void CGetLockInfo::ConstructL()
00075         {
00076         // Empty method
00077         }
00078 
00083 void CGetLockInfo::RunL()
00084         {
00085         if(iStatus != KErrNone)
00086                 {
00087                 iConsole->Printf(KError);
00088                 
00089                 // Print the error status code
00090                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00091                 }
00092         else
00093                 {
00094                 if( iIccLockInfoV1.iSetting == CTelephony::ELockSetEnabled)
00095         {
00096                         iConsole->Printf(_L("Lock 2 is available for the phone to use\n"));
00097                         switch (iIccLockInfoV1.iStatus)
00098                                 {
00099                         case CTelephony::EStatusUnlocked:
00100                                 iConsole->Printf(_L("Its current status is Unlocked\n"));
00101                                 break;
00102                         case CTelephony::EStatusBlocked:
00103                                 iConsole->Printf(_L("Its current status is blocked\n"));
00104                                 break;
00105                         case CTelephony::EStatusLocked:
00106                                 iConsole->Printf(_L("Its current status is locked\n"));
00107                                 break;
00108                         case CTelephony::EStatusUnknown:
00109                                 iConsole->Printf(_L("Its current status is unknown\n"));
00110                                 break;
00111                                 }
00112                         if (iIccLockInfoV1.iStatus == CTelephony::EStatusUnlocked)
00113                                 {
00114                                 // Lock is enabled but unlocked so can continue.
00115                                 ExampleComplete();
00116                                 }
00117                         else
00118                                 {
00119                                 DoRequestNotificationL();
00120                                 // Alert user that they may not be able to call number if it's 
00121                                 // not in their FDN phone book.
00122                                 }
00123                         }
00124                 else
00125                         {
00126                         // Lock isn't enabled so can continue
00127                         ExampleComplete();
00128                         }
00129                 }
00130         }
00131 
00135 void CGetLockInfo::DoRequestNotificationL()
00136         {
00137         // Panic if this object is already performing an asynchronous operation.
00138         // Application will panic if you call SetActive() on an already active object.
00139         _LIT( KNotifyPanic, "CGetLockInfo Notify Method" );
00140         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00141         iRequestNotify = ETrue;
00142         
00143         // Registers interest in receiving change notifications for events.
00144         iTelephony->NotifyChange(       iStatus,
00145                                                                 CTelephony::EPin2LockInfoChange,
00146                                                                 iIccLockInfoV1Pckg );
00147         SetActive();
00148         }
00149 
00153 void CGetLockInfo::DoCancel()
00154         {
00155         // Cancels an outstanding asynchronous request.
00156         iTelephony->CancelAsync(CTelephony::EPin2LockInfoChangeCancel);
00157         }
00158 

Generated by  doxygen 1.6.2