radioengine/engine/src/cradionetworkinfolistener.cpp
branchGCC_SURGE
changeset 37 451b2e1545b2
parent 14 63aabac4416d
parent 28 075425b8d9a4
equal deleted inserted replaced
26:6bcf277166c1 37:451b2e1545b2
    34 // ---------------------------------------------------------------------------
    34 // ---------------------------------------------------------------------------
    35 //
    35 //
    36 CRadioNetworkInfoListener* CRadioNetworkInfoListener::NewL( MRadioSettingsSetter& aSetter,
    36 CRadioNetworkInfoListener* CRadioNetworkInfoListener::NewL( MRadioSettingsSetter& aSetter,
    37                                                             MRadioNetworkChangeObserver* aObserver )
    37                                                             MRadioNetworkChangeObserver* aObserver )
    38     {
    38     {
       
    39     LEVEL3( LOG_METHOD_AUTO );
    39     CRadioNetworkInfoListener* self = new ( ELeave ) CRadioNetworkInfoListener( aSetter, aObserver );
    40     CRadioNetworkInfoListener* self = new ( ELeave ) CRadioNetworkInfoListener( aSetter, aObserver );
    40     CleanupStack::PushL( self );
    41     CleanupStack::PushL( self );
    41     self->ConstructL();
    42     self->ConstructL();
    42     CleanupStack::Pop( self );
    43     CleanupStack::Pop( self );
    43     return self;
    44     return self;
    53     , iSetter( aSetter )
    54     , iSetter( aSetter )
    54     , iObserver( aObserver )
    55     , iObserver( aObserver )
    55     , iSubscriberIdPckg( iSubscriberId )
    56     , iSubscriberIdPckg( iSubscriberId )
    56     , iNetworkInfoPckg( iNetworkInfo )
    57     , iNetworkInfoPckg( iNetworkInfo )
    57     {
    58     {
       
    59     LEVEL3( LOG_METHOD_AUTO );
    58     CActiveScheduler::Add( this );
    60     CActiveScheduler::Add( this );
    59     }
    61     }
    60 
    62 
    61 // ---------------------------------------------------------------------------
    63 // ---------------------------------------------------------------------------
    62 //
    64 //
   168         // Leave if we are not allowed to get network info.
   170         // Leave if we are not allowed to get network info.
   169         // Other action could also be considered!!!!
   171         // Other action could also be considered!!!!
   170         User::Leave( KErrNotSupported );
   172         User::Leave( KErrNotSupported );
   171         }
   173         }
   172 
   174 
   173     if ( identityCaps & RMobilePhone::KCapsGetSubscriberId )
       
   174         {
       
   175         TRequestStatus stat;
       
   176         RMobilePhone::TMobilePhoneSubscriberId subscriberId;
       
   177         mobilePhone.GetSubscriberId( stat, subscriberId );
       
   178         User::WaitForRequest( stat );
       
   179 
       
   180         CTelephony::TSubscriberIdV1 telephonySubscriberId;
       
   181 
       
   182         if ( stat == KErrNone )
       
   183             {
       
   184             telephonySubscriberId.iSubscriberId = subscriberId;
       
   185             }
       
   186         else
       
   187             {
       
   188             telephonySubscriberId.iSubscriberId = iSetter.SubscriberId();
       
   189             }
       
   190 
       
   191         iSubscriberIdPckg() = telephonySubscriberId;
       
   192         }
       
   193 
       
   194     CleanupStack::PopAndDestroy( 2, &telServer );
   175     CleanupStack::PopAndDestroy( 2, &telServer );
   195 #endif
   176 #endif
   196     // At the end, update the local variables by simulating the "netid changed" event.
   177     // At the end, update the local variables by simulating the "netid changed" event.
   197     RunL();
   178     RunL();
   198     }
   179     }
   201 //
   182 //
   202 // ---------------------------------------------------------------------------
   183 // ---------------------------------------------------------------------------
   203 //
   184 //
   204 CRadioNetworkInfoListener::~CRadioNetworkInfoListener()
   185 CRadioNetworkInfoListener::~CRadioNetworkInfoListener()
   205     {
   186     {
       
   187     LEVEL3( LOG_METHOD_AUTO );
   206     Cancel();
   188     Cancel();
   207 
   189 
   208 #ifndef __WINS__
   190 #ifndef __WINS__
   209     delete iTelephony;
   191     delete iTelephony;
   210 #endif
   192 #endif
   214 //
   196 //
   215 // ---------------------------------------------------------------------------
   197 // ---------------------------------------------------------------------------
   216 //
   198 //
   217 TInt CRadioNetworkInfoListener::CompoundNetworkId() const
   199 TInt CRadioNetworkInfoListener::CompoundNetworkId() const
   218     {
   200     {
   219     LOG_FORMAT( "CRadioNetworkInfoListener::CompoundNetworkId() - %d", iCompoundNetworkId );
   201     LEVEL3( LOG_METHOD_AUTO );
       
   202     LOG_FORMAT( "Returning iCompoundNetworkId: %d", iCompoundNetworkId );
   220     return iCompoundNetworkId;
   203     return iCompoundNetworkId;
   221     }
   204     }
   222 
   205 
   223 // ---------------------------------------------------------------------------
   206 // ---------------------------------------------------------------------------
   224 //
   207 //
   225 // ---------------------------------------------------------------------------
   208 // ---------------------------------------------------------------------------
   226 //
   209 //
   227 TPtrC CRadioNetworkInfoListener::SubscriberId() const
   210 TPtrC CRadioNetworkInfoListener::SubscriberId() const
   228     {
   211     {
       
   212     LEVEL3( LOG_METHOD_AUTO );
   229     TPtrC id = iSubscriberId.iSubscriberId;
   213     TPtrC id = iSubscriberId.iSubscriberId;
   230     LOG_FORMAT( "CRadioNetworkInfoListener::SubscriberId() - %S", &id );
   214     LOG_FORMAT( "SubscriberId: %S", &id );
   231     return id;
   215     return id;
   232     }
   216     }
   233 
   217 
   234 // ---------------------------------------------------------------------------
   218 // ---------------------------------------------------------------------------
   235 //
   219 //
   236 // ---------------------------------------------------------------------------
   220 // ---------------------------------------------------------------------------
   237 //
   221 //
   238 TPtrC CRadioNetworkInfoListener::CountryCode() const
   222 TPtrC CRadioNetworkInfoListener::CountryCode() const
   239     {
   223     {
       
   224     LEVEL3( LOG_METHOD_AUTO );
   240     TPtrC countryCode = iSetter.CountryCode();
   225     TPtrC countryCode = iSetter.CountryCode();
   241     LOG_FORMAT( "CRadioNetworkInfoListener::CountryCode() - %S", &countryCode );
   226     LOG_FORMAT( "CountryCode: %S", &countryCode );
   242     return countryCode;
   227     return countryCode;
   243     }
   228     }
   244 
   229 
   245 // ---------------------------------------------------------------------------
   230 // ---------------------------------------------------------------------------
   246 //
   231 //
   247 // ---------------------------------------------------------------------------
   232 // ---------------------------------------------------------------------------
   248 //
   233 //
   249 void CRadioNetworkInfoListener::SaveNetworkInfoL()
   234 void CRadioNetworkInfoListener::SaveNetworkInfoL()
   250     {
   235     {
       
   236     LEVEL3( LOG_METHOD_AUTO );
   251 #ifdef __WINS__
   237 #ifdef __WINS__
   252     iNetworkInfo.iCountryCode.Copy( _L("244") );
   238     iNetworkInfo.iCountryCode.Copy( _L("244") );
   253     iNetworkInfo.iNetworkId.Zero();
   239     iNetworkInfo.iNetworkId.Zero();
   254 #endif
   240 #endif
   255 
   241 
   256     LOG_FORMAT( "CRadioNetworkInfoListener::SaveNetworkInfoL() - iNetworkInfo.iCountryCode = %S",
   242     LOG_FORMAT( "iNetworkInfo.iCountryCode = %S",
   257                   &iNetworkInfo.iCountryCode );
   243                   &iNetworkInfo.iCountryCode );
   258 
   244 
   259     User::LeaveIfError( iSetter.SetCountryCode( iNetworkInfo.iCountryCode ) );
   245     User::LeaveIfError( iSetter.SetCountryCode( iNetworkInfo.iCountryCode ) );
   260 
   246 
   261     // The compound network identifier is composed of the current network identifier and country code.
   247     // The compound network identifier is composed of the current network identifier and country code.
   286 //
   272 //
   287 // ---------------------------------------------------------------------------
   273 // ---------------------------------------------------------------------------
   288 //
   274 //
   289 void CRadioNetworkInfoListener::DoCancel()
   275 void CRadioNetworkInfoListener::DoCancel()
   290     {
   276     {
       
   277     LEVEL3( LOG_METHOD_AUTO );
   291 #ifndef __WINS__
   278 #ifndef __WINS__
   292     iTelephony->CancelAsync( CTelephony::ECurrentNetworkInfoChangeCancel );
   279     iTelephony->CancelAsync( CTelephony::ECurrentNetworkInfoChangeCancel );
   293 #endif
   280 #endif
   294     }
   281     }
   295 
   282 
   297 //
   284 //
   298 // ---------------------------------------------------------------------------
   285 // ---------------------------------------------------------------------------
   299 //
   286 //
   300 void CRadioNetworkInfoListener::RunL()
   287 void CRadioNetworkInfoListener::RunL()
   301     {
   288     {
   302     LOG_FORMAT( "CRadioNetworkInfoListener::RunL() - iStatus.Int() = %d", iStatus.Int() );
   289     LEVEL3( LOG_METHOD_AUTO );
       
   290     LEVEL3( LOG_FORMAT( "iStatus.Int() = %d", iStatus.Int() ) );
   303 #ifndef __WINS__
   291 #ifndef __WINS__
   304     iTelephony->NotifyChange( iStatus, CTelephony::ECurrentNetworkInfoChange, iNetworkInfoPckg );
   292     iTelephony->NotifyChange( iStatus, CTelephony::ECurrentNetworkInfoChange, iNetworkInfoPckg );
   305     SetActive();
   293     SetActive();
   306 #endif
   294 #endif
   307     SaveNetworkInfoL();
   295     SaveNetworkInfoL();