examples/Telephony/ETel3rdPartyExample/AutoDTMFDialler/CLineStatus.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 "CLineStatus.h"
00032 
00039 CLineStatus* CLineStatus::NewL(MExecAsync* aController)
00040         {
00041         CLineStatus* self = new(ELeave) CLineStatus(aController);
00042         CleanupStack::PushL(self);
00043         self->ConstructL();
00044         CleanupStack::Pop(self);
00045         return self;
00046         }
00047 
00052 CLineStatus::~CLineStatus()
00053         {
00054         Cancel();
00055         }
00056 
00060 void CLineStatus::DoStartRequestL()
00061         {
00062     iRequestNotify = EFalse;
00063     CTelephony::TPhoneLine line = CTelephony::EVoiceLine;
00064    
00065     // Retrieves the status of the line selected by the argument
00066         iTelephony->GetLineStatus(line, iLineStatusV1Pckg);
00067         CTelephony::TCallStatus voiceLineStatus = iLineStatusV1.iStatus;
00068         switch (voiceLineStatus)
00069                 {
00070         case CTelephony::EStatusRinging:
00071                 iConsole->Printf(_L("RING RING RING\n"));
00072                 break;
00073         case CTelephony::EStatusConnected:
00074                 iConsole->Printf(_L("Line Status connected\n"));
00075                 break;
00076         case CTelephony::EStatusConnecting:
00077                 iConsole->Printf(_L("Line Status connecting\n"));
00078                 break;
00079         case CTelephony::EStatusAnswering:
00080                 iConsole->Printf(_L("Line Status Answering\n"));
00081                 break;
00082         case CTelephony::EStatusIdle:
00083                 iConsole->Printf(_L("Line Status Idle\n"));
00084                 break;
00085         case CTelephony::EStatusDisconnecting:
00086                 iConsole->Printf(_L("Line Status Disconnecting\n"));
00087                 break;
00088         case CTelephony::EStatusHold:
00089                 iConsole->Printf(_L("Line Status on Hold\n"));
00090                 break;
00091         default:
00092                 iConsole->Printf(_L("Line status changed\n"));
00093                 break;
00094                 }
00095         if (voiceLineStatus == CTelephony::EStatusIdle)
00096                 {
00097                 ExampleNotify();
00098                 }
00099         else
00100                 {
00101                 if (!IsActive())
00102                         {
00103                                 RequestNotificationL();
00104                         }
00105                 }
00106         }
00107 
00112 CLineStatus::CLineStatus(MExecAsync* aController)
00113         : CISVAPIAsync(aController, KLineStatus),
00114           iLineStatusV1Pckg(iLineStatusV1)
00115         {
00116         // Empty method
00117         }
00118 
00122 void CLineStatus::ConstructL()
00123         {
00124         // Empty method
00125         }
00126 
00131 void CLineStatus::RunL()
00132         {
00133         CTelephony::TCallStatus voiceLineStatus = iLineStatusV1.iStatus;
00134         // Print Line Info
00135         if(iStatus != KErrNone)
00136                 {
00137                 iConsole->Printf(KError);
00138                 
00139                 // Print error status code
00140                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00141                 }
00142         else
00143                 {
00144                 switch (voiceLineStatus)
00145                         {
00146                 case CTelephony::EStatusRinging:
00147                         iConsole->Printf(_L("RING RING RING\n"));
00148                         break;
00149                 case CTelephony::EStatusConnected:
00150                         iConsole->Printf(_L("Line Status: Connected\n"));
00151                         break;
00152                 case CTelephony::EStatusConnecting:
00153                         iConsole->Printf(_L("Line Status: Connecting\n"));
00154                         break;
00155                 case CTelephony::EStatusAnswering:
00156                         iConsole->Printf(_L("Line Status: Answering\n"));
00157                         break;
00158                 case CTelephony::EStatusIdle:
00159                         iConsole->Printf(_L("Line Status: Idle\n"));
00160                         break;
00161                 case CTelephony::EStatusDisconnecting:
00162                         iConsole->Printf(_L("Line Status: Disconnecting\n"));
00163                         break;
00164                 case CTelephony::EStatusHold:
00165                         iConsole->Printf(_L("Line Status: On Hold\n"));
00166                         break;
00167                 default:
00168                         iConsole->Printf(_L("Line status: Changed\n"));
00169                         break;
00170                         }
00171                 if (voiceLineStatus == CTelephony::EStatusIdle )
00172                         {
00173                         ExampleNotify();
00174                         }
00175                 else
00176                         {
00177                         if (!IsActive())
00178                                 {
00179                                 RequestNotificationL();
00180                                 }
00181                         }
00182                 }
00183         }
00184 
00189 void CLineStatus::DoRequestNotificationL()
00190         {
00191         // Panic if this object is already performing an asynchronous operation. 
00192         // Application will crash if you call SetActive() on an already active object.
00193         _LIT( KNotifyPanic, "CLineStatus Notify Method" );
00194         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00195         iRequestNotify = ETrue;
00196         
00197         // Notify if there is any change in line status
00198         iTelephony->NotifyChange(       iStatus,
00199                                                                 CTelephony::EVoiceLineStatusChange,
00200                                                                 iLineStatusV1Pckg );
00201         SetActive();
00202         }
00203         
00207 void CLineStatus::DoCancel()
00208         {
00209         // Cancels an outstanding asynchronous request.
00210         iTelephony->CancelAsync(CTelephony::EVoiceLineStatusChangeCancel);
00211         }

Generated by  doxygen 1.6.2