584 // Find a plugin by file extension. |
584 // Find a plugin by file extension. |
585 // ----------------------------------------------------------------------------- |
585 // ----------------------------------------------------------------------------- |
586 // |
586 // |
587 TInt PluginHandler::findPluginByExtension(const TDesC8& url) |
587 TInt PluginHandler::findPluginByExtension(const TDesC8& url) |
588 { |
588 { |
|
589 TInt idx = -1; |
|
590 PluginInfo* pluginInfo = pluginInfoByExtention(url, &idx); |
|
591 TInt ret = pluginInfo ? pluginInfo->m_handle : KErrNotFound; |
|
592 return ret; |
|
593 } |
|
594 |
|
595 |
|
596 // ----------------------------------------------------------------------------- |
|
597 // PluginHandler::pluginInfoByExtention |
|
598 // aUrl - url that should be handle by plugin |
|
599 // aExtIdx - return value of the index in the m_mimeFileExtensions for the extention |
|
600 // returns a pointer to the PluginInfo object of the plugin that should handle aUrl |
|
601 // ----------------------------------------------------------------------------- |
|
602 PluginInfo* PluginHandler::pluginInfoByExtention(const TPtrC8& aUrl, TInt* aExtIdx) |
|
603 { |
589 LOAD_PLUGINS |
604 LOAD_PLUGINS |
590 |
605 |
591 TInt pluginIndex; |
606 TInt pluginIndex; |
592 TInt extIndex; |
607 TInt extIndex; |
593 |
608 |
594 TPtrC8 extPtr(url.Mid(url.LocateReverse('.') + 1)); |
609 TPtrC8 extPtr(aUrl.Mid(aUrl.LocateReverse('.') + 1)); |
595 for (pluginIndex = 0; pluginIndex < m_pluginInfoArray.Count(); pluginIndex++) { |
610 for (pluginIndex = 0; pluginIndex < m_pluginInfoArray.Count(); pluginIndex++) { |
596 |
611 |
597 for (extIndex = 0; |
612 for (extIndex = 0; |
598 extIndex < m_pluginInfoArray[pluginIndex]-> |
613 extIndex < m_pluginInfoArray[pluginIndex]-> |
599 m_mimeFileExtensions.Count(); extIndex++) { |
614 m_mimeFileExtensions.Count(); extIndex++) { |
600 |
615 |
601 if (!m_pluginInfoArray[pluginIndex]->m_mimeFileExtensions[extIndex]->CompareF(extPtr)) { |
616 if (!m_pluginInfoArray[pluginIndex]->m_mimeFileExtensions[extIndex]->CompareF(extPtr)) { |
602 return m_pluginInfoArray[pluginIndex]->m_handle; |
617 *aExtIdx = extIndex; |
|
618 return m_pluginInfoArray[pluginIndex]; |
603 } |
619 } |
604 } |
620 } |
605 } |
621 } |
606 |
622 |
607 return KErrNotFound; |
623 return NULL; |
|
624 } |
|
625 |
|
626 |
|
627 // ----------------------------------------------------------------------------- |
|
628 // PluginHandler::pluginMimeByExtention |
|
629 // aUrl - url that should be handle by plugin |
|
630 // returns pointer to mime type in m_mimeExtensionToTypeMap array |
|
631 // ----------------------------------------------------------------------------- |
|
632 HBufC* PluginHandler::pluginMimeByExtention(const TPtrC8& url) |
|
633 { |
|
634 TInt idx = -1; |
|
635 PluginInfo* pluginInfo = pluginInfoByExtention(url, &idx); |
|
636 HBufC* mimeType = NULL; |
|
637 if (pluginInfo && idx < pluginInfo->m_mimeExtensionToTypeMap.Count()) { |
|
638 mimeType = pluginInfo->m_mimeExtensionToTypeMap[idx]; |
|
639 } |
|
640 return mimeType; |
608 } |
641 } |
609 |
642 |
610 |
643 |
611 // ----------------------------------------------------------------------------- |
644 // ----------------------------------------------------------------------------- |
612 // PluginHandler::loadPluginL |
645 // PluginHandler::loadPluginL |