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 #include "CLineStatus.h" 00017 00024 CLineStatus* CLineStatus::NewL(MExecAsync* aController) 00025 { 00026 CLineStatus* self = new(ELeave) CLineStatus(aController); 00027 CleanupStack::PushL(self); 00028 self->ConstructL(); 00029 CleanupStack::Pop(self); 00030 return self; 00031 } 00032 00037 CLineStatus::~CLineStatus() 00038 { 00039 Cancel(); 00040 } 00041 00045 void CLineStatus::DoStartRequestL() 00046 { 00047 iRequestNotify = EFalse; 00048 CTelephony::TPhoneLine line = CTelephony::EVoiceLine; 00049 00050 // Retrieves the status of the line selected by the argument 00051 iTelephony->GetLineStatus(line, iLineStatusV1Pckg); 00052 CTelephony::TCallStatus voiceLineStatus = iLineStatusV1.iStatus; 00053 switch (voiceLineStatus) 00054 { 00055 case CTelephony::EStatusRinging: 00056 iConsole->Printf(_L("RING RING RING\n")); 00057 break; 00058 case CTelephony::EStatusConnected: 00059 iConsole->Printf(_L("Line Status connected\n")); 00060 break; 00061 case CTelephony::EStatusConnecting: 00062 iConsole->Printf(_L("Line Status connecting\n")); 00063 break; 00064 case CTelephony::EStatusAnswering: 00065 iConsole->Printf(_L("Line Status Answering\n")); 00066 break; 00067 case CTelephony::EStatusIdle: 00068 iConsole->Printf(_L("Line Status Idle\n")); 00069 break; 00070 case CTelephony::EStatusDisconnecting: 00071 iConsole->Printf(_L("Line Status Disconnecting\n")); 00072 break; 00073 case CTelephony::EStatusHold: 00074 iConsole->Printf(_L("Line Status on Hold\n")); 00075 break; 00076 default: 00077 iConsole->Printf(_L("Line status changed\n")); 00078 break; 00079 } 00080 if (voiceLineStatus == CTelephony::EStatusIdle) 00081 { 00082 ExampleNotify(); 00083 } 00084 else 00085 { 00086 if (!IsActive()) 00087 { 00088 RequestNotificationL(); 00089 } 00090 } 00091 } 00092 00097 CLineStatus::CLineStatus(MExecAsync* aController) 00098 : CISVAPIAsync(aController, KLineStatus), 00099 iLineStatusV1Pckg(iLineStatusV1) 00100 { 00101 // Empty method 00102 } 00103 00107 void CLineStatus::ConstructL() 00108 { 00109 // Empty method 00110 } 00111 00116 void CLineStatus::RunL() 00117 { 00118 CTelephony::TCallStatus voiceLineStatus = iLineStatusV1.iStatus; 00119 // Print Line Info 00120 if(iStatus != KErrNone) 00121 { 00122 iConsole->Printf(KError); 00123 00124 // Print error status code 00125 iConsole->Printf(_L("%d\n"), iStatus.Int()); 00126 } 00127 else 00128 { 00129 switch (voiceLineStatus) 00130 { 00131 case CTelephony::EStatusRinging: 00132 iConsole->Printf(_L("RING RING RING\n")); 00133 break; 00134 case CTelephony::EStatusConnected: 00135 iConsole->Printf(_L("Line Status: Connected\n")); 00136 break; 00137 case CTelephony::EStatusConnecting: 00138 iConsole->Printf(_L("Line Status: Connecting\n")); 00139 break; 00140 case CTelephony::EStatusAnswering: 00141 iConsole->Printf(_L("Line Status: Answering\n")); 00142 break; 00143 case CTelephony::EStatusIdle: 00144 iConsole->Printf(_L("Line Status: Idle\n")); 00145 break; 00146 case CTelephony::EStatusDisconnecting: 00147 iConsole->Printf(_L("Line Status: Disconnecting\n")); 00148 break; 00149 case CTelephony::EStatusHold: 00150 iConsole->Printf(_L("Line Status: On Hold\n")); 00151 break; 00152 default: 00153 iConsole->Printf(_L("Line status: Changed\n")); 00154 break; 00155 } 00156 if (voiceLineStatus == CTelephony::EStatusIdle ) 00157 { 00158 ExampleNotify(); 00159 } 00160 else 00161 { 00162 if (!IsActive()) 00163 { 00164 RequestNotificationL(); 00165 } 00166 } 00167 } 00168 } 00169 00174 void CLineStatus::DoRequestNotificationL() 00175 { 00176 // Panic if this object is already performing an asynchronous operation. 00177 // Application will crash if you call SetActive() on an already active object. 00178 _LIT( KNotifyPanic, "CLineStatus Notify Method" ); 00179 __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 )); 00180 iRequestNotify = ETrue; 00181 00182 // Notify if there is any change in line status 00183 iTelephony->NotifyChange( iStatus, 00184 CTelephony::EVoiceLineStatusChange, 00185 iLineStatusV1Pckg ); 00186 SetActive(); 00187 } 00188 00192 void CLineStatus::DoCancel() 00193 { 00194 // Cancels an outstanding asynchronous request. 00195 iTelephony->CancelAsync(CTelephony::EVoiceLineStatusChangeCancel); 00196 }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.