From baf34304c4433de81841fa1cf02a4045edc83e40 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Mon, 18 Oct 2010 18:37:00 +0200 Subject: [PATCH 1/2] Bug 603848 - Add a notifier observer about the IME State [r=masayuki,a=blocking-fennec] --- content/events/src/nsIMEStateManager.cpp | 26 ++++++++++++++++++++++++ dom/ipc/TabParent.cpp | 11 +++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/content/events/src/nsIMEStateManager.cpp b/content/events/src/nsIMEStateManager.cpp index 5fd22bd710f..1c6e4b4f4f1 100644 --- a/content/events/src/nsIMEStateManager.cpp +++ b/content/events/src/nsIMEStateManager.cpp @@ -63,6 +63,8 @@ #include "nsISelectionController.h" #include "nsIMutationObserver.h" #include "nsContentEventHandler.h" +#include "nsIObserverService.h" +#include "mozilla/Services.h" /******************************************************************/ /* nsIMEStateManager */ @@ -235,6 +237,28 @@ nsIMEStateManager::GetNewIMEState(nsPresContext* aPresContext, return aContent->GetDesiredIMEState(); } +// Helper class, used for IME enabled state change notification +class IMEEnabledStateChangedEvent : public nsRunnable { +public: + IMEEnabledStateChangedEvent(PRUint32 aState) + : mState(aState) + { + } + + NS_IMETHOD Run() { + nsCOMPtr observerService = mozilla::services::GetObserverService(); + if (observerService) { + nsAutoString state; + state.AppendInt(mState); + observerService->NotifyObservers(nsnull, "ime-enabled-state-changed", state.get()); + } + return NS_OK; + } + +private: + PRUint32 mState; +}; + void nsIMEStateManager::SetIMEState(PRUint32 aState, nsIWidget* aWidget) @@ -243,6 +267,8 @@ nsIMEStateManager::SetIMEState(PRUint32 aState, PRUint32 state = nsContentUtils::GetWidgetStatusFromIMEStatus(aState); aWidget->SetIMEEnabled(state); + + nsContentUtils::AddScriptRunner(new IMEEnabledStateChangedEvent(state)); } if (aState & nsIContent::IME_STATUS_MASK_OPENED) { PRBool open = !!(aState & nsIContent::IME_STATUS_OPEN); diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 33a9cad9b76..5ad477654d3 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -530,8 +530,17 @@ bool TabParent::RecvSetIMEEnabled(const PRUint32& aValue) { nsCOMPtr widget = GetWidget(); - if (widget) + if (widget) { widget->SetIMEEnabled(aValue); + + nsCOMPtr observerService = mozilla::services::GetObserverService(); + if (observerService) { + nsAutoString state; + state.AppendInt(aValue); + observerService->NotifyObservers(nsnull, "ime-enabled-state-changed", state.get()); + } + } + return true; } From 1ed4371ff3a63a067ccb5cd058611779e0b19009 Mon Sep 17 00:00:00 2001 From: Tero Turtiainen Date: Mon, 18 Oct 2010 09:46:42 -0700 Subject: [PATCH 2/2] Bug 582621 - Sharing back-end for MeeGo r=dougt a=blocking-fennec --HG-- extra : rebase_source : 81386b7a9f512a2d060efcbe7b272bb0f4936fa4 --- config/autoconf.mk.in | 1 + config/system-headers | 3 + configure.in | 11 +++ docshell/build/nsDocShellModule.cpp | 10 +-- uriloader/exthandler/Makefile.in | 7 ++ .../unix/nsExternalSharingAppService.h | 62 ++++++++++++++ .../unix/nsMeegoExternalSharingAppService.cpp | 82 +++++++++++++++++++ 7 files changed, 171 insertions(+), 5 deletions(-) create mode 100644 uriloader/exthandler/unix/nsExternalSharingAppService.h create mode 100644 uriloader/exthandler/unix/nsMeegoExternalSharingAppService.cpp diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in index 773656b6dbd..1b9a0c660e7 100644 --- a/config/autoconf.mk.in +++ b/config/autoconf.mk.in @@ -536,6 +536,7 @@ MOZ_QT_CFLAGS = @MOZ_QT_CFLAGS@ MOZ_QT_LIBS = @MOZ_QT_LIBS@ MOZ_ENABLE_QTNETWORK = @MOZ_ENABLE_QTNETWORK@ MOZ_ENABLE_MEEGOTOUCH = @MOZ_ENABLE_MEEGOTOUCH@ +MOZ_ENABLE_MEEGOTOUCHSHARE = @MOZ_ENABLE_MEEGOTOUCHSHARE@ MOZ_DBUS_CFLAGS = @MOZ_DBUS_CFLAGS@ MOZ_DBUS_LIBS = @MOZ_DBUS_LIBS@ diff --git a/config/system-headers b/config/system-headers index 01c8dcb213b..b831a69fd02 100644 --- a/config/system-headers +++ b/config/system-headers @@ -1048,3 +1048,6 @@ contentaction/contentaction.h #ifndef MOZ_TREE_PIXMAN pixman.h #endif +#if MOZ_ENABLE_MEEGOTOUCHSHARE +shareuiinterface.h +#endif diff --git a/configure.in b/configure.in index dad5930c03c..f40ab08126b 100644 --- a/configure.in +++ b/configure.in @@ -7008,6 +7008,17 @@ if test $MOZ_PLATFORM_MAEMO; then fi AC_SUBST(MOZ_MAEMO_LIBLOCATION) + PKG_CHECK_MODULES(LIBMEEGOTOUCHSHARE, ShareUiInterface-maemo-meegotouch >= 0.3.31 mdatauri, _LIB_FOUND=1, _LIB_FOUND=) + MOZ_PLATFORM_MAEMO_LIBS="$MOZ_PLATFORM_MAEMO_LIBS $LIBMEEGOTOUCHSHARE_LIBS" + MOZ_PLATFORM_MAEMO_CFLAGS="$MOZ_PLATFORM_MAEMO_CFLAGS $LIBMEEGOTOUCHSHARE_CFLAGS" + if test "$_LIB_FOUND"; then + MOZ_ENABLE_MEEGOTOUCHSHARE=1 + AC_DEFINE(MOZ_ENABLE_MEEGOTOUCHSHARE) + else + AC_MSG_WARN([Cannot find maemo-meegotouch-interfaces-dev or libmdatauri-dev. Disabling meegotouch share ui.]) + fi + AC_SUBST(MOZ_ENABLE_MEEGOTOUCHSHARE) + AC_SUBST(MOZ_PLATFORM_MAEMO_LIBS) AC_SUBST(MOZ_PLATFORM_MAEMO_CFLAGS) fi diff --git a/docshell/build/nsDocShellModule.cpp b/docshell/build/nsDocShellModule.cpp index 9680b4c6cbe..fe0d357a0d4 100644 --- a/docshell/build/nsDocShellModule.cpp +++ b/docshell/build/nsDocShellModule.cpp @@ -57,7 +57,7 @@ #ifdef MOZ_ENABLE_DBUS #include "nsDBusHandlerApp.h" #endif -#ifdef ANDROID +#if defined(ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE) #include "nsExternalSharingAppService.h" #endif @@ -113,7 +113,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(PlatformLocalHandlerApp_t) #ifdef MOZ_ENABLE_DBUS NS_GENERIC_FACTORY_CONSTRUCTOR(nsDBusHandlerApp) #endif -#ifdef ANDROID +#if defined(ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE) NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalSharingAppService) #endif @@ -140,7 +140,7 @@ NS_DEFINE_NAMED_CID(NS_LOCALHANDLERAPP_CID); #ifdef MOZ_ENABLE_DBUS NS_DEFINE_NAMED_CID(NS_DBUSHANDLERAPP_CID); #endif -#ifdef ANDROID +#if defined(ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE) NS_DEFINE_NAMED_CID(NS_EXTERNALSHARINGAPPSERVICE_CID); #endif NS_DEFINE_NAMED_CID(NS_SHENTRY_CID); @@ -167,7 +167,7 @@ const mozilla::Module::CIDEntry kDocShellCIDs[] = { #ifdef MOZ_ENABLE_DBUS { &kNS_DBUSHANDLERAPP_CID, false, NULL, nsDBusHandlerAppConstructor }, #endif -#ifdef ANDROID +#if defined(ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE) { &kNS_EXTERNALSHARINGAPPSERVICE_CID, false, NULL, nsExternalSharingAppServiceConstructor }, #endif { &kNS_SHENTRY_CID, false, NULL, nsSHEntryConstructor }, @@ -212,7 +212,7 @@ const mozilla::Module::ContractIDEntry kDocShellContracts[] = { #ifdef MOZ_ENABLE_DBUS { NS_DBUSHANDLERAPP_CONTRACTID, &kNS_DBUSHANDLERAPP_CID }, #endif -#ifdef ANDROID +#if defined(ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE) { NS_EXTERNALSHARINGAPPSERVICE_CONTRACTID, &kNS_EXTERNALSHARINGAPPSERVICE_CID }, #endif { NS_SHENTRY_CONTRACTID, &kNS_SHENTRY_CID }, diff --git a/uriloader/exthandler/Makefile.in b/uriloader/exthandler/Makefile.in index 15289b3b699..8149cc10030 100644 --- a/uriloader/exthandler/Makefile.in +++ b/uriloader/exthandler/Makefile.in @@ -169,6 +169,13 @@ LOCAL_INCLUDES += $(TK_CFLAGS) $(MOZ_DBUS_CFLAGS) EXTRA_DSO_LDOPTS += $(MOZ_DBUS_LIBS) endif +ifdef MOZ_ENABLE_MEEGOTOUCHSHARE +OSHELPER += nsMeegoExternalSharingAppService.cpp +LOCAL_INCLUDES += $(MOZ_PLATFORM_MAEMO_CFLAGS) +EXTRA_DSO_LDOPTS += $(MOZ_PLATFORM_MAEMO_LIBS) +EXPORTS += nsExternalSharingAppService.h +endif + ifeq ($(MOZ_PLATFORM_MAEMO),5) ifdef MOZ_ENABLE_GNOMEVFS LOCAL_INCLUDES += $(MOZ_GNOMEVFS_CFLAGS) diff --git a/uriloader/exthandler/unix/nsExternalSharingAppService.h b/uriloader/exthandler/unix/nsExternalSharingAppService.h new file mode 100644 index 00000000000..4ccd019a1df --- /dev/null +++ b/uriloader/exthandler/unix/nsExternalSharingAppService.h @@ -0,0 +1,62 @@ +/* ***** 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 Nokia Corporation Code. + * + * The Initial Developer of the Original Code is Nokia Corporation. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either 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 NS_EXTERNAL_SHARING_APP_SERVICE_H +#define NS_EXTERNAL_SHARING_APP_SERVICE_H + +#include "nsIExternalSharingAppService.h" +#include "nsAutoPtr.h" + +class ShareUiInterface; + +#define NS_EXTERNALSHARINGAPPSERVICE_CID \ + {0xea782c90, 0xc6ec, 0x11df, \ + {0xbd3, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66, 0x74}} + +class nsExternalSharingAppService : public nsIExternalSharingAppService +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIEXTERNALSHARINGAPPSERVICE + + nsExternalSharingAppService(); + +private: + ~nsExternalSharingAppService(); + +protected: + nsAutoPtr mShareUi; +}; +#endif diff --git a/uriloader/exthandler/unix/nsMeegoExternalSharingAppService.cpp b/uriloader/exthandler/unix/nsMeegoExternalSharingAppService.cpp new file mode 100644 index 00000000000..e0f118c6f64 --- /dev/null +++ b/uriloader/exthandler/unix/nsMeegoExternalSharingAppService.cpp @@ -0,0 +1,82 @@ +/* ***** 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 Nokia Corporation Code. + * + * The Initial Developer of the Original Code is Nokia Corporation. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either 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 "shareuiinterface.h" +#include +#include "nsExternalSharingAppService.h" +#include "nsString.h" + +NS_IMPL_ISUPPORTS1(nsExternalSharingAppService, nsIExternalSharingAppService) + +nsExternalSharingAppService::nsExternalSharingAppService() + : mShareUi(nsnull) +{ +} + +nsExternalSharingAppService::~nsExternalSharingAppService() +{ +} + +NS_IMETHODIMP +nsExternalSharingAppService::ShareWithDefault(const nsAString & aData, + const nsAString & aMime, + const nsAString & aTitle) +{ + if (!mShareUi) + mShareUi = new ShareUiInterface(); + + if (!mShareUi || !mShareUi->isValid()) + return NS_ERROR_NOT_AVAILABLE; + + if (aData.IsEmpty()) + return NS_ERROR_INVALID_ARG; + + MDataUri uri; + uri.setTextData(QString::fromUtf16(aData.BeginReading(), aData.Length())); + uri.setMimeType(QString::fromUtf16(aMime.BeginReading(), aMime.Length())); + uri.setAttribute("title", QString::fromUtf16(aTitle.BeginReading(), 0)); + + mShareUi->share(QStringList(uri.toString())); + + return NS_OK; +} + +NS_IMETHODIMP +nsExternalSharingAppService::GetSharingApps(const nsAString & aMIMEType, + PRUint32 *aLen NS_OUTPARAM, + nsISharingHandlerApp ***aHandlers NS_OUTPARAM) +{ + return NS_ERROR_NOT_IMPLEMENTED; +}