cmmanager/cmmgr/Plugins/cmpluginpacketdata/src/cmpluginpacketdata.cpp
changeset 4 77415202bfc8
parent 0 5a93021fdf25
equal deleted inserted replaced
3:f7816ffc66ed 4:77415202bfc8
    24 #include <cmpluginpacketdata.mbg>           // icons
    24 #include <cmpluginpacketdata.mbg>           // icons
    25 #include <cmpacketdataui.rsg>
    25 #include <cmpacketdataui.rsg>
    26 #include <AknQueryDialog.h>
    26 #include <AknQueryDialog.h>
    27 #include <StringLoader.h>
    27 #include <StringLoader.h>
    28 #include <cmmanager.rsg>
    28 #include <cmmanager.rsg>
       
    29 #include <featmgr.h>                     // FeatureManager
       
    30 #include <centralrepository.h>           // CRepository 
       
    31 #include <CoreApplicationUIsSDKCRKeys.h> // KCRUidCoreApplicationUIs, 
       
    32 
    29 // User
    33 // User
    30 #include "cmpluginpacketdata.h"
    34 #include "cmpluginpacketdata.h"
    31 #include <cmpluginpacketdatadef.h>
    35 #include <cmpluginpacketdatadef.h>
    32 #include "cmpacketdatacommonconstants.h"
    36 #include "cmpacketdatacommonconstants.h"
    33 #include "cmlogger.h"
    37 #include "cmlogger.h"
   215     }
   219     }
   216 
   220 
   217 // ======== MEMBER FUNCTIONS ========
   221 // ======== MEMBER FUNCTIONS ========
   218 
   222 
   219 class CCmPDCoverageCheck : public CActive
   223 class CCmPDCoverageCheck : public CActive
   220     {
   224     {        
   221     enum EPacketCoverageState
       
   222         {
       
   223         EServiceStatus,
       
   224         EPDPAttach,
       
   225         EPDPDetach,                        
       
   226         };
       
   227         
       
   228     public:
   225     public:
   229     
   226     
   230         CCmPDCoverageCheck();
   227         CCmPDCoverageCheck();
   231         ~CCmPDCoverageCheck();
   228         ~CCmPDCoverageCheck();
   232         
   229         
   234         
   231         
   235     protected:  // from CActive
   232     protected:  // from CActive
   236     
   233     
   237         virtual void DoCancel();
   234         virtual void DoCancel();
   238         virtual void RunL();
   235         virtual void RunL();
   239 
   236         
   240     private:
   237     private:
   241 
   238 
   242         TUint32                 iProgState;
   239         TBool IsPhoneOfflineL() const;     	        
       
   240 
       
   241     private:
       
   242 
   243         TBool                   iCoverage;
   243         TBool                   iCoverage;
   244         CActiveSchedulerWait    iWait;    
   244         CActiveSchedulerWait    iWait;    
   245         RTelServer              iServer;
   245         RTelServer              iServer;
   246         RPhone                  iPhone;
   246         RPhone                  iPhone;
   247         RPacketService          iService;        
   247         RPacketService          iService;
       
   248         RPacketService::TRegistrationStatus iNwRegStatus;        
   248     };
   249     };
   249 
   250 
   250 // ----------------------------------------------------------------------------
   251 // ----------------------------------------------------------------------------
   251 // CCmPDCoverageCheck::CCmPDCoverageCheck()
   252 // CCmPDCoverageCheck::CCmPDCoverageCheck()
   252 // ----------------------------------------------------------------------------
   253 // ----------------------------------------------------------------------------
   282 // CCmPDCoverageCheck::RunL
   283 // CCmPDCoverageCheck::RunL
   283 // ----------------------------------------------------------------------------
   284 // ----------------------------------------------------------------------------
   284 //
   285 //
   285 void CCmPDCoverageCheck::RunL()
   286 void CCmPDCoverageCheck::RunL()
   286     {
   287     {
   287     switch( iProgState )
   288     if( !iStatus.Int() )
   288         {
   289         {
   289         case EPDPAttach:
   290         CLOG_WRITE_1( "CCmPDCoverageCheck::RunL: iNwRegStatus: [%d]", iNwRegStatus );
   290             {
   291         	
   291             if( !iStatus.Int() )
   292         if ( iNwRegStatus == RPacketService::ERegisteredOnHomeNetwork ||
   292                 // PDP context created -> there's a usable PD coverage.
   293              iNwRegStatus == RPacketService::ERegisteredRoaming ||
   293                 {
   294              iNwRegStatus == RPacketService::ENotRegisteredButAvailable )
   294                 iService.Detach( iStatus );
   295             {
   295                 SetActive();
   296             iCoverage = ETrue;	
   296 
   297             }	
   297                 iCoverage = ETrue;
   298         iWait.AsyncStop();
   298                 iProgState = EPDPDetach;
   299         }
   299                 }
   300     else
   300             else
   301         // something went wrong -> no coverage.
   301                 // something went wrong -> no coverage.
   302         {
   302                 {
   303         CLOG_WRITE_1( "CCmPDCoverageCheck::RunL: FAILED: [%d]", iStatus.Int() );        	
   303                 iWait.AsyncStop();
   304         iWait.AsyncStop();
   304                 }
       
   305             }
       
   306             break;
       
   307             
       
   308         case EPDPDetach:
       
   309             {
       
   310             iWait.AsyncStop();
       
   311             }
       
   312             break;
       
   313             
       
   314         default:
       
   315             {
       
   316             User::Leave( KErrCorrupt );
       
   317             }
       
   318         }
   305         }
   319     }
   306     }
   320     
   307     
   321 // ----------------------------------------------------------------------------
   308 // ----------------------------------------------------------------------------
   322 // CCmPDCoverageCheck::IsThereCoverageL
   309 // CCmPDCoverageCheck::IsThereCoverageL
   323 // ----------------------------------------------------------------------------
   310 // ----------------------------------------------------------------------------
   324 //
   311 //
   325 TBool CCmPDCoverageCheck::IsThereCoverageL()
   312 TBool CCmPDCoverageCheck::IsThereCoverageL()
   326     {
   313     {
   327     iProgState = EServiceStatus;
       
   328     iCoverage = EFalse;
   314     iCoverage = EFalse;
   329     
   315     
   330     User::LeaveIfError( iServer.Connect() );
   316     if ( !IsPhoneOfflineL() )
   331     CLOG_WRITE( "Server open" );
   317         {
   332     
   318         User::LeaveIfError( iServer.Connect() );
   333     RTelServer::TPhoneInfo info;
   319         CLOG_WRITE( "Server open" );
   334     User::LeaveIfError( iServer.GetPhoneInfo( 0, info ) );
   320     
   335     CLOG_WRITE( "Phone info ok" );
   321         RTelServer::TPhoneInfo info;
   336     
   322         User::LeaveIfError( iServer.GetPhoneInfo( 0, info ) );
   337     User::LeaveIfError( iPhone.Open(iServer, info.iName ) );
   323         CLOG_WRITE( "Phone info ok" );
   338     CLOG_WRITE( "Phone open" );
   324     
   339 
   325         User::LeaveIfError( iPhone.Open(iServer, info.iName ) );
   340     User::LeaveIfError( iService.Open( iPhone ) );
   326         CLOG_WRITE( "Phone open" );
   341     CLOG_WRITE( "service ok" );
   327 
   342 
   328         User::LeaveIfError( iService.Open( iPhone ) );
   343     RPacketService::TStatus status;
   329         CLOG_WRITE( "service ok" );
   344     User::LeaveIfError( iService.GetStatus( status ) );
   330 
   345     if( status == RPacketService::EStatusAttached ||
   331         iService.GetNtwkRegStatus( iStatus, iNwRegStatus );
   346         status == RPacketService::EStatusActive || 
       
   347         status == RPacketService::EStatusSuspended )
       
   348         // Attached/active/suspened, so there's a coverage
       
   349         {
       
   350         iCoverage = ETrue;
       
   351         }
       
   352     else if( status == RPacketService::EStatusUnattached )
       
   353         {
       
   354         iProgState = EPDPAttach;
       
   355         iService.Attach( iStatus );
       
   356         SetActive();
   332         SetActive();
   357         iWait.Start();
   333         iWait.Start();
   358         }
   334     
   359     else
   335         User::LeaveIfError( iStatus.Int() );  	
   360         {
   336         }
   361         CLOG_WRITE( "Unknown state" );
       
   362         }
       
   363         
       
   364 
       
   365     User::LeaveIfError( iStatus.Int() );
       
   366     
   337     
   367     return iCoverage;
   338     return iCoverage;
   368     }
   339     }
   369 
   340 
       
   341 // ----------------------------------------------------------------------------
       
   342 // CCmPDCoverageCheck::IsPhoneOfflineL
       
   343 // ----------------------------------------------------------------------------
       
   344 //
       
   345 TBool CCmPDCoverageCheck::IsPhoneOfflineL() const
       
   346     {
       
   347     if ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) )
       
   348         {
       
   349         CRepository* repository = CRepository::NewLC( KCRUidCoreApplicationUIs );
       
   350         TInt connAllowed( ECoreAppUIsNetworkConnectionAllowed );
       
   351         
       
   352         repository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed );
       
   353         CleanupStack::PopAndDestroy( repository );
       
   354         	 
       
   355         if ( !connAllowed )
       
   356             {
       
   357             CLOG_WRITE( "Phone is in offline mode." );
       
   358             return ETrue;
       
   359             }
       
   360         }
       
   361         
       
   362     CLOG_WRITE( "Phone is NOT in offline mode." );
       
   363     return EFalse;
       
   364     }
       
   365     
   370 // ----------------------------------------------------------------------------
   366 // ----------------------------------------------------------------------------
   371 // CCmPluginPacketData::NewOutgoingL
   367 // CCmPluginPacketData::NewOutgoingL
   372 // ----------------------------------------------------------------------------
   368 // ----------------------------------------------------------------------------
   373 //
   369 //
   374 CCmPluginPacketData* CCmPluginPacketData::NewL(
   370 CCmPluginPacketData* CCmPluginPacketData::NewL(