examples/Telephony/ETel3rdPartyExample/IncomingCalls/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 
00040 CNetworkRegInfo* CNetworkRegInfo::NewL(MExecAsync* aController)
00041         {
00042         CNetworkRegInfo* self = new(ELeave) CNetworkRegInfo(aController);
00043         CleanupStack::PushL(self);
00044         self->ConstructL();
00045         CleanupStack::Pop(self);
00046         return self;
00047         }
00048 
00053 CNetworkRegInfo::~CNetworkRegInfo()
00054         {
00055         Cancel();
00056         delete iTelephony;
00057         }
00058 
00063 void CNetworkRegInfo::StartRequestL()
00064         {
00065         iRequestNotify = EFalse;
00066         iTelephony->GetNetworkRegistrationStatus(iStatus, iNetworkRegV1Pckg);
00067         SetActive();
00068         }
00069 
00075 CNetworkRegInfo::CNetworkRegInfo(MExecAsync* aController)
00076         : CISVAPIAsync(aController)
00077         , iNetworkRegV1Pckg(iNetworkRegV1)
00078         {
00079         iExtensionId = KNetworkRegInfo;
00080         }
00081 
00085 void CNetworkRegInfo::ConstructL()
00086         {
00087         CActiveScheduler::Add(this);
00088         iTelephony = CTelephony::NewL();
00089         iRequestNotify = EFalse;
00090         }
00091 
00097 void CNetworkRegInfo::RunL()
00098         {
00099         TBool isNotification = iRequestNotify;
00100         if(iStatus != KErrNone)
00101                 {
00102                 gConsole->Printf(KErrorRom);
00103                 }
00104         else
00105                 {
00106                 TBuf<30> theStatus;
00107                 gConsole->Printf(KNetworkRegMsgRom);
00108                 switch(iNetworkRegV1.iRegStatus)
00109                         {
00110                                 case CTelephony::ERegistrationUnknown:
00111                                         theStatus.Append(_L("ERegistrationUnknown\n"));
00112                                         break;
00113                                 case CTelephony::ENotRegisteredNoService:
00114                                         theStatus.Append(_L("ENotRegisteredNoService\n"));
00115                                         break;
00116                                 case CTelephony::ENotRegisteredEmergencyOnly:
00117                                         theStatus.Append(_L("ENotRegisteredEmergencyOnly\n"));
00118                                         break;
00119                                 case CTelephony::ENotRegisteredSearching:
00120                                         theStatus.Append(_L("ENotRegisteredSearching\n"));
00121                                         break;
00122                                 case CTelephony::ERegisteredBusy:
00123                                         theStatus.Append(_L("ERegisteredBusy\n"));
00124                                         break;
00125                                 case CTelephony::ERegisteredOnHomeNetwork:
00126                                         theStatus.Append(_L("ERegisteredOnHomeNetwork\n"));
00127                                         break;
00128                                 case CTelephony::ERegistrationDenied:
00129                                         theStatus.Append(_L("ERegistrationDenied\n"));
00130                                         break;
00131                                 case CTelephony::ERegisteredRoaming:
00132                                         theStatus.Append(_L("ERegisteredRoaming\n"));
00133                                         break;
00134                                 default:
00135                                         break;
00136                         }
00137                 gConsole->Printf(theStatus);
00138                 }
00139         iRequestNotify = EFalse;
00140         if (isNotification)
00141                 {
00142                 ExampleNotify();
00143                 }
00144         else
00145                 {
00146                 ExampleComplete();
00147                 }
00148         }
00149 
00154 void CNetworkRegInfo::RequestNotificationL()
00155         {
00156         /*
00157         Panics if this object is already performing an asynchronous
00158         operation. Application will panic if you call SetActive() on an already
00159         active object.
00160         */
00161         _LIT( KNotifyPanic, "CNetworkReg Notify Method" );
00162         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00163         iRequestNotify = ETrue;
00164         iTelephony->NotifyChange(       iStatus,
00165                                                                 CTelephony::ENetworkRegistrationStatusChange,
00166                                                                 iNetworkRegV1Pckg );
00167         SetActive();
00168         }
00169 
00173 void CNetworkRegInfo::DoCancel()
00174         {
00175         iRequestNotify = EFalse;
00176         iTelephony->CancelAsync(CTelephony::ENetworkRegistrationStatusChangeCancel);
00177         }

Generated by  doxygen 1.6.2