browserutilities/downloadmgr/DownloadMgrServEng/Src/HttpConnHandler.cpp
branchRCL_3
changeset 94 919f36ff910f
parent 93 79859ed3eea9
child 95 d96eed154187
equal deleted inserted replaced
93:79859ed3eea9 94:919f36ff910f
    13 *
    13 *
    14 * Description:  ?Description
    14 * Description:  ?Description
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
       
    19 
       
    20 // INCLUDE FILES
    18 // INCLUDE FILES
    21 #include "HttpClientApp.h"
    19 #include "HttpClientApp.h"
    22 #include "HttpClientAppInstance.h"
    20 #include "HttpClientAppInstance.h"
    23 #include "HttpDownload.h"
    21 #include "HttpDownload.h"
    24 #include "HttpConnHandler.h"
    22 #include "HttpConnHandler.h"
    25 #include "HttpDownloadManagerServerEngine.h"
    23 #include "HttpDownloadManagerServerEngine.h"
    26 #include "FileExt.h"
    24 #include "FileExt.h"
    27 #include "HttpDownloadMgrLogger.h"
    25 #include "HttpDownloadMgrLogger.h"
    28 
    26 
    29 #include <in_sock.h>
    27 #include <in_sock.h>
    30 #include <commdbconnpref.h>
    28 #include <CommDbConnPref.h>
    31 #include <httpfilterauthenticationinterface.h>
    29 #include <httpfilterauthenticationinterface.h>
    32 #include <uaproffilter_interface.h>
    30 #include <uaproffilter_interface.h>
    33 #include <httpfiltercommonstringsext.h>
    31 #include <httpfiltercommonstringsext.h>
    34 #include <cdblen.h>
    32 #include <cdblen.h>
    35 //#include <DeflateFilterInterface.h>
    33 //#include <deflatefilterinterface.h>
    36 #include <cookiefilterinterface.h>
    34 #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
    37 
    46 
    38 // EXTERNAL DATA STRUCTURES
    47 // EXTERNAL DATA STRUCTURES
    39 //extern  ?external_data;
    48 //extern  ?external_data;
    40 
    49 
    41 // EXTERNAL FUNCTION PROTOTYPES  
    50 // EXTERNAL FUNCTION PROTOTYPES  
   237 void CHttpConnStageNotifier::RunL()
   246 void CHttpConnStageNotifier::RunL()
   238     {
   247     {
   239     if( iStatus == KErrNone )
   248     if( iStatus == KErrNone )
   240         {
   249         {
   241         TInt stage = iProgressBuf().iStage;
   250         TInt stage = iProgressBuf().iStage;
   242 
   251         if ( iProgressBuf().iStage == KLinkLayerClosed && iProgressBuf().iError == KErrDisconnected )
       
   252             iConnHandler->RetryNeeded(ETrue);
       
   253         
   243         iConnHandler->ConnectionStageChanged( stage );
   254         iConnHandler->ConnectionStageChanged( stage );
   244 
   255 
   245         if( stage > KConnectionUninitialised )
   256         if( stage != KLinkLayerClosed )
   246             // connection is still alive
   257             // connection is still alive
   247             {
   258             {
   248             iConnHandler->Connection().ProgressNotification( iProgressBuf, iStatus );
   259             iConnHandler->Connection().ProgressNotification( iProgressBuf, iStatus );
   249             SetActive();
   260             SetActive();
   250             }
   261             }
   286     CLOG_ATTACH( iShutDown, this );
   297     CLOG_ATTACH( iShutDown, this );
   287 
   298 
   288     iHttpSession.OpenL();
   299     iHttpSession.OpenL();
   289     CLOG_WRITE8( "Session open" );
   300     CLOG_WRITE8( "Session open" );
   290     InitSessionL();
   301     InitSessionL();
       
   302 
       
   303 	//Set it to zero
       
   304 	iIapId = 0;
       
   305 	iRetryNeeded = EFalse;
   291     }
   306     }
   292 
   307 
   293 // -----------------------------------------------------------------------------
   308 // -----------------------------------------------------------------------------
   294 // CHttpConnHandler::NewL
   309 // CHttpConnHandler::NewL
   295 // Two-phased constructor.
   310 // Two-phased constructor.
   350             CLOG_WRITE_1("ConnName set: [%S]", iConnName);
   365             CLOG_WRITE_1("ConnName set: [%S]", iConnName);
   351             
   366             
   352             TName connName;
   367             TName connName;
   353 
   368 
   354             connName.Copy( *iConnName );
   369             connName.Copy( *iConnName );
   355 
       
   356             User::LeaveIfError( iConnection.Open( iClientApp->Engine()->SocketServ(), connName ) );
   370             User::LeaveIfError( iConnection.Open( iClientApp->Engine()->SocketServ(), connName ) );
   357 
   371 
   358             CLOG_WRITE( "connection open" );
   372             CLOG_WRITE( "connection open" );
   359             
   373             
   360             TNifProgress progress;
   374             TNifProgress progress;
   378             else
   392             else
   379                 {
   393                 {
   380                 iPref.SetDialogPreference( ECommDbDialogPrefPrompt );
   394                 iPref.SetDialogPreference( ECommDbDialogPrefPrompt );
   381                 }
   395                 }
   382 
   396 
       
   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
   383             iConnection.Start( iPref, iStatus );
   435             iConnection.Start( iPref, iStatus );
       
   436         #endif //BRDO_OCC_ENABLED_FF
   384 
   437 
   385             // RConnection will complete us.
   438             // RConnection will complete us.
   386             doComplete = EFalse;
   439             doComplete = EFalse;
   387             }
   440             }
   388 
   441 
   712     {
   765     {
   713     CLOG_WRITE8_1( "Stage: %d", aStage );
   766     CLOG_WRITE8_1( "Stage: %d", aStage );
   714 
   767 
   715     iConnStage = aStage;
   768     iConnStage = aStage;
   716 
   769 
   717     if( iConnStage == KConnectionUninitialised || 
   770    if( iConnStage == KLinkLayerClosed || 
   718         iConnStage == KDataTransferTemporarilyBlocked
   771         iConnStage == KDataTransferTemporarilyBlocked
   719         )
   772         )
   720         {
   773         {
   721         __ASSERT_DEBUG( iClientApp, DMPanic( KErrCorrupt ) );
   774         __ASSERT_DEBUG( iClientApp, DMPanic( KErrCorrupt ) );
   722         CArrayPtrFlat<CHttpDownload>* downloads = 
   775         CArrayPtrFlat<CHttpDownload>* downloads = 
   723                                     iClientApp->Downloads();
   776                                     iClientApp->Downloads();
   724         for( TInt i = 0; i < downloads->Count(); ++i )
   777         for( TInt i = 0; i < downloads->Count(); ++i )
   725             {
   778             {            
       
   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             {               
   726             if( (*downloads)[i]->ConnHandler() == this )
   788             if( (*downloads)[i]->ConnHandler() == this )
   727                 {
   789                 {
   728                 if( iConnStage == KConnectionUninitialised )
   790                 if( iConnStage == KLinkLayerClosed )
   729                     {
   791                     {
   730                     // from now on this name is invalid -> forget it!
   792                     // from now on this name is invalid -> forget it!
   731                     delete iConnName; iConnName = NULL;
   793                      delete iConnName; iConnName = NULL;                     
   732 
   794                      (*downloads)[i]->Disconnected();                  
   733                     (*downloads)[i]->Disconnected();
   795                                         
   734                     }
   796                     }
   735                 else
   797                 else
   736                     {
   798                     {                    
   737                     (*downloads)[i]->Suspended();
   799                     (*downloads)[i]->Suspended();
   738                     }
   800                     }
   739                 }
   801                 }
   740             }
   802             }
   741 
   803 
   742         if( iConnStage == KConnectionUninitialised )
   804         if( iConnStage == KLinkLayerClosed )
   743             {
   805             {
   744             ShutDown();
   806             ShutDown();
   745             }
   807             }
   746         if ( iConnStage == KDataTransferTemporarilyBlocked )
   808         if ( iConnStage == KDataTransferTemporarilyBlocked )
   747             {
   809             {
   751     else if( iConnStage == KLinkLayerOpen )
   813     else if( iConnStage == KLinkLayerOpen )
   752         // connection open
   814         // connection open
   753         {
   815         {
   754         Connected();
   816         Connected();
   755         }
   817         }
       
   818     iRetryNeeded = EFalse;
   756     }
   819     }
   757 
   820 
   758 // -----------------------------------------------------------------------------
   821 // -----------------------------------------------------------------------------
   759 // CHttpConnHandler::ConnectionError
   822 // CHttpConnHandler::ConnectionError
   760 // ?implementation_description
   823 // ?implementation_description
   965         query.Format( _L("%s\\%s"), IAP, COMMDB_ID );
  1028         query.Format( _L("%s\\%s"), IAP, COMMDB_ID );
   966         iConnection.GetIntSetting( query, iIapId );
  1029         iConnection.GetIntSetting( query, iIapId );
   967         }
  1030         }
   968     }
  1031     }
   969 
  1032 
       
  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 
   970 //  End of File  
  1129 //  End of File