examples/Telephony/ETel3rdPartyExample/OutgoingCalls/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 
00032 #include "CLineStatus.h"
00033 
00041 CLineStatus* CLineStatus::NewL(MExecAsync* aController)
00042         {
00043         CLineStatus* self = new(ELeave) CLineStatus(aController);
00044         CleanupStack::PushL(self);
00045         self->ConstructL();
00046         CleanupStack::Pop(self);
00047         return self;
00048         }
00049 
00054 CLineStatus::~CLineStatus()
00055         {
00056         Cancel();
00057         }
00058 
00063 void CLineStatus::DoStartRequestL()
00064         {
00065     iRequestNotify = EFalse;
00066     CTelephony::TPhoneLine line = CTelephony::EVoiceLine;
00067    
00068    // Retrieves the status of the line selected by the specified argument
00069         iTelephony->GetLineStatus(line, iLineStatusV1Pckg);
00070         CTelephony::TCallStatus voiceLineStatus = iLineStatusV1.iStatus;
00071         switch (voiceLineStatus)
00072                 {
00073         case CTelephony::EStatusRinging:
00074                 iConsole->Printf(_L("RING RING RING\n"));
00075                 break;
00076         case CTelephony::EStatusConnected:
00077                 iConsole->Printf(_L("Line Status: Connected\n"));
00078                 break;
00079         case CTelephony::EStatusConnecting:
00080                 iConsole->Printf(_L("Line Status: Connecting\n"));
00081                 break;
00082         case CTelephony::EStatusAnswering:
00083                 iConsole->Printf(_L("Line Status: Answering\n"));
00084                 break;
00085         case CTelephony::EStatusIdle:
00086                 iConsole->Printf(_L("Line Status: Idle\n"));
00087                 break;
00088         case CTelephony::EStatusDisconnecting:
00089                 iConsole->Printf(_L("Line Status: Disconnecting\n"));
00090                 break;
00091         case CTelephony::EStatusHold:
00092                 iConsole->Printf(_L("Line Status: On Hold\n"));
00093                 break;
00094         default:
00095                 iConsole->Printf(_L("Line status changed.\n"));
00096                 break;
00097                 }
00098         if (voiceLineStatus == CTelephony::EStatusIdle)
00099                 {
00100                 ExampleNotify();
00101                 }
00102         else
00103                 {
00104                 if (!IsActive())
00105                         {
00106                         RequestNotificationL();
00107                         }
00108                 }
00109         }
00110         
00117 CLineStatus::CLineStatus(MExecAsync* aController)
00118         : CISVAPIAsync(aController, KLineStatus),
00119           iLineStatusV1Pckg(iLineStatusV1)
00120         {
00121         // Empty method
00122         }
00123 
00127 void CLineStatus::ConstructL()
00128         {
00129         // Empty method
00130         }
00131 
00136 void CLineStatus::RunL()
00137         {
00138         CTelephony::TCallStatus voiceLineStatus = iLineStatusV1.iStatus;
00139         // Print Line Information.
00140         if(iStatus != KErrNone)
00141                 {
00142                 iConsole->Printf(KError);
00143                 
00144                 // Print the error status code
00145                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00146                 }
00147         else
00148                 {
00149                 switch (voiceLineStatus)
00150                         {
00151                 case CTelephony::EStatusRinging:
00152                         iConsole->Printf(_L("RING RING RING\n"));
00153                         break;
00154                 case CTelephony::EStatusConnected:
00155                         iConsole->Printf(_L("Line Status: Connected\n"));
00156                         break;
00157                 case CTelephony::EStatusConnecting:
00158                         iConsole->Printf(_L("Line Status: Connecting\n"));
00159                         break;
00160                 case CTelephony::EStatusAnswering:
00161                         iConsole->Printf(_L("Line Status: Answering\n"));
00162                         break;
00163                 case CTelephony::EStatusIdle:
00164                         iConsole->Printf(_L("Line Status: Idle\n"));
00165                         break;
00166                 case CTelephony::EStatusDisconnecting:
00167                         iConsole->Printf(_L("Line Status: Disconnecting\n"));
00168                         break;
00169                 case CTelephony::EStatusHold:
00170                         iConsole->Printf(_L("Line Status: On Hold\n"));
00171                         break;
00172                 default:
00173                         iConsole->Printf(_L("Line status changed.\n"));
00174                         break;
00175                         }
00176                 if (voiceLineStatus == CTelephony::EStatusIdle
00177                                 ||  voiceLineStatus == CTelephony::EStatusHold)
00178                         {
00179                         ExampleNotify();
00180                         }
00181                 else if (voiceLineStatus == CTelephony::EStatusRinging)
00182                         {
00183                         ExampleComplete();
00184                         }
00185                 else
00186                         {
00187                         if (!IsActive())
00188                                 {
00189                                 RequestNotificationL();
00190                                 }
00191                         }
00192                 }
00193         }
00194 
00199 void CLineStatus::DoRequestNotificationL()
00200         {
00201         // Panic if this object is already performing an asynchronous operation. 
00202         // Application will panic if you call SetActive() on an already active object.
00203         _LIT( KNotifyPanic, "CLineStatus Notify Method" );
00204         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00205         iRequestNotify = ETrue;
00206         
00207         // Registers interest in receiving change notifications for events.
00208         iTelephony->NotifyChange(iStatus,
00209                                                                 CTelephony::EVoiceLineStatusChange,
00210                                                                 iLineStatusV1Pckg );
00211         SetActive();
00212         }
00213 
00217 void CLineStatus::DoCancel()
00218         {
00219         // Cancels an outstanding asynchronous request.
00220         iTelephony->CancelAsync(CTelephony::EVoiceLineStatusChangeCancel);
00221         }
00222 

Generated by  doxygen 1.6.2