diff --git a/uriloader/exthandler/Makefile.in b/uriloader/exthandler/Makefile.in --- a/uriloader/exthandler/Makefile.in +++ b/uriloader/exthandler/Makefile.in @@ -158,16 +158,21 @@ CPPSRCS = \ $(NULL) ifdef MOZ_ENABLE_DBUS CPPSRCS += nsDBusHandlerApp.cpp LOCAL_INCLUDES += $(TK_CFLAGS) $(MOZ_DBUS_GLIB_CFLAGS) EXTRA_DSO_LDOPTS += $(MOZ_DBUS_GLIB_LIBS) endif +ifdef MOZ_ENABLE_GNOMEVFS +LOCAL_INCLUDES += $(MOZ_GNOMEVFS_CFLAGS) +EXTRA_DSO_LDOPTS += $(MOZ_GNOMEVFS_LIBS) +endif + ifeq ($(OS_ARCH),WINNT WINCE) OS_LIBS += shell32.lib GARBAGE += nsOSHelperAppService.cpp $(srcdir)/nsOSHelperAppService.cpp \ nsMIMEInfoWin.cpp $(srcdir)/nsMIMEInfoWin.cpp endif EXTRA_COMPONENTS = \ nsHandlerService.js \ diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -785,16 +785,17 @@ nsresult nsExternalHelperAppService::Get } ////////////////////////////////////////////////////////////////////////////////////////////////////// // begin external protocol service default implementation... ////////////////////////////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP nsExternalHelperAppService::ExternalProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists) { + printf("\t-->nsExternalHelperAppService::ExternalProtocolHandlerExists\n"); nsCOMPtr handlerInfo; nsresult rv = GetProtocolHandlerInfo(nsDependentCString(aProtocolScheme), getter_AddRefs(handlerInfo)); NS_ENSURE_SUCCESS(rv, rv); // See if we have any known possible handler apps for this nsCOMPtr possibleHandlers; handlerInfo->GetPossibleApplicationHandlers(getter_AddRefs(possibleHandlers)); @@ -851,16 +852,17 @@ NS_IMETHODIMP nsExternalHelperAppService static const char kExternalProtocolPrefPrefix[] = "network.protocol-handler.external."; static const char kExternalProtocolDefaultPref[] = "network.protocol-handler.external-default"; NS_IMETHODIMP nsExternalHelperAppService::LoadURI(nsIURI *aURI, nsIInterfaceRequestor *aWindowContext) { + printf("****nsExternalHelperAppService::LoadURI\n"); NS_ENSURE_ARG_POINTER(aURI); nsCAutoString spec; aURI->GetSpec(spec); if (spec.Find("%00") != -1) return NS_ERROR_MALFORMED_URI; @@ -902,19 +904,21 @@ nsExternalHelperAppService::LoadURI(nsIU nsHandlerInfoAction preferredAction; handler->GetPreferredAction(&preferredAction); PRBool alwaysAsk = PR_TRUE; handler->GetAlwaysAskBeforeHandling(&alwaysAsk); // if we are not supposed to ask, and the preferred action is to use // a helper app or the system default, we just launch the URI. if (!alwaysAsk && (preferredAction == nsIHandlerInfo::useHelperApp || - preferredAction == nsIHandlerInfo::useSystemDefault)) + preferredAction == nsIHandlerInfo::useSystemDefault)) { + printf("****nsExternalHelperAppService::LoadURI 2\n"); return handler->LaunchWithURI(uri, aWindowContext); - + } + nsCOMPtr chooser = do_CreateInstance("@mozilla.org/content-dispatch-chooser;1", &rv); NS_ENSURE_SUCCESS(rv, rv); return chooser->Ask(handler, aWindowContext, uri, nsIContentDispatchChooser::REASON_CANNOT_HANDLE); } @@ -984,16 +988,17 @@ static const char kExternalWarningPrefPr "network.protocol-handler.warn-external."; static const char kExternalWarningDefaultPref[] = "network.protocol-handler.warn-external-default"; NS_IMETHODIMP nsExternalHelperAppService::GetProtocolHandlerInfo(const nsACString &aScheme, nsIHandlerInfo **aHandlerInfo) { + printf("nsExternalHelperAppService::GetProtocolHandlerInfo\n"); // XXX enterprise customers should be able to turn this support off with a // single master pref (maybe use one of the "exposed" prefs here?) PRBool exists; nsresult rv = GetProtocolHandlerInfoFromOS(aScheme, &exists, aHandlerInfo); if (NS_FAILED(rv)) { // Either it knows nothing, or we ran out of memory return NS_ERROR_FAILURE; @@ -1021,16 +1026,17 @@ nsExternalHelperAppService::GetProtocolH // intended to be implemented by the subclass return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP nsExternalHelperAppService::SetProtocolHandlerDefaults(nsIHandlerInfo *aHandlerInfo, PRBool aOSHandlerExists) { + printf("--------->nsExternalHelperAppService::SetProtocolHandlerDefaults\n"); // this type isn't in our database, so we've only got an OS default handler, // if one exists if (aOSHandlerExists) { // we've got a default, so use it aHandlerInfo->SetPreferredAction(nsIHandlerInfo::useSystemDefault); // whether or not to ask the user depends on the warning preference @@ -1629,16 +1635,17 @@ NS_IMETHODIMP nsExternalAppHandler::OnSt action = nsIMIMEInfo::saveToDisk; } } #endif if (action == nsIMIMEInfo::useHelperApp || action == nsIMIMEInfo::useSystemDefault) { + printf("nsExternalAppHandler::OnStartRequest - LaunchWithApplication\n"); rv = LaunchWithApplication(nsnull, PR_FALSE); } else // Various unknown actions go here too { rv = SaveToDisk(nsnull, PR_FALSE); } } @@ -1851,58 +1858,65 @@ NS_IMETHODIMP nsExternalAppHandler::OnSt // close the stream... if (mOutStream) { mOutStream->Close(); mOutStream = nsnull; } + printf("\t-->nsExternalAppHandler::OnStopRequest - ExecuteDesiredAction\n"); // Do what the user asked for ExecuteDesiredAction(); // At this point, the channel should still own us. So releasing the reference // to us in the nsITransfer should be ok. // This nsITransfer object holds a reference to us (we are its observer), so // we need to release the reference to break a reference cycle (and therefore // to prevent leaking) mWebProgressListener = nsnull; return NS_OK; } nsresult nsExternalAppHandler::ExecuteDesiredAction() { + printf("\t-->nsExternalAppHandler::ExecuteDesiredAction\n"); nsresult rv = NS_OK; if (mProgressListenerInitialized && !mCanceled) { + printf("\t-->nsExternalAppHandler::ExecuteDesiredAction 2\n"); nsHandlerInfoAction action = nsIMIMEInfo::saveToDisk; mMimeInfo->GetPreferredAction(&action); if (action == nsIMIMEInfo::useHelperApp || action == nsIMIMEInfo::useSystemDefault) { + printf("\t-->nsExternalAppHandler::ExecuteDesiredAction 3\n"); // Make sure the suggested name is unique since in this case we don't // have a file name that was guaranteed to be unique by going through // the File Save dialog rv = mFinalFileDestination->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600); if (NS_SUCCEEDED(rv)) { + printf("\t-->nsExternalAppHandler::ExecuteDesiredAction 4\n"); // Source and dest dirs should be == so this should just do a rename rv = MoveFile(mFinalFileDestination); - if (NS_SUCCEEDED(rv)) - rv = OpenWithApplication(); + if (NS_SUCCEEDED(rv)) { printf("\t-->nsExternalAppHandler::ExecuteDesiredAction 5\n"); + rv = OpenWithApplication(); } } } else // Various unknown actions go here too { + printf("\t-->nsExternalAppHandler::ExecuteDesiredAction 7\n"); // XXX Put progress dialog in barber-pole mode // and change text to say "Copying from:". rv = MoveFile(mFinalFileDestination); if (NS_SUCCEEDED(rv) && action == nsIMIMEInfo::saveToDisk) { + printf("\t-->nsExternalAppHandler::ExecuteDesiredAction 8\n"); nsCOMPtr destfile(do_QueryInterface(mFinalFileDestination)); gExtProtSvc->FixFilePermissions(destfile); } } // Notify dialog that download is complete. // By waiting till this point, it ensures that the progress dialog doesn't indicate // success until we're really done. @@ -2169,16 +2183,17 @@ NS_IMETHODIMP nsExternalAppHandler::Save ProcessAnyRefreshTags(); return NS_OK; } nsresult nsExternalAppHandler::OpenWithApplication() { + printf("\t-->nsExternalAppHandler::OpenWithApplication\n"); nsresult rv = NS_OK; if (mCanceled) return NS_OK; // we only should have gotten here if the on stop request had been fired already. NS_ASSERTION(mStopRequestIssued, "uhoh, how did we get here if we aren't done getting data?"); // if a stop request was already issued then proceed with launching the application. @@ -2202,89 +2217,97 @@ nsresult nsExternalAppHandler::OpenWithA // make the tmp file readonly so users won't edit it and lose the changes // only if we're going to delete the file if (deleteTempFileOnExit || gExtProtSvc->InPrivateBrowsing()) mFinalFileDestination->SetPermissions(0400); rv = mMimeInfo->LaunchWithFile(mFinalFileDestination); if (NS_FAILED(rv)) { + printf("\t-->nsExternalAppHandler::OpenWithApplication 2\n"); // Send error notification. nsAutoString path; mFinalFileDestination->GetPath(path); SendStatusChange(kLaunchError, rv, nsnull, path); Cancel(rv); // Cancel, and clean up temp file. } // Always schedule files to be deleted at the end of the private browsing // mode, regardless of the value of the pref. else if (deleteTempFileOnExit || gExtProtSvc->InPrivateBrowsing()) { NS_ASSERTION(gExtProtSvc, "Service gone away!?"); + printf("\t-->nsExternalAppHandler::OpenWithApplication 3\n"); gExtProtSvc->DeleteTemporaryFileOnExit(mFinalFileDestination); } } return rv; } // LaunchWithApplication should only be called by the helper app dialog which allows // the user to say launch with application or save to disk. It doesn't actually // perform launch with application. That won't happen until we are done downloading // the content and are sure we've showna progress dialog. This was done to simplify the // logic that was showing up in this method. NS_IMETHODIMP nsExternalAppHandler::LaunchWithApplication(nsIFile * aApplication, PRBool aRememberThisPreference) { + printf("\t-->nsExternalAppHandler::LaunchWithApplication\n"); if (mCanceled) return NS_OK; // user has chosen to launch using an application, fire any refresh tags now... ProcessAnyRefreshTags(); mReceivedDispositionInfo = PR_TRUE; if (mMimeInfo && aApplication) { + printf("\t-->nsExternalAppHandler::LaunchWithApplication 2\n"); PlatformLocalHandlerApp_t *handlerApp = new PlatformLocalHandlerApp_t(EmptyString(), aApplication); mMimeInfo->SetPreferredApplicationHandler(handlerApp); } // Now check if the file is local, in which case we won't bother with saving // it to a temporary directory and just launch it from where it is nsCOMPtr fileUrl(do_QueryInterface(mSourceUrl)); if (fileUrl && mIsFileChannel) { + printf("\t-->nsExternalAppHandler::LaunchWithApplication 3\n"); Cancel(NS_BINDING_ABORTED); nsCOMPtr file; nsresult rv = fileUrl->GetFile(getter_AddRefs(file)); if (NS_SUCCEEDED(rv)) { + printf("\t-->nsExternalAppHandler::LaunchWithApplication 4\n"); rv = mMimeInfo->LaunchWithFile(file); if (NS_SUCCEEDED(rv)) return NS_OK; } nsAutoString path; if (file) file->GetPath(path); // If we get here, an error happened SendStatusChange(kLaunchError, rv, nsnull, path); + printf("\t-->nsExternalAppHandler::LaunchWithApplication 5\n"); return rv; } // Now that the user has elected to launch the downloaded file with a helper app, we're justified in // removing the 'salted' name. We'll rename to what was specified in mSuggestedFileName after the // download is done prior to launching the helper app. So that any existing file of that name won't // be overwritten we call CreateUnique() before calling MoveFile(). Also note that we use the same // directory as originally downloaded to so that MoveFile() just does an in place rename. nsCOMPtr fileToUse; (void) GetDownloadDirectory(getter_AddRefs(fileToUse)); if (mSuggestedFileName.IsEmpty()) { // Keep using the leafname of the temp file, since we're just starting a helper mTempFile->GetLeafName(mSuggestedFileName); + printf("\t-->nsExternalAppHandler::LaunchWithApplication 6\n"); } #ifdef XP_WIN fileToUse->Append(mSuggestedFileName + mTempFileExtension); #else fileToUse->Append(mSuggestedFileName); #endif @@ -2424,58 +2447,59 @@ nsExternalAppHandler::Notify(nsITimer* t ////////////////////////////////////////////////////////////////////////////////////////////////////////////// // The following section contains our nsIMIMEService implementation and related methods. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////// // nsIMIMEService methods NS_IMETHODIMP nsExternalHelperAppService::GetFromTypeAndExtension(const nsACString& aMIMEType, const nsACString& aFileExt, nsIMIMEInfo **_retval) { + printf("\t-->nsExternalHelperAppService::GetFromTypeAndExtension\n"); NS_PRECONDITION(!aMIMEType.IsEmpty() || !aFileExt.IsEmpty(), "Give me something to work with"); LOG(("Getting mimeinfo from type '%s' ext '%s'\n", PromiseFlatCString(aMIMEType).get(), PromiseFlatCString(aFileExt).get())); *_retval = nsnull; // OK... we need a type. Get one. nsCAutoString typeToUse(aMIMEType); if (typeToUse.IsEmpty()) { nsresult rv = GetTypeFromExtension(aFileExt, typeToUse); if (NS_FAILED(rv)) return NS_ERROR_NOT_AVAILABLE; } - + printf("\t-->nsExternalHelperAppService::GetFromTypeAndExtension2\n"); // We promise to only send lower case mime types to the OS ToLowerCase(typeToUse); // (1) Ask the OS for a mime info PRBool found; *_retval = GetMIMEInfoFromOS(typeToUse, aFileExt, &found).get(); LOG(("OS gave back 0x%p - found: %i\n", *_retval, found)); // If we got no mimeinfo, something went wrong. Probably lack of memory. if (!*_retval) return NS_ERROR_OUT_OF_MEMORY; - + printf("\t-->nsExternalHelperAppService::GetFromTypeAndExtension3\n"); // (2) Now, let's see if we can find something in our datastore // This will not overwrite the OS information that interests us // (i.e. default application, default app. description) nsresult rv; nsCOMPtr handlerSvc = do_GetService(NS_HANDLERSERVICE_CONTRACTID); if (handlerSvc) { PRBool hasHandler = PR_FALSE; (void) handlerSvc->Exists(*_retval, &hasHandler); if (hasHandler) { rv = handlerSvc->FillHandlerInfo(*_retval, EmptyCString()); LOG(("Data source: Via type: retval 0x%08x\n", rv)); } else { rv = NS_ERROR_NOT_AVAILABLE; } - + printf("\t-->nsExternalHelperAppService::GetFromTypeAndExtension4\n"); found = found || NS_SUCCEEDED(rv); if (!found || NS_FAILED(rv)) { // No type match, try extension match if (!aFileExt.IsEmpty()) { nsCAutoString overrideType; rv = handlerSvc->GetTypeFromExtension(aFileExt, overrideType); if (NS_SUCCEEDED(rv) && !overrideType.IsEmpty()) { @@ -2487,62 +2511,68 @@ NS_IMETHODIMP nsExternalHelperAppService found = found || NS_SUCCEEDED(rv); } } } } // (3) No match yet. Ask extras. if (!found) { + printf("\t-->nsExternalHelperAppService::GetFromTypeAndExtension 5\n"); rv = NS_ERROR_FAILURE; #ifdef XP_WIN /* XXX Gross hack to wallpaper over the most common Win32 * extension issues caused by the fix for bug 116938. See bug * 120327, comment 271 for why this is needed. Not even sure we * want to remove this once we have fixed all this stuff to work * right; any info we get from extras on this type is pretty much * useless.... */ if (!typeToUse.Equals(APPLICATION_OCTET_STREAM, nsCaseInsensitiveCStringComparator())) #endif rv = FillMIMEInfoForMimeTypeFromExtras(typeToUse, *_retval); LOG(("Searched extras (by type), rv 0x%08X\n", rv)); + printf("\t-->nsExternalHelperAppService::GetFromTypeAndExtension 6 --> Searched extras (by type), rv 0x%08X\n", rv); // If that didn't work out, try file extension from extras if (NS_FAILED(rv) && !aFileExt.IsEmpty()) { rv = FillMIMEInfoForExtensionFromExtras(aFileExt, *_retval); LOG(("Searched extras (by ext), rv 0x%08X\n", rv)); + printf("\t-->nsExternalHelperAppService::GetFromTypeAndExtension 7 --> Searched extras (by ext), rv 0x%08X\n", rv); } } // Finally, check if we got a file extension and if yes, if it is an // extension on the mimeinfo, in which case we want it to be the primary one if (!aFileExt.IsEmpty()) { PRBool matches = PR_FALSE; (*_retval)->ExtensionExists(aFileExt, &matches); LOG(("Extension '%s' matches mime info: %i\n", PromiseFlatCString(aFileExt).get(), matches)); + printf("nsExternalHelperAppService::GetFromTypeAndExtension --> Extension '%s' matches mime info: %i\n", PromiseFlatCString(aFileExt).get(), matches); if (matches) (*_retval)->SetPrimaryExtension(aFileExt); } -#ifdef PR_LOGGING - if (LOG_ENABLED()) { +/*#ifdef PR_LOGGING + if (LOG_ENABLED()) {*/ nsCAutoString type; (*_retval)->GetMIMEType(type); nsCAutoString ext; (*_retval)->GetPrimaryExtension(ext); LOG(("MIME Info Summary: Type '%s', Primary Ext '%s'\n", type.get(), ext.get())); - } -#endif + printf("MIME Info Summary: Type '%s', Primary Ext '%s'\n", type.get(), ext.get()); +// } +// #endif return NS_OK; } NS_IMETHODIMP nsExternalHelperAppService::GetTypeFromExtension(const nsACString& aFileExt, nsACString& aContentType) { + printf("nsExternalHelperAppService::GetTypeFromExtension\n"); // OK. We want to try the following sources of mimetype information, in this order: // 1. defaultMimeEntries array // 2. User-set preferences (managed by the handler service) // 3. OS-provided information // 4. our "extras" array // 5. Information from plugins // 6. The "ext-to-type-mapping" category @@ -2598,16 +2628,17 @@ NS_IMETHODIMP nsExternalHelperAppService rv = NS_ERROR_NOT_AVAILABLE; } return rv; } NS_IMETHODIMP nsExternalHelperAppService::GetPrimaryExtension(const nsACString& aMIMEType, const nsACString& aFileExt, nsACString& _retval) { + printf("nsExternalHelperAppService::GetPrimaryExtension\n"); NS_ENSURE_ARG(!aMIMEType.IsEmpty()); nsCOMPtr mi; nsresult rv = GetFromTypeAndExtension(aMIMEType, aFileExt, getter_AddRefs(mi)); if (NS_FAILED(rv)) return rv; return mi->GetPrimaryExtension(_retval); @@ -2667,16 +2698,17 @@ NS_IMETHODIMP nsExternalHelperAppService } // We found no information; say so. return NS_ERROR_NOT_AVAILABLE; } NS_IMETHODIMP nsExternalHelperAppService::GetTypeFromFile(nsIFile* aFile, nsACString& aContentType) { + printf("\t-->nsExternalHelperAppService::GetTypeFromFile\n"); nsresult rv; nsCOMPtr info; // Get the Extension nsAutoString fileName; rv = aFile->GetLeafName(fileName); if (NS_FAILED(rv)) return rv; diff --git a/uriloader/exthandler/nsExternalProtocolHandler.cpp b/uriloader/exthandler/nsExternalProtocolHandler.cpp --- a/uriloader/exthandler/nsExternalProtocolHandler.cpp +++ b/uriloader/exthandler/nsExternalProtocolHandler.cpp @@ -351,16 +351,17 @@ nsExternalProtocolHandler::AllowPort(PRI { // don't override anything. *_retval = PR_FALSE; return NS_OK; } // returns TRUE if the OS can handle this protocol scheme and false otherwise. PRBool nsExternalProtocolHandler::HaveExternalProtocolHandler(nsIURI * aURI) { + printf("nsExternalProtocolHandler::HaveExternalProtocolHandler\n"); PRBool haveHandler = PR_FALSE; if (aURI) { nsCAutoString scheme; aURI->GetScheme(scheme); if (gExtProtSvc) gExtProtSvc->ExternalProtocolHandlerExists(scheme.get(), &haveHandler); } @@ -419,16 +420,17 @@ NS_IMETHODIMP nsExternalProtocolHandler: return NS_ERROR_UNKNOWN_PROTOCOL; } /////////////////////////////////////////////////////////////////////// // External protocol handler interface implementation ////////////////////////////////////////////////////////////////////// NS_IMETHODIMP nsExternalProtocolHandler::ExternalAppExistsForScheme(const nsACString& aScheme, PRBool *_retval) { + printf("nsExternalProtocolHandler::ExternalAppExistsForScheme\n"); if (gExtProtSvc) return gExtProtSvc->ExternalProtocolHandlerExists( PromiseFlatCString(aScheme).get(), _retval); // In case we don't have external protocol service. *_retval = PR_FALSE; return NS_OK; } diff --git a/uriloader/exthandler/nsMIMEInfoImpl.cpp b/uriloader/exthandler/nsMIMEInfoImpl.cpp --- a/uriloader/exthandler/nsMIMEInfoImpl.cpp +++ b/uriloader/exthandler/nsMIMEInfoImpl.cpp @@ -288,16 +288,17 @@ nsMIMEInfoBase::SetPreferredApplicationH { mPreferredApplication = aPreferredAppHandler; return NS_OK; } NS_IMETHODIMP nsMIMEInfoBase::GetPossibleApplicationHandlers(nsIMutableArray ** aPossibleAppHandlers) { + printf("\t-->nsMIMEInfoBase::GetPossibleApplicationHandlers\n"); if (!mPossibleApplications) mPossibleApplications = do_CreateInstance(NS_ARRAY_CONTRACTID); if (!mPossibleApplications) return NS_ERROR_OUT_OF_MEMORY; *aPossibleAppHandlers = mPossibleApplications; NS_IF_ADDREF(*aPossibleAppHandlers); @@ -347,51 +348,54 @@ nsMIMEInfoBase::GetLocalFileFromURI(nsIU if (NS_FAILED(rv)) return rv; return CallQueryInterface(file, aFile); } NS_IMETHODIMP nsMIMEInfoBase::LaunchWithFile(nsIFile* aFile) { + printf("LaunchWithFile\n"); nsresult rv; // it doesn't make any sense to call this on protocol handlers NS_ASSERTION(mClass == eMIMEInfo, "nsMIMEInfoBase should have mClass == eMIMEInfo"); if (mPreferredAction == useSystemDefault) { + printf("LaunchWithFile 2\n"); return LaunchDefaultWithFile(aFile); } if (mPreferredAction == useHelperApp) { - if (!mPreferredApplication) - return NS_ERROR_FILE_NOT_FOUND; - + if (!mPreferredApplication) { printf("LaunchWithFile 3\n"); + return NS_ERROR_FILE_NOT_FOUND; } + printf("LaunchWithFile 4\n"); // at the moment, we only know how to hand files off to local handlers nsCOMPtr localHandler = do_QueryInterface(mPreferredApplication, &rv); NS_ENSURE_SUCCESS(rv, rv); - + printf("LaunchWithFile 5\n"); nsCOMPtr executable; rv = localHandler->GetExecutable(getter_AddRefs(executable)); NS_ENSURE_SUCCESS(rv, rv); - + printf("LaunchWithFile 6\n"); nsCAutoString path; aFile->GetNativePath(path); return LaunchWithIProcess(executable, path); } return NS_ERROR_INVALID_ARG; } NS_IMETHODIMP nsMIMEInfoBase::LaunchWithURI(nsIURI* aURI, nsIInterfaceRequestor* aWindowContext) { + printf("nsMIMEInfoBase::LaunchWithURI\n"); // for now, this is only being called with protocol handlers; that // will change once we get to more general registerContentHandler // support NS_ASSERTION(mClass == eProtocolInfo, "nsMIMEInfoBase should be a protocol handler"); if (mPreferredAction == useSystemDefault) { return LoadUriInternal(aURI); @@ -417,28 +421,28 @@ nsMIMEInfoBase::CopyBasicDataTo(nsMIMEIn aOther->mMacType = mMacType; aOther->mMacCreator = mMacCreator; } /* static */ nsresult nsMIMEInfoBase::LaunchWithIProcess(nsIFile* aApp, const nsCString& aArg) { + printf("LaunchWithIProcess\n"); NS_ASSERTION(aApp, "Unexpected null pointer, fix caller"); nsresult rv; nsCOMPtr process = do_CreateInstance(NS_PROCESS_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; - + printf("LaunchWithIProcess 2\n"); if (NS_FAILED(rv = process->Init(aApp))) return rv; - + printf("LaunchWithIProcess 3\n"); const char *string = aArg.get(); - return process->Run(PR_FALSE, &string, 1); } // nsMIMEInfoImpl implementation NS_IMETHODIMP nsMIMEInfoImpl::GetDefaultDescription(nsAString& aDefaultDescription) { if (mDefaultAppDescription.IsEmpty() && mDefaultApplication) { @@ -450,33 +454,35 @@ nsMIMEInfoImpl::GetDefaultDescription(ns } return NS_OK; } NS_IMETHODIMP nsMIMEInfoImpl::GetHasDefaultHandler(PRBool * _retval) { + printf("\t-->nsMIMEInfoImpl::GetHasDefaultHandler\n"); *_retval = !mDefaultAppDescription.IsEmpty(); if (mDefaultApplication) { PRBool exists; *_retval = NS_SUCCEEDED(mDefaultApplication->Exists(&exists)) && exists; } return NS_OK; } nsresult nsMIMEInfoImpl::LaunchDefaultWithFile(nsIFile* aFile) { + printf("LaunchDefaultWithFile\n"); if (!mDefaultApplication) return NS_ERROR_FILE_NOT_FOUND; - + printf("LaunchDefaultWithFile 2\n"); nsCAutoString nativePath; aFile->GetNativePath(nativePath); - + printf("LaunchDefaultWithFile 3\n"); return LaunchWithIProcess(mDefaultApplication, nativePath); } NS_IMETHODIMP nsMIMEInfoBase::GetPossibleLocalHandlers(nsIArray **_retval) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/uriloader/exthandler/unix/nsGNOMERegistry.cpp b/uriloader/exthandler/unix/nsGNOMERegistry.cpp --- a/uriloader/exthandler/unix/nsGNOMERegistry.cpp +++ b/uriloader/exthandler/unix/nsGNOMERegistry.cpp @@ -47,19 +47,25 @@ #include "nsIGConfService.h" #include "nsIGnomeVFSService.h" #ifdef MOZ_WIDGET_GTK2 #include #include #endif +#include +#include +#include +#include + /* static */ PRBool nsGNOMERegistry::HandlerExists(const char *aProtocolScheme) { + printf("@@@@@@@@nsGNOMERegistry::HandlerExists\n"); nsCOMPtr gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID); if (!gconf) return PR_FALSE; PRBool isEnabled; nsCAutoString handler; if (NS_FAILED(gconf->GetAppForProtocol(nsDependentCString(aProtocolScheme), &isEnabled, handler))) return PR_FALSE; @@ -73,27 +79,29 @@ nsGNOMERegistry::HandlerExists(const cha // falls back to using gnomevfs modules. See bug 389632. We don't want // this fallback to happen as we are not sure of the safety of all gnomevfs // modules and MIME-default applications. (gnomevfs should be handled in // nsGnomeVFSProtocolHandler.) /* static */ nsresult nsGNOMERegistry::LoadURL(nsIURI *aURL) { + printf("@@@@@@@@nsGNOMERegistry::LoadURL\n"); nsCOMPtr vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID); if (!vfs) return NS_ERROR_FAILURE; return vfs->ShowURI(aURL); } /* static */ void nsGNOMERegistry::GetAppDescForScheme(const nsACString& aScheme, nsAString& aDesc) { + printf("@@@@@@@@@@@nsGNOMERegistry::GetAppDescForScheme\n"); nsCOMPtr gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID); if (!gconf) return; PRBool isEnabled; nsCAutoString app; if (NS_FAILED(gconf->GetAppForProtocol(aScheme, &isEnabled, app))) return; @@ -113,50 +121,58 @@ nsGNOMERegistry::GetAppDescForScheme(con } } /* static */ already_AddRefed nsGNOMERegistry::GetFromExtension(const nsACString& aFileExt) { NS_ASSERTION(aFileExt[0] != '.', "aFileExt shouldn't start with a dot"); + nsCOMPtr vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID); if (!vfs) return nsnull; - + printf("nsGNOMERegistry::GetFromExtension\n"); // Get the MIME type from the extension, then call GetFromType to // fill in the MIMEInfo. nsCAutoString mimeType; if (NS_FAILED(vfs->GetMimeTypeFromExtension(aFileExt, mimeType)) || mimeType.EqualsLiteral("application/octet-stream")) return nsnull; return GetFromType(mimeType); } /* static */ already_AddRefed nsGNOMERegistry::GetFromType(const nsACString& aMIMEType) { nsCOMPtr vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID); if (!vfs) return nsnull; - + printf("nsGNOMERegistry::GetFromType '%s'\n", PromiseFlatCString(aMIMEType).get()); nsCOMPtr handlerApp; if (NS_FAILED(vfs->GetAppForMimeType(aMIMEType, getter_AddRefs(handlerApp))) || !handlerApp) return nsnull; - + printf("nsGNOMERegistry::GetFromType 2\n"); nsRefPtr mimeInfo = new nsMIMEInfoUnix(aMIMEType); NS_ENSURE_TRUE(mimeInfo, nsnull); - + printf("nsGNOMERegistry::GetFromType 3\n"); nsCAutoString description; vfs->GetDescriptionForMimeType(aMIMEType, description); mimeInfo->SetDescription(NS_ConvertUTF8toUTF16(description)); + printf("nsGNOMERegistry::GetFromType desc '%s'\n", PromiseFlatCString(description).get()); nsCAutoString name; handlerApp->GetName(name); +#if defined(MOZ_PLATFORM_HILDON) + nsCAutoString realName (dgettext("maemo-af-desktop", PromiseFlatCString(name).get())); + mimeInfo->SetDefaultDescription(NS_ConvertUTF8toUTF16(realName)); + printf("nsGNOMERegistry::GetFromType name '%s'\n", PromiseFlatCString(realName).get()); +#else mimeInfo->SetDefaultDescription(NS_ConvertUTF8toUTF16(name)); +#endif mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault); - + printf("nsGNOMERegistry::GetFromType 4\n"); nsMIMEInfoBase* retval; NS_ADDREF((retval = mimeInfo)); return retval; } diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp --- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp +++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp @@ -35,32 +35,39 @@ * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #ifdef MOZ_PLATFORM_HILDON #include #include +#include +#include +#include +#include +#include +#include #endif - #include "nsMIMEInfoUnix.h" #include "nsGNOMERegistry.h" #include "nsIGnomeVFSService.h" #ifdef MOZ_ENABLE_DBUS #include "nsDBusHandlerApp.h" #endif nsresult nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI) -{ +{ + printf("nsMIMEInfoUnix::LoadUriInternal\n"); nsresult rv = nsGNOMERegistry::LoadURL(aURI); #ifdef MOZ_PLATFORM_HILDON + printf("nsMIMEInfoUnix::LoadUriInternal hildon | '%s'\n", mType.get()); if (NS_FAILED(rv)){ HildonURIAction *action = hildon_uri_get_default_action(mType.get(), nsnull); if (action) { nsCAutoString spec; aURI->GetAsciiSpec(spec); if (hildon_uri_open(spec.get(), action, nsnull)) rv = NS_OK; hildon_uri_action_unref(action); @@ -68,116 +75,191 @@ nsMIMEInfoUnix::LoadUriInternal(nsIURI * } #endif return rv; } NS_IMETHODIMP nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval) { + printf("\t-->nsMIMEInfoUnix::GetHasDefaultHandler\n"); *_retval = PR_FALSE; nsCOMPtr vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID); if (vfs) { nsCOMPtr app; - if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app) + if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app) { *_retval = PR_TRUE; +#ifdef DEBUG + printf("\n\t *****************-->nsMIMEInfoUnix::GetHasDefaultHandler \\o/\n\n"); + nsCAutoString appName; + app->GetName(appName); + printf("\tGnomeVFS AppName: '%s'\n", PromiseFlatCString(appName).get()); +#ifdef MOZ_PLATFORM_HILDON + printf("\tGnomeVFS Handler: '%s'\n", dgettext("maemo-af-desktop", PromiseFlatCString(appName).get())); +#endif + nsCAutoString mimeDescription; + vfs->GetDescriptionForMimeType(mType, mimeDescription); + printf("\tGnomeVFS '%s' description: '%s'\n", mType.get(), PromiseFlatCString(mimeDescription).get()); +#endif + } } if (*_retval) return NS_OK; #ifdef MOZ_PLATFORM_HILDON + printf("\t-->nsMIMEInfoUnix::GetHasDefaultHandler hildon | '%s'\n", mType.get()); HildonURIAction *action = hildon_uri_get_default_action(mType.get(), nsnull); if (action) { + printf("nsMIMEInfoUnix::GetHasDefaultHandler hildon TRUE\n"); *_retval = PR_TRUE; hildon_uri_action_unref(action); return NS_OK; } #endif - + + printf("\t-->nsMIMEInfoUnix::GetHasDefaultHandler DEFAULT\n"); // If we didn't find a VFS handler, fallback. return nsMIMEInfoImpl::GetHasDefaultHandler(_retval); } nsresult nsMIMEInfoUnix::LaunchDefaultWithFile(nsIFile *aFile) { + printf("nsMIMEInfoUnix::LaunchDefaultWithFile\n"); nsCAutoString nativePath; aFile->GetNativePath(nativePath); - nsCOMPtr vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID); + printf("nsMIMEInfoUnix::LaunchDefaultWithFile %s'\n", PromiseFlatCString(nativePath).get()); - if (vfs) { - nsCOMPtr app; - if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app) - return app->Launch(nativePath); +#if defined (MOZ_PLATFORM_HILDON) + DBusError err; + dbus_error_init(&err); + + DBusConnection *connection; + connection = dbus_bus_get(DBUS_BUS_SESSION, &err); + if (dbus_error_is_set(&err)) { + dbus_error_free(&err); + return NS_ERROR_FAILURE; } - if (!mDefaultApplication) + if (nsnull == connection) + return NS_ERROR_FAILURE; + + dbus_connection_set_exit_on_disconnect(connection,false); + + PRBool openresult = hildon_mime_open_file_with_mime_type(connection, + PromiseFlatCString(nativePath).get(), + mType.get()); +#else + + nsCOMPtr vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID); + if (vfs) { + printf("nsMIMEInfoUnix::LaunchDefaultWithFile 2\n"); + nsCOMPtr app; + if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app) { + printf("nsMIMEInfoUnix::LaunchDefaultWithFile 3\n"); + return app->Launch(nativePath); + } + } +#endif + if (!mDefaultApplication) { + printf("nsMIMEInfoUnix::LaunchDefaultWithFile 4\n"); return NS_ERROR_FILE_NOT_FOUND; - + } + printf("nsMIMEInfoUnix::LaunchDefaultWithFile 5\n"); return LaunchWithIProcess(mDefaultApplication, nativePath); } #ifdef MOZ_PLATFORM_HILDON /* static */ PRBool nsMIMEInfoUnix::HandlerExists(const char *aProtocolScheme) { + printf("nsMIMEInfoUnix::HandlerExistshildon\n"); PRBool isEnabled = PR_FALSE; HildonURIAction *action = hildon_uri_get_default_action(aProtocolScheme, nsnull); if (action) { isEnabled = PR_TRUE; hildon_uri_action_unref(action); } return isEnabled; } NS_IMETHODIMP nsMIMEInfoUnix::GetPossibleApplicationHandlers(nsIMutableArray ** aPossibleAppHandlers) { + printf("\tnsMIMEInfoUnix::GetPossibleApplicationHandlers hildon\n"); if (!mPossibleApplications) { mPossibleApplications = do_CreateInstance(NS_ARRAY_CONTRACTID); if (!mPossibleApplications) return NS_ERROR_OUT_OF_MEMORY; - - GSList *actions = hildon_uri_get_actions(mType.get(), nsnull); - GSList *actionsPtr = actions; - while (actionsPtr) { - HildonURIAction *action = (HildonURIAction*)actionsPtr->data; - actionsPtr = actionsPtr->next; - nsDBusHandlerApp* app = new nsDBusHandlerApp(); - if (!app){ - hildon_uri_free_actions(actions); - return NS_ERROR_OUT_OF_MEMORY; + + if(GSList *actions = hildon_uri_get_actions(mType.get(), nsnull)) { + GSList *actionsPtr = actions; + while (actionsPtr) { + HildonURIAction *action = (HildonURIAction*)actionsPtr->data; + actionsPtr = actionsPtr->next; + nsDBusHandlerApp *app = new nsDBusHandlerApp(); + if (!app) { + hildon_uri_free_actions(actions); + return NS_ERROR_OUT_OF_MEMORY; + } + nsDependentCString method(hildon_uri_action_get_method(action)); + printf("\tnsMIMEInfoUnix::GetPossibleApplicationHandlers hildon method '%s'\n", PromiseFlatCString(method).get()); + nsDependentCString key(hildon_uri_action_get_service(action)); + printf("\tnsMIMEInfoUnix::GetPossibleApplicationHandlers hildon key '%s'\n", PromiseFlatCString(key).get()); + nsCString service, objpath, interface; + app->SetMethod(method); + app->SetName(NS_ConvertUTF8toUTF16(key)); + + if (key.FindChar('.', 0) > 0) { + service.Assign(key); + objpath.Assign(NS_LITERAL_CSTRING("/")+ key); + objpath.ReplaceChar('.', '/'); + interface.Assign(key); + printf("\tnsMIMEInfoUnix::GetPossibleApplicationHandlers hildon 4\n"); + } else { + service.Assign(NS_LITERAL_CSTRING("com.nokia.")+ key); + objpath.Assign(NS_LITERAL_CSTRING("/com/nokia/")+ key); + interface.Assign(NS_LITERAL_CSTRING("com.nokia.")+ key); + printf("\tnsMIMEInfoUnix::GetPossibleApplicationHandlers hildon 5\n"); + } + + app->SetService(service); + app->SetObjectPath(objpath); + app->SetDBusInterface(interface); + + mPossibleApplications->AppendElement(app, PR_FALSE); } - nsDependentCString method(hildon_uri_action_get_method(action)); - nsDependentCString key(hildon_uri_action_get_service(action)); - nsCString service, objpath, interface; - app->SetMethod(method); - app->SetName(NS_ConvertUTF8toUTF16(key)); - - if (key.FindChar('.', 0) > 0) { - service.Assign(key); - objpath.Assign(NS_LITERAL_CSTRING("/")+ key); - objpath.ReplaceChar('.', '/'); - interface.Assign(key); - } else { - service.Assign(NS_LITERAL_CSTRING("com.nokia.")+ key); - objpath.Assign(NS_LITERAL_CSTRING("/com/nokia/")+ key); - interface.Assign(NS_LITERAL_CSTRING("com.nokia.")+ key); - } - - app->SetService(service); - app->SetObjectPath(objpath); - app->SetDBusInterface(interface); - - mPossibleApplications->AppendElement(app, PR_FALSE); + hildon_uri_free_actions(actions); + } else { + if (!gnome_vfs_initialized()) + gnome_vfs_init(); + + GList *actions, *actionsPtr; + if (actions = actionsPtr = gnome_vfs_mime_get_all_applications(mType.get())) + while (actionsPtr) { + GnomeVFSMimeApplication *mimeHandler = (GnomeVFSMimeApplication*) actionsPtr->data; + printf("\tGnomeVFS Handler: '%s'\n", g_strdup(dgettext("maemo-af-desktop", mimeHandler->name))); + + nsDBusHandlerApp *app = new nsDBusHandlerApp(); + if (!app) { + gnome_vfs_mime_application_free(mimeHandler); + return NS_ERROR_OUT_OF_MEMORY; + } + nsDependentCString method("mime_open"); + nsDependentCString key(dgettext("maemo-af-desktop", mimeHandler->name)); + app->SetMethod(method); + app->SetName(NS_ConvertUTF8toUTF16(key)); + + mPossibleApplications->AppendElement(app, PR_FALSE); + actionsPtr = actionsPtr->next; + } } - hildon_uri_free_actions(actions); + printf("\tnsMIMEInfoUnix::GetPossibleApplicationHandlers hildon 7\n"); + *aPossibleAppHandlers = mPossibleApplications; + NS_ADDREF(*aPossibleAppHandlers); } - - *aPossibleAppHandlers = mPossibleApplications; - NS_ADDREF(*aPossibleAppHandlers); return NS_OK; } #endif diff --git a/uriloader/exthandler/unix/nsOSHelperAppService.cpp b/uriloader/exthandler/unix/nsOSHelperAppService.cpp --- a/uriloader/exthandler/unix/nsOSHelperAppService.cpp +++ b/uriloader/exthandler/unix/nsOSHelperAppService.cpp @@ -369,16 +369,23 @@ nsOSHelperAppService::GetTypeAndDescript nsAString& aMajorType, nsAString& aMinorType, nsAString& aDescription) { LOG(("-- GetTypeAndDescriptionFromMimetypesFile\n")); LOG(("Getting type and description from types file '%s'\n", NS_LossyConvertUTF16toASCII(aFilename).get())); LOG(("Using extension '%s'\n", NS_LossyConvertUTF16toASCII(aFileExtension).get())); + + printf("-- GetTypeAndDescriptionFromMimetypesFile\n"); + printf("Getting type and description from types file '%s'\n", + NS_LossyConvertUTF16toASCII(aFilename).get()); + printf("Using extension '%s'\n", + NS_LossyConvertUTF16toASCII(aFileExtension).get()); + nsresult rv = NS_OK; nsCOMPtr mimeFile; nsCOMPtr mimeTypes; PRBool netscapeFormat; nsAutoString buf; nsCAutoString cBuf; PRBool more = PR_FALSE; rv = CreateInputStream(aFilename, getter_AddRefs(mimeFile), getter_AddRefs(mimeTypes), @@ -1204,16 +1211,17 @@ nsOSHelperAppService::GetHandlerAndDescr /* Looks up the handler for a specific scheme from prefs and returns the * file representing it in aApp. Note: This function doesn't guarantee the * existance of *aApp. */ nsresult nsOSHelperAppService::GetHandlerAppFromPrefs(const char* aScheme, /*out*/ nsIFile** aApp) { + printf("\t->>nsOSHelperAppService::GetHandlerAppFromPrefs\n"); nsresult rv; nsCOMPtr srv(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); if (NS_FAILED(rv)) // we have no pref service... that's bad return rv; nsCOMPtr branch; srv->GetBranch("network.protocol-handler.app.", getter_AddRefs(branch)); if (!branch) // No protocol handlers set up -> can't load url @@ -1251,16 +1259,17 @@ nsOSHelperAppService::GetHandlerAppFromP } // Thirdly, search the path return GetFileTokenForPath(utf16AppPath.get(), aApp); } nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists) { + printf("\t->>nsOSHelperAppService::OSProtocolHandlerExists\n"); LOG(("-- nsOSHelperAppService::OSProtocolHandlerExists for '%s'\n", aProtocolScheme)); *aHandlerExists = PR_FALSE; nsCOMPtr app; nsresult rv = GetHandlerAppFromPrefs(aProtocolScheme, getter_AddRefs(app)); if (NS_SUCCEEDED(rv)) { PRBool isExecutable = PR_FALSE, exists = PR_FALSE; @@ -1270,26 +1279,27 @@ nsresult nsOSHelperAppService::OSProtoco LOG((" handler exists: %s\n", *aHandlerExists ? "yes" : "no")); } #ifdef MOZ_WIDGET_GTK2 // Check the GConf registry for a protocol handler if (!*aHandlerExists) *aHandlerExists = nsGNOMERegistry::HandlerExists(aProtocolScheme); #ifdef MOZ_PLATFORM_HILDON - if (!*aHandlerExists) - *aHandlerExists = nsMIMEInfoUnix::HandlerExists(aProtocolScheme); + if (!*aHandlerExists) { printf("\t->>nsOSHelperAppService::OSProtocolHandlerExists hildon\n"); + *aHandlerExists = nsMIMEInfoUnix::HandlerExists(aProtocolScheme); } #endif #endif return NS_OK; } NS_IMETHODIMP nsOSHelperAppService::GetApplicationDescription(const nsACString& aScheme, nsAString& _retval) { + printf("\t->>nsOSHelperAppService::GetApplicationDescription\n"); nsCOMPtr appFile; nsresult rv = GetHandlerAppFromPrefs(PromiseFlatCString(aScheme).get(), getter_AddRefs(appFile)); if (NS_SUCCEEDED(rv)) return appFile->GetLeafName(_retval); #ifdef MOZ_WIDGET_GTK2 nsGNOMERegistry::GetAppDescForScheme(aScheme, _retval); @@ -1368,33 +1378,36 @@ nsresult nsOSHelperAppService::GetFileTo already_AddRefed nsOSHelperAppService::GetFromExtension(const nsCString& aFileExt) { // if the extension is empty, return immediately if (aFileExt.IsEmpty()) return nsnull; LOG(("Here we do an extension lookup for '%s'\n", aFileExt.get())); + printf("nsOSHelperAppService::GetFromExtension -- Here we do an extension lookup for '%s'\n", aFileExt.get()); nsAutoString majorType, minorType, mime_types_description, mailcap_description, handler, mozillaFlags; nsresult rv = LookUpTypeAndDescription(NS_ConvertUTF8toUTF16(aFileExt), majorType, minorType, mime_types_description, PR_TRUE); if (NS_FAILED(rv) || majorType.IsEmpty()) { #ifdef MOZ_WIDGET_GTK2 LOG(("Looking in GNOME registry\n")); + printf("nsOSHelperAppService::GetFromExtension -- Looking in GNOME registry\n"); nsMIMEInfoBase *gnomeInfo = nsGNOMERegistry::GetFromExtension(aFileExt).get(); if (gnomeInfo) { + printf("nsOSHelperAppService::GetFromExtension -- Got MIMEInfo from GNOME registry\n"); LOG(("Got MIMEInfo from GNOME registry\n")); return gnomeInfo; } #endif rv = LookUpTypeAndDescription(NS_ConvertUTF8toUTF16(aFileExt), majorType, minorType, @@ -1613,61 +1626,77 @@ nsOSHelperAppService::GetFromType(const return mimeInfo; } already_AddRefed nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aType, const nsACString& aFileExt, PRBool *aFound) { + printf("\t->>nsOSHelperAppService::GetMIMEInfoFromOS\n"); *aFound = PR_TRUE; nsMIMEInfoBase* retval = GetFromType(PromiseFlatCString(aType)).get(); + PRBool hasDefault = PR_FALSE; if (retval) retval->GetHasDefaultHandler(&hasDefault); + + if (hasDefault) + printf("\t->>nsOSHelperAppService::GetMIMEInfoFromOS TRUE \n"); + else + printf("\t->>nsOSHelperAppService::GetMIMEInfoFromOS FALSE \n"); + + if (retval) + printf("\t->>nsOSHelperAppService::GetMIMEInfoFromOS TRUE 2 \n"); + else + printf("\t->>nsOSHelperAppService::GetMIMEInfoFromOS FALSE 2 \n"); + if (!retval || !hasDefault) { + printf("\t->>nsOSHelperAppService::GetMIMEInfoFromOS !retval || !hasDefault\n"); nsRefPtr miByExt = GetFromExtension(PromiseFlatCString(aFileExt)); // If we had no extension match, but a type match, use that if (!miByExt && retval) return retval; // If we had an extension match but no type match, set the mimetype and use // it if (!retval && miByExt) { if (!aType.IsEmpty()) miByExt->SetMIMEType(aType); miByExt.swap(retval); - + printf("\t->>nsOSHelperAppService::GetMIMEInfoFromOS ret 2\n"); return retval; } // If we got nothing, make a new mimeinfo if (!retval) { *aFound = PR_FALSE; retval = new nsMIMEInfoUnix(aType); if (retval) { NS_ADDREF(retval); if (!aFileExt.IsEmpty()) retval->AppendExtension(aFileExt); } - + printf("\t->>nsOSHelperAppService::GetMIMEInfoFromOS ret3\n"); return retval; } // Copy the attributes of retval onto miByExt, to return it retval->CopyBasicDataTo(miByExt); miByExt.swap(retval); } + printf("\t->>nsOSHelperAppService::GetMIMEInfoFromOS ret4\n"); return retval; } NS_IMETHODIMP nsOSHelperAppService::GetProtocolHandlerInfoFromOS(const nsACString &aScheme, PRBool *found, nsIHandlerInfo **_retval) { + printf("nsOSHelperAppService::GetProtocolHandlerInfoFromOS\n"); NS_ASSERTION(!aScheme.IsEmpty(), "No scheme was specified!"); // We must check that a registered handler exists so that gnome_url_show // doesn't fallback to gnomevfs. // See nsGNOMERegistry::LoadURL and bug 389632. nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(), found); if (NS_FAILED(rv))