Bug 582621 - Sharing back-end for MeeGo r=dougt a=blocking-fennec

--HG--
extra : rebase_source : 81386b7a9f512a2d060efcbe7b272bb0f4936fa4
This commit is contained in:
Tero Turtiainen 2010-10-18 09:46:42 -07:00
parent baf34304c4
commit 1ed4371ff3
7 changed files with 171 additions and 5 deletions

View File

@ -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@

View File

@ -1048,3 +1048,6 @@ contentaction/contentaction.h
#ifndef MOZ_TREE_PIXMAN
pixman.h
#endif
#if MOZ_ENABLE_MEEGOTOUCHSHARE
shareuiinterface.h
#endif

View File

@ -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

View File

@ -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 },

View File

@ -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)

View File

@ -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<ShareUiInterface> mShareUi;
};
#endif

View File

@ -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 <MDataUri>
#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;
}