Bug 437950 - Support for mailto: r=cbiesinger
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -614,16 +614,21 @@ MOZ_XULRUNNER = @MOZ_XULRUNNER@
MOZ_XUL_APP = @MOZ_XUL_APP@
WINCE = @WINCE@
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@
XCODEBUILD_VERSION= @XCODEBUILD_VERSION@
HAS_XCODE_2_1 = @HAS_XCODE_2_1@
UNIVERSAL_BINARY= @UNIVERSAL_BINARY@
HAVE_DTRACE= @HAVE_DTRACE@
--- a/configure.in
+++ b/configure.in
@@ -6077,27 +6077,31 @@ dnl ====================================
dnl = Hildon and OSSO checks
dnl ========================================================
PKG_CHECK_MODULES(LIBHILDONMIME,libhildonmime,
MOZ_PLATFORM_HILDON=1,
MOZ_PLATFORM_HILDON=)
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,
NS_OSSO=)
if test $NS_OSSO; then
if test -z "$MOZ_ENABLE_DBUS"; then
AC_MSG_ERROR([DBus is required when building for OSSO])
fi
AC_DEFINE(NS_OSSO)
fi
+AC_SUBST(LIBOSSO_CFLAGS)
+AC_SUBST(LIBOSSO_LIBS)
dnl ========================================================
dnl =
dnl = Feature options that require extra sources to be pulled
dnl =
dnl ========================================================
dnl MOZ_ARG_HEADER(Features that require extra sources)
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -210,16 +210,24 @@ ifdef MOZ_OGG
EXTRA_DSO_LDOPTS += \
-framework CoreAudio \
-framework AudioToolbox \
-framework AudioUnit \
$(NULL)
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
ifeq (gtk2,$(MOZ_WIDGET_TOOLKIT))
EXTRA_DSO_LDOPTS += $(XLDFLAGS) $(XLIBS) $(MOZ_XFT_LIBS) $(MOZ_GTK2_LIBS) $(XT_LIBS) -lgthread-2.0
EXTRA_DSO_LDOPTS += $(FT2_LIBS)
endif
--- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
+++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
@@ -32,40 +32,72 @@
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* 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 <glib.h>
+#include <hildon-uri.h>
+#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
nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
{
*_retval = PR_FALSE;
nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
if (vfs) {
nsCOMPtr<nsIGnomeVFSMimeApp> app;
if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app)
*_retval = PR_TRUE;
}
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);
}
nsresult
nsMIMEInfoUnix::LaunchDefaultWithFile(nsIFile *aFile)
{
nsCAutoString nativePath;
@@ -79,8 +111,61 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(ns
return app->Launch(nativePath);
}
if (!mDefaultApplication)
return NS_ERROR_FILE_NOT_FOUND;
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
--- a/uriloader/exthandler/unix/nsMIMEInfoUnix.h
+++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.h
@@ -51,11 +51,14 @@ public:
nsMIMEInfoImpl(aType, aClass) {}
protected:
NS_IMETHOD GetHasDefaultHandler(PRBool *_retval);
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_