telephonyutils/etel3rdpartyapi/ExampleApps/IncomingCalls/CCallBarringStatus.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "CCallBarringStatus.h"
       
    17 
       
    18 /**
       
    19 Factory constructor.
       
    20 
       
    21 @param  aController Pointer to MExecAsync object passed to constructor of 
       
    22                     CISVAPIBase
       
    23 @return             Instance of CCallBarringStatus class
       
    24 */
       
    25 CCallBarringStatus* CCallBarringStatus::NewL(MExecAsync* aController)
       
    26 	{
       
    27 	CCallBarringStatus* self = new(ELeave) CCallBarringStatus(aController);
       
    28 	CleanupStack::PushL(self);
       
    29 	self->ConstructL();
       
    30 	CleanupStack::Pop(self);
       
    31 	return self;
       
    32 	}
       
    33 
       
    34 /**
       
    35 Destructor.
       
    36 Calls Cancel() to cancel outstanding requests.
       
    37 */
       
    38 CCallBarringStatus::~CCallBarringStatus()
       
    39 	{
       
    40 	Cancel();
       
    41 	}
       
    42 
       
    43 /**
       
    44 Gets the current call barring status and stores the result in
       
    45 iCallBarringStatusV1Pckg.
       
    46 */
       
    47 void CCallBarringStatus::DoStartRequestL()
       
    48 	{
       
    49 	_LIT( KNotifyPanic, "CCallBarringStatus Get Method" );
       
    50 	__ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
       
    51 	iRequestNotify = EFalse;
       
    52 	CTelephony::TCallBarringCondition condition = CTelephony::EBarAllIncoming;
       
    53 	
       
    54 	// Interrogate the current status of the call barring services
       
    55 	iTelephony->GetCallBarringStatus(	iStatus,
       
    56 										condition,
       
    57 										iCallBarringStatusV1Pckg);
       
    58 	SetActive();
       
    59 	}
       
    60 
       
    61 /**
       
    62 Constructor.
       
    63 
       
    64 @param aController Pointer to an MExecAsync object passed to constructor of 
       
    65                    CISVAPIBase.
       
    66 */
       
    67 CCallBarringStatus::CCallBarringStatus(MExecAsync* aController)
       
    68 	: CISVAPIAsync(aController, KCallBarringStatus)
       
    69 	, iCallBarringStatusV1Pckg(iCallBarringStatusV1)
       
    70 	{
       
    71 	//
       
    72 	}
       
    73 
       
    74 /**
       
    75 Second phase constructor.
       
    76 */
       
    77 void CCallBarringStatus::ConstructL()
       
    78 	{
       
    79 	// Empty method
       
    80 	}
       
    81 
       
    82 /**
       
    83 Checks the status of the active object and displays the retrieved call barring
       
    84 status if there is no error.
       
    85 */
       
    86 void CCallBarringStatus::RunL()
       
    87 	{
       
    88 	if(iStatus != KErrNone)
       
    89 		{
       
    90 		iConsole->Printf(KError);
       
    91 		
       
    92 		// Print the error status code
       
    93 		iConsole->Printf(_L("%d\n"), iStatus.Int());
       
    94 		}
       
    95 	else
       
    96 		{
       
    97 		// Print the console output message if there is no error
       
    98 		iConsole->Printf(KCallBarringStatusMsg);
       
    99 		switch(iCallBarringStatusV1.iCallBarring)
       
   100 			{
       
   101 		case CTelephony::EStatusActive:
       
   102 			// Call barring is active and restricts all incoming calls!
       
   103 			// Could end application here by calling Terminate().
       
   104 			// Wait for 5 seconds then continue by calling ExampleComplete()
       
   105 			iConsole->Printf(_L("Call Barring Restricts incoming calls!\n"));
       
   106 			iConsole->Printf(_L("Recify this to remove this delay\n"));
       
   107 			User::After(5000000);
       
   108 			ExampleComplete();
       
   109 			break;
       
   110 		case CTelephony::ENotActive:
       
   111 		case CTelephony::ENotProvisioned:
       
   112 		case CTelephony::ENotAvailable:
       
   113 		case CTelephony::EUnknown:
       
   114 			ExampleComplete();
       
   115 			break;
       
   116 			}
       
   117 		}
       
   118 	}
       
   119 
       
   120 /**
       
   121 Cancels asynchronous request to CTelephony::GetCallBarringStatus().
       
   122 */
       
   123 void CCallBarringStatus::DoCancel()
       
   124 	{
       
   125 	// Cancels an outstanding asynchronous request
       
   126 	iTelephony->CancelAsync(CTelephony::EGetCallBarringStatusCancel);
       
   127 	}