michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "shareuiinterface.h" michael@0: #include michael@0: #include "nsExternalSharingAppService.h" michael@0: #include "nsString.h" michael@0: michael@0: NS_IMPL_ISUPPORTS(nsExternalSharingAppService, nsIExternalSharingAppService) michael@0: michael@0: nsExternalSharingAppService::nsExternalSharingAppService() michael@0: : mShareUi(nullptr) michael@0: { michael@0: } michael@0: michael@0: nsExternalSharingAppService::~nsExternalSharingAppService() michael@0: { michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsExternalSharingAppService::ShareWithDefault(const nsAString & aData, michael@0: const nsAString & aMime, michael@0: const nsAString & aTitle) michael@0: { michael@0: if (!mShareUi) michael@0: mShareUi = new ShareUiInterface(); michael@0: michael@0: if (!mShareUi || !mShareUi->isValid()) michael@0: return NS_ERROR_NOT_AVAILABLE; michael@0: michael@0: if (aData.IsEmpty()) michael@0: return NS_ERROR_INVALID_ARG; michael@0: michael@0: MDataUri uri; michael@0: uri.setTextData(QString::fromUtf16(aData.BeginReading(), aData.Length())); michael@0: uri.setMimeType(QString::fromUtf16(aMime.BeginReading(), aMime.Length())); michael@0: uri.setAttribute("title", QString::fromUtf16(aTitle.BeginReading(), 0)); michael@0: michael@0: mShareUi->share(QStringList(uri.toString())); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsExternalSharingAppService::GetSharingApps(const nsAString & aMIMEType, michael@0: uint32_t *aLen, michael@0: nsISharingHandlerApp ***aHandlers) michael@0: { michael@0: return NS_ERROR_NOT_IMPLEMENTED; michael@0: }