examples/Telephony/ETel3rdPartyExample/AutoDTMFDialler/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 #include "CNetworkRegInfo.h"
00032 
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 
00052 CNetworkRegInfo::~CNetworkRegInfo()
00053         {
00054         Cancel();
00055         }
00056 
00060 void CNetworkRegInfo::DoStartRequestL()
00061         {
00062     iRequestNotify = EFalse;
00063     
00064     // Retrieves the current network registration status.
00065         iTelephony->GetNetworkRegistrationStatus(iStatus, iNetworkRegV1Pckg);
00066         SetActive();
00067         }
00068 
00075 CNetworkRegInfo::CNetworkRegInfo(MExecAsync* aController)
00076         : CISVAPIAsync(aController, KNetworkRegInfo),
00077           iNetworkRegV1Pckg(iNetworkRegV1)
00078         {
00079         // Empty method
00080         }
00081 
00085 void CNetworkRegInfo::ConstructL()
00086         {
00087         iRequestNotify = EFalse;
00088         }
00089 
00093 void CNetworkRegInfo::RunL()
00094         {
00095         if(iStatus != KErrNone)
00096                 {
00097                 iConsole->Printf(KError);
00098                 
00099                 // Print the error status code
00100                 iConsole->Printf(_L("%d\n"), iStatus.Int());
00101                 }
00102         else
00103                 {
00104                 // There is no error, so display the current registration status to the
00105                 // user.
00106                 TBuf<30> theStatus;
00107                 if(iRequestNotify)
00108                         {
00109                         iConsole->ClearScreen();
00110                         iConsole->Printf(_L("*~This is a notifcation\n~*"));
00111                         }
00112                 iConsole->Printf(KNetworkRegMsg);
00113                 switch(iNetworkRegV1.iRegStatus)
00114                         {
00115                 case CTelephony::ERegistrationUnknown:
00116                         theStatus.Append(_L("ERegistrationUnknown\n"));
00117                         break;
00118                 case CTelephony::ENotRegisteredNoService:
00119                         theStatus.Append(_L("ENotRegisteredNoService\n"));
00120                         break;
00121                 case CTelephony::ENotRegisteredEmergencyOnly:
00122                         theStatus.Append(_L("ENotRegisteredEmergencyOnly\n"));
00123                         break;
00124                 case CTelephony::ENotRegisteredSearching:
00125                         theStatus.Append(_L("ENotRegisteredSearching\n"));
00126                         break;
00127                 case CTelephony::ERegisteredBusy:
00128                         theStatus.Append(_L("ERegisteredBusy\n"));
00129                         break;
00130                 case CTelephony::ERegisteredOnHomeNetwork:
00131                         theStatus.Append(_L("ERegisteredOnHomeNetwork\n"));
00132                         break;
00133                 case CTelephony::ERegistrationDenied:
00134                         theStatus.Append(_L("ERegistrationDenied\n"));
00135                         break;
00136                 case CTelephony::ERegisteredRoaming:
00137                         theStatus.Append(_L("ERegisteredRoaming\n"));
00138                         break;
00139                 default:
00140                         break;
00141                         }
00142                 iConsole->Printf(theStatus);
00143                 }
00144         if (iNetworkRegV1.iRegStatus == CTelephony::ERegisteredOnHomeNetwork)
00145                 {
00146                 ExampleNotify();
00147                 }
00148         else
00149                 {
00150                 RequestNotificationL();
00151                 }
00152         }
00153 
00158 void CNetworkRegInfo::DoRequestNotificationL()
00159         {
00160         // Panic if this object is already performing an asynchronous operation.
00161         // Application will panic if you call SetActive() on an already active object.
00162         _LIT( KNotifyPanic, "CNetworkReg Notify Method" );
00163         __ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyPanic, 1 ));
00164         iRequestNotify = ETrue;
00165         
00166         // Notify if there is any change
00167         iTelephony->NotifyChange(iStatus,
00168                                  CTelephony::ENetworkRegistrationStatusChange,
00169                                  iNetworkRegV1Pckg );
00170         SetActive();
00171         }
00172 
00176 void CNetworkRegInfo::DoCancel()
00177         {
00178         iRequestNotify = EFalse;
00179         
00180         // Cancels an outstanding asynchronous request.
00181         iTelephony->CancelAsync(CTelephony::ENetworkRegistrationStatusChangeCancel);
00182         }

Generated by  doxygen 1.6.2