From dde2e3009f285733b29c48370b3b6ec52270c531 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 14 Nov 2017 14:08:14 +0100 Subject: [PATCH] Added API to create and store a fake LinphoneCallLog --- coreapi/call_log.c | 19 ++++++++++++++++++- coreapi/linphonecore_jni.cc | 12 ++++++++++++ include/linphone/call_log.h | 17 +++++++++++++++++ .../org/linphone/core/LinphoneCore.java | 6 ++++++ .../org/linphone/core/LinphoneCoreImpl.java | 8 ++++++++ 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/coreapi/call_log.c b/coreapi/call_log.c index 0dc3c5a83..542570cc3 100644 --- a/coreapi/call_log.c +++ b/coreapi/call_log.c @@ -168,6 +168,23 @@ bctbx_list_t * call_logs_read_from_config_file(LinphoneCore *lc){ * Public functions * ******************************************************************************/ +LinphoneCallLog *linphone_core_create_call_log(LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, LinphoneCallDir dir, + int duration, time_t start_time, time_t connected_time, LinphoneCallStatus status, bool_t video_enabled, float quality) { + LinphoneCallLog *log = linphone_call_log_new(dir, linphone_address_ref(from), linphone_address_ref(to)); + + log->duration = duration; + log->start_date_time = start_time; + set_call_log_date(log,log->start_date_time); + log->connected_date_time = connected_time; + log->status = status; + log->video_enabled = video_enabled; + log->quality = quality; + + linphone_core_store_call_log(lc, log); + + return log; +} + const char *linphone_call_log_get_call_id(const LinphoneCallLog *cl){ return cl->call_id; } @@ -317,7 +334,7 @@ LinphoneCallLog * linphone_call_log_new(LinphoneCallDir dir, LinphoneAddress *fr set_call_log_date(cl,cl->start_date_time); cl->from=from; - cl->to=to; + cl->to=to; cl->status=LinphoneCallAborted; /*default status*/ cl->quality=-1; diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 1ffaba727..6a0442a0f 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -8890,3 +8890,15 @@ extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getTlsKeyPath(JNIEnv return NULL; } } + +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createCallLog(JNIEnv *env, jobject, jlong jcore, jlong jfrom, jlong jto, jint jdir, jint duration, jlong start_time, jlong connected_time, jint jstatus, jboolean video_enabled, jfloat quality) { + LinphoneCore *core = (LinphoneCore*)jcore; + LinphoneAddress *from = (LinphoneAddress *)jfrom; + LinphoneAddress *to = (LinphoneAddress *)jto; + LinphoneCallDir dir = (LinphoneCallDir)jdir; + time_t start = (time_t) start_time; + time_t connected = (time_t) connected_time; + LinphoneCallStatus status = (LinphoneCallStatus)jstatus; + LinphoneCallLog *log = linphone_core_create_call_log(core, from, to, dir, duration, start, connected, status, video_enabled, quality); + return (jlong) log; +} diff --git a/include/linphone/call_log.h b/include/linphone/call_log.h index 4320cb72b..d1610c577 100644 --- a/include/linphone/call_log.h +++ b/include/linphone/call_log.h @@ -197,6 +197,23 @@ LINPHONE_PUBLIC LinphoneCallLog * linphone_call_log_ref(LinphoneCallLog *cl); **/ LINPHONE_PUBLIC void linphone_call_log_unref(LinphoneCallLog *cl); +/** + * Creates a fake LinphoneCallLog. + * @param[in] lc LinphoneCore object + * @param[in] from LinphoneAddress of caller + * @param[in] to LinphoneAddress of callee + * @param[in] dir LinphoneCallDir of call + * @param[in] duration call length in seconds + * @param[in] start_time timestamp of call start time + * @param[in] connected_time timestamp of call connection + * @param[in] status LinphoneCallStatus of call + * @param[in] video_enabled whether video was enabled or not for this call + * @param[in] quality call quality + * @return LinphoneCallLog object +**/ +LINPHONE_PUBLIC LinphoneCallLog *linphone_core_create_call_log(LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, LinphoneCallDir dir, + int duration, time_t start_time, time_t connected_time, LinphoneCallStatus status, bool_t video_enabled, float quality); + /******************************************************************************* * DEPRECATED * diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index db64a5c82..e1815f0e9 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -2549,4 +2549,10 @@ public interface LinphoneCore { * @return a new LinphoneFriend with the given address link with this LinphoneCore */ public LinphoneFriend createFriendWithAddress(String address); + + /** + * Creates and stores a fake LinphoneCallLog + * @return the LinphoneCallLog created and stored + */ + public LinphoneCallLog createCallLog(LinphoneAddress from, LinphoneAddress to, CallDirection dir, int duration, long start, long connected, LinphoneCallLog.CallStatus status, boolean videoEnabled, float quality); } diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index cd076e837..a72ef2aec 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -1824,4 +1824,12 @@ class LinphoneCoreImpl implements LinphoneCore { public LinphoneFriend createFriendWithAddress(String address) { return (LinphoneFriend) createFriendWithAddress(nativePtr, address); } + + private native long createCallLog(long ptr, long from, long to, int dir, int duration, long start, long connected, int status, boolean videoEnabled, float quality); + @Override + public LinphoneCallLog createCallLog(LinphoneAddress from, LinphoneAddress to, CallDirection dir, int duration, long start, long connected, LinphoneCallLog.CallStatus status, boolean videoEnabled, float quality) { + long logPtr = createCallLog(nativePtr, ((LinphoneAddressImpl) from).nativePtr, ((LinphoneAddressImpl) to).nativePtr, dir == CallDirection.Incoming ? 1 : 0, duration, start, connected, status.toInt(), videoEnabled, quality); + LinphoneCallLog log = new LinphoneCallLogImpl(logPtr); + return log; + } }