2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-10-18 09:46:42 -07:00
|
|
|
|
|
|
|
#include "shareuiinterface.h"
|
|
|
|
#include <MDataUri>
|
|
|
|
#include "nsExternalSharingAppService.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(nsExternalSharingAppService, nsIExternalSharingAppService)
|
|
|
|
|
|
|
|
nsExternalSharingAppService::nsExternalSharingAppService()
|
2012-07-30 07:20:58 -07:00
|
|
|
: mShareUi(nullptr)
|
2010-10-18 09:46:42 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t *aLen,
|
2012-07-06 13:14:07 -07:00
|
|
|
nsISharingHandlerApp ***aHandlers)
|
2010-10-18 09:46:42 -07:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|