emailuis/emailui/src/FreestyleEmailUiHtmlViewerContainer.cpp
branchRCL_3
changeset 70 968773a0b6ef
parent 64 3533d4323edc
child 80 726fba06891a
equal deleted inserted replaced
64:3533d4323edc 70:968773a0b6ef
  1041             }
  1041             }
  1042         return ETrue;
  1042         return ETrue;
  1043         }
  1043         }
  1044     else
  1044     else
  1045         {
  1045         {
       
  1046         // special handling for such file links that for which corresponding
       
  1047         // file is not found in local disk. We try to modify such links to
       
  1048         // have http prefix so that browser could open them as they're likely
       
  1049         // <href=www...> type tags (i.e., tags missing the scheme) which the
       
  1050         // browser control has interpreted as local files
       
  1051         HBufC* modifiedUrl = CreateModifiedUrlIfNeededL( aUrl );
       
  1052         if ( modifiedUrl )
       
  1053             {
       
  1054             TBool rVal( ETrue ); 
       
  1055             CleanupStack::PushL( modifiedUrl );
       
  1056             rVal = iEventHandler->HandleEventL( *modifiedUrl );
       
  1057             CleanupStack::PopAndDestroy( modifiedUrl );
       
  1058             return rVal;
       
  1059             }
       
  1060         
  1046         if ( NeedToLaunchBrowserL( aUrl ) )
  1061         if ( NeedToLaunchBrowserL( aUrl ) )
  1047             {
  1062             {
  1048             LaunchBrowserL( aUrl );
  1063             LaunchBrowserL( aUrl );
  1049             return ETrue;
  1064             return ETrue;
  1050             }
  1065             }
  2163     CleanupStack::PopAndDestroy( &messageHeader );
  2178     CleanupStack::PopAndDestroy( &messageHeader );
  2164     CleanupStack::PopAndDestroy( &targetFile );
  2179     CleanupStack::PopAndDestroy( &targetFile );
  2165     CleanupStack::PopAndDestroy( content8 );
  2180     CleanupStack::PopAndDestroy( content8 );
  2166     }
  2181     }
  2167 
  2182 
       
  2183 HBufC* CFsEmailUiHtmlViewerContainer::CreateModifiedUrlIfNeededL( 
       
  2184         const TDesC& aUrl )
       
  2185     {
       
  2186     _LIT( KFileLink, "file:///");        
       
  2187     HBufC* modifiedUrl = NULL;
       
  2188     
       
  2189     // check if this really is file-URL
       
  2190     if ( aUrl.Left( KFileLink().Length() ).CompareF( KFileLink ) == 0 )
       
  2191         {
       
  2192         // convert URL-style slashes to backslashes
       
  2193         _LIT( KBackslash, "\\" );
       
  2194         HBufC* url = aUrl.Mid( KFileLink().Length() ).AllocLC();
       
  2195         TPtr urlPtr = url->Des();
       
  2196         for ( TInt pos = urlPtr.Locate('/'); pos >= 0; pos = urlPtr.Locate('/') )
       
  2197             {
       
  2198             urlPtr.Replace( pos, 1, KBackslash );
       
  2199             }
       
  2200         // check if the file exists, if not convert the file-URL to http-URL
       
  2201         // (i.e., remove the whole path and replace the prefix with "http:")
       
  2202         if ( !BaflUtils::FileExists( iFs, *url ) )
       
  2203             {
       
  2204             TInt pos = url->FindF( iTempHtmlFolderPath );
       
  2205             if ( pos >= 0 )
       
  2206                 {
       
  2207                 _LIT( KHttpPrefix, "http://" );
       
  2208                 TPtrC filename = url->Mid( pos + iTempHtmlFolderPath.Length() );
       
  2209                 modifiedUrl = HBufC::NewL( filename.Length() + KHttpPrefix().Length() );
       
  2210                 TPtr modifiedPtr = modifiedUrl->Des();
       
  2211                 modifiedPtr.Append( KHttpPrefix );
       
  2212                 modifiedPtr.Append( filename );
       
  2213                 }
       
  2214             }
       
  2215         CleanupStack::PopAndDestroy( url );
       
  2216         }
       
  2217     return modifiedUrl;
       
  2218     }
  2168 
  2219 
  2169 
  2220 
  2170 /******************************************************************************
  2221 /******************************************************************************
  2171  * class PlainTextToHtmlConverter
  2222  * class PlainTextToHtmlConverter
  2172  ******************************************************************************/
  2223  ******************************************************************************/