browserutilities/downloadmgr/DownloadMgrClntSrv/src/DownloadMgrClntSession.cpp
changeset 65 5bfc169077b2
parent 37 cb62a4f66ebe
child 68 92a765b5b3e7
equal deleted inserted replaced
42:d39add9822e2 65:5bfc169077b2
    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;
       
    40 
    39 
    41 _LIT8( KHttpScheme, "http" );
    40 _LIT8( KHttpScheme, "http" );
    42 _LIT8( KHttpsScheme, "https" );
    41 _LIT8( KHttpsScheme, "https" );
    43 
    42 
    44 // GLOBAL FUNCTIONS
    43 // GLOBAL FUNCTIONS
   598     {
   597     {
   599     __ASSERT_DEBUG( Handle(), DMPanic( KErrDisconnected ) );
   598     __ASSERT_DEBUG( Handle(), DMPanic( KErrDisconnected ) );
   600     
   599     
   601     CLOG_ENTERFN( "RHttpDownloadMgr::CreateDownloadL" )
   600     CLOG_ENTERFN( "RHttpDownloadMgr::CreateDownloadL" )
   602     
   601     
   603     //Leave if the number of parallel downloads exceeds 16.
       
   604     if(!IsNewDownloadPossible()){
       
   605         User::LeaveIfError(KErrServerBusy);
       
   606         }
       
   607     
       
   608     RHttpDownload* download = new (ELeave) RHttpDownload ( this );
   602     RHttpDownload* download = new (ELeave) RHttpDownload ( this );
   609     CleanupStack::PushL( download );
   603     CleanupStack::PushL( download );
   610     CleanupClosePushL( *download );
   604     CleanupClosePushL( *download );
   611     HBufC8* buf = PackedDefaultAttributesLC();
   605     HBufC8* buf = PackedDefaultAttributesLC();
   612     download->CreateL( aUrl, buf->Des() );
   606     download->CreateL( aUrl, buf->Des() );
   843 
   837 
   844     return err;
   838     return err;
   845     }
   839     }
   846 
   840 
   847 // ---------------------------------------------------------
   841 // ---------------------------------------------------------
   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 // ---------------------------------------------------------
       
   864 // RHttpDownloadMgr::Disconnect
   842 // RHttpDownloadMgr::Disconnect
   865 // ---------------------------------------------------------
   843 // ---------------------------------------------------------
   866 //
   844 //
   867 EXPORT_C TInt RHttpDownloadMgr::Disconnect()
   845 EXPORT_C TInt RHttpDownloadMgr::Disconnect()
   868     {
   846     {