mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
add DcContext.sendMsg() and related functions to bindings
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include "messenger-backend/cmdline/cmdline.h"
|
||||
|
||||
|
||||
static dc_msg_t* get_dc_msg(JNIEnv *env, jobject obj);
|
||||
|
||||
#define CHAR_REF(a) \
|
||||
const char* a##Ptr = (a)? (*env)->GetStringUTFChars(env, (a), 0) : NULL; // passing a NULL-jstring results in a NULL-ptr - this is needed by functions using eg. NULL for "delete"
|
||||
|
||||
@@ -473,6 +475,12 @@ JNIEXPORT jlong Java_com_b44t_messenger_DcContext_DcContextGetMsg(JNIEnv *env, j
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jlong Java_com_b44t_messenger_DcContext_createMsgCPtr(JNIEnv *env, jobject obj)
|
||||
{
|
||||
return (jlong)dc_msg_new(get_dc_context(env, obj));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jstring Java_com_b44t_messenger_DcContext_getMsgInfo(JNIEnv *env, jobject obj, jint msg_id)
|
||||
{
|
||||
char* temp = dc_get_msg_info(get_dc_context(env, obj), msg_id);
|
||||
@@ -500,6 +508,12 @@ JNIEXPORT void Java_com_b44t_messenger_DcContext_forwardMsgs(JNIEnv *env, jobjec
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_DcContext_sendMsg(JNIEnv *env, jobject obj, jint chat_id, jobject msg)
|
||||
{
|
||||
return dc_send_msg(get_dc_context(env, obj), chat_id, get_dc_msg(env, msg));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_DcContext_sendTextMsg(JNIEnv *env, jobject obj, jint chat_id, jstring text)
|
||||
{
|
||||
CHAR_REF(text);
|
||||
@@ -1095,6 +1109,51 @@ JNIEXPORT jstring Java_com_b44t_messenger_DcMsg_getSetupCodeBegin(JNIEnv *env, j
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcMsg_setType(JNIEnv *env, jobject obj, int type)
|
||||
{
|
||||
dc_msg_set_type(get_dc_msg(env, obj), type);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcMsg_setText(JNIEnv *env, jobject obj, jstring text)
|
||||
{
|
||||
CHAR_REF(text);
|
||||
dc_msg_set_text(get_dc_msg(env, obj), textPtr);
|
||||
CHAR_UNREF(text);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcMsg_setFile(JNIEnv *env, jobject obj, jstring file, jstring filemime)
|
||||
{
|
||||
CHAR_REF(file);
|
||||
CHAR_REF(filemime);
|
||||
dc_msg_set_file(get_dc_msg(env, obj), filePtr, filemimePtr);
|
||||
CHAR_UNREF(filemime);
|
||||
CHAR_UNREF(file);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcMsg_setDimension(JNIEnv *env, jobject obj, int width, int height)
|
||||
{
|
||||
dc_msg_set_dimension(get_dc_msg(env, obj), width, height);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcMsg_setDuration(JNIEnv *env, jobject obj, int duration)
|
||||
{
|
||||
dc_msg_set_duration(get_dc_msg(env, obj), duration);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcMsg_setMediainfo(JNIEnv *env, jobject obj, jstring author, jstring trackname)
|
||||
{
|
||||
CHAR_REF(author);
|
||||
CHAR_REF(trackname);
|
||||
dc_msg_set_mediainfo(get_dc_msg(env, obj), authorPtr, tracknamePtr);
|
||||
CHAR_UNREF(trackname);
|
||||
CHAR_UNREF(author);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* DcContact
|
||||
|
||||
@@ -134,6 +134,7 @@ public class DcContext {
|
||||
public native int getFreshMsgCount(int chat_id);
|
||||
public native void deleteMsgs(int msg_ids[]);
|
||||
public native void forwardMsgs(int msg_ids[], int chat_ids);
|
||||
public native int sendMsg(int chat_id, DcMsg msg);
|
||||
public native int sendTextMsg(int chat_id, String text);
|
||||
public native int sendVcardMsg(int chat_id, int contact_id);
|
||||
public native int sendMediaMsg(int chat_id, int type, String file, String mime, int w, int h, int time_ms, String author, String trackname);
|
||||
@@ -156,6 +157,7 @@ public class DcContext {
|
||||
// working with raw c-data
|
||||
private long m_hContext = 0; // must not be renamed as referenced by JNI
|
||||
private native long DcContextNew(String osName);
|
||||
public native long createMsgCPtr();
|
||||
private native static long DcContextGetChatlist(long hContext, int listflags, String query, int queryId);
|
||||
private native static long DcContextGetChat(long hContext, int chat_id);
|
||||
private native static long DcContextGetMsg(long hMailbox, int id);
|
||||
|
||||
@@ -45,6 +45,10 @@ public class DcMsg {
|
||||
public final static int DC_MSG_ID_MARKER1 = 1;
|
||||
public final static int DC_MSG_ID_DAYMARKER = 9;
|
||||
|
||||
public DcMsg(DcContext context) {
|
||||
m_hMsg = context.createMsgCPtr();
|
||||
}
|
||||
|
||||
public DcMsg(long hMsg) {
|
||||
m_hMsg = hMsg;
|
||||
}
|
||||
@@ -82,6 +86,13 @@ public class DcMsg {
|
||||
public native String getSetupCodeBegin();
|
||||
public native boolean isIncreation();
|
||||
|
||||
public native void setType(int type);
|
||||
public native void setText(String text);
|
||||
public native void setFile(String file, String filemime);
|
||||
public native void setDimension(int width, int height);
|
||||
public native void setDuration(int duration);
|
||||
public native void setMediainfo(String author, String trackname);
|
||||
|
||||
// working with raw c-data
|
||||
private long m_hMsg; // must not be renamed as referenced by JNI
|
||||
private native static void DcMsgUnref(long hMsg);
|
||||
|
||||
Reference in New Issue
Block a user