From f7f1eae0c20dbb9ab2cf7dcb2cf04f09be0fe3d4 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Wed, 10 Sep 2008 12:10:23 -0400 Subject: [PATCH] Bug 437950 - Support for mailto: r=cbiesinger --- config/autoconf.mk.in | 5 ++ configure.in | 4 + toolkit/library/Makefile.in | 8 ++ uriloader/exthandler/unix/nsMIMEInfoUnix.cpp | 89 +++++++++++++++++++- uriloader/exthandler/unix/nsMIMEInfoUnix.h | 3 + 5 files changed, 107 insertions(+), 2 deletions(-) diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in index 1f9f447ce6b..151bcf53ad8 100644 --- a/config/autoconf.mk.in +++ b/config/autoconf.mk.in @@ -619,6 +619,11 @@ MOZ_DISTRIBUTION_ID = @MOZ_DISTRIBUTION_ID@ NS_OSSO = @NS_OSSO@ MOZ_PLATFORM_HILDON = @MOZ_PLATFORM_HILDON@ +LIBHILDONMIME_CFLAGS = @LIBHILDONMIME_CFLAGS@ +LIBHILDONMIME_LIBS = @LIBHILDONMIME_LIBS@ +LIBOSSO_CFLAGS = @LIBOSSO_CFLAGS@ +LIBOSSO_LIBS = @LIBOSSO_LIBS@ + MACOS_SDK_DIR = @MACOS_SDK_DIR@ NEXT_ROOT = @NEXT_ROOT@ GCC_VERSION = @GCC_VERSION@ diff --git a/configure.in b/configure.in index 66ea52ca627..43deddc7068 100644 --- a/configure.in +++ b/configure.in @@ -6082,6 +6082,8 @@ PKG_CHECK_MODULES(LIBHILDONMIME,libhildonmime, if test $MOZ_PLATFORM_HILDON; then AC_DEFINE(MOZ_PLATFORM_HILDON) fi +AC_SUBST(LIBHILDONMIME_CFLAGS) +AC_SUBST(LIBHILDONMIME_LIBS) PKG_CHECK_MODULES(LIBOSSO,libosso, NS_OSSO=1, @@ -6093,6 +6095,8 @@ if test $NS_OSSO; then fi AC_DEFINE(NS_OSSO) fi +AC_SUBST(LIBOSSO_CFLAGS) +AC_SUBST(LIBOSSO_LIBS) dnl ======================================================== dnl = diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in index c8bb9cfc2b9..21233b53b36 100644 --- a/toolkit/library/Makefile.in +++ b/toolkit/library/Makefile.in @@ -215,6 +215,14 @@ EXTRA_DSO_LDOPTS += \ endif endif +ifdef MOZ_PLATFORM_HILDON +EXTRA_DSO_LDOPTS += $(LIBHILDONMIME_LIBS) +endif + +ifdef NS_OSSO +EXTRA_DSO_LDOPTS += $(LIBOSSO_LIBS) +endif + ifdef MOZ_ENABLE_DBUS EXTRA_DSO_LDOPTS += $(MOZ_DBUS_GLIB_LIBS) endif diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp index 2b1430666b0..0b55ce9e612 100644 --- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp +++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp @@ -37,14 +37,37 @@ * * ***** END LICENSE BLOCK ***** */ +#ifdef MOZ_PLATFORM_HILDON +#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) -{ - return nsGNOMERegistry::LoadURL(aURI); +{ + nsresult rv = nsGNOMERegistry::LoadURL(aURI); +#ifdef MOZ_PLATFORM_HILDON + 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); + } + } +#endif + return rv; } NS_IMETHODIMP @@ -61,6 +84,15 @@ nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval) if (*_retval) return NS_OK; +#ifdef MOZ_PLATFORM_HILDON + HildonURIAction *action = hildon_uri_get_default_action(mType.get(), nsnull); + if (action) { + *_retval = PR_TRUE; + hildon_uri_action_unref(action); + return NS_OK; + } +#endif + // If we didn't find a VFS handler, fallback. return nsMIMEInfoImpl::GetHasDefaultHandler(_retval); } @@ -84,3 +116,56 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(nsIFile *aFile) return LaunchWithIProcess(mDefaultApplication, nativePath); } + +#ifdef MOZ_PLATFORM_HILDON + +NS_IMETHODIMP +nsMIMEInfoUnix::GetPossibleApplicationHandlers(nsIMutableArray ** aPossibleAppHandlers) +{ + 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; + } + 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); + } + + *aPossibleAppHandlers = mPossibleApplications; + NS_ADDREF(*aPossibleAppHandlers); + return NS_OK; +} +#endif diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.h b/uriloader/exthandler/unix/nsMIMEInfoUnix.h index 09688aa7c95..24fabf3e1a3 100644 --- a/uriloader/exthandler/unix/nsMIMEInfoUnix.h +++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.h @@ -56,6 +56,9 @@ protected: virtual NS_HIDDEN_(nsresult) LoadUriInternal(nsIURI *aURI); virtual NS_HIDDEN_(nsresult) LaunchDefaultWithFile(nsIFile *aFile); +#ifdef MOZ_PLATFORM_HILDON + NS_IMETHOD GetPossibleApplicationHandlers(nsIMutableArray * *aPossibleAppHandlers); +#endif }; #endif // nsMIMEInfoUnix_h_