Commit 6c2489ab authored by Ronan's avatar Ronan

feat(call): add a linphone_core_get_call_history_2 function to get call...

feat(call): add a linphone_core_get_call_history_2 function to get call history from peer/local addresses
parent 9c1e5d38
......@@ -668,6 +668,45 @@ bctbx_list_t * linphone_core_get_call_history_for_address(LinphoneCore *lc, cons
return clsres.result;
}
bctbx_list_t *linphone_core_get_call_history_2(
LinphoneCore *lc,
const LinphoneAddress *peer_addr,
const LinphoneAddress *local_addr
) {
char *buf;
char *peer_addr_str;
char *local_addr_str;
uint64_t begin, end;
CallLogStorageResult clsres;
if (!lc || !lc->logs_db || !peer_addr || !local_addr) return NULL;
peer_addr_str = bctbx_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(peer_addr)->asStringUriOnly().c_str());
local_addr_str = bctbx_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(local_addr)->asStringUriOnly().c_str());
buf = sqlite3_mprintf(
"SELECT * FROM call_history WHERE "
"(caller LIKE '%%%q%%' AND callee LIKE '%%%q%%' AND direction = 0) OR "
"(caller LIKE '%%%q%%' AND callee LIKE '%%%q%%' AND direction = 1) "
"ORDER BY id DESC",
local_addr_str,
peer_addr_str,
peer_addr_str,
local_addr_str
);
clsres.core = lc;
clsres.result = NULL;
begin = ortp_get_cur_time_ms();
linphone_sql_request_call_log(lc->logs_db, buf, &clsres);
end = ortp_get_cur_time_ms();
bctbx_message("%s(): completed in %i ms", __FUNCTION__, (int)(end - begin));
sqlite3_free(buf);
bctbx_free(peer_addr_str);
bctbx_free(local_addr_str);
return clsres.result;
}
LinphoneCallLog * linphone_core_get_last_outgoing_call_log(LinphoneCore *lc) {
char *buf;
uint64_t begin,end;
......
......@@ -3260,9 +3260,23 @@ LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_call_logs(LinphoneCore *l
* @param[in] lc #LinphoneCore object
* @param[in] addr #LinphoneAddress object
* @return \bctbx_list{LinphoneCallLog} \onTheFlyList
* @deprecated Use #linphone_core_get_call_history_2 instead. Deprecated since 2018-10-29.
**/
LINPHONE_PUBLIC bctbx_list_t * linphone_core_get_call_history_for_address(LinphoneCore *lc, const LinphoneAddress *addr);
/**
* Get the list of call logs (past calls).
* At the contrary of linphone_core_get_call_logs, it is your responsibility to unref the logs and free this list once you are done using it.
* @param[in] lc #LinphoneCore object.
* @param[in] peer_addr A #LinphoneAddress object.
* @return \bctbx_list{LinphoneCallLog} \onTheFlyList
**/
LINPHONE_PUBLIC bctbx_list_t *linphone_core_get_call_history_2(
LinphoneCore *lc,
const LinphoneAddress *peer_addr,
const LinphoneAddress *local_addr
);
/**
* Get the latest outgoing call log.
* @param[in] lc #LinphoneCore object
......
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