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

Generated by  doxygen 1.6.2