1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/uriloader/exthandler/unix/nsMeegoExternalSharingAppService.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "shareuiinterface.h" 1.9 +#include <MDataUri> 1.10 +#include "nsExternalSharingAppService.h" 1.11 +#include "nsString.h" 1.12 + 1.13 +NS_IMPL_ISUPPORTS(nsExternalSharingAppService, nsIExternalSharingAppService) 1.14 + 1.15 +nsExternalSharingAppService::nsExternalSharingAppService() 1.16 + : mShareUi(nullptr) 1.17 +{ 1.18 +} 1.19 + 1.20 +nsExternalSharingAppService::~nsExternalSharingAppService() 1.21 +{ 1.22 +} 1.23 + 1.24 +NS_IMETHODIMP 1.25 +nsExternalSharingAppService::ShareWithDefault(const nsAString & aData, 1.26 + const nsAString & aMime, 1.27 + const nsAString & aTitle) 1.28 +{ 1.29 + if (!mShareUi) 1.30 + mShareUi = new ShareUiInterface(); 1.31 + 1.32 + if (!mShareUi || !mShareUi->isValid()) 1.33 + return NS_ERROR_NOT_AVAILABLE; 1.34 + 1.35 + if (aData.IsEmpty()) 1.36 + return NS_ERROR_INVALID_ARG; 1.37 + 1.38 + MDataUri uri; 1.39 + uri.setTextData(QString::fromUtf16(aData.BeginReading(), aData.Length())); 1.40 + uri.setMimeType(QString::fromUtf16(aMime.BeginReading(), aMime.Length())); 1.41 + uri.setAttribute("title", QString::fromUtf16(aTitle.BeginReading(), 0)); 1.42 + 1.43 + mShareUi->share(QStringList(uri.toString())); 1.44 + 1.45 + return NS_OK; 1.46 +} 1.47 + 1.48 +NS_IMETHODIMP 1.49 +nsExternalSharingAppService::GetSharingApps(const nsAString & aMIMEType, 1.50 + uint32_t *aLen, 1.51 + nsISharingHandlerApp ***aHandlers) 1.52 +{ 1.53 + return NS_ERROR_NOT_IMPLEMENTED; 1.54 +}