examples/Telephony/ETel3rdPartyExample/OutgoingCalls/CNetworkRegInfo.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 "CNetworkRegInfo.h"
00033 
00041 CNetworkRegInfo* CNetworkRegInfo::NewL(MExecAsync* aController)
00042         {
00043         CNetworkRegInfo* self = new(ELeave) CNetworkRegInfo(aController);
00044         CleanupStack::PushL(self);
00045         self->ConstructL();
00046         CleanupStack::Pop(self);
00047         return self;
00048         }
00049 
00053 CNetworkRegInfo::~CNetworkRegInfo()
00054         {
00055         Cancel();
00056         }
00057 
00062 void CNetworkRegInfo::DoStartRequestL()
00063         {
00064     iRequestNotify = EFalse;
00065    
00066     // Retrieves the current network registration status
00067         iTelephony->GetNetworkRegistrationStatus(iStatus, iNetworkRegV1Pckg);
00068         SetActive();
00069         }
00070 
00077 CNetworkRegInfo::CNetworkRegInfo(MExecAsync* aController)
00078         : CISVAPIAsync(aController, KNetworkRegInfo),
00079           iNetworkRegV1Pckg(iNetworkRegV1)
00080         {
00081         // Empty method
00082         }
00083 
00087 void CNetworkRegInfo::ConstructL()
00088         {
00089         iRequestNotify = EFalse;
00090         }
00091 
00096 void CNetworkRegInfo::RunL()
00097         {
00098         if(iStatus != KErrNone)
00099                 {
00100                 iConsole->Printf(KError);
00101                 
00102                 // Print the output to console if there is no error
00103                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00104                 }
00105         else
00106                 {
00107                 TBuf<30> theStatus;
00108                 iConsole->Printf(KNetworkRegMsg);
00109                 switch(iNetworkRegV1.iRegStatus)
00110                         {
00111                 case CTelephony::ERegistrationUnknown:
00112                         theStatus.Append(_L("ERegistrationUnknown\n"));
00113                         break;
00114                 case CTelephony::ENotRegisteredNoService:
00115                         theStatus.Append(_L("ENotRegisteredNoService\n"));
00116                         break;
00117                 case CTelephony::ENotRegisteredEmergencyOnly:
00118                         theStatus.Append(_L("ENotRegisteredEmergencyOnly\n"));
00119                         break;
00120                 case CTelephony::ENotRegisteredSearching:
00121                         theStatus.Append(_L("ENotRegisteredSearching\n"));
00122                         break;
00123                 case CTelephony::ERegisteredBusy:
00124                         theStatus.Append(_L("ERegisteredBusy\n"));
00125                         break;
00126                 case CTelephony::ERegisteredOnHomeNetwork:
00127                         theStatus.Append(_L("ERegisteredOnHomeNetwork\n"));
00128                         break;
00129                 case CTelephony::ERegistrationDenied:
00130                         theStatus.Append(_L("ERegistrationDenied\n"));
00131                         break;
00132                 case CTelephony::ERegisteredRoaming:
00133                         theStatus.Append(_L("ERegisteredRoaming\n"));
00134                         break;
00135                 default:
00136                         break;
00137                         }
00138                 iConsole->Printf(theStatus);
00139                 }
00140         if (iNetworkRegV1.iRegStatus == CTelephony::ERegisteredOnHomeNetwork)
00141                 {
00142                 ExampleNotify();
00143                 }
00144         else
00145                 {
00146                 RequestNotificationL();
00147                 }
00148         }
00149 
00154 void CNetworkRegInfo::DoRequestNotificationL()
00155         {
00156         // Panic if this object is already performing an asynchronous operation.
00157         // Application will panic if you call SetActive() on an already active object.
00158         _LIT( KNotifyPanic, "CNetworkReg Notify Method" );
00159         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00160         iRequestNotify = ETrue;
00161         
00162         // Registers interest in receiving change notifications for events.
00163         iTelephony->NotifyChange(       iStatus,
00164                                                                 CTelephony::ENetworkRegistrationStatusChange,
00165                                                                 iNetworkRegV1Pckg );
00166         SetActive();
00167         }
00168         
00172 void CNetworkRegInfo::DoCancel()
00173         {
00174         iRequestNotify = EFalse;
00175         
00176         // Cancels an outstanding asynchronous request
00177         iTelephony->CancelAsync(CTelephony::ENetworkRegistrationStatusChangeCancel);
00178         }

Generated by  doxygen 1.6.2