mmappcomponents/playbackhelper/src/streaminglinkmodel.cpp
branchRCL_3
changeset 59 666f9a5a90a9
parent 56 63223d4fd956
child 67 16db3449d7ba
equal deleted inserted replaced
56:63223d4fd956 59:666f9a5a90a9
    13 *
    13 *
    14 * Description:  Implementation of CStreamingLinkModel
    14 * Description:  Implementation of CStreamingLinkModel
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 4 %
    18 // Version : %version: 5 %
    19 
    19 
    20 
    20 
    21 
    21 
    22 // INCLUDE FILES
    22 // INCLUDE FILES
    23 #include <utf.h>
    23 #include <utf.h>
   557     iLinkArray.ResetAndDestroy();
   557     iLinkArray.ResetAndDestroy();
   558     iLinkCount = 0;
   558     iLinkCount = 0;
   559 
   559 
   560     TInt size = 0;
   560     TInt size = 0;
   561     TInt result = KErrNone;
   561     TInt result = KErrNone;
       
   562     
       
   563     TBool linkadded = EFalse;
   562 
   564 
   563     if ( aRamFile.Size( size ) == KErrNone && size <= KMaxLinkFileSize )
   565     if ( aRamFile.Size( size ) == KErrNone && size <= KMaxLinkFileSize )
   564     {
   566     {
   565         HBufC8* buffer = HBufC8::NewLC( size );
   567         HBufC8* buffer = HBufC8::NewLC( size );
   566         TPtr8 ptr = buffer->Des();
   568         TPtr8 ptr = buffer->Des();
   574         CleanupStack::PushL( recognizer );
   576         CleanupStack::PushL( recognizer );
   575 
   577 
   576         // Get links from buffer
   578         // Get links from buffer
   577         while ( ret == KErrNone )
   579         while ( ret == KErrNone )
   578         {
   580         {
       
   581             linkadded = EFalse;
       
   582         
   579             // Create a linkitem ptr
   583             // Create a linkitem ptr
   580             LinkStruct* linkItem = new( ELeave ) LinkStruct;   
   584             LinkStruct* linkItem = new( ELeave ) LinkStruct;   
   581             CleanupStack::PushL( linkItem );
   585             CleanupStack::PushL( linkItem );
   582 
   586 
   583             linkItem->seek = ETrue;
   587             linkItem->seek = ETrue;
   591                 // check if line is link or not
   595                 // check if line is link or not
   592                 if ( recognizer->IsValidUrlPrefix( ptr2 ) )
   596                 if ( recognizer->IsValidUrlPrefix( ptr2 ) )
   593                 {
   597                 {
   594                     ptr2.TrimRight();
   598                     ptr2.TrimRight();
   595                     iLinkArray.Append( linkItem );
   599                     iLinkArray.Append( linkItem );
       
   600                     linkadded = ETrue;
   596                 }
   601                 }
   597             }
   602             }
   598             else
   603             else
   599             {
   604             {
   600                 iLinkArray.Append( linkItem );
   605                 iLinkArray.Append( linkItem );
       
   606                 linkadded = ETrue;
   601             }
   607             }
   602             
   608             
   603             CleanupStack::Pop(2); // pop the linkItem and the HbufC created for linkItem->link
   609             if ( linkadded )
       
   610             {
       
   611                 CleanupStack::Pop(2); // pop the linkItem and the HbufC created for linkItem->link               
       
   612             }                              
       
   613             else 
       
   614             {
       
   615                 CleanupStack::PopAndDestroy(2); //pop and destroy linkItem and the HbufC created for linkItem->link
       
   616             }
   604         }
   617         }
   605 
   618 
   606         CleanupStack::PopAndDestroy(2);  // buffer, recognizer
   619         CleanupStack::PopAndDestroy(2);  // buffer, recognizer
   607 
   620 
   608         if ( iLinkArray.Count() == 0 )
   621         if ( iLinkArray.Count() == 0 )
   634 
   647 
   635     iLinkArray.ResetAndDestroy();
   648     iLinkArray.ResetAndDestroy();
   636     iLinkCount = 0;
   649     iLinkCount = 0;
   637 
   650 
   638     TInt ret = KErrNone;
   651     TInt ret = KErrNone;
       
   652     
       
   653     TBool linkadded = EFalse;
   639 
   654 
   640     if ( aAsxParser )
   655     if ( aAsxParser )
   641     {
   656     {
   642         TUint urlCount = 0;
   657         TUint urlCount = 0;
   643         AsxStruct* asxItem;
   658         AsxStruct* asxItem;
   648             CMediaRecognizer* recognizer = CMediaRecognizer::NewL();
   663             CMediaRecognizer* recognizer = CMediaRecognizer::NewL();
   649             CleanupStack::PushL( recognizer );
   664             CleanupStack::PushL( recognizer );
   650 
   665 
   651             for (TInt i=1; i <= urlCount; i++)
   666             for (TInt i=1; i <= urlCount; i++)
   652             {
   667             {
       
   668 
       
   669                 linkadded = EFalse;
       
   670                 
   653                 // Get the asx struct from the parser
   671                 // Get the asx struct from the parser
   654                 asxItem = aAsxParser->GetUrl(i);
   672                 asxItem = aAsxParser->GetUrl(i);
   655                 // Set the url to the bufferptr
   673                 // Set the url to the bufferptr
   656                 iBufferPtr.Set(asxItem->url->Des());
   674                 iBufferPtr.Set(asxItem->url->Des());
   657                 
   675                 
   675                     // check if line is link or not
   693                     // check if line is link or not
   676                     if ( recognizer->IsValidUrlPrefix( ptr2 ) )
   694                     if ( recognizer->IsValidUrlPrefix( ptr2 ) )
   677                     {
   695                     {
   678                         ptr2.TrimRight();
   696                         ptr2.TrimRight();
   679                         iLinkArray.Append( linkItem );
   697                         iLinkArray.Append( linkItem );
       
   698                         linkadded = ETrue;
   680                     }
   699                     }
   681                 }
   700                 }
   682                 else
   701                 else
   683                 {
   702                 {
   684                     iLinkArray.Append( linkItem );
   703                     iLinkArray.Append( linkItem );
       
   704                     linkadded = ETrue;
   685                 }
   705                 }
   686                 
   706                                               
   687                 CleanupStack::Pop(2); // pop the linkItem and the HbufC created for linkItem->link 
   707                 if ( linkadded )
   688 
   708                 {
       
   709                     CleanupStack::Pop(2); // pop the linkItem and the HbufC created for linkItem->link                    
       
   710                 }                              
       
   711                 else 
       
   712                 {
       
   713                     CleanupStack::PopAndDestroy(2); //pop and destroy linkItem and the HbufC created for linkItem->link
       
   714                 }
   689             }
   715             }
   690 
   716 
   691             CleanupStack::PopAndDestroy();  //recognizer
   717             CleanupStack::PopAndDestroy();  //recognizer
   692         }
   718         }
   693         else
   719         else