Commit 47662ce9 authored by Margaux Clerc's avatar Margaux Clerc
Browse files

Add calllogs in database for android

parent edf07feb
......@@ -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/
......
......@@ -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) {
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment