examples/Telephony/ETel3rdPartyExample/IncomingCalls/CCallStatus.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 
00017 #include "CCallStatus.h"
00018 
00027 CCallStatus* CCallStatus::NewL(MExecAsync* aController, CTelephony::TCallId aCallId)
00028         {
00029         CCallStatus* self = new(ELeave) CCallStatus(aController, aCallId);
00030         CleanupStack::PushL(self);
00031         self->ConstructL();
00032         CleanupStack::Pop(self);
00033         return self;
00034         }
00035 
00039 CCallStatus::~CCallStatus()
00040         {
00041         Cancel();
00042         }
00043 
00048 void CCallStatus::DoStartRequestL()
00049         {
00050         iTelephony->GetCallStatus(iCallId, iCallStatusV1Pckg);
00051         iConsole->Printf((_L("%d ")), iCallId);
00052         CTelephony::TCallStatus callStatus = iCallStatusV1.iStatus;
00053         switch(callStatus)
00054                         {
00055         case CTelephony::EStatusRinging:
00056                 iConsole->Printf(_L("RING RING RING\n"));
00057                 break;
00058         case CTelephony::EStatusConnected:
00059                 iConsole->Printf(_L("Call Status connected\n"));
00060                 break;
00061         case CTelephony::EStatusConnecting:
00062                 iConsole->Printf(_L("Call Status connecting\n"));
00063                 break;
00064         case CTelephony::EStatusAnswering:
00065                 iConsole->Printf(_L("Call Status Answering\n"));
00066                 break;
00067         case CTelephony::EStatusIdle:
00068                 iConsole->Printf(_L("Call Status Idle\n"));
00069                 break;
00070         case CTelephony::EStatusDisconnecting:
00071                 iConsole->Printf(_L("Call Status Disconnecting\n"));
00072                 break;
00073         case CTelephony::EStatusHold:
00074                 iConsole->Printf(_L("Call Status on Hold\n"));
00075                 break;
00076         default:
00077                 iConsole->Printf((_L("Call status changed is %d \n")), callStatus);
00078                 break;
00079                         }
00080 
00081         if(callStatus == CTelephony::EStatusConnected)
00082                 {
00083                 ExampleComplete();
00084                 }
00085         else
00086                 {
00087                 RequestNotificationL();
00088                 }
00089         }
00090 
00098 CCallStatus::CCallStatus(MExecAsync* aController, CTelephony::TCallId aCallId)
00099         : CISVAPIAsync(aController, KCallStatus),
00100         iCallId(aCallId),
00101         iCallStatusV1Pckg(iCallStatusV1)
00102         {
00103         // Empty method
00104         }
00105 
00109 void CCallStatus::ConstructL()
00110         {
00111         // Empty method
00112         }
00113 
00117 void CCallStatus::RunL()
00118         {
00119         // Print Call Info
00120         if(iStatus != KErrNone)
00121                 {
00122                 // Return error
00123                 iConsole->Printf(KError);
00124                 
00125                 // Print the error status code
00126                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00127                 }
00128         else
00129                 {
00130                 // Print output to the console if there is no error
00131                 iConsole->Printf((_L("%d ")), iCallId);
00132                 CTelephony::TCallStatus CallStatus = iCallStatusV1.iStatus;
00133                 switch(CallStatus)
00134                         {
00135                 case CTelephony::EStatusRinging:
00136                         iConsole->Printf(_L("RING RING RING\n"));
00137                         break;
00138                 case CTelephony::EStatusConnected:
00139                         iConsole->Printf(_L("Call Status connected\n"));
00140                         break;
00141                 case CTelephony::EStatusConnecting:
00142                         iConsole->Printf(_L("Call Status connecting\n"));
00143                         break;
00144                 case CTelephony::EStatusAnswering:
00145                         iConsole->Printf(_L("Call Status Answering\n"));
00146                         break;
00147                 case CTelephony::EStatusIdle:
00148                         iConsole->Printf(_L("Call Status Idle\n"));
00149                         break;
00150                 case CTelephony::EStatusDisconnecting:
00151                         iConsole->Printf(_L("Call Status Disconnecting\n"));
00152                         break;
00153                 case CTelephony::EStatusHold:
00154                         iConsole->Printf(_L("Call Status on Hold\n"));
00155                         break;
00156                 default:
00157                         iConsole->Printf((_L("Call status is %d \n")), CallStatus);
00158                         break;
00159                         }
00160                 if (CallStatus == CTelephony::EStatusDisconnecting)
00161                         {
00162                         ExampleNotify();
00163                         }
00164                 else if(CallStatus == CTelephony::EStatusConnected)
00165                         {
00166                         ExampleComplete();
00167                         }
00168                 else
00169                         {
00170                         RequestNotificationL();
00171                         }
00172                 }
00173         }
00174 
00179 void CCallStatus::DoRequestNotificationL()
00180         {
00181         // Panic if this object is already performing an asynchronous
00182         // operation. Application will crash if you call SetActive() on an already
00183         // SetActive() 
00184         _LIT( KNotifyPanic, "CCallStatus Notify Method" );
00185         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00186         iRequestNotify = ETrue;
00187         CTelephony::TNotificationEvent iEvent;
00188 
00189         switch(iCallId)
00190                 {
00191         case CTelephony::EISVCall1:
00192                 iEvent = CTelephony::EOwnedCall1StatusChange;
00193                 break;
00194         case CTelephony::EISVCall2:
00195                 iEvent = CTelephony::EOwnedCall2StatusChange;
00196                 break;
00197         default:
00198                 // We have not been given a valid call ID
00199                 break;
00200                 }
00201 
00202         // Notify if there is any change in call status
00203         iTelephony->NotifyChange(iStatus, iEvent, iCallStatusV1Pckg);
00204         SetActive();
00205         }
00206 
00210 void CCallStatus::DoCancel()
00211         {
00212         switch(iCallId)
00213                 {
00214         case CTelephony::EISVCall1:
00215                 iTelephony->CancelAsync(CTelephony::EOwnedCall1StatusChangeCancel);
00216                 break;
00217         case CTelephony::EISVCall2:
00218                 iTelephony->CancelAsync(CTelephony::EOwnedCall2StatusChangeCancel);
00219                 break;
00220         default:
00221                 // We have not been given a valid call ID
00222                 break;
00223                 }
00224         }

Generated by  doxygen 1.6.2