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

Generated by  doxygen 1.6.2