mpd/src/android/LogListener.cxx
2023-03-06 14:59:48 +01:00

25 lines
617 B
C++

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project
#include "LogListener.hxx"
#include "java/Class.hxx"
#include "java/String.hxx"
LogListener::LogListener(JNIEnv *env, jobject obj) noexcept
:Java::GlobalObject(env, obj)
{
Java::Class cls(env, env->GetObjectClass(Get()));
onLogMethod = env->GetMethodID(cls, "onLog", "(ILjava/lang/String;)V");
assert(onLogMethod);
}
void
LogListener::OnLog(JNIEnv *env, int priority, const char *msg) const noexcept
{
assert(env != nullptr);
env->CallVoidMethod(Get(), onLogMethod, priority,
Java::String(env, msg).Get());
}