wmdrm/camese/wmdrmdlaapp/src/wmdrmdlabrowserview.cpp
changeset 23 493788a4a8a4
parent 0 95b198f216e5
child 47 5ed7931150e9
equal deleted inserted replaced
5:79d62d1d7957 23:493788a4a8a4
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <f32file.h>
    20 #include <f32file.h>
    21 #include <bautils.h>
    21 #include <bautils.h>
    22 #include <aknviewappui.h>
    22 #include <aknViewAppUi.h>
    23 #include <coeaui.h>
    23 #include <coeaui.h>
    24 #include <coecntrl.h>
    24 #include <coecntrl.h>
    25 #include <brctlinterface.h>
    25 #include <brctlinterface.h>
    26 #include <internetconnectionmanager.h>
    26 #include <InternetConnectionManager.h>
    27 #include <wmdrmdlaapp.rsg>
    27 #include <wmdrmdlaapp.rsg>
    28 #include "wmdrmdlabrowserview.h"
    28 #include "wmdrmdlabrowserview.h"
    29 #include "wmdrmdlabrowsercontainer.h"
    29 #include "wmdrmdlabrowsercontainer.h"
    30 #include "wmdrmdlaappconstants.h"
    30 #include "wmdrmdlaappconstants.h"
    31 
    31 
   110     const TDesC8& aPostContentType,
   110     const TDesC8& aPostContentType,
   111     const TDesC8& aPostData,
   111     const TDesC8& aPostData,
   112     const TDesC8& aPostContentBoundary )
   112     const TDesC8& aPostContentBoundary )
   113     {
   113     {
   114     iCallback = aCallback;
   114     iCallback = aCallback;
   115     iContainer->BrCtlInterface()->PostUrlL( aPostUrl, 
   115     iContainer->BrCtlInterface()->PostUrlL( aPostUrl,
   116                                             aPostContentType, 
   116                                             aPostContentType,
   117                                             aPostData, 
   117                                             aPostData,
   118                                             &aPostContentBoundary, 
   118                                             &aPostContentBoundary,
   119                                             (TAny*)iContainer );
   119                                             (TAny*)iContainer );
   120     iContainer->BrCtlInterface()->SetFocus( ETrue, EDrawNow );
   120     iContainer->BrCtlInterface()->SetFocus( ETrue, EDrawNow );
   121     }
   121     }
   122 
   122 
   123 // ---------------------------------------------------------------------------
   123 // ---------------------------------------------------------------------------
   144 // ---------------------------------------------------------------------------
   144 // ---------------------------------------------------------------------------
   145 //
   145 //
   146 void CWmDrmDlaBrowserView::HandleCommandL(
   146 void CWmDrmDlaBrowserView::HandleCommandL(
   147     TInt aCommand )
   147     TInt aCommand )
   148     {
   148     {
   149     if ( aCommand >= TBrCtlDefs::ECommandIdBase + 
   149     if ( aCommand >= TBrCtlDefs::ECommandIdBase +
   150                      TBrCtlDefs::ECommandIdWMLBase &&
   150                      TBrCtlDefs::ECommandIdWMLBase &&
   151          aCommand <= TBrCtlDefs::ECommandIdBase + 
   151          aCommand <= TBrCtlDefs::ECommandIdBase +
   152                      TBrCtlDefs::ECommandIdRange )
   152                      TBrCtlDefs::ECommandIdRange )
   153         {
   153         {
   154         BrCtlHandleCommandL( aCommand );
   154         BrCtlHandleCommandL( aCommand );
   155         }
   155         }
   156     else
   156     else
   165 //
   165 //
   166 void CWmDrmDlaBrowserView::DoActivateL(
   166 void CWmDrmDlaBrowserView::DoActivateL(
   167     const TVwsViewId& /*aPrevViewId*/,
   167     const TVwsViewId& /*aPrevViewId*/,
   168     TUid /*aCustomMessageId*/,
   168     TUid /*aCustomMessageId*/,
   169     const TDesC8& /*aCustomMessage*/ )
   169     const TDesC8& /*aCustomMessage*/ )
   170     {  
   170     {
   171     CreateContainerL();
   171     CreateContainerL();
   172     AppUi()->AddToStackL( *this, iContainer );
   172     AppUi()->AddToStackL( *this, iContainer );
   173     HandleClientRectChange();
   173     HandleClientRectChange();
   174     }
   174     }
   175 
   175 
   200 //
   200 //
   201 void CWmDrmDlaBrowserView::CreateContainerL()
   201 void CWmDrmDlaBrowserView::CreateContainerL()
   202     {
   202     {
   203     RemoveContainer();
   203     RemoveContainer();
   204     iContainer = CWmDrmDlaBrowserContainer::NewL( this, this );
   204     iContainer = CWmDrmDlaBrowserContainer::NewL( this, this );
   205     iContainer->SetMopParent( this );    
   205     iContainer->SetMopParent( this );
   206     }
   206     }
   207 
   207 
   208 // ---------------------------------------------------------------------------
   208 // ---------------------------------------------------------------------------
   209 // CWmDrmDlaBrowserView::RemoveContainer
   209 // CWmDrmDlaBrowserView::RemoveContainer
   210 // ---------------------------------------------------------------------------
   210 // ---------------------------------------------------------------------------
   230 
   230 
   231 // ---------------------------------------------------------------------------
   231 // ---------------------------------------------------------------------------
   232 // CWmDrmDlaBrowserView::NetworkConnectionNeededL
   232 // CWmDrmDlaBrowserView::NetworkConnectionNeededL
   233 // ---------------------------------------------------------------------------
   233 // ---------------------------------------------------------------------------
   234 //
   234 //
   235 void CWmDrmDlaBrowserView::NetworkConnectionNeededL( 
   235 void CWmDrmDlaBrowserView::NetworkConnectionNeededL(
   236     TInt* aConnectionPtr, 
   236     TInt* aConnectionPtr,
   237     TInt* aSockSvrHandle, 
   237     TInt* aSockSvrHandle,
   238     TBool* aNewConn, 
   238     TBool* aNewConn,
   239     TApBearerType* aBearerType )
   239     TApBearerType* aBearerType )
   240     {
   240     {
   241     TInt ret( 0 );
   241     TInt ret( 0 );
   242     // If not connected, try to start a new connection
   242     // If not connected, try to start a new connection
   243     if ( !iConMgr->Connected() )
   243     if ( !iConMgr->Connected() )
   244         {
   244         {
   245         iConMgr->SetRequestedAP( iIap );
   245         iConMgr->SetRequestedAP( iIap );
   246         ret = iConMgr->StartConnectionL( ETrue );
   246         ret = iConMgr->StartConnectionL( ETrue );
   247         }
   247         }
   248     
   248 
   249     // If connected, return needed info to framework
   249     // If connected, return needed info to framework
   250     if ( !ret )
   250     if ( !ret )
   251         {
   251         {
   252         *aConnectionPtr =  reinterpret_cast<TInt>(&iConMgr->Connection() );
   252         *aConnectionPtr =  reinterpret_cast<TInt>(&iConMgr->Connection() );
   253         *aSockSvrHandle =  iConMgr->SocketServer().Handle();
   253         *aSockSvrHandle =  iConMgr->SocketServer().Handle();
   254         *aNewConn = EFalse;
   254         *aNewConn = EFalse;
   255         *aBearerType = EApBearerTypeAllBearers;
   255         *aBearerType = EApBearerTypeAllBearers;
   256         }
   256         }
   257     else 
   257     else
   258         {
   258         {
   259         User::Leave( KErrCancel );
   259         User::Leave( KErrCancel );
   260         }
   260         }
   261     }
   261     }
   262 
   262 
   263 // ---------------------------------------------------------------------------
   263 // ---------------------------------------------------------------------------
   264 // CWmDrmDlaBrowserView::HandleRequestL
   264 // CWmDrmDlaBrowserView::HandleRequestL
   265 // ---------------------------------------------------------------------------
   265 // ---------------------------------------------------------------------------
   266 //
   266 //
   267 TBool CWmDrmDlaBrowserView::HandleRequestL( 
   267 TBool CWmDrmDlaBrowserView::HandleRequestL(
   268     RArray<TUint>* /*aTypeArray*/, 
   268     RArray<TUint>* /*aTypeArray*/,
   269     CDesCArrayFlat* /*aDesArray*/ )
   269     CDesCArrayFlat* /*aDesArray*/ )
   270     {
   270     {
   271     return EFalse;
   271     return EFalse;
   272     }
   272     }
   273 
   273 
   274 // ---------------------------------------------------------------------------
   274 // ---------------------------------------------------------------------------
   275 // CWmDrmDlaBrowserView::HandleDownloadL
   275 // CWmDrmDlaBrowserView::HandleDownloadL
   276 // ---------------------------------------------------------------------------
   276 // ---------------------------------------------------------------------------
   277 //
   277 //
   278 TBool CWmDrmDlaBrowserView::HandleDownloadL( 
   278 TBool CWmDrmDlaBrowserView::HandleDownloadL(
   279     RArray<TUint>* aTypeArray, 
   279     RArray<TUint>* aTypeArray,
   280     CDesCArrayFlat* aDesArray )
   280     CDesCArrayFlat* aDesArray )
   281     {
   281     {
   282     //Check that content type and local file name exists
   282     //Check that content type and local file name exists
   283     //There must be both, because download manager downloads POST-content 
   283     //There must be both, because download manager downloads POST-content
   284     //in advance calling this function
   284     //in advance calling this function
   285     TInt contentTypeIndex( aTypeArray->Find( EParamReceivedContentType ) ); 
   285     TInt contentTypeIndex( aTypeArray->Find( EParamReceivedContentType ) );
   286     TInt fileNameIndex( aTypeArray->Find( EParamLocalFileName ) );
   286     TInt fileNameIndex( aTypeArray->Find( EParamLocalFileName ) );
   287     if ( contentTypeIndex != KErrNotFound &&  
   287     if ( contentTypeIndex != KErrNotFound &&
   288          fileNameIndex != KErrNotFound &&
   288          fileNameIndex != KErrNotFound &&
   289          contentTypeIndex < aDesArray->Count() &&
   289          contentTypeIndex < aDesArray->Count() &&
   290          fileNameIndex < aDesArray->Count() )
   290          fileNameIndex < aDesArray->Count() )
   291         {
   291         {
   292         //Check that the downloaded content is license response
   292         //Check that the downloaded content is license response
   293         TPtrC16 dataTypePtr( (*aDesArray)[contentTypeIndex] );
   293         TPtrC16 dataTypePtr( (*aDesArray)[contentTypeIndex] );
   294         if ( dataTypePtr.CompareF( KDataTypeLicenseResponse ) == 0 )
   294         if ( dataTypePtr.CompareF( KDataTypeLicenseResponse ) == 0 )
   295             {
   295             {
   296             //Get the path to the license response,
   296             //Get the path to the license response,
   297             //read the response, delete the file and 
   297             //read the response, delete the file and
   298             //make a license received - callback
   298             //make a license received - callback
   299             TPtrC16 filePathPtr( (*aDesArray)[fileNameIndex] );
   299             TPtrC16 filePathPtr( (*aDesArray)[fileNameIndex] );
   300             RFs fs;
   300             RFs fs;
   301             User::LeaveIfError( fs.Connect() );
   301             User::LeaveIfError( fs.Connect() );
   302             CleanupClosePushL( fs );
   302             CleanupClosePushL( fs );