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