531 // |
531 // |
532 // Find a plugin by MIME type. |
532 // Find a plugin by MIME type. |
533 // ----------------------------------------------------------------------------- |
533 // ----------------------------------------------------------------------------- |
534 // |
534 // |
535 TInt PluginHandler::findPlugin(const TDesC& mimeType) |
535 TInt PluginHandler::findPlugin(const TDesC& mimeType) |
536 { |
536 { |
537 LOAD_PLUGINS |
537 LOAD_PLUGINS |
538 |
538 |
539 HBufC* newMimeType = NULL; |
539 TInt bufSize( KMimeTypeLength > mimeType.Length() ? KMimeTypeLength : mimeType.Length() ); |
540 _LIT(KSeparator, "*"); |
540 HBufC* newMimeType = HBufC::New(bufSize); |
541 TInt pluginIndex; |
541 if( newMimeType == NULL ) |
|
542 { |
|
543 return KErrNoMemory; |
|
544 } |
|
545 _LIT(KSeparator, "*"); |
|
546 TInt pluginIndex; |
542 TInt mimeIndex; |
547 TInt mimeIndex; |
543 |
548 |
544 if (mimeType.FindF(KMimeTypeAudio) != KErrNotFound){ |
549 if( mimeType.FindF(KMimeTypeAudio) != KErrNotFound ) |
545 newMimeType = HBufC::NewLC(KMimeTypeLength); |
550 { |
546 newMimeType->Des().Copy(KMimeTypeAudio); |
551 newMimeType->Des().Copy(KMimeTypeAudio); |
547 newMimeType->Des().Append(KSeparator); |
552 newMimeType->Des().Append(KSeparator); |
548 } |
553 } |
549 else if (mimeType.FindF(KMimeTypeVideo) != KErrNotFound){ |
554 else if ( mimeType.FindF(KMimeTypeVideo) != KErrNotFound ) |
550 newMimeType = HBufC::NewLC(KMimeTypeLength); |
555 { |
551 newMimeType->Des().Copy(KMimeTypeVideo); |
556 newMimeType->Des().Copy(KMimeTypeVideo); |
552 newMimeType->Des().Append(KSeparator); |
557 newMimeType->Des().Append(KSeparator); |
553 } |
558 } |
554 else{ |
559 else |
555 newMimeType = HBufC::NewLC(mimeType.Length()); |
560 { |
556 newMimeType = mimeType.AllocL(); |
561 newMimeType->Des().Copy(mimeType); |
557 } |
562 } |
558 CleanupStack::Pop(); //pop newMimeType |
563 |
559 |
564 for (pluginIndex = 0; pluginIndex < m_pluginInfoArray.Count(); pluginIndex++) |
560 for (pluginIndex = 0; pluginIndex < m_pluginInfoArray.Count(); pluginIndex++) { |
565 { |
561 for (mimeIndex = 0; |
566 for (mimeIndex = 0; |
562 mimeIndex < m_pluginInfoArray[pluginIndex]->m_mimeTypes.Count(); |
567 mimeIndex < m_pluginInfoArray[pluginIndex]->m_mimeTypes.Count(); |
563 mimeIndex++) { |
568 mimeIndex++) |
564 if (!m_pluginInfoArray[pluginIndex]->m_mimeTypes[mimeIndex]->CompareF(*newMimeType)) { |
569 { |
|
570 if (!m_pluginInfoArray[pluginIndex]->m_mimeTypes[mimeIndex]->CompareF(*newMimeType)) |
|
571 { |
565 delete newMimeType; |
572 delete newMimeType; |
566 return m_pluginInfoArray[pluginIndex]->m_handle; |
573 return m_pluginInfoArray[pluginIndex]->m_handle; |
|
574 } |
567 } |
575 } |
568 } |
576 } |
569 } |
577 delete newMimeType; |
570 delete newMimeType; |
|
571 return KErrNotFound; |
578 return KErrNotFound; |
572 } |
579 } |
573 |
580 |
574 // ----------------------------------------------------------------------------- |
581 // ----------------------------------------------------------------------------- |
575 // PluginHandler::findPluginByExtension |
582 // PluginHandler::findPluginByExtension |
576 // |
583 // |
577 // Find a plugin by file extension. |
584 // Find a plugin by file extension. |