examples/Telephony/ETel3rdPartyExample/IncomingCalls/CCallForwardingStatus.cpp

00001 /*
00002 Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 * Redistributions in binary form must reproduce the above copyright notice,
00010   this list of conditions and the following disclaimer in the documentation
00011   and/or other materials provided with the distribution.
00012 * Neither the name of Nokia Corporation nor the names of its contributors
00013   may be used to endorse or promote products derived from this software
00014   without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 Description:  
00028 */
00029 
00030 
00031 #include "CCallForwardingStatus.h"
00032 
00040 CCallForwardingStatus* CCallForwardingStatus::NewL(MExecAsync* aController)
00041         {
00042         CCallForwardingStatus* self = new(ELeave) CCallForwardingStatus(aController);
00043         CleanupStack::PushL(self);
00044         self->ConstructL();
00045         CleanupStack::Pop(self);
00046         return self;
00047         }
00048 
00052 CCallForwardingStatus::~CCallForwardingStatus()
00053         {
00054         Cancel();
00055         }
00056 
00060 void CCallForwardingStatus::ConstructL()
00061         {
00062         iSecondCondition = EFalse;
00063         }
00064 
00068 void CCallForwardingStatus::DoStartRequestL()
00069         {
00070         _LIT( KNotifyPanic, "CCallForwardingStatus Get Method" );
00071         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00072         iRequestNotify = EFalse;
00073         if (iSecondCondition)
00074                 {
00075                 iSecondCondition = EFalse;
00076                 CTelephony::TCallForwardingCondition condition2 = CTelephony::ECallForwardingUnconditional;
00077                 
00078                 // Interrogates the current status of the call forwarding services.
00079                 iTelephony->GetCallForwardingStatus(iStatus,
00080                                                     condition2,
00081                                                     iCallForwardingStatus2V1Pckg);
00082                 }
00083         else
00084                 {
00085                 iSecondCondition = ETrue;
00086                 CTelephony::TCallForwardingCondition condition1 = CTelephony::ECallForwardingNoReply;
00087                 
00088                 // Interrogates the current status of the call forwarding services.
00089                 iTelephony->GetCallForwardingStatus(iStatus,
00090                                                     condition1,
00091                                                     iCallForwardingStatus1V1Pckg);
00092                 }
00093         SetActive();
00094         }
00095 
00102 CCallForwardingStatus::CCallForwardingStatus(MExecAsync* aController)
00103         : CISVAPIAsync(aController, KCallForwardingStatus),
00104           iCallForwardingStatus1V1Pckg(iCallForwardingStatus1V1),
00105           iCallForwardingStatus2V1Pckg(iCallForwardingStatus2V1)
00106         {
00107         // Empty method
00108         }
00109 
00114 void CCallForwardingStatus::RunL()
00115         {
00116         if(iStatus != KErrNone)
00117                 {
00118                 iConsole->Printf(KError);
00119                 
00120                 // Print the error status code
00121                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00122                 }
00123         else
00124                 {
00125                 if (!iSecondCondition)
00126                         {
00127                         iConsole->Printf(KCallForwardingStatusMsg);
00128                         switch(iCallForwardingStatus1V1.iCallForwarding)
00129                                 {
00130                         case CTelephony::EStatusActive:
00131                                 // Call Forwarding is active when there is no answer!
00132                                 // Could end application here by calling Terminate().
00133                                 // Wait for 5 seconds then continue by calling ExampleComplete().
00134                                 iConsole->Printf(_L("Call Forwarding impinges on incoming calls!\n"));
00135                                 iConsole->Printf(_L("Recify this to remove this delay\n"));
00136                                 User::After(5000000);
00137                         case CTelephony::ENotActive:
00138                         case CTelephony::ENotProvisioned:
00139                         case CTelephony::ENotAvailable:
00140                         case CTelephony::EUnknown:
00141                                 break;
00142                                 }
00143                         switch(iCallForwardingStatus2V1.iCallForwarding)
00144                                 {
00145                         case CTelephony::EStatusActive:
00146                                 // Call Forwarding is active on all incoming calls!
00147                                 // Could end application here by calling Terminate().
00148                                 // Wait for 5 seconds then continue by calling ExampleComplete().
00149                                 iConsole->Printf(_L("Call Forwarding impinges on incoming calls!\n"));
00150                                 iConsole->Printf(_L("Recify this to remove this delay\n"));
00151                                 User::After(5000000);
00152                         case CTelephony::ENotActive:
00153                         case CTelephony::ENotProvisioned:
00154                         case CTelephony::ENotAvailable:
00155                         case CTelephony::EUnknown:
00156                                 ExampleComplete();
00157                                 break;
00158                                 }
00159                         }
00160                 else
00161                         {
00162                         ExampleNotify();
00163                         }
00164                 }
00165         }
00166 
00170 void CCallForwardingStatus::DoCancel()
00171         {
00172         // Cancels an outstanding asynchronous request.
00173         iTelephony->CancelAsync(CTelephony::EGetCallForwardingStatusCancel);
00174         }

Generated by  doxygen 1.6.2