examples/Telephony/ETel3rdPartyExample/OutgoingCalls/CLineStatus.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 "CLineStatus.h"
00018 
00026 CLineStatus* CLineStatus::NewL(MExecAsync* aController)
00027         {
00028         CLineStatus* self = new(ELeave) CLineStatus(aController);
00029         CleanupStack::PushL(self);
00030         self->ConstructL();
00031         CleanupStack::Pop(self);
00032         return self;
00033         }
00034 
00039 CLineStatus::~CLineStatus()
00040         {
00041         Cancel();
00042         }
00043 
00048 void CLineStatus::DoStartRequestL()
00049         {
00050     iRequestNotify = EFalse;
00051     CTelephony::TPhoneLine line = CTelephony::EVoiceLine;
00052    
00053    // Retrieves the status of the line selected by the specified argument
00054         iTelephony->GetLineStatus(line, iLineStatusV1Pckg);
00055         CTelephony::TCallStatus voiceLineStatus = iLineStatusV1.iStatus;
00056         switch (voiceLineStatus)
00057                 {
00058         case CTelephony::EStatusRinging:
00059                 iConsole->Printf(_L("RING RING RING\n"));
00060                 break;
00061         case CTelephony::EStatusConnected:
00062                 iConsole->Printf(_L("Line Status: Connected\n"));
00063                 break;
00064         case CTelephony::EStatusConnecting:
00065                 iConsole->Printf(_L("Line Status: Connecting\n"));
00066                 break;
00067         case CTelephony::EStatusAnswering:
00068                 iConsole->Printf(_L("Line Status: Answering\n"));
00069                 break;
00070         case CTelephony::EStatusIdle:
00071                 iConsole->Printf(_L("Line Status: Idle\n"));
00072                 break;
00073         case CTelephony::EStatusDisconnecting:
00074                 iConsole->Printf(_L("Line Status: Disconnecting\n"));
00075                 break;
00076         case CTelephony::EStatusHold:
00077                 iConsole->Printf(_L("Line Status: On Hold\n"));
00078                 break;
00079         default:
00080                 iConsole->Printf(_L("Line status changed.\n"));
00081                 break;
00082                 }
00083         if (voiceLineStatus == CTelephony::EStatusIdle)
00084                 {
00085                 ExampleNotify();
00086                 }
00087         else
00088                 {
00089                 if (!IsActive())
00090                         {
00091                         RequestNotificationL();
00092                         }
00093                 }
00094         }
00095         
00102 CLineStatus::CLineStatus(MExecAsync* aController)
00103         : CISVAPIAsync(aController, KLineStatus),
00104           iLineStatusV1Pckg(iLineStatusV1)
00105         {
00106         // Empty method
00107         }
00108 
00112 void CLineStatus::ConstructL()
00113         {
00114         // Empty method
00115         }
00116 
00121 void CLineStatus::RunL()
00122         {
00123         CTelephony::TCallStatus voiceLineStatus = iLineStatusV1.iStatus;
00124         // Print Line Information.
00125         if(iStatus != KErrNone)
00126                 {
00127                 iConsole->Printf(KError);
00128                 
00129                 // Print the error status code
00130                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00131                 }
00132         else
00133                 {
00134                 switch (voiceLineStatus)
00135                         {
00136                 case CTelephony::EStatusRinging:
00137                         iConsole->Printf(_L("RING RING RING\n"));
00138                         break;
00139                 case CTelephony::EStatusConnected:
00140                         iConsole->Printf(_L("Line Status: Connected\n"));
00141                         break;
00142                 case CTelephony::EStatusConnecting:
00143                         iConsole->Printf(_L("Line Status: Connecting\n"));
00144                         break;
00145                 case CTelephony::EStatusAnswering:
00146                         iConsole->Printf(_L("Line Status: Answering\n"));
00147                         break;
00148                 case CTelephony::EStatusIdle:
00149                         iConsole->Printf(_L("Line Status: Idle\n"));
00150                         break;
00151                 case CTelephony::EStatusDisconnecting:
00152                         iConsole->Printf(_L("Line Status: Disconnecting\n"));
00153                         break;
00154                 case CTelephony::EStatusHold:
00155                         iConsole->Printf(_L("Line Status: On Hold\n"));
00156                         break;
00157                 default:
00158                         iConsole->Printf(_L("Line status changed.\n"));
00159                         break;
00160                         }
00161                 if (voiceLineStatus == CTelephony::EStatusIdle
00162                                 ||  voiceLineStatus == CTelephony::EStatusHold)
00163                         {
00164                         ExampleNotify();
00165                         }
00166                 else if (voiceLineStatus == CTelephony::EStatusRinging)
00167                         {
00168                         ExampleComplete();
00169                         }
00170                 else
00171                         {
00172                         if (!IsActive())
00173                                 {
00174                                 RequestNotificationL();
00175                                 }
00176                         }
00177                 }
00178         }
00179 
00184 void CLineStatus::DoRequestNotificationL()
00185         {
00186         // Panic if this object is already performing an asynchronous operation. 
00187         // Application will panic if you call SetActive() on an already active object.
00188         _LIT( KNotifyPanic, "CLineStatus Notify Method" );
00189         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00190         iRequestNotify = ETrue;
00191         
00192         // Registers interest in receiving change notifications for events.
00193         iTelephony->NotifyChange(iStatus,
00194                                                                 CTelephony::EVoiceLineStatusChange,
00195                                                                 iLineStatusV1Pckg );
00196         SetActive();
00197         }
00198 
00202 void CLineStatus::DoCancel()
00203         {
00204         // Cancels an outstanding asynchronous request.
00205         iTelephony->CancelAsync(CTelephony::EVoiceLineStatusChangeCancel);
00206         }
00207 

Generated by  doxygen 1.6.2