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

Generated by  doxygen 1.6.2