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,23 @@ 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_PLATFORM_HILDON +ifdef MOZ_ENABLE_GNOMEVFS +LOCAL_INCLUDES += $(MOZ_GNOMEVFS_CFLAGS) +EXTRA_DSO_LDOPTS += $(MOZ_GNOMEVFS_LIBS) +endif +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/unix/nsGNOMERegistry.cpp b/uriloader/exthandler/unix/nsGNOMERegistry.cpp --- a/uriloader/exthandler/unix/nsGNOMERegistry.cpp +++ b/uriloader/exthandler/unix/nsGNOMERegistry.cpp @@ -45,16 +45,20 @@ #include "nsMIMEInfoUnix.h" #include "nsAutoPtr.h" #include "nsIGConfService.h" #include "nsIGnomeVFSService.h" #ifdef MOZ_WIDGET_GTK2 #include #include + +#ifdef MOZ_PLATFORM_HILDON +#include +#endif #endif /* static */ PRBool nsGNOMERegistry::HandlerExists(const char *aProtocolScheme) { nsCOMPtr gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID); if (!gconf) return PR_FALSE; @@ -113,16 +117,17 @@ 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; // Get the MIME type from the extension, then call GetFromType to // fill in the MIMEInfo. nsCAutoString mimeType; if (NS_FAILED(vfs->GetMimeTypeFromExtension(aFileExt, mimeType)) || @@ -148,15 +153,21 @@ nsGNOMERegistry::GetFromType(const nsACS NS_ENSURE_TRUE(mimeInfo, nsnull); nsCAutoString description; vfs->GetDescriptionForMimeType(aMIMEType, description); mimeInfo->SetDescription(NS_ConvertUTF8toUTF16(description)); nsCAutoString name; handlerApp->GetName(name); +#if defined(MOZ_PLATFORM_HILDON) + nsCAutoString realName (dgettext("maemo-af-desktop", PromiseFlatCString(name).get())); + mimeInfo->SetDefaultDescription(NS_ConvertUTF8toUTF16(realName)); + +#else mimeInfo->SetDefaultDescription(NS_ConvertUTF8toUTF16(name)); +#endif mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault); 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,38 @@ * 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 #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); @@ -72,61 +78,107 @@ nsMIMEInfoUnix::LoadUriInternal(nsIURI * NS_IMETHODIMP nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval) { *_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 + nsCAutoString appName; + app->GetName(appName); + printf("\n\t *****************GnomeVFS AppName: '%s'\n", PromiseFlatCString(appName).get()); +#ifdef MOZ_PLATFORM_HILDON + printf("\n\t *****************GnomeVFS Handler: '%s'\n", dgettext("maemo-af-desktop", PromiseFlatCString(appName).get())); +#endif + nsCAutoString mimeDescription; + vfs->GetDescriptionForMimeType(mType, mimeDescription); + printf("\n\t *****************GnomeVFS '%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); + + int openresult = hildon_mime_open_file_with_mime_type(connection, + PromiseFlatCString(nativePath).get(), + mType.get()); + if (openresult == 1) + return NS_OK; +#endif + + 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); + } + } + + 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; } @@ -176,8 +228,9 @@ nsMIMEInfoUnix::GetPossibleApplicationHa hildon_uri_free_actions(actions); } *aPossibleAppHandlers = mPossibleApplications; NS_ADDREF(*aPossibleAppHandlers); return NS_OK; } #endif +