uriloader/exthandler/unix/nsMeegoExternalSharingAppService.cpp

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

mercurial