browserutilities/downloadmgr/DownloadMgrServEng/Src/HttpConnHandler.cpp
branchRCL_3
changeset 48 79859ed3eea9
parent 36 c711bdda59f4
child 49 919f36ff910f
equal deleted inserted replaced
47:e1bea15f9a39 48:79859ed3eea9
    13 *
    13 *
    14 * Description:  ?Description
    14 * Description:  ?Description
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 
       
    19 
    18 // INCLUDE FILES
    20 // INCLUDE FILES
    19 #include "HttpClientApp.h"
    21 #include "HttpClientApp.h"
    20 #include "HttpClientAppInstance.h"
    22 #include "HttpClientAppInstance.h"
    21 #include "HttpDownload.h"
    23 #include "HttpDownload.h"
    22 #include "HttpConnHandler.h"
    24 #include "HttpConnHandler.h"
    23 #include "HttpDownloadManagerServerEngine.h"
    25 #include "HttpDownloadManagerServerEngine.h"
    24 #include "FileExt.h"
    26 #include "FileExt.h"
    25 #include "HttpDownloadMgrLogger.h"
    27 #include "HttpDownloadMgrLogger.h"
    26 
    28 
    27 #include <in_sock.h>
    29 #include <in_sock.h>
    28 #include <CommDbConnPref.h>
    30 #include <commdbconnpref.h>
    29 #include <httpfilterauthenticationinterface.h>
    31 #include <httpfilterauthenticationinterface.h>
    30 #include <uaproffilter_interface.h>
    32 #include <uaproffilter_interface.h>
    31 #include <httpfiltercommonstringsext.h>
    33 #include <httpfiltercommonstringsext.h>
    32 #include <cdblen.h>
    34 #include <cdblen.h>
    33 //#include <deflatefilterinterface.h>
    35 //#include <DeflateFilterInterface.h>
    34 #include <cookiefilterinterface.h>
    36 #include <cookiefilterinterface.h>
    35 #include <platform/mw/browser_platform_variant.hrh>
       
    36 #ifdef BRDO_OCC_ENABLED_FF
       
    37 #include <extendedconnpref.h>
       
    38 #include <FeatMgr.h>
       
    39 #include <CentralRepository.h>
       
    40 #include <CoreApplicationUIsSDKCRKeys.h>
       
    41 #include <cmgenconnsettings.h>
       
    42 #include <cmmanagerkeys.h>
       
    43 #include <etelmm.h>
       
    44 #include <rconnmon.h>
       
    45 #endif
       
    46 
    37 
    47 // EXTERNAL DATA STRUCTURES
    38 // EXTERNAL DATA STRUCTURES
    48 //extern  ?external_data;
    39 //extern  ?external_data;
    49 
    40 
    50 // EXTERNAL FUNCTION PROTOTYPES  
    41 // EXTERNAL FUNCTION PROTOTYPES  
   246 void CHttpConnStageNotifier::RunL()
   237 void CHttpConnStageNotifier::RunL()
   247     {
   238     {
   248     if( iStatus == KErrNone )
   239     if( iStatus == KErrNone )
   249         {
   240         {
   250         TInt stage = iProgressBuf().iStage;
   241         TInt stage = iProgressBuf().iStage;
   251         if ( iProgressBuf().iStage == KLinkLayerClosed && iProgressBuf().iError == KErrDisconnected )
   242 
   252             iConnHandler->RetryNeeded(ETrue);
       
   253         
       
   254         iConnHandler->ConnectionStageChanged( stage );
   243         iConnHandler->ConnectionStageChanged( stage );
   255 
   244 
   256         if( stage != KLinkLayerClosed )
   245         if( stage > KConnectionUninitialised )
   257             // connection is still alive
   246             // connection is still alive
   258             {
   247             {
   259             iConnHandler->Connection().ProgressNotification( iProgressBuf, iStatus );
   248             iConnHandler->Connection().ProgressNotification( iProgressBuf, iStatus );
   260             SetActive();
   249             SetActive();
   261             }
   250             }
   297     CLOG_ATTACH( iShutDown, this );
   286     CLOG_ATTACH( iShutDown, this );
   298 
   287 
   299     iHttpSession.OpenL();
   288     iHttpSession.OpenL();
   300     CLOG_WRITE8( "Session open" );
   289     CLOG_WRITE8( "Session open" );
   301     InitSessionL();
   290     InitSessionL();
   302 
       
   303 	//Set it to zero
       
   304 	iIapId = 0;
       
   305 	iRetryNeeded = EFalse;
       
   306     }
   291     }
   307 
   292 
   308 // -----------------------------------------------------------------------------
   293 // -----------------------------------------------------------------------------
   309 // CHttpConnHandler::NewL
   294 // CHttpConnHandler::NewL
   310 // Two-phased constructor.
   295 // Two-phased constructor.
   365             CLOG_WRITE_1("ConnName set: [%S]", iConnName);
   350             CLOG_WRITE_1("ConnName set: [%S]", iConnName);
   366             
   351             
   367             TName connName;
   352             TName connName;
   368 
   353 
   369             connName.Copy( *iConnName );
   354             connName.Copy( *iConnName );
       
   355 
   370             User::LeaveIfError( iConnection.Open( iClientApp->Engine()->SocketServ(), connName ) );
   356             User::LeaveIfError( iConnection.Open( iClientApp->Engine()->SocketServ(), connName ) );
   371 
   357 
   372             CLOG_WRITE( "connection open" );
   358             CLOG_WRITE( "connection open" );
   373             
   359             
   374             TNifProgress progress;
   360             TNifProgress progress;
   392             else
   378             else
   393                 {
   379                 {
   394                 iPref.SetDialogPreference( ECommDbDialogPrefPrompt );
   380                 iPref.SetDialogPreference( ECommDbDialogPrefPrompt );
   395                 }
   381                 }
   396 
   382 
   397         #ifdef BRDO_OCC_ENABLED_FF
       
   398            TExtendedConnPref extPref;
       
   399            CLOG_WRITE( "Setting OCC parameters");
       
   400            CLOG_WRITE_1( "Iap: %d", iIapId );
       
   401            if (iIapId)
       
   402            {
       
   403               CLOG_WRITE( "Iap is found");
       
   404               extPref.SetSnapPurpose(CMManager::ESnapPurposeUnknown);
       
   405               extPref.SetIapId(iIapId);
       
   406            }
       
   407            else
       
   408            {
       
   409               CLOG_WRITE( "Using Internet Snap");
       
   410               extPref.SetSnapPurpose(CMManager::ESnapPurposeInternet);
       
   411            }
       
   412            //Default dialog behaviour
       
   413            extPref.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent);
       
   414            
       
   415            if ( !IsPhoneOfflineL() )
       
   416            {
       
   417               TInt currentmode = KErrNone;
       
   418               CRepository* rep = CRepository::NewLC( KCRUidCmManager );
       
   419               rep->Get(KCurrentCellularDataUsage, currentmode );
       
   420               CleanupStack::PopAndDestroy(); //rep
       
   421               if(ECmCellularDataUsageConfirm == currentmode)
       
   422               {
       
   423                  if ( IsRoamingL() || (iIapId == 0) )
       
   424                  {
       
   425                     CLOG_WRITE( "Setting note behaviour as Default");
       
   426                     extPref.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault);
       
   427                  }
       
   428               }
       
   429            }
       
   430            
       
   431            TConnPrefList prefList;
       
   432            prefList.AppendL(&extPref);
       
   433            iConnection.Start( prefList, iStatus );
       
   434         #else
       
   435             iConnection.Start( iPref, iStatus );
   383             iConnection.Start( iPref, iStatus );
   436         #endif //BRDO_OCC_ENABLED_FF
       
   437 
   384 
   438             // RConnection will complete us.
   385             // RConnection will complete us.
   439             doComplete = EFalse;
   386             doComplete = EFalse;
   440             }
   387             }
   441 
   388 
   765     {
   712     {
   766     CLOG_WRITE8_1( "Stage: %d", aStage );
   713     CLOG_WRITE8_1( "Stage: %d", aStage );
   767 
   714 
   768     iConnStage = aStage;
   715     iConnStage = aStage;
   769 
   716 
   770    if( iConnStage == KLinkLayerClosed || 
   717     if( iConnStage == KConnectionUninitialised || 
   771         iConnStage == KDataTransferTemporarilyBlocked
   718         iConnStage == KDataTransferTemporarilyBlocked
   772         )
   719         )
   773         {
   720         {
   774         __ASSERT_DEBUG( iClientApp, DMPanic( KErrCorrupt ) );
   721         __ASSERT_DEBUG( iClientApp, DMPanic( KErrCorrupt ) );
   775         CArrayPtrFlat<CHttpDownload>* downloads = 
   722         CArrayPtrFlat<CHttpDownload>* downloads = 
   776                                     iClientApp->Downloads();
   723                                     iClientApp->Downloads();
   777         for( TInt i = 0; i < downloads->Count(); ++i )
   724         for( TInt i = 0; i < downloads->Count(); ++i )
   778             {            
   725             {
   779             if(iRetryNeeded  && ((*downloads)[i]->State() == EHttpDlMultipleMOFailed || 
       
   780                (*downloads)[i]->State() == EHttpDlInprogress ))
       
   781                 {
       
   782                 (*downloads)[i]->SetRetryFlag(ETrue);                
       
   783                 }
       
   784             }        
       
   785         
       
   786         for( TInt i = 0; i < downloads->Count(); ++i )
       
   787             {               
       
   788             if( (*downloads)[i]->ConnHandler() == this )
   726             if( (*downloads)[i]->ConnHandler() == this )
   789                 {
   727                 {
   790                 if( iConnStage == KLinkLayerClosed )
   728                 if( iConnStage == KConnectionUninitialised )
   791                     {
   729                     {
   792                     // from now on this name is invalid -> forget it!
   730                     // from now on this name is invalid -> forget it!
   793                      delete iConnName; iConnName = NULL;                     
   731                     delete iConnName; iConnName = NULL;
   794                      (*downloads)[i]->Disconnected();                  
   732 
   795                                         
   733                     (*downloads)[i]->Disconnected();
   796                     }
   734                     }
   797                 else
   735                 else
   798                     {                    
   736                     {
   799                     (*downloads)[i]->Suspended();
   737                     (*downloads)[i]->Suspended();
   800                     }
   738                     }
   801                 }
   739                 }
   802             }
   740             }
   803 
   741 
   804         if( iConnStage == KLinkLayerClosed )
   742         if( iConnStage == KConnectionUninitialised )
   805             {
   743             {
   806             ShutDown();
   744             ShutDown();
   807             }
   745             }
   808         if ( iConnStage == KDataTransferTemporarilyBlocked )
   746         if ( iConnStage == KDataTransferTemporarilyBlocked )
   809             {
   747             {
   813     else if( iConnStage == KLinkLayerOpen )
   751     else if( iConnStage == KLinkLayerOpen )
   814         // connection open
   752         // connection open
   815         {
   753         {
   816         Connected();
   754         Connected();
   817         }
   755         }
   818     iRetryNeeded = EFalse;
       
   819     }
   756     }
   820 
   757 
   821 // -----------------------------------------------------------------------------
   758 // -----------------------------------------------------------------------------
   822 // CHttpConnHandler::ConnectionError
   759 // CHttpConnHandler::ConnectionError
   823 // ?implementation_description
   760 // ?implementation_description
  1028         query.Format( _L("%s\\%s"), IAP, COMMDB_ID );
   965         query.Format( _L("%s\\%s"), IAP, COMMDB_ID );
  1029         iConnection.GetIntSetting( query, iIapId );
   966         iConnection.GetIntSetting( query, iIapId );
  1030         }
   967         }
  1031     }
   968     }
  1032 
   969 
  1033 #ifdef BRDO_OCC_ENABLED_FF
       
  1034 // ---------------------------------------------------------
       
  1035 // CHttpConnHandler::IsPhoneOfflineL
       
  1036 //
       
  1037 // Checks if phone is in offline mode or not.
       
  1038 // Return ETrue if phone is in offline mode.
       
  1039 // Return EFalse if phone is not in offline mode.
       
  1040 // ---------------------------------------------------------
       
  1041 //
       
  1042 TBool CHttpConnHandler::IsPhoneOfflineL() const
       
  1043      {
       
  1044      LOGGER_ENTERFN( "CHttpConnHandler::IsPhoneOfflineL" );
       
  1045      if ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) )
       
  1046          {
       
  1047          CRepository* repository = CRepository::NewLC( KCRUidCoreApplicationUIs );
       
  1048          TInt connAllowed = 1;
       
  1049          repository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed );
       
  1050          CleanupStack::PopAndDestroy();  // repository
       
  1051          if ( !connAllowed )
       
  1052              {
       
  1053              CLOG_WRITE( "Yes, Phone is in Offline mode" );
       
  1054              return ETrue;
       
  1055              }
       
  1056          }
       
  1057      CLOG_WRITE( "Phone is in Online mode" );
       
  1058      return EFalse;
       
  1059      }
       
  1060 
       
  1061 // ---------------------------------------------------------
       
  1062 // CHttpConnHandler::IsRoamingL
       
  1063 //
       
  1064 // Checks if phone is in home network or in roam network.
       
  1065 // Return ETrue if phone is in foriegn network.
       
  1066 // Return EFalse if phone is in home network.
       
  1067 // ---------------------------------------------------------
       
  1068 //
       
  1069 TBool CHttpConnHandler::IsRoamingL()
       
  1070     {
       
  1071         LOGGER_ENTERFN( "CHttpConnHandler::IsRoamingL" );
       
  1072         RTelServer telServer;
       
  1073         User::LeaveIfError( telServer.Connect());
       
  1074         
       
  1075         RTelServer::TPhoneInfo teleinfo;
       
  1076         User::LeaveIfError( telServer.GetPhoneInfo( 0, teleinfo ) );
       
  1077         
       
  1078         RMobilePhone phone;
       
  1079         User::LeaveIfError( phone.Open( telServer, teleinfo.iName ) );
       
  1080         User::LeaveIfError(phone.Initialise()); 
       
  1081         
       
  1082         RMobilePhone::TMobilePhoneNetworkMode mode;                     
       
  1083         TInt err = phone.GetCurrentMode( mode );
       
  1084         phone.Close();
       
  1085         telServer.Close();
       
  1086         TInt Bearer = EBearerIdGSM ;
       
  1087         if( KErrNone == err )
       
  1088         {
       
  1089            switch(mode)
       
  1090            {
       
  1091                 case RMobilePhone::ENetworkModeGsm:     
       
  1092                 {           
       
  1093                 Bearer = EBearerIdGSM ;
       
  1094                     break;      
       
  1095                 }
       
  1096                 case RMobilePhone::ENetworkModeWcdma:
       
  1097                 {                                   
       
  1098                     Bearer = EBearerIdWCDMA  ;
       
  1099                     break;  
       
  1100                 }   
       
  1101                 default: 
       
  1102                 {                   
       
  1103                 
       
  1104                 }                       
       
  1105             }
       
  1106         }   
       
  1107         RConnectionMonitor monitor;
       
  1108         TRequestStatus status;
       
  1109         // open RConnectionMonitor object
       
  1110         monitor.ConnectL();
       
  1111         CleanupClosePushL( monitor );
       
  1112         TInt netwStatus ;
       
  1113         monitor.GetIntAttribute( Bearer, 0, KNetworkRegistration, netwStatus, status );
       
  1114         User::WaitForRequest( status );
       
  1115         CleanupStack::PopAndDestroy(); // Destroying monitor
       
  1116         if ( status.Int() == KErrNone && netwStatus == ENetworkRegistrationRoaming )
       
  1117         {
       
  1118             CLOG_WRITE( "Yes, Phone is in Forign network" );
       
  1119             return ETrue;
       
  1120         }
       
  1121         else //home n/w or some other state in n/w
       
  1122         {
       
  1123             CLOG_WRITE( "Phone is in Home network" );
       
  1124             return EFalse;
       
  1125         }
       
  1126    }
       
  1127 #endif
       
  1128 
       
  1129 //  End of File  
   970 //  End of File