browserutilities/downloadmgr/DownloadMgrClntSrv/src/DownloadMgrClntSession.cpp
branchRCL_3
changeset 94 919f36ff910f
parent 93 79859ed3eea9
equal deleted inserted replaced
93:79859ed3eea9 94:919f36ff910f
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include "DownloadMgrLogger.h"
    21 #include "DownloadMgrLogger.h"
    22 #include "DownloadMgrClient.h"
    22 #include <downloadmgrclient.h>
    23 #include "DownloadMgrServer.h"
    23 #include "DownloadMgrServer.h"
    24 #include "DownloadMgrStart.h"
    24 #include "DownloadMgrStart.h"
    25 #include "DownloadMgrDef.h"
    25 #include "DownloadMgrDef.h"
    26 #include "DownloadMgrDefAttrib.h"
    26 #include "DownloadMgrDefAttrib.h"
    27 #include "DownloadMgrHandler.h"
    27 #include "DownloadMgrHandler.h"
    28 #include <e32svr.h>
    28 #include <e32svr.h>
    29 #include <escapeutils.h>
    29 #include <EscapeUtils.h>
    30 #include <centralrepository.h>
    30 #include <centralrepository.h>
    31 #include "DownloadMgrCRKeys.h"
    31 #include "DownloadMgrCRKeys.h"
    32 #include <BrowserUiSDKCRKeys.h>
    32 #include <browseruisdkcrkeys.h>
    33 #include <CodDownload.h>
    33 #include <coddownload.h>
    34 
    34 
    35 // CONSTANTS
    35 // CONSTANTS
    36 const TInt KHttpDownloadMgrObserverArrayGranularity = 4;
    36 const TInt KHttpDownloadMgrObserverArrayGranularity = 4;
    37 const TInt KHttpDownloadMgrDefalutAttribsGranularity = 4;
    37 const TInt KHttpDownloadMgrDefalutAttribsGranularity = 4;
    38 const TInt KDefaultMsgSlots = 16;
    38 const TInt KDefaultMsgSlots = 16;
       
    39 const TInt KNumOfSubSessions = 16;
    39 
    40 
    40 _LIT8( KHttpScheme, "http" );
    41 _LIT8( KHttpScheme, "http" );
    41 _LIT8( KHttpsScheme, "https" );
    42 _LIT8( KHttpsScheme, "https" );
    42 
    43 
    43 // GLOBAL FUNCTIONS
    44 // GLOBAL FUNCTIONS
   597     {
   598     {
   598     __ASSERT_DEBUG( Handle(), DMPanic( KErrDisconnected ) );
   599     __ASSERT_DEBUG( Handle(), DMPanic( KErrDisconnected ) );
   599     
   600     
   600     CLOG_ENTERFN( "RHttpDownloadMgr::CreateDownloadL" )
   601     CLOG_ENTERFN( "RHttpDownloadMgr::CreateDownloadL" )
   601     
   602     
       
   603     //Leave if the number of parallel downloads exceeds 16.
       
   604     if(!IsNewDownloadPossible()){
       
   605         User::LeaveIfError(KErrServerBusy);
       
   606         }
       
   607     
   602     RHttpDownload* download = new (ELeave) RHttpDownload ( this );
   608     RHttpDownload* download = new (ELeave) RHttpDownload ( this );
   603     CleanupStack::PushL( download );
   609     CleanupStack::PushL( download );
   604     CleanupClosePushL( *download );
   610     CleanupClosePushL( *download );
   605     HBufC8* buf = PackedDefaultAttributesLC();
   611     HBufC8* buf = PackedDefaultAttributesLC();
   606     download->CreateL( aUrl, buf->Des() );
   612     download->CreateL( aUrl, buf->Des() );
   837 
   843 
   838     return err;
   844     return err;
   839     }
   845     }
   840 
   846 
   841 // ---------------------------------------------------------
   847 // ---------------------------------------------------------
       
   848 // RHttpDownloadMgr::IsNewDownloadPossible()
       
   849 // ---------------------------------------------------------
       
   850  TBool RHttpDownloadMgr::IsNewDownloadPossible()
       
   851 {
       
   852     TInt32 value(0);    
       
   853     TPckg<TInt32> pckg( value );
       
   854     if(KErrNone ==  SendReceive( EHttpDownMgrNumOfSubSessions, 
       
   855                            TIpcArgs(&pckg ) )){
       
   856         if(value < KNumOfSubSessions){
       
   857             return ETrue;
       
   858         }
       
   859     }
       
   860     return EFalse;
       
   861 }
       
   862 
       
   863 // ---------------------------------------------------------
   842 // RHttpDownloadMgr::Disconnect
   864 // RHttpDownloadMgr::Disconnect
   843 // ---------------------------------------------------------
   865 // ---------------------------------------------------------
   844 //
   866 //
   845 EXPORT_C TInt RHttpDownloadMgr::Disconnect()
   867 EXPORT_C TInt RHttpDownloadMgr::Disconnect()
   846     {
   868     {