uriloader/exthandler/unix/nsMeegoExternalSharingAppService.cpp

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #include "shareuiinterface.h"
michael@0 6 #include <MDataUri>
michael@0 7 #include "nsExternalSharingAppService.h"
michael@0 8 #include "nsString.h"
michael@0 9
michael@0 10 NS_IMPL_ISUPPORTS(nsExternalSharingAppService, nsIExternalSharingAppService)
michael@0 11
michael@0 12 nsExternalSharingAppService::nsExternalSharingAppService()
michael@0 13 : mShareUi(nullptr)
michael@0 14 {
michael@0 15 }
michael@0 16
michael@0 17 nsExternalSharingAppService::~nsExternalSharingAppService()
michael@0 18 {
michael@0 19 }
michael@0 20
michael@0 21 NS_IMETHODIMP
michael@0 22 nsExternalSharingAppService::ShareWithDefault(const nsAString & aData,
michael@0 23 const nsAString & aMime,
michael@0 24 const nsAString & aTitle)
michael@0 25 {
michael@0 26 if (!mShareUi)
michael@0 27 mShareUi = new ShareUiInterface();
michael@0 28
michael@0 29 if (!mShareUi || !mShareUi->isValid())
michael@0 30 return NS_ERROR_NOT_AVAILABLE;
michael@0 31
michael@0 32 if (aData.IsEmpty())
michael@0 33 return NS_ERROR_INVALID_ARG;
michael@0 34
michael@0 35 MDataUri uri;
michael@0 36 uri.setTextData(QString::fromUtf16(aData.BeginReading(), aData.Length()));
michael@0 37 uri.setMimeType(QString::fromUtf16(aMime.BeginReading(), aMime.Length()));
michael@0 38 uri.setAttribute("title", QString::fromUtf16(aTitle.BeginReading(), 0));
michael@0 39
michael@0 40 mShareUi->share(QStringList(uri.toString()));
michael@0 41
michael@0 42 return NS_OK;
michael@0 43 }
michael@0 44
michael@0 45 NS_IMETHODIMP
michael@0 46 nsExternalSharingAppService::GetSharingApps(const nsAString & aMIMEType,
michael@0 47 uint32_t *aLen,
michael@0 48 nsISharingHandlerApp ***aHandlers)
michael@0 49 {
michael@0 50 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 51 }

mercurial