forked from jbagg/QtZeroConf
Use jlong instead of jint for intptr_t
Signed-off-by: Jonathan Bagg <drwho@infidigm.net>
This commit is contained in:
committed by
Jonathan Bagg
parent
966877a9a0
commit
2a7a8fb9d8
@ -39,14 +39,14 @@ import android.net.nsd.NsdManager;
|
||||
|
||||
public class QZeroConfNsdManager {
|
||||
|
||||
public static native void onServiceResolvedJNI(int id, String name, String type, String hostname, String address, int port, Map<String, byte[]> txtRecords);
|
||||
public static native void onServiceRemovedJNI(int id, String name);
|
||||
public static native void onBrowserStateChangedJNI(int id, boolean running, boolean error);
|
||||
public static native void onPublisherStateChangedJNI(int id, boolean running, boolean error);
|
||||
public static native void onServiceNameChangedJNI(int id, String newName);
|
||||
public static native void onServiceResolvedJNI(long id, String name, String type, String hostname, String address, int port, Map<String, byte[]> txtRecords);
|
||||
public static native void onServiceRemovedJNI(long id, String name);
|
||||
public static native void onBrowserStateChangedJNI(long id, boolean running, boolean error);
|
||||
public static native void onPublisherStateChangedJNI(long id, boolean running, boolean error);
|
||||
public static native void onServiceNameChangedJNI(long id, String newName);
|
||||
|
||||
private static String TAG = "QZeroConfNsdManager";
|
||||
private int id;
|
||||
private long id;
|
||||
private Context context;
|
||||
private NsdManager nsdManager;
|
||||
private NsdManager.DiscoveryListener discoveryListener;
|
||||
@ -57,7 +57,7 @@ public class QZeroConfNsdManager {
|
||||
static private ArrayList<NsdServiceInfo> resolverQueue = new ArrayList<NsdServiceInfo>();
|
||||
static private NsdServiceInfo pendingResolve = null;
|
||||
|
||||
public QZeroConfNsdManager(int id, Context context) {
|
||||
public QZeroConfNsdManager(long id, Context context) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.context = context;
|
||||
|
@ -42,16 +42,16 @@ QZeroConfPrivate::QZeroConfPrivate(QZeroConf *parent)
|
||||
QAndroidJniEnvironment env;
|
||||
|
||||
JNINativeMethod methods[] {
|
||||
{ "onServiceResolvedJNI", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/util/Map;)V", (void*)QZeroConfPrivate::onServiceResolvedJNI },
|
||||
{ "onServiceRemovedJNI", "(ILjava/lang/String;)V", (void*)QZeroConfPrivate::onServiceRemovedJNI },
|
||||
{ "onBrowserStateChangedJNI", "(IZZ)V", (void*)QZeroConfPrivate::onBrowserStateChangedJNI },
|
||||
{ "onPublisherStateChangedJNI", "(IZZ)V", (void*)QZeroConfPrivate::onPublisherStateChangedJNI },
|
||||
{ "onServiceNameChangedJNI", "(ILjava/lang/String;)V", (void*)QZeroConfPrivate::onServiceNameChangedJNI }
|
||||
{ "onServiceResolvedJNI", "(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/util/Map;)V", (void*)QZeroConfPrivate::onServiceResolvedJNI },
|
||||
{ "onServiceRemovedJNI", "(JLjava/lang/String;)V", (void*)QZeroConfPrivate::onServiceRemovedJNI },
|
||||
{ "onBrowserStateChangedJNI", "(JZZ)V", (void*)QZeroConfPrivate::onBrowserStateChangedJNI },
|
||||
{ "onPublisherStateChangedJNI", "(JZZ)V", (void*)QZeroConfPrivate::onPublisherStateChangedJNI },
|
||||
{ "onServiceNameChangedJNI", "(JLjava/lang/String;)V", (void*)QZeroConfPrivate::onServiceNameChangedJNI }
|
||||
};
|
||||
|
||||
// Passing "this" as ID down to Java so we can access "this" in callbacks.
|
||||
// There seems to be no straight forward way to match the "thiz" pointer from JNI calls to our pointer of the Java class
|
||||
nsdManager = QAndroidJniObject("qtzeroconf/QZeroConfNsdManager", "(ILandroid/content/Context;)V", reinterpret_cast<intptr_t>(this), QtAndroid::androidActivity().object());
|
||||
nsdManager = QAndroidJniObject("qtzeroconf/QZeroConfNsdManager", "(JLandroid/content/Context;)V", reinterpret_cast<uintptr_t>(this), QtAndroid::androidActivity().object());
|
||||
if (nsdManager.isValid()) {
|
||||
jclass objectClass = env->GetObjectClass(nsdManager.object<jobject>());
|
||||
env->RegisterNatives(objectClass, methods, sizeof(methods) / sizeof(methods[0]));
|
||||
@ -120,7 +120,7 @@ void QZeroConfPrivate::stopBrowser()
|
||||
// Callbacks will come in from the android thread. So we're never accessing any of our members directly but instead
|
||||
// propagate callbacks through Qt::QueuedConnection invokes into the Qt thread. Be sure to check if the instance is still
|
||||
// alive by checking s_instances while holding the mutex before scheduling the invokation.
|
||||
void QZeroConfPrivate::onServiceResolvedJNI(JNIEnv */*env*/, jobject /*thiz*/, jint id, jstring name, jstring type, jstring hostname, jstring address, jint port, jobject txtRecords)
|
||||
void QZeroConfPrivate::onServiceResolvedJNI(JNIEnv */*env*/, jobject /*thiz*/, jlong id, jstring name, jstring type, jstring hostname, jstring address, jint port, jobject txtRecords)
|
||||
{
|
||||
QMap<QByteArray, QByteArray> txtMap;
|
||||
QAndroidJniObject txt(txtRecords);
|
||||
@ -157,7 +157,7 @@ void QZeroConfPrivate::onServiceResolvedJNI(JNIEnv */*env*/, jobject /*thiz*/, j
|
||||
|
||||
}
|
||||
|
||||
void QZeroConfPrivate::onServiceRemovedJNI(JNIEnv */*env*/, jobject /*this*/, jint id, jstring name)
|
||||
void QZeroConfPrivate::onServiceRemovedJNI(JNIEnv */*env*/, jobject /*this*/, jlong id, jstring name)
|
||||
{
|
||||
QZeroConfPrivate *ref = reinterpret_cast<QZeroConfPrivate*>(id);
|
||||
QMutexLocker locker(&s_instancesMutex);
|
||||
@ -168,7 +168,7 @@ void QZeroConfPrivate::onServiceRemovedJNI(JNIEnv */*env*/, jobject /*this*/, ji
|
||||
}
|
||||
|
||||
|
||||
void QZeroConfPrivate::onBrowserStateChangedJNI(JNIEnv */*env*/, jobject /*thiz*/, jint id, jboolean running, jboolean error)
|
||||
void QZeroConfPrivate::onBrowserStateChangedJNI(JNIEnv */*env*/, jobject /*thiz*/, jlong id, jboolean running, jboolean error)
|
||||
{
|
||||
QZeroConfPrivate *ref = reinterpret_cast<QZeroConfPrivate*>(id);
|
||||
QMutexLocker locker(&s_instancesMutex);
|
||||
@ -178,7 +178,7 @@ void QZeroConfPrivate::onBrowserStateChangedJNI(JNIEnv */*env*/, jobject /*thiz*
|
||||
QMetaObject::invokeMethod(ref, "onBrowserStateChanged", Qt::QueuedConnection, Q_ARG(bool, running), Q_ARG(bool, error));
|
||||
}
|
||||
|
||||
void QZeroConfPrivate::onPublisherStateChangedJNI(JNIEnv */*env*/, jobject /*this*/, jint id, jboolean running, jboolean error)
|
||||
void QZeroConfPrivate::onPublisherStateChangedJNI(JNIEnv */*env*/, jobject /*this*/, jlong id, jboolean running, jboolean error)
|
||||
{
|
||||
QZeroConfPrivate *ref = reinterpret_cast<QZeroConfPrivate*>(id);
|
||||
QMutexLocker locker(&s_instancesMutex);
|
||||
@ -188,7 +188,7 @@ void QZeroConfPrivate::onPublisherStateChangedJNI(JNIEnv */*env*/, jobject /*thi
|
||||
QMetaObject::invokeMethod(ref, "onPublisherStateChanged", Qt::QueuedConnection, Q_ARG(bool, running), Q_ARG(bool, error));
|
||||
}
|
||||
|
||||
void QZeroConfPrivate::onServiceNameChangedJNI(JNIEnv */*env*/, jobject /*thiz*/, jint id, jstring newName)
|
||||
void QZeroConfPrivate::onServiceNameChangedJNI(JNIEnv */*env*/, jobject /*thiz*/, jlong id, jstring newName)
|
||||
{
|
||||
QZeroConfPrivate *ref = reinterpret_cast<QZeroConfPrivate*>(id);
|
||||
QMutexLocker locker(&s_instancesMutex);
|
||||
|
@ -42,11 +42,11 @@ public:
|
||||
void stopServicePublish();
|
||||
void startBrowser(QString type, QAbstractSocket::NetworkLayerProtocol protocol);
|
||||
void stopBrowser();
|
||||
static void onServiceResolvedJNI(JNIEnv */*env*/, jobject /*this*/, jint id, jstring name, jstring type, jstring hostname, jstring address, jint port, jobject txtRecords);
|
||||
static void onServiceRemovedJNI(JNIEnv */*env*/, jobject /*this*/, jint id, jstring name);
|
||||
static void onBrowserStateChangedJNI(JNIEnv */*env*/, jobject /*thiz*/, jint id, jboolean running, jboolean error);
|
||||
static void onPublisherStateChangedJNI(JNIEnv */*env*/, jobject /*thiz*/, jint id, jboolean running, jboolean error);
|
||||
static void onServiceNameChangedJNI(JNIEnv */*env*/, jobject /*thiz*/, jint id, jstring newName);
|
||||
static void onServiceResolvedJNI(JNIEnv */*env*/, jobject /*thiz*/, jlong id, jstring name, jstring type, jstring hostname, jstring address, jint port, jobject txtRecords);
|
||||
static void onServiceRemovedJNI(JNIEnv */*env*/, jobject /*this*/, jlong id, jstring name);
|
||||
static void onBrowserStateChangedJNI(JNIEnv */*env*/, jobject /*thiz*/, jlong id, jboolean running, jboolean error);
|
||||
static void onPublisherStateChangedJNI(JNIEnv */*env*/, jobject /*thiz*/, jlong id, jboolean running, jboolean error);
|
||||
static void onServiceNameChangedJNI(JNIEnv */*env*/, jobject /*thiz*/, jlong id, jstring newName);
|
||||
|
||||
QZeroConf *pub;
|
||||
QAndroidJniObject nsdManager;
|
||||
|
Reference in New Issue
Block a user