2 * Copyright (C) 2018 Christian Browet
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "JNIXBMCJsonHandler.h"
11 #include "CompileInfo.h"
12 #include "interfaces/json-rpc/JSONRPC.h"
13 #include "interfaces/json-rpc/JSONServiceDescription.h"
14 #include "interfaces/json-rpc/JSONUtils.h"
16 #include <androidjni/Context.h>
17 #include <androidjni/jutils-details.hpp>
21 static std::string s_className
= std::string(CCompileInfo::GetClass()) + "/XBMCJsonRPC";
23 void CJNIXBMCJsonHandler::RegisterNatives(JNIEnv
*env
)
25 jclass cClass
= env
->FindClass(s_className
.c_str());
28 JNINativeMethod methods
[] =
30 {"_requestJSON", "(Ljava/lang/String;)Ljava/lang/String;", (void*)&CJNIXBMCJsonHandler::_requestJSON
},
33 env
->RegisterNatives(cClass
, methods
, sizeof(methods
)/sizeof(methods
[0]));
37 jstring
CJNIXBMCJsonHandler::_requestJSON(JNIEnv
*env
, jobject thiz
, jstring request
)
40 CJNITransportLayer transportLayer
;
42 std::string strRequest
= jcast
<std::string
>(jhstring::fromJNI(request
));
43 std::string responseData
= JSONRPC::CJSONRPC::MethodCall(strRequest
, &transportLayer
, &client
);
45 jstring jres
= env
->NewStringUTF(responseData
.c_str());
49 /**********************************/
51 bool CJNIXBMCJsonHandler::CJNITransportLayer::PrepareDownload(const char *path
, CVariant
&details
, std::string
&protocol
)
56 bool CJNIXBMCJsonHandler::CJNITransportLayer::Download(const char *path
, CVariant
&result
)
61 int CJNIXBMCJsonHandler::CJNITransportLayer::GetCapabilities()
63 return JSONRPC::Response
;
66 int CJNIXBMCJsonHandler::CJNIClient::GetPermissionFlags()
68 return JSONRPC::OPERATION_PERMISSION_ALL
;
71 int CJNIXBMCJsonHandler::CJNIClient::GetAnnouncementFlags()
73 // Does not support broadcast
77 bool CJNIXBMCJsonHandler::CJNIClient::SetAnnouncementFlags(int flags
)