Back out of bug 441636

This commit is contained in:
"Brad Lassey" 2008-07-27 09:26:54 -04:00
parent a6b45b982b
commit 8431aba025
10 changed files with 178 additions and 302 deletions

View File

@ -627,6 +627,11 @@ MOZ_DISTRIBUTION_ID = @MOZ_DISTRIBUTION_ID@
NS_HILDON = @NS_HILDON@
NS_OSSO = @NS_OSSO@
NS_HILDONMIME_CFLAGS = @NS_HILDONMIME_CFLAGS@
NS_HILDONMIME_LIBS = @NS_HILDONMIME_LIBS@
NS_OSSO_CFLAGS = @NS_OSSO_CFLAGS@
NS_OSSO_LIBS = @NS_OSSO_LIBS@
MACOS_SDK_DIR = @MACOS_SDK_DIR@
NEXT_ROOT = @NEXT_ROOT@

View File

@ -1582,14 +1582,16 @@ SEAMONKEY_VERSION=`cat $topsrcdir/suite/config/version.txt`
AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
PKG_CHECK_MODULES(LIBHILONMIME,libhildonmime,
PKG_CHECK_MODULES(NS_HILDONMIME,libhildonmime,
NS_HILDON=1,
NS_HILDON=)
if test $NS_HILDON; then
AC_DEFINE(NS_HILDON)
fi
AC_SUBST(NS_HILDONMIME_CFLAGS)
AC_SUBST(NS_HILDONMIME_LIBS)
PKG_CHECK_MODULES(LIBOSSO,libosso,
PKG_CHECK_MODULES(NS_OSSO,libosso,
NS_OSSO=1,
NS_OSSO=)
@ -1597,6 +1599,9 @@ if test $NS_OSSO; then
AC_DEFINE(NS_OSSO)
fi
AC_SUBST(NS_OSSO_CFLAGS)
AC_SUBST(NS_OSSO_LIBS)
dnl ========================================================
dnl System overrides of the defaults for target
dnl ========================================================

View File

@ -207,6 +207,14 @@ EXTRA_DSO_LDOPTS += \
$(NULL)
endif
ifdef NS_HILDON
EXTRA_DSO_LDOPTS += $(NS_HILDONMIME_LIBS)
endif
ifdef NS_OSSO
EXTRA_DSO_LDOPTS += $(NS_OSSO_LIBS)
endif
ifdef MOZ_ENABLE_DBUS
EXTRA_DSO_LDOPTS += $(MOZ_DBUS_GLIB_LIBS)
endif

View File

@ -1,230 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:expandtab:shiftwidth=2:tabstop=2:cin:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is
* the Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brad Lassey <blassey@mozila.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* 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 ***** */
#include <dbus/dbus.h>
#include "nsDBusHandlerApp.h"
#include "nsIURI.h"
#include "nsIGenericFactory.h"
#include "nsIClassInfoImpl.h"
#include "nsCOMPtr.h"
#ifdef NS_OSSO
#include <libosso.h>
#define APP_LAUNCH_BANNER_SERVICE "com.nokia.hildon-desktop"
#define APP_LAUNCH_BANNER_METHOD_INTERFACE "com.nokia.hildon.hdwm.startupnotification"
#define APP_LAUNCH_BANNER_METHOD_PATH "/com/nokia/hildon/hdwm"
#define APP_LAUNCH_BANNER_METHOD "starting"
#endif
// XXX why does nsMIMEInfoImpl have a threadsafe nsISupports? do we need one
// here too?
NS_IMPL_ISUPPORTS2_CI(nsDBusHandlerApp, nsIDBusHandlerApp, nsIHandlerApp)
////////////////////////////////////////////////////////////////////////////////
//// nsIHandlerApp
NS_IMETHODIMP nsDBusHandlerApp::GetName(nsAString& aName)
{
aName.Assign(mName);
return NS_OK;
}
NS_IMETHODIMP nsDBusHandlerApp::SetName(const nsAString & aName)
{
mName.Assign(aName);
return NS_OK;
}
NS_IMETHODIMP
nsDBusHandlerApp::Equals(nsIHandlerApp *aHandlerApp, PRBool *_retval)
{
NS_ENSURE_ARG_POINTER(aHandlerApp);
// If the handler app isn't a dbus handler app, then it's not the same app.
nsCOMPtr<nsIDBusHandlerApp> dbusHandlerApp = do_QueryInterface(aHandlerApp);
if (!dbusHandlerApp) {
*_retval = PR_FALSE;
return NS_OK;
}
nsCAutoString service;
nsCAutoString method;
nsresult rv = dbusHandlerApp->GetService(service);
if (NS_FAILED(rv)) {
*_retval = PR_FALSE;
return NS_OK;
}
rv = dbusHandlerApp->GetMethod(method);
if (NS_FAILED(rv)) {
*_retval = PR_FALSE;
return NS_OK;
}
*_retval = service.Equals(mService) && method.Equals(mMethod);
return NS_OK;
}
NS_IMETHODIMP
nsDBusHandlerApp::LaunchWithURI(nsIURI *aURI,
nsIInterfaceRequestor *aWindowContext)
{
nsCAutoString spec;
nsresult rv = aURI->GetAsciiSpec(spec);
NS_ENSURE_SUCCESS(rv,rv);
const char* uri = spec.get();
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 (nsnull == connection) {
return NS_ERROR_FAILURE;
}
dbus_connection_set_exit_on_disconnect(connection,false);
DBusMessage* msg;
msg = dbus_message_new_method_call(mService.get(),
mObjpath.get(),
mInterface.get(),
mMethod.get());
if (!msg) {
return NS_ERROR_FAILURE;
}
dbus_message_set_no_reply(msg, PR_TRUE);
DBusMessageIter iter;
dbus_message_iter_init_append(msg, &iter);
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &uri);
if (dbus_connection_send(connection, msg, NULL)) {
dbus_connection_flush(connection);
dbus_message_unref(msg);
#ifdef NS_OSSO
msg = dbus_message_new_method_call (APP_LAUNCH_BANNER_SERVICE,
APP_LAUNCH_BANNER_METHOD_PATH,
APP_LAUNCH_BANNER_METHOD_INTERFACE,
APP_LAUNCH_BANNER_METHOD);
if (msg) {
const char* service = mService.get();
if (dbus_message_append_args(msg,
DBUS_TYPE_STRING,
&service,
DBUS_TYPE_INVALID)) {
if (dbus_connection_send(connection, msg, NULL)) {
dbus_connection_flush(connection);
}
dbus_message_unref(msg);
}
}
#endif
} else {
dbus_message_unref(msg);
return NS_ERROR_FAILURE;
}
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
//// nsIDBusHandlerApp
/* attribute AUTF8String service; */
NS_IMETHODIMP nsDBusHandlerApp::GetService(nsACString & aService)
{
aService.Assign(mService);
return NS_OK;
}
NS_IMETHODIMP nsDBusHandlerApp::SetService(const nsACString & aService)
{
mService.Assign(aService);
return NS_OK;
}
/* attribute AUTF8String method; */
NS_IMETHODIMP nsDBusHandlerApp::GetMethod(nsACString & aMethod)
{
aMethod.Assign(mMethod);
return NS_OK;
}
NS_IMETHODIMP nsDBusHandlerApp::SetMethod(const nsACString & aMethod)
{
mMethod.Assign(aMethod);
return NS_OK;
}
/* attribute AUTF8String interface; */
NS_IMETHODIMP nsDBusHandlerApp::GetDBusInterface(nsACString & aInterface)
{
aInterface.Assign(mInterface);
return NS_OK;
}
NS_IMETHODIMP nsDBusHandlerApp::SetDBusInterface(const nsACString & aInterface)
{
mInterface.Assign(aInterface);
return NS_OK;
}
/* attribute AUTF8String objpath; */
NS_IMETHODIMP nsDBusHandlerApp::GetObjectPath(nsACString & aObjpath)
{
aObjpath.Assign(mObjpath);
return NS_OK;
}
NS_IMETHODIMP nsDBusHandlerApp::SetObjectPath(const nsACString & aObjpath)
{
mObjpath.Assign(aObjpath);
return NS_OK;
}
NS_DECL_CLASSINFO(nsDBusHandlerApp)

View File

@ -1,65 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:expandtab:shiftwidth=2:tabstop=2:cin:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is
* the Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brad Lassey <blassey@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* 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 ***** */
#ifndef __nsDBusHandlerAppImpl_h__
#define __nsDBusHandlerAppImpl_h__
#include "nsString.h"
#include "nsIMIMEInfo.h"
class nsDBusHandlerApp : public nsIDBusHandlerApp
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIHANDLERAPP
NS_DECL_NSIDBUSHANDLERAPP
nsDBusHandlerApp() { }
virtual ~nsDBusHandlerApp() { }
protected:
nsString mName;
nsCString mService;
nsCString mMethod;
nsCString mInterface;
nsCString mObjpath;
};
#endif

View File

@ -96,6 +96,17 @@ const NC_PATH = NC_NS + "path";
// nsIWebHandlerApp::uriTemplate
const NC_URI_TEMPLATE = NC_NS + "uriTemplate";
// nsIDBusHandlerApp::service
const NC_SERVICE = NC_NS + "service";
// nsIDBusHandlerApp::method
const NC_METHOD = NC_NS + "method";
// nsIDBusHandlerApp::objectPath
const NC_OBJPATH = NC_NS + "objectPath";
// nsIDBusHandlerApp::dbusInterface
const NC_INTERFACE = NC_NS + "dBusInterface";
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@ -566,6 +577,31 @@ HandlerService.prototype = {
createInstance(Ci.nsIWebHandlerApp);
handlerApp.uriTemplate = uriTemplate;
}
else if (this._hasValue(aHandlerAppID, NC_SERVICE)) {
let service = this._getValue(aHandlerAppID, NC_SERVICE);
if (!service)
return null;
let method = this._getValue(aHandlerAppID, NC_METHOD);
if (!method)
return null;
let objpath = this._getValue(aHandlerAppID, NC_OBJPATH);
if (!objpath)
return null;
let interface = this._getValue(aHandlerAppID, NC_INTERFACE);
if (!interface)
return null;
handlerApp = Cc["@mozilla.org/uriloader/dbus-handler-app;1"].
createInstance(Ci.nsIDBusHandlerApp);
handlerApp.service = service;
handlerApp.method = method;
handlerApp.objectPath = objpath;
handlerApp.dBusInterface = interface;
}
else
return null;
@ -771,15 +807,28 @@ HandlerService.prototype = {
if (aHandlerApp instanceof Ci.nsILocalHandlerApp) {
this._setLiteral(aHandlerAppID, NC_PATH, aHandlerApp.executable.path);
this._removeTarget(aHandlerAppID, NC_URI_TEMPLATE);
this._removeTarget(aHandlerAppID, NC_METHOD);
this._removeTarget(aHandlerAppID, NC_SERVICE);
this._removeTarget(aHandlerAppID, NC_OBJPATH);
this._removeTarget(aHandlerAppID, NC_INTERFACE);
}
else if(aHandlerApp instanceof Ci.nsIWebHandlerApp){
aHandlerApp.QueryInterface(Ci.nsIWebHandlerApp);
this._setLiteral(aHandlerAppID, NC_URI_TEMPLATE, aHandlerApp.uriTemplate);
this._removeTarget(aHandlerAppID, NC_PATH);
this._removeTarget(aHandlerAppID, NC_METHOD);
this._removeTarget(aHandlerAppID, NC_SERVICE);
this._removeTarget(aHandlerAppID, NC_OBJPATH);
this._removeTarget(aHandlerAppID, NC_INTERFACE);
}
else if(aHandlerApp instanceof Ci.nsIDBusHandlerApp){
aHandlerApp.QueryInterface(Ci.nsIDBusHandlerApp);
this._setLiteral(aHandlerAppID, NC_SERVICE, aHandlerApp.service);
this._setLiteral(aHandlerAppID, NC_METHOD, aHandlerApp.method);
this._setLiteral(aHandlerAppID, NC_OBJPATH, aHandlerApp.objectPath);
this._setLiteral(aHandlerAppID, NC_INTERFACE, aHandlerApp.dBusInterface);
this._removeTarget(aHandlerAppID, NC_PATH);
this._removeTarget(aHandlerAppID, NC_URI_TEMPLATE);
}
else {
throw "unknown handler type";

View File

@ -37,14 +37,38 @@
*
* ***** END LICENSE BLOCK ***** */
#ifdef NS_HILDON
#include <glib.h>
#include <hildon-uri.h>
#endif
#include "nsMIMEInfoUnix.h"
#include "nsGNOMERegistry.h"
#include "nsIGnomeVFSService.h"
#include "nsPrintfCString.h"
#ifdef MOZ_ENABLE_DBUS
#include "nsDBusHandlerApp.h"
#endif
nsresult
nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI)
{
return nsGNOMERegistry::LoadURL(aURI);
{
nsresult rv = nsGNOMERegistry::LoadURL(aURI);
#ifdef NS_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 +85,15 @@ nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
if (*_retval)
return NS_OK;
#ifdef NS_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 +117,58 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(nsIFile *aFile)
return LaunchWithIProcess(mDefaultApplication, nativePath);
}
#ifdef NS_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);
int len = key.Length() + 1;
objpath.Assign(NS_LITERAL_CSTRING("/") + key);
objpath.ReplaceChar('.', '/');
interface.Assign(key);
} else {
int len = key.Length() + 11;
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

View File

@ -56,6 +56,9 @@ protected:
virtual NS_HIDDEN_(nsresult) LoadUriInternal(nsIURI *aURI);
virtual NS_HIDDEN_(nsresult) LaunchDefaultWithFile(nsIFile *aFile);
#ifdef NS_HILDON
NS_IMETHOD GetPossibleApplicationHandlers(nsIMutableArray * *aPossibleAppHandlers);
#endif
};
#endif // nsMIMEInfoUnix_h_

View File

@ -130,12 +130,24 @@ install:: $(pkg_config_files)
GARBAGE += $(MOZILLA_VERSION).system.conf $(pkg_config_files)
GARBAGE += debian/changelog
DEBDESTDIR=debian/$(MOZ_BUILD_APP)
GRE_MILESTONE = $(shell $(PYTHON) $(topsrcdir)/config/printconfigsetting.py $(LIBXUL_DIST)/bin/platform.ini Build Milestone)
GRE_BUILDID = $(shell $(PYTHON) $(topsrcdir)/config/printconfigsetting.py $(LIBXUL_DIST)/bin/platform.ini Build BuildID)
MOZ_DEB_TIMESTAMP = "$(shell date +"%a, %d %b %Y %T %z" )"
DEFINES += -DGRE_MILESTONE=$(GRE_MILESTONE) -DGRE_BUILDID=$(GRE_BUILDID) -DMOZ_DEB_TIMESTAMP=$(MOZ_DEB_TIMESTAMP)
ifeq ($(OS_TARGET),Linux)
deb:
debian/changelog: $(srcdir)/debian/changelog.in $(LIBXUL_DIST)/bin/platform.ini
mkdir -p debian
$(PYTHON) $(topsrcdir)/config/Preprocessor.py \
$(AUTOMATION_PPARGS) $(DEFINES) $(ACDEFINES) $< > $@
deb: debian/changelog
$(NSINSTALL) $(topsrcdir)/$(MOZ_BUILD_APP)/installer/debian .
rm -rf $(DEBDESTDIR)/usr/local/*
$(NSINSTALL) -D $(DEBDESTDIR)/usr/local

View File

@ -1,4 +1,5 @@
xulrunner (@MOZ_APP_VERSION@) unstable; urgency=low
#filter substitution
xulrunner (@GRE_MILESTONE@-@GRE_BUILDID@) unstable; urgency=low
* Mozilla Nightly (Closes: #nnnn) <nnnn is the bug number of your ITP>