diff --git a/build/android/Android.mk b/build/android/Android.mk index 98a531789..60553ea53 100755 --- a/build/android/Android.mk +++ b/build/android/Android.mk @@ -259,7 +259,7 @@ ifeq ($(BUILD_SRTP),1) endif ifeq ($(BUILD_SQLITE),1) -LOCAL_CFLAGS += -DMSG_STORAGE_ENABLED +LOCAL_CFLAGS += -DMSG_STORAGE_ENABLED -DCALL_LOGS_STORAGE_ENABLED LOCAL_STATIC_LIBRARIES += liblinsqlite LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/../../externals/sqlite3/ diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index b3cbb37ee..433efcae4 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -1526,6 +1526,11 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNI ,jlong lc) { return (jint)ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc)); } +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getLastOutgoingCallLog( JNIEnv* env + ,jobject thiz + ,jlong lc) { + return (jlong)linphone_core_get_last_outgoing_call_log((LinphoneCore*)lc); +} extern "C" void Java_org_linphone_core_LinphoneCoreImpl_migrateCallLogs(JNIEnv* env ,jobject thiz @@ -2777,6 +2782,24 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* en return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr); } +extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getCallLogs(JNIEnv* env + ,jobject thiz + ,jlong lc) { + const MSList *logs = linphone_core_get_call_logs((LinphoneCore *) lc); + int logsCount = ms_list_size(logs); + jlongArray jLogs = env->NewLongArray(logsCount); + jlong *jInternalArray = env->GetLongArrayElements(jLogs, NULL); + + for (int i = 0; i < logsCount; i++) { + jInternalArray[i] = (unsigned long) (logs->data); + logs = logs->next; + } + + env->ReleaseLongArrayElements(jLogs, jInternalArray, 0); + + return jLogs; +} + extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env ,jobject thiz ,jlong ptr, jstring path) { diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 2a2c93766..f2ce0ccab 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -746,6 +746,11 @@ public interface LinphoneCore { */ public LinphoneCallLog[] getCallLogs(); + /** + * @return the latest outgoing call log. + */ + public LinphoneCallLog getLastOutgoingCallLog(); + /** * This method is called by the application to notify the Linphone core library when network is reachable. * Calling this method with true trigger Linphone to initiate a registration process for all proxy @@ -1885,6 +1890,12 @@ public interface LinphoneCore { */ public void setChatDatabasePath(String path); + /** + * Sets the path to the database where the logs will be stored (if enabled) + * @param path the database where the logs will be stored. + */ + public void setCallLogsDatabasePath(String path); + /** * Gets the chat rooms * @return an array of LinphoneChatRoom diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 67f019232..87842c78e 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -62,7 +62,9 @@ class LinphoneCoreImpl implements LinphoneCore { private native boolean isInComingInvitePending(long nativePtr); private native void acceptCall(long nativePtr, long call); private native long getCallLog(long nativePtr,int position); + native private long[] getCallLogs(long nativePtr); private native int getNumberOfCallLogs(long nativePtr); + private native long getLastOutgoingCallLog(long nativePtr); private native void delete(long nativePtr); private native void setNetworkStateReachable(long nativePtr,boolean isReachable); private native boolean isNetworkStateReachable(long nativePtr); @@ -209,7 +211,7 @@ class LinphoneCoreImpl implements LinphoneCore { WifiManager wifiManager=(WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); MulticastLock lock = wifiManager.createMulticastLock("linphonecore ["+ nativePtr+"] multicast-lock"); lock.setReferenceCounted(true); - setAndroidMulticastLock(nativePtr,lock); + setAndroidMulticastLock(nativePtr, lock); } } @@ -220,7 +222,7 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized void removeAuthInfo(LinphoneAuthInfo info) { isValid(); - removeAuthInfo(nativePtr,((LinphoneAuthInfoImpl)info).nativePtr); + removeAuthInfo(nativePtr, ((LinphoneAuthInfoImpl) info).nativePtr); } public synchronized LinphoneProxyConfig getDefaultProxyConfig() { @@ -285,16 +287,23 @@ class LinphoneCoreImpl implements LinphoneCore { } public synchronized void acceptCall(LinphoneCall aCall) { isValid(); - acceptCall(nativePtr,((LinphoneCallImpl)aCall).nativePtr); + acceptCall(nativePtr, ((LinphoneCallImpl) aCall).nativePtr); } public synchronized LinphoneCallLog[] getCallLogs() { - isValid(); - LinphoneCallLog[] logs = new LinphoneCallLog[getNumberOfCallLogs(nativePtr)]; - for (int i=0;i < getNumberOfCallLogs(nativePtr);i++) { - logs[i] = new LinphoneCallLogImpl(getCallLog(nativePtr, i)); + long[] typesPtr = getCallLogs(nativePtr); + if (typesPtr == null) return null; + isValid(); + LinphoneCallLog[] logs = new LinphoneCallLog[typesPtr.length]; + for (int i=0;i < logs.length; i++) { + logs[i] = new LinphoneCallLogImpl(typesPtr[i]); } return logs; } + public synchronized LinphoneCallLog getLastOutgoingCallLog(){ + isValid(); + long callLog = getLastOutgoingCallLog(nativePtr); + return new LinphoneCallLogImpl(callLog); + } public synchronized void destroy() { setAndroidPowerManager(null); delete(nativePtr);