Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#define _GNU_SOURCE
+
#include "linphonecore.h"
#include "sipsetup.h"
#include "lpconfig.h"
#endif /*_WIN32_WCE*/
}
-static void set_call_log_date(LinphoneCallLog *cl, const struct tm *loctime){
- my_strftime(cl->start_date,sizeof(cl->start_date),"%c",loctime);
-}
-
-LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *from, LinphoneAddress *to){
- LinphoneCallLog *cl=ms_new0(LinphoneCallLog,1);
+static void set_call_log_date(LinphoneCallLog *cl, time_t start_time){
struct tm loctime;
- cl->dir=call->dir;
#ifdef WIN32
#if !defined(_WIN32_WCE)
- loctime=*localtime(&call->start_time);
+ loctime=*localtime(&start_time);
/*FIXME*/
#endif /*_WIN32_WCE*/
#else
- localtime_r(&call->start_time,&loctime);
+ localtime_r(&start_time,&loctime);
#endif
- set_call_log_date(cl,&loctime);
+ my_strftime(cl->start_date,sizeof(cl->start_date),"%c",&loctime);
+}
+
+LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *from, LinphoneAddress *to){
+ LinphoneCallLog *cl=ms_new0(LinphoneCallLog,1);
+ cl->dir=call->dir;
+ cl->start_date_time=call->start_time;
+ set_call_log_date(cl,cl->start_date_time);
cl->from=from;
cl->to=to;
cl->status=LinphoneCallAborted; /*default status*/
for(i=0,elem=lc->call_logs;elem!=NULL;elem=elem->next,++i){
LinphoneCallLog *cl=(LinphoneCallLog*)elem->data;
snprintf(logsection,sizeof(logsection),"call_log_%i",i);
+ lp_config_clean_section(cfg,logsection);
lp_config_set_int(cfg,logsection,"dir",cl->dir);
lp_config_set_int(cfg,logsection,"status",cl->status);
tmp=linphone_address_as_string(cl->from);
tmp=linphone_address_as_string(cl->to);
lp_config_set_string(cfg,logsection,"to",tmp);
ms_free(tmp);
- lp_config_set_string(cfg,logsection,"start_date",cl->start_date);
+ lp_config_set_int64(cfg,logsection,"start_date_time",(int64_t)cl->start_date_time);
lp_config_set_int(cfg,logsection,"duration",cl->duration);
if (cl->refkey) lp_config_set_string(cfg,logsection,"refkey",cl->refkey);
lp_config_set_float(cfg,logsection,"quality",cl->quality);
}
}
+static time_t string_to_time(const char *date){
+ struct tm tmtime={0};
+ strptime(date,"%c",&tmtime);
+ return mktime(&tmtime);
+}
+
static void call_logs_read_from_config_file(LinphoneCore *lc){
char logsection[32];
int i;
const char *tmp;
+ uint64_t sec;
LpConfig *cfg=lc->config;
for(i=0;;++i){
snprintf(logsection,sizeof(logsection),"call_log_%i",i);
if (tmp) cl->from=linphone_address_new(tmp);
tmp=lp_config_get_string(cfg,logsection,"to",NULL);
if (tmp) cl->to=linphone_address_new(tmp);
- tmp=lp_config_get_string(cfg,logsection,"start_date",NULL);
- if (tmp) strncpy(cl->start_date,tmp,sizeof(cl->start_date));
+ sec=lp_config_get_int64(cfg,logsection,"start_date_time",0);
+ if (sec) {
+ /*new call log format with date expressed in seconds */
+ cl->start_date_time=(time_t)sec;
+ set_call_log_date(cl,cl->start_date_time);
+ }else{
+ tmp=lp_config_get_string(cfg,logsection,"start_date",NULL);
+ if (tmp) {
+ strncpy(cl->start_date,tmp,sizeof(cl->start_date));
+ cl->start_date_time=string_to_time(cl->start_date);
+ }
+ }
cl->duration=lp_config_get_int(cfg,logsection,"duration",0);
tmp=lp_config_get_string(cfg,logsection,"refkey",NULL);
if (tmp) cl->refkey=ms_strdup(tmp);
else return default_value;
}
+int64_t lp_config_get_int64(LpConfig *lpconfig,const char *section, const char *key, int64_t default_value){
+ const char *str=lp_config_get_string(lpconfig,section,key,NULL);
+ if (str!=NULL) {
+#ifdef WIN32
+ return (int64_t)_atoi64(str);
+#else
+ return atoll(str);
+#endif
+ }
+ else return default_value;
+}
+
float lp_config_get_float(LpConfig *lpconfig,const char *section, const char *key, float default_value){
const char *str=lp_config_get_string(lpconfig,section,key,NULL);
float ret=default_value;
lp_config_set_string(lpconfig,section,key,tmp);
}
+void lp_config_set_int64(LpConfig *lpconfig,const char *section, const char *key, int64_t value){
+ char tmp[30];
+ snprintf(tmp,sizeof(tmp),"%lli",(long long)value);
+ lp_config_set_string(lpconfig,section,key,tmp);
+}
+
+
void lp_config_set_float(LpConfig *lpconfig,const char *section, const char *key, float value){
char tmp[30];
snprintf(tmp,sizeof(tmp),"%f",value);
* The default integer value is returned if the config item isn't found.
**/
int lp_config_get_int(LpConfig *lpconfig,const char *section, const char *key, int default_value);
+
+/**
+ * Retrieves a configuration item as a 64 bit integer, given its section, key, and default value.
+ *
+ * @ingroup misc
+ * The default integer value is returned if the config item isn't found.
+**/
+int64_t lp_config_get_int64(LpConfig *lpconfig,const char *section, const char *key, int64_t default_value);
+
+
int lp_config_read_file(LpConfig *lpconfig, const char *filename);
/**
* Retrieves a configuration item as a float, given its section, key, and default value.
* @ingroup misc
**/
void lp_config_set_int(LpConfig *lpconfig,const char *section, const char *key, int value);
+/**
+ * Sets a 64 bits integer config item
+ *
+ * @ingroup misc
+**/
+void lp_config_set_int64(LpConfig *lpconfig,const char *section, const char *key, int64_t value);
+
/**
* Sets a float config item
*