Commit 1caa2d8d authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Add reference count handling to LinphoneCallLog objects.

parent 34c945f2
......@@ -235,32 +235,38 @@ bool_t linphone_call_log_video_enabled(LinphoneCallLog *cl) {
* Reference and user data handling functions *
******************************************************************************/
void *linphone_call_log_get_user_data(const LinphoneCallLog *cl){
return cl->user_pointer;
void *linphone_call_log_get_user_data(const LinphoneCallLog *cl) {
return cl->user_data;
}
void linphone_call_log_set_user_data(LinphoneCallLog *cl, void *ud){
cl->user_pointer=ud;
void linphone_call_log_set_user_data(LinphoneCallLog *cl, void *ud) {
cl->user_data = ud;
}
LinphoneCallLog * linphone_call_log_ref(LinphoneCallLog *cl) {
belle_sip_object_ref(cl);
return cl;
}
void linphone_call_log_unref(LinphoneCallLog *cl) {
belle_sip_object_unref(cl);
}
/*******************************************************************************
* Constructor and destructor functions *
******************************************************************************/
void linphone_call_log_destroy(LinphoneCallLog *cl){
static void _linphone_call_log_destroy(LinphoneCallLog *cl){
if (cl->from!=NULL) linphone_address_destroy(cl->from);
if (cl->to!=NULL) linphone_address_destroy(cl->to);
if (cl->refkey!=NULL) ms_free(cl->refkey);
if (cl->call_id) ms_free(cl->call_id);
if (cl->reporting.reports[LINPHONE_CALL_STATS_AUDIO]!=NULL) linphone_reporting_destroy(cl->reporting.reports[LINPHONE_CALL_STATS_AUDIO]);
if (cl->reporting.reports[LINPHONE_CALL_STATS_VIDEO]!=NULL) linphone_reporting_destroy(cl->reporting.reports[LINPHONE_CALL_STATS_VIDEO]);
ms_free(cl);
}
LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *from, LinphoneAddress *to){
LinphoneCallLog *cl=ms_new0(LinphoneCallLog,1);
LinphoneCallLog *cl=belle_sip_object_new(LinphoneCallLog);
cl->dir=call->dir;
cl->start_date_time=time(NULL);
set_call_log_date(cl,cl->start_date_time);
......@@ -273,3 +279,17 @@ LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *fro
cl->reporting.reports[LINPHONE_CALL_STATS_VIDEO]=linphone_reporting_new();
return cl;
}
/* DEPRECATED */
void linphone_call_log_destroy(LinphoneCallLog *cl) {
belle_sip_object_unref(cl);
}
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneCallLog);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneCallLog, belle_sip_object_t,
(belle_sip_object_destroy_t)linphone_call_log_destroy,
NULL, // clone
NULL, // marshal
FALSE
);
......@@ -198,6 +198,19 @@ LINPHONE_PUBLIC void *linphone_call_log_get_user_data(const LinphoneCallLog *cl)
**/
LINPHONE_PUBLIC void linphone_call_log_set_user_data(LinphoneCallLog *cl, void *ud);
/**
* Acquire a reference to the call log.
* @param[in] cl LinphoneCallLog object
* @return The same LinphoneCallLog object
**/
LINPHONE_PUBLIC LinphoneCallLog * linphone_call_log_ref(LinphoneCallLog *cl);
/**
* Release a reference to the call log.
* @param[in] cl LinphoneCallLog object
**/
LINPHONE_PUBLIC void linphone_call_log_unref(LinphoneCallLog *cl);
/*******************************************************************************
* DEPRECATED *
......@@ -215,6 +228,13 @@ LINPHONE_PUBLIC void linphone_call_log_set_user_data(LinphoneCallLog *cl, void *
/** @deprecated Use linphone_call_log_get_user_data() instead. */
#define linphone_call_log_get_user_pointer(cl) linphone_call_log_get_user_data(cl)
/**
* Destroy a LinphoneCallLog.
* @param cl LinphoneCallLog object
* @deprecated Use linphone_call_log_unref() instead.
*/
LINPHONE_PUBLIC void linphone_call_log_destroy(LinphoneCallLog *cl);
/**
* @}
......
......@@ -111,6 +111,8 @@ struct _LinphoneQualityReporting{
};
struct _LinphoneCallLog{
belle_sip_object_t base;
void *user_data;
struct _LinphoneCore *lc;
LinphoneCallDir dir; /**< The direction of the call*/
LinphoneCallStatus status; /**< The status of the call*/
......@@ -119,18 +121,17 @@ struct _LinphoneCallLog{
char start_date[128]; /**<Human readable string containing the start date*/
int duration; /**<Duration of the call in seconds*/
char *refkey;
void *user_pointer;
rtp_stats_t local_stats;
rtp_stats_t remote_stats;
float quality;
time_t start_date_time; /**Start date of the call in seconds as expressed in a time_t */
char* call_id; /**unique id of a call*/
struct _LinphoneQualityReporting reporting;
bool_t video_enabled;
};
BELLE_SIP_DECLARE_VPTR(LinphoneCallLog);
typedef struct _CallCallbackObj
{
......@@ -922,14 +923,15 @@ const MSCryptoSuite * linphone_core_get_srtp_crypto_suites(LinphoneCore *lc);
*/
BELLE_SIP_DECLARE_TYPES_BEGIN(linphone,10000)
BELLE_SIP_TYPE_ID(LinphoneContactSearch),
BELLE_SIP_TYPE_ID(LinphoneContactProvider),
BELLE_SIP_TYPE_ID(LinphoneLDAPContactProvider),
BELLE_SIP_TYPE_ID(LinphoneLDAPContactSearch),
BELLE_SIP_TYPE_ID(LinphoneContactSearch),
BELLE_SIP_TYPE_ID(LinphoneCall),
BELLE_SIP_TYPE_ID(LinphoneCallLog),
BELLE_SIP_TYPE_ID(LinphoneChatMessage),
BELLE_SIP_TYPE_ID(LinphoneChatRoom),
BELLE_SIP_TYPE_ID(LinphoneProxyConfig),
BELLE_SIP_TYPE_ID(LinphoneCall)
BELLE_SIP_TYPE_ID(LinphoneLDAPContactProvider),
BELLE_SIP_TYPE_ID(LinphoneLDAPContactSearch),
BELLE_SIP_TYPE_ID(LinphoneProxyConfig)
BELLE_SIP_DECLARE_TYPES_END
......
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