linphone-LinphoneChatRoomImpl文件对应的JNI层文件分析
说明
这是个聊天内容的类, 这里还对sqlite3数据库进行了操作,已经文件的传输也在这里。
native函数
private native long createLinphoneChatMessage(long ptr, String message);
private native long getPeerAddress(long ptr);
private native void sendMessage(long ptr, String message);
private native void sendMessage2(long ptr, Object msg, long messagePtr, StateListener listener);
private native long[] getHistoryRange(long ptr, int begin, int end);
private native long[] getHistory(long ptr, int limit);
private native void destroy(long ptr);
private native int getUnreadMessagesCount(long ptr);
private native int getHistorySize(long ptr);
private native void deleteHistory(long ptr);
private native void compose(long ptr);
private native boolean isRemoteComposing(long ptr);
private native void markAsRead(long ptr);
private native void deleteMessage(long room, long message);
private native long createLinphoneChatMessage2(long ptr, String message,String url, int state, long timestamp, boolean isRead,boolean isIncoming);
private native void sendChatMessage(long ptr, Object message, long messagePtr);
private native Object getCore(long nativePtr);
private native long createFileTransferMessage(long ptr, String name, String type, String subtype, int size);
private native Object getCall(long nativePtr);
private native long getChar(long nativePtr);
createLinphoneChatMessage
extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env,jobject thiz,jlong ptr,jstring jmessage) {const char* message = env->GetStringUTFChars(jmessage, NULL);LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);env->ReleaseStringUTFChars(jmessage, message);return (jlong) chatMessage;
}
linphone_chat_room_create_message
submodules/linphone/coreapi/chat.c:LinphoneChatMessage *linphone_chat_room_create_message(LinphoneChatRoom *cr, const char *message) {
LinphoneChatMessage *linphone_chat_room_create_message(LinphoneChatRoom *cr, const char *message) {LinphoneChatMessage *msg = belle_sip_object_new(LinphoneChatMessage);msg->state = LinphoneChatMessageStateIdle;msg->callbacks = linphone_chat_message_cbs_new();msg->chat_room = (LinphoneChatRoom *)cr;msg->message = message ? ms_strdup(message) : NULL;msg->is_read = TRUE;msg->content_type = NULL; /* this property is used only when transfering file */msg->file_transfer_information = NULL; /* this property is used only when transfering file */msg->http_request = NULL;msg->time = ms_time(0);return msg;
}
LinphoneChatRoom
submodules/linphone/coreapi/private.h:struct _LinphoneChatRoom{
struct _LinphoneChatRoom{belle_sip_object_t base;void *user_data;struct _LinphoneCore *lc;char *peer;LinphoneAddress *peer_url;MSList *messages_hist;MSList *transient_messages;int unread_count;LinphoneIsComposingState remote_is_composing;LinphoneIsComposingState is_composing;belle_sip_source_t *remote_composing_refresh_timer;belle_sip_source_t *composing_idle_timer;belle_sip_source_t *composing_refresh_timer;LinphoneCall *call;LinphoneChatMessage *pending_message;MSList *received_rtt_characters;
};
linphone_chat_message_cbs_new
LinphoneChatMessageCbs *linphone_chat_message_cbs_new(void) {return belle_sip_object_new(LinphoneChatMessageCbs);
}
belle_sip_object_new
submodules/belle-sip/include/belle-sip/object.h:BELLESIP_EXPORT belle_sip_object_t * _belle_sip_object_new(size_t objsize, belle_sip_object_vptr_t *vptr);
submodules/belle-sip/include/belle-sip/object.h:#define belle_sip_object_new(_type) (_type*)_belle_sip_object_new(sizeof(_type),(belle_sip_object_vptr_t*)BELLE_SIP_OBJECT_GET_VPTR_FUNC(_type)())
getPeerAddress
extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env,jobject thiz,jlong ptr) {return (jlong) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr);
}
linphone_chat_message_get_peer_address
const LinphoneAddress *linphone_chat_message_get_peer_address(LinphoneChatMessage *msg) {return linphone_chat_room_get_peer_address(msg->chat_room);
}
linphone_chat_room_get_peer_address
const LinphoneAddress *linphone_chat_room_get_peer_address(LinphoneChatRoom *cr) {return cr->peer_url;
}
sendMessage
extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env,jobject thiz,jlong ptr,jstring jmessage) {const char* message = env->GetStringUTFChars(jmessage, NULL);linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message);env->ReleaseStringUTFChars(jmessage, message);
}
linphone_chat_room_send_message
void linphone_chat_room_send_message2(LinphoneChatRoom *cr, LinphoneChatMessage *msg,LinphoneChatMessageStateChangedCb status_cb, void *ud) {msg->message_state_changed_cb = status_cb;msg->message_state_changed_user_data = ud;_linphone_chat_room_send_message(cr, msg);
}
LinphoneChatMessageStateChangedCb
特像一个回调函数, 先不管他了, 这样吧。
_linphone_chat_room_send_message
oid _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg) {/*stubed rtt text*/if (cr->call && linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(cr->call))) {uint32_t new_line = 0x2028;linphone_chat_message_put_char(msg, new_line); // New Linelinphone_chat_message_set_state(msg, LinphoneChatMessageStateDelivered);linphone_chat_message_unref(msg);return;}msg->dir = LinphoneChatMessageOutgoing;// add to transient listcr->transient_messages = ms_list_append(cr->transient_messages, linphone_chat_message_ref(msg));/* Check if we shall upload a file to a server */if (msg->file_transfer_information != NULL && msg->content_type == NULL) {/* open a transaction with the server and send an empty request(RCS5.1 section 3.5.4.8.3.1) */linphone_chat_room_upload_file(msg);} else {SalOp *op = NULL;LinphoneCall *call;char *content_type;const char *identity = NULL;msg->time = ms_time(0);if (lp_config_get_int(cr->lc->config, "sip", "chat_use_call_dialogs", 0) != 0) {if ((call = linphone_core_get_call_by_remote_address(cr->lc, cr->peer)) != NULL) {if (call->state == LinphoneCallConnected || call->state == LinphoneCallStreamsRunning ||call->state == LinphoneCallPaused || call->state == LinphoneCallPausing ||call->state == LinphoneCallPausedByRemote) {ms_message("send SIP msg through the existing call.");op = call->op;identity = linphone_core_find_best_identity(cr->lc, linphone_call_get_remote_address(call));}}}if (op == NULL) {LinphoneProxyConfig *proxy = linphone_core_lookup_known_proxy(cr->lc, cr->peer_url);if (proxy) {identity = linphone_proxy_config_get_identity(proxy);} elseidentity = linphone_core_get_primary_contact(cr->lc);/*sending out of calls*/msg->op = op = sal_op_new(cr->lc->sal);linphone_configure_op(cr->lc, op, cr->peer_url, msg->custom_headers,lp_config_get_int(cr->lc->config, "sip", "chat_msg_with_contact", 0));sal_op_set_user_pointer(op, msg); /*if out of call, directly store msg*/}if (msg->external_body_url) {content_type = ms_strdup_printf("message/external-body; access-type=URL; URL=\"%s\"", msg->external_body_url);sal_message_send(op, identity, cr->peer, content_type, NULL, NULL);ms_free(content_type);} else {char *peer_uri = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));const char *content_type;if (linphone_chat_room_lime_enabled(cr)) {/* ref the msg or it may be destroyed by callback if the encryption failed */if (msg->content_type && strcmp(msg->content_type, "application/vnd.gsma.rcs-ft-http+xml") == 0) {/* it's a file transfer, content type shall be set toapplication/cipher.vnd.gsma.rcs-ft-http+xml*/content_type = "application/cipher.vnd.gsma.rcs-ft-http+xml";} else {content_type = "xml/cipher";}} else {content_type = msg->content_type;}if (content_type == NULL) {sal_text_send(op, identity, cr->peer, msg->message);} else {sal_message_send(op, identity, cr->peer, content_type, msg->message, peer_uri);}ms_free(peer_uri);}if (msg->from){/** BUG* the file transfer message constructor sets the from, but doesn't do it as well as here.*/linphone_address_destroy(msg->from);}msg->from = linphone_address_new(identity);msg->storage_id = linphone_chat_message_store(msg);if (cr->unread_count >= 0 && !msg->is_read)cr->unread_count++;if (cr->is_composing == LinphoneIsComposingActive) {cr->is_composing = LinphoneIsComposingIdle;}linphone_chat_room_delete_composing_idle_timer(cr);linphone_chat_room_delete_composing_refresh_timer(cr);}// if operation failed, we should not change message stateif (msg->dir == LinphoneChatMessageOutgoing) {linphone_chat_message_set_state(msg, LinphoneChatMessageStateInProgress);}
}
遇见这个么长的一串, 真的不知所错。
sendMessage2
extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env,jobject thiz,jlong chatroom_ptr,jobject message,jlong messagePtr,jobject jlistener) {jobject listener = env->NewGlobalRef(jlistener);message = env->NewGlobalRef(message);linphone_chat_message_ref((LinphoneChatMessage*)messagePtr);linphone_chat_message_set_user_data((LinphoneChatMessage*)messagePtr, message);linphone_chat_room_send_message2((LinphoneChatRoom*)chatroom_ptr, (LinphoneChatMessage*)messagePtr, chat_room_impl_callback, (void*)listener);
}
linphone_chat_message_set_user_data
void linphone_chat_message_set_user_data(LinphoneChatMessage *msg, void *ud) {msg->message_userdata = ud;
}
linphone_chat_room_send_message2
void linphone_chat_room_send_message2(LinphoneChatRoom *cr, LinphoneChatMessage *msg,LinphoneChatMessageStateChangedCb status_cb, void *ud) {msg->message_state_changed_cb = status_cb;msg->message_state_changed_user_data = ud;_linphone_chat_room_send_message(cr, msg);
}
getHistoryRange
extern "C" jlongArray Java_org_linphone_core_LinphoneChatRoomImpl_getHistoryRange(JNIEnv* env,jobject thiz,jlong ptr,jint start,jint end) {MSList* history = linphone_chat_room_get_history_range((LinphoneChatRoom*)ptr, start, end);return _LinphoneChatRoomImpl_getHistory(env, thiz, ptr, history);
}
_LinphoneChatRoomImpl_getHistory
submodules/linphone/coreapi/linphonecore_jni.cc:extern "C" jlongArray _LinphoneChatRoomImpl_getHistory(JNIEnv* env
getHistory
extern "C" jlongArray _LinphoneChatRoomImpl_getHistory(JNIEnv* env,jobject thiz,jlong ptr,MSList* history) {int historySize = ms_list_size(history);jlongArray jHistory = env->NewLongArray(historySize);jlong *jInternalArray = env->GetLongArrayElements(jHistory, NULL);for (int i = 0; i < historySize; i++) {jInternalArray[i] = (unsigned long) (history->data);history = history->next;}ms_list_free(history);env->ReleaseLongArrayElements(jHistory, jInternalArray, 0);return jHistory;
}
destroy
getUnreadMessagesCount
extern "C" jint Java_org_linphone_core_LinphoneChatRoomImpl_getUnreadMessagesCount(JNIEnv* env,jobject thiz,jlong ptr) {return (jint) linphone_chat_room_get_unread_messages_count((LinphoneChatRoom*)ptr);
}
linphone_chat_room_get_unread_messages_count
submodules/linphone/coreapi/linphonecore.h:LINPHONE_PUBLIC int linphone_chat_room_get_unread_messages_count(LinphoneChatRoom *cr);submodules/linphone/coreapi/message_storage.c:int linphone_chat_room_get_unread_messages_count(LinphoneChatRoom *cr){
int linphone_chat_room_get_unread_messages_count(LinphoneChatRoom *cr){return linphone_chat_room_get_messages_count(cr, TRUE);
}
linphone_chat_room_get_messages_count
static int linphone_chat_room_get_messages_count(LinphoneChatRoom *cr, bool_t unread_only){LinphoneCore *lc=linphone_chat_room_get_core(cr);int numrows=0;char *peer;char *buf;sqlite3_stmt *selectStatement;int returnValue;if (lc->db==NULL) return 0;// optimization: do not read database if the count is already available in memoryif(unread_only && cr->unread_count >= 0) return cr->unread_count;peer=linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));buf=sqlite3_mprintf("SELECT count(*) FROM history WHERE remoteContact = %Q %s;",peer,unread_only?"AND read = 0":"");returnValue = sqlite3_prepare_v2(lc->db,buf,-1,&selectStatement,NULL);if (returnValue == SQLITE_OK){if(sqlite3_step(selectStatement) == SQLITE_ROW){numrows= sqlite3_column_int(selectStatement, 0);}}sqlite3_finalize(selectStatement);sqlite3_free(buf);ms_free(peer);/* no need to test the sign of cr->unread_count here* because it has been tested above */if(unread_only) cr->unread_count = numrows;return numrows;
}
啊哈, 这里涉及到了sqlite3数据, 太高兴了, 但是怎么兴奋不起来呢。 看完了之后我表示有点看不懂, 也不是真的看不懂, 就是不习惯这样用sqlite3数据库。
getHistorySize
extern "C" jint Java_org_linphone_core_LinphoneChatRoomImpl_getHistorySize (JNIEnv* env,jobject thiz,jlong ptr) {return (jint) linphone_chat_room_get_history_size((LinphoneChatRoom*)ptr);
}
linphone_chat_room_get_history_size
int linphone_chat_room_get_history_size(LinphoneChatRoom *cr){return linphone_chat_room_get_messages_count(cr, FALSE);
}
linphone_chat_room_get_messages_count
static int linphone_chat_room_get_messages_count(LinphoneChatRoom *cr, bool_t unread_only){LinphoneCore *lc=linphone_chat_room_get_core(cr);int numrows=0;char *peer;char *buf;sqlite3_stmt *selectStatement;int returnValue;if (lc->db==NULL) return 0;// optimization: do not read database if the count is already available in memoryif(unread_only && cr->unread_count >= 0) return cr->unread_count;peer=linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));buf=sqlite3_mprintf("SELECT count(*) FROM history WHERE remoteContact = %Q %s;",peer,unread_only?"AND read = 0":"");returnValue = sqlite3_prepare_v2(lc->db,buf,-1,&selectStatement,NULL);if (returnValue == SQLITE_OK){if(sqlite3_step(selectStatement) == SQLITE_ROW){numrows= sqlite3_column_int(selectStatement, 0);}}sqlite3_finalize(selectStatement);sqlite3_free(buf);ms_free(peer);/* no need to test the sign of cr->unread_count here* because it has been tested above */if(unread_only) cr->unread_count = numrows;return numrows;
}
突然发现,我所看见的这几个函数都是关于sqlite3数据库的, 没有猜错的化, 这里就是专门进行数据库存储的。
deleteHistory
extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_deleteHistory(JNIEnv* env,jobject thiz,jlong ptr) {linphone_chat_room_delete_history((LinphoneChatRoom*)ptr);
}
linphone_chat_room_delete_history
void linphone_chat_room_delete_history(LinphoneChatRoom *cr){LinphoneCore *lc=cr->lc;char *peer;char *buf;if (lc->db==NULL) return ;peer=linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));buf=sqlite3_mprintf("DELETE FROM history WHERE remoteContact = %Q;",peer);linphone_sql_request(lc->db,buf);sqlite3_free(buf);ms_free(peer);if(cr->unread_count > 0) cr->unread_count = 0;
}
linphone_sql_request
int linphone_sql_request(sqlite3* db,const char *stmt){char* errmsg=NULL;int ret;ret=sqlite3_exec(db,stmt,NULL,NULL,&errmsg);if(ret != SQLITE_OK) {ms_error("linphone_sql_request: statement %s -> error sqlite3_exec(): %s.", stmt, errmsg);sqlite3_free(errmsg);}return ret;
}
compose
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneChatRoomImpl_compose(JNIEnv *env, jobject thiz, jlong ptr) {linphone_chat_room_compose((LinphoneChatRoom *)ptr);
}
linphone_chat_room_compose
void linphone_chat_room_compose(LinphoneChatRoom *cr) {int idle_timeout =lp_config_get_int(cr->lc->config, "sip", "composing_idle_timeout", COMPOSING_DEFAULT_IDLE_TIMEOUT);int refresh_timeout =lp_config_get_int(cr->lc->config, "sip", "composing_refresh_timeout", COMPOSING_DEFAULT_REFRESH_TIMEOUT);if (cr->is_composing == LinphoneIsComposingIdle) {cr->is_composing = LinphoneIsComposingActive;linphone_chat_room_send_is_composing_notification(cr);if (!cr->composing_refresh_timer) {cr->composing_refresh_timer = sal_create_timer(cr->lc->sal, linphone_chat_room_refresh_composing, cr,refresh_timeout * 1000, "composing refresh timeout");} else {belle_sip_source_set_timeout(cr->composing_refresh_timer, refresh_timeout * 1000);}if (!cr->composing_idle_timer) {cr->composing_idle_timer = sal_create_timer(cr->lc->sal, linphone_chat_room_stop_composing, cr,idle_timeout * 1000, "composing idle timeout");}}belle_sip_source_set_timeout(cr->composing_idle_timer, idle_timeout * 1000);
}
isRemoteComposing
JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneChatRoomImpl_isRemoteComposing(JNIEnv *env, jobject thiz, jlong ptr) {return (jboolean)linphone_chat_room_is_remote_composing((LinphoneChatRoom *)ptr);
}
linphone_chat_room_is_remote_composing
bool_t linphone_chat_room_is_remote_composing(const LinphoneChatRoom *cr) {return (cr->remote_is_composing == LinphoneIsComposingActive) ? TRUE : FALSE;
}
markAsRead
extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_markAsRead(JNIEnv* env,jobject thiz,jlong ptr) {linphone_chat_room_mark_as_read((LinphoneChatRoom*)ptr);
}
linphone_chat_room_mark_as_read
void linphone_chat_room_mark_as_read(LinphoneChatRoom *cr){LinphoneCore *lc=linphone_chat_room_get_core(cr);int read=1;char *peer;char *buf;if (lc->db==NULL) return ;// optimization: do not modify the database if no message is marked as unreadif(linphone_chat_room_get_unread_messages_count(cr) == 0) return;peer=linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));buf=sqlite3_mprintf("UPDATE history SET read=%i WHERE remoteContact = %Q;",read,peer);linphone_sql_request(lc->db,buf);sqlite3_free(buf);ms_free(peer);cr->unread_count = 0;
}
deleteMessage
extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_deleteMessage(JNIEnv* env,jobject thiz,jlong room,jlong msg) {linphone_chat_room_delete_message((LinphoneChatRoom*)room, (LinphoneChatMessage*)msg);
}
linphone_chat_room_delete_message
void linphone_chat_room_delete_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg) {LinphoneCore *lc=cr->lc;char *buf;if (lc->db==NULL) return ;buf=sqlite3_mprintf("DELETE FROM history WHERE id = %i;", msg->storage_id);linphone_sql_request(lc->db,buf);sqlite3_free(buf);/* Invalidate unread_count when we modify the database, so that nexttime we need it it will be recomputed from latest database state */cr->unread_count = -1;
}
linphone_chat_room_delete_message
void linphone_chat_room_delete_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg) {LinphoneCore *lc=cr->lc;char *buf;if (lc->db==NULL) return ;buf=sqlite3_mprintf("DELETE FROM history WHERE id = %i;", msg->storage_id);linphone_sql_request(lc->db,buf);sqlite3_free(buf);/* Invalidate unread_count when we modify the database, so that nexttime we need it it will be recomputed from latest database state */cr->unread_count = -1;
}
createLinphoneChatMessage2
extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage2(JNIEnv* env,jobject thiz,jlong ptr,jstring jmessage,jstring jurl,jint state,jlong time,jboolean read,jboolean incoming) {const char* message = jmessage?env->GetStringUTFChars(jmessage, NULL):NULL;const char* url = jurl?env->GetStringUTFChars(jurl, NULL):NULL;LinphoneChatMessage *chatMessage = linphone_chat_room_create_message_2((LinphoneChatRoom *)ptr, message, url, (LinphoneChatMessageState)state,(time_t)time, read, incoming);if (jmessage != NULL)env->ReleaseStringUTFChars(jmessage, message);if (jurl != NULL)env->ReleaseStringUTFChars(jurl, url);return (jlong) chatMessage;
}
linphone_chat_room_create_message_2
LinphoneChatMessage *linphone_chat_room_create_message_2(LinphoneChatRoom *cr, const char *message,const char *external_body_url, LinphoneChatMessageState state,time_t time, bool_t is_read, bool_t is_incoming) {LinphoneChatMessage *msg = linphone_chat_room_create_message(cr, message);LinphoneCore *lc = linphone_chat_room_get_core(cr);msg->external_body_url = external_body_url ? ms_strdup(external_body_url) : NULL;msg->time = time;msg->is_read = is_read;linphone_chat_message_set_state(msg, state);if (is_incoming) {msg->dir = LinphoneChatMessageIncoming;linphone_chat_message_set_from(msg, linphone_chat_room_get_peer_address(cr));msg->to = linphone_address_new(linphone_core_get_identity(lc)); /*direct assignment*/} else {msg->dir = LinphoneChatMessageOutgoing;linphone_chat_message_set_to(msg, linphone_chat_room_get_peer_address(cr));msg->from = linphone_address_new(linphone_core_get_identity(lc));/*direct assignment*/}return msg;
}
sendChatMessage
extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendChatMessage(JNIEnv* env,jobject thiz,jlong chatroom_ptr,jobject message,jlong messagePtr) {message = env->NewGlobalRef(message);linphone_chat_message_ref((LinphoneChatMessage*)messagePtr);linphone_chat_message_set_user_data((LinphoneChatMessage*)messagePtr, message);linphone_chat_room_send_chat_message((LinphoneChatRoom*)chatroom_ptr, (LinphoneChatMessage*)messagePtr);
}
linphone_chat_message_ref
LinphoneChatMessage *linphone_chat_message_ref(LinphoneChatMessage *msg) {belle_sip_object_ref(msg);return msg;
}
linphone_chat_message_set_user_data
void linphone_chat_message_set_user_data(LinphoneChatMessage *msg, void *ud) {msg->message_userdata = ud;
}
linphone_chat_room_send_chat_message
void linphone_chat_room_send_chat_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg) {_linphone_chat_room_send_message(cr, msg);
}
getCore
JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneEventImpl_getCore(JNIEnv *env, jobject jobj, jlong evptr){LinphoneCore *lc=linphone_event_get_core((LinphoneEvent*)evptr);LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);jobject core = ljb->getCore();return core;
}
linphone_event_get_core
submodules/linphone/coreapi/event.h:LINPHONE_PUBLIC LinphoneCore *linphone_event_get_core(const LinphoneEvent *lev);
submodules/linphone/coreapi/event.c:LinphoneCore *linphone_event_get_core(const LinphoneEvent *lev){
linphone_core_get_user_data
submodules/linphone/coreapi/linphonecore.h:LINPHONE_PUBLIC void *linphone_core_get_user_data(const LinphoneCore *lc);
submodules/linphone/coreapi/linphonecore.c:void *linphone_core_get_user_data(const LinphoneCore *lc){
createFileTransferMessage
extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createFileTransferMessage(JNIEnv* env, jobject thiz, jlong ptr, jstring jname, jstring jtype, jstring jsubtype, jint data_size) {LinphoneCore *lc = linphone_chat_room_get_core((LinphoneChatRoom*) ptr);LinphoneContent * content = linphone_core_create_content(lc);LinphoneChatMessage *message = NULL;const char *tmp;linphone_content_set_type(content, tmp = env->GetStringUTFChars(jtype, NULL));env->ReleaseStringUTFChars(jtype, tmp);linphone_content_set_subtype(content, tmp = env->GetStringUTFChars(jsubtype, NULL));env->ReleaseStringUTFChars(jsubtype, tmp);linphone_content_set_name(content, tmp = env->GetStringUTFChars(jname, NULL));env->ReleaseStringUTFChars(jname, tmp);linphone_content_set_size(content, data_size);message = linphone_chat_room_create_file_transfer_message((LinphoneChatRoom *)ptr, content);linphone_content_unref(content);return (jlong) message;
}
linphone_chat_room_create_file_transfer_message
submodules/linphone/coreapi/linphonecore.h:LINPHONE_PUBLIC LinphoneChatMessage* linphone_chat_room_create_file_transfer_message(LinphoneChatRoom *cr, const LinphoneContent* initial_content);
submodules/linphone/coreapi/chat_file_transfer.c:LinphoneChatMessage *linphone_chat_room_create_file_transfer_message(LinphoneChatRoom *cr,
LinphoneChatMessage *linphone_chat_room_create_file_transfer_message(LinphoneChatRoom *cr,const LinphoneContent *initial_content) {LinphoneChatMessage *msg = belle_sip_object_new(LinphoneChatMessage);msg->callbacks = linphone_chat_message_cbs_new();msg->chat_room = (LinphoneChatRoom *)cr;msg->message = NULL;msg->is_read = TRUE;msg->file_transfer_information = linphone_content_copy(initial_content);msg->dir = LinphoneChatMessageOutgoing;linphone_chat_message_set_to(msg, linphone_chat_room_get_peer_address(cr));msg->from = linphone_address_new(linphone_core_get_identity(cr->lc)); /*direct assignment*//* this will be set to application/vnd.gsma.rcs-ft-http+xml when we will transfer the xml reply from server to the peers */msg->content_type = NULL;/* this will store the http request during file upload to the server */msg->http_request = NULL;msg->time = ms_time(0);return msg;
}
getCall
extern "C" jobject Java_org_linphone_core_LinphoneChatRoomImpl_getCall(JNIEnv* env ,jobject thiz, jlong ptr) {return getCall(env, linphone_chat_room_get_call((LinphoneChatRoom *)ptr));
}
jobject getCall(JNIEnv *env, LinphoneCall *call){jobject jobj=0;if (call!=NULL){LinphoneCore *lc = linphone_call_get_core(call);LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);void *up=linphone_call_get_user_pointer(call);if (up==NULL){jobj=env->NewObject(ljb->callClass, ljb->callCtrId, (jlong)call);jobj=env->NewGlobalRef(jobj);linphone_call_set_user_pointer(call,(void*)jobj);linphone_call_ref(call);}else{jobj=(jobject)up;}}return jobj;
}
linphone_call_get_user_pointer
submodules/linphone/coreapi/linphonecore.h:#define linphone_call_get_user_pointer(call) linphone_call_get_user_data(call)
getChar
extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_getChar(JNIEnv* env ,jobject thiz, jlong ptr) {return linphone_chat_room_get_char((LinphoneChatRoom *)ptr);
}
linphone_chat_room_get_char
uint32_t linphone_chat_room_get_char(const LinphoneChatRoom *cr) {if (cr && cr->received_rtt_characters) {MSList *characters = cr->received_rtt_characters;while (characters != NULL) {LinphoneChatMessageCharacter *cmc = (LinphoneChatMessageCharacter *)characters->data;if (!cmc->has_been_read) {cmc->has_been_read = TRUE;return cmc->value;}characters = ms_list_next(characters);}}return 0;
}
linphone-LinphoneChatRoomImpl文件对应的JNI层文件分析相关推荐
- linphone-LinphoneAddressImpl文件对应的JNI层文件分析
说明 本篇是java及对应的c语言的分析的第一篇,旨在通过每一个文件对jni层部分的主要逻辑进行分析. UML类图 newLinphoneAddressImpl函数分析 /** *@params ur ...
- linphone-LinphoneCallLogImpl文件对应的JNI层文件分析
说明 本篇所有的功能全部围绕着LinphoneCallLog 展开. 疑惑 这里只是取得里面的值, 但是什么时候设置的值就不得而知了. 估计是接电话的时候创建的值吧. native函数 private ...
- javah生成JNI头文件
Administrator@ibm /cygdrive/z/workspace/com.example.hellojni.hellojni/src <---- 从此文件夹执行 javah *** ...
- java jni调用dll文件_Java通过jni调用动态链接库
(1)JNI简介 JNI是Java Native Interface的缩写,它提供了若干的API实现了Java和其他语言的通信(主要是C&C++).从Java1.1开始,JNI标准成为java ...
- 【Android NDK 开发】Visual Studio 2019 使用 CMake 开发 JNI 动态库 ( 动态库编译配置 | JNI 头文件导入 | JNI 方法命名规范 )
文章目录 I . JNI 与 NDK 区别 II . Visual Studio 编译动态库 III. 配置 导入 jni.h 头文件 IV . IntelliJ IDEA Community Edi ...
- 文件签名魔塔50层android反编译破解
发一下牢骚和主题无关: 缘由:该游戏作者有点可爱,原来就是拿别人的游戏,还在游戏中参加积分的轨制,打到20层后,需要积分.看不惯,就把它破解了,打到20层后,直接跳过要积分进程. 本文不提供破解后的安 ...
- AndroidStudio快速生成JNI头文件
依次打开Settings-->Tools-->External Tools-->点击加号创建一个快速生成jni头文件的工具 Program: javah Parameters: -v ...
- ida导入jni头文件_IDA导入Jni.h
IDA 分析Android so 文件时,因为缺少JNIEnv结构定义,反编译后看起来很不友好,如下图(后面注释是我自己手工对照加的 = =).为避免以后无穷无尽的手动加注,接下来我们就来导入 JNI ...
- ida导入jni头文件_IDA动态调试无法导入JNI文件的解决办法
前言:学习过程中遇到了,特此记录一下. 样本app链接在这里: https://pan.baidu.com/s/1pVLBBuBKRzDzHlBClrBA2A 提取码: 9tz8 它是 2015年阿里 ...
最新文章
- python 调用函数内部参数
- 计算机操作员考评标准,计算机操作员职业技能鉴定标准.doc
- jsp 如何动态给图片赋值_在Excel表格中你知道如何动态引用图片吗?
- CSS从大图中抠取小图完整教程(background-position应用)【转】
- IDEA(2018)连接MySQL数据库失败的解决方法(报错08001)
- mysql的max case_MySQL -- 行转列 -- GROUP_CONCAT -- MAX(CASE WHEN THEN)
- [转载] 用Python进行简单的文本相似度分析
- oracle 10g dg参数配置,Windows平台之Oracle10g DG配置
- python运维都做些什么,Python运维工程师主要做什么?岗位职责!
- Django城市信息查询功能(3)
- 遗传算法求解立体仓库货位优化
- UltraEdit+UE注册机并运行Java程序
- python计算偏态、极差、方差、标准差、平均数、中位数、众数
- Aurora使用技巧详解
- 苹果ll是什么版本_苹果12系列手机收到货如何验货?
- 土法炼钢:服务器定时汇报IP地址给我
- 2019 ICPC 上海站网络赛 K.Peekaboo (圆上整点)
- 免费高清录直播的软件分享
- docker pull redis 镜像
- Hadoop3.X环境配置