mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
adapt to location-rendering-api
This commit is contained in:
@@ -752,6 +752,73 @@ JNIEXPORT jboolean Java_com_b44t_messenger_DcContext_setLocation(JNIEnv *env, jo
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jlong Java_com_b44t_messenger_DcContext_getLocationsCPtr(JNIEnv *env, jobject obj, jint chat_id, jint contact_id)
|
||||
{
|
||||
return (jlong)dc_get_locations(get_dc_context(env, obj), chat_id, contact_id);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* DcArray
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
static dc_array_t* get_dc_array(JNIEnv *env, jobject obj)
|
||||
{
|
||||
static jfieldID fid = 0;
|
||||
if (fid==0) {
|
||||
jclass cls = (*env)->GetObjectClass(env, obj);
|
||||
fid = (*env)->GetFieldID(env, cls, "arrayCPtr", "J" /*Signature, J=long*/);
|
||||
}
|
||||
if (fid) {
|
||||
return (dc_array_t*)(*env)->GetLongField(env, obj, fid);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcArray_unrefArrayCPtr(JNIEnv *env, jobject obj)
|
||||
{
|
||||
dc_array_unref(get_dc_array(env, obj));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_DcArray_getCnt(JNIEnv *env, jobject obj)
|
||||
{
|
||||
return dc_array_get_cnt(get_dc_array(env, obj));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jfloat Java_com_b44t_messenger_DcArray_getLatitude(JNIEnv *env, jobject obj, jint index)
|
||||
{
|
||||
return (jfloat)dc_array_get_latitude(get_dc_array(env, obj), index);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jfloat Java_com_b44t_messenger_DcArray_getLongitude(JNIEnv *env, jobject obj, jint index)
|
||||
{
|
||||
return (jfloat)dc_array_get_longitude(get_dc_array(env, obj), index);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jfloat Java_com_b44t_messenger_DcArray_getAccuracy(JNIEnv *env, jobject obj, jint index)
|
||||
{
|
||||
return (jfloat)dc_array_get_accuracy(get_dc_array(env, obj), index);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jlong Java_com_b44t_messenger_DcArray_getTimestamp(JNIEnv *env, jobject obj, jint index)
|
||||
{
|
||||
return JTIMESTAMP(dc_array_get_timestamp(get_dc_array(env, obj), index));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_DcArray_getMsgId(JNIEnv *env, jobject obj, jint index)
|
||||
{
|
||||
return dc_array_get_msg_id(get_dc_array(env, obj), index);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* DcChatlist
|
||||
******************************************************************************/
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.b44t.messenger;
|
||||
|
||||
public class DcArray {
|
||||
|
||||
public DcArray(long arrayCPtr) {
|
||||
this.arrayCPtr = arrayCPtr;
|
||||
}
|
||||
|
||||
@Override protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
unrefArrayCPtr();
|
||||
arrayCPtr = 0;
|
||||
}
|
||||
|
||||
public native int getCnt ();
|
||||
public native float getLatitude (int index);
|
||||
public native float getLongitude(int index);
|
||||
public native float getAccuracy (int index);
|
||||
public native long getTimestamp(int index);
|
||||
public native int getMsgId (int index);
|
||||
|
||||
// working with raw c-data
|
||||
private long arrayCPtr; // CAVE: the name is referenced in the JNI
|
||||
private native void unrefArrayCPtr();
|
||||
}
|
||||
@@ -21,6 +21,7 @@ public class DcContext {
|
||||
public final static int DC_EVENT_MSG_READ = 2015;
|
||||
public final static int DC_EVENT_CHAT_MODIFIED = 2020;
|
||||
public final static int DC_EVENT_CONTACTS_CHANGED = 2030;
|
||||
public final static int DC_EVENT_LOCATION_CHANGED = 2035;
|
||||
public final static int DC_EVENT_CONFIGURE_PROGRESS = 2041;
|
||||
public final static int DC_EVENT_IMEX_PROGRESS = 2051;
|
||||
public final static int DC_EVENT_IMEX_FILE_WRITTEN = 2052;
|
||||
@@ -154,6 +155,7 @@ public class DcContext {
|
||||
public native int joinSecurejoin (String qr);
|
||||
public native void sendLocationsToChat (int chat_id, int seconds);
|
||||
public native boolean isSendingLocationsToChat(int chat_id);
|
||||
public @NonNull DcArray getLocations (int chat_id, int contact_id) { return new DcArray(getLocationsCPtr(chat_id, contact_id)); }
|
||||
|
||||
/**
|
||||
* @return true if at least one chat has location streaming enabled
|
||||
@@ -180,4 +182,5 @@ public class DcContext {
|
||||
private native long getMsgCPtr (int id);
|
||||
private native long getDraftCPtr (int id);
|
||||
private native long getContactCPtr (int id);
|
||||
private native long getLocationsCPtr (int chat_id, int contact_id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user