/* DB layout: * | 0 | storage_id * | 1 | from * | 2 | to * | 3 | direction flag * | 4 | duration * | 5 | start date time (time_t) * | 6 | connected date time (time_t) * | 7 | status * | 8 | video enabled (1 or 0) * | 9 | quality * | 10 | call_id * | 11 | refkey */ static int create_call_log(void *data, int argc, char **argv, char **colName) { MSList **list = (MSList **)data; LinphoneAddress *from; LinphoneAddress *to; LinphoneCallDir dir; LinphoneCallLog *log; unsigned int storage_id = atoi(argv[0]); from = linphone_address_new(argv[1]); to = linphone_address_new(argv[2]); dir = (LinphoneCallDir) atoi(argv[3]); log = linphone_call_log_new(dir, from, to); log->storage_id = storage_id; log->duration = atoi(argv[4]); log->start_date_time = (time_t)atol(argv[5]); log->connected_date_time = (time_t)atol(argv[6]); log->status = (LinphoneCallStatus) atoi(argv[7]); log->video_enabled = atoi(argv[8]) == 1; log->quality = atof(argv[9]); if (argc > 10) { if (argv[10] != NULL) { log->call_id = ms_strdup(argv[10]); } if (argv[10] != NULL) { log->refkey = ms_strdup(argv[11]); } } *list = ms_list_append(*list, log); return 0; }
static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from, LinphoneAddress *to){ int port_offset; call->refcnt=1; call->state=LinphoneCallIdle; call->start_time=time(NULL); call->media_start_time=0; call->log=linphone_call_log_new(call, from, to); call->owns_call_log=TRUE; linphone_core_notify_all_friends(call->core,LinphoneStatusOnThePhone); port_offset=find_port_offset (call->core); if (port_offset==-1) return; call->audio_port=linphone_core_get_audio_port(call->core)+port_offset; call->video_port=linphone_core_get_video_port(call->core)+port_offset; }
/* DB layout: * | 0 | storage_id * | 1 | from * | 2 | to * | 3 | direction flag * | 4 | duration * | 5 | start date time (time_t) * | 6 | connected date time (time_t) * | 7 | status * | 8 | video enabled (1 or 0) * | 9 | quality * | 10 | call_id * | 11 | refkey */ static int create_call_log(void *data, int argc, char **argv, char **colName) { bctbx_list_t **list = (bctbx_list_t **)data; LinphoneAddress *from; LinphoneAddress *to; LinphoneCallDir dir; LinphoneCallLog *log; unsigned int storage_id = (unsigned int)atoi(argv[0]); from = linphone_address_new(argv[1]); to = linphone_address_new(argv[2]); if (from == NULL || to == NULL) goto error; dir = (LinphoneCallDir) atoi(argv[3]); log = linphone_call_log_new(dir, from, to); log->storage_id = storage_id; log->duration = atoi(argv[4]); log->start_date_time = (time_t)atol(argv[5]); set_call_log_date(log,log->start_date_time); log->connected_date_time = (time_t)atol(argv[6]); log->status = (LinphoneCallStatus) atoi(argv[7]); log->video_enabled = atoi(argv[8]) == 1; log->quality = (float)atof(argv[9]); if (argc > 10) { if (argv[10] != NULL) { log->call_id = ms_strdup(argv[10]); } if (argv[10] != NULL) { log->refkey = ms_strdup(argv[11]); } } *list = bctbx_list_append(*list, log); return 0; error: if (from){ linphone_address_destroy(from); } if (to){ linphone_address_destroy(to); } ms_error("Bad call log at storage_id %u", storage_id); return 0; }
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 (lp_config_has_section(cfg,logsection)){ LinphoneCallLog *cl; LinphoneAddress *from=NULL,*to=NULL; tmp=lp_config_get_string(cfg,logsection,"from",NULL); if (tmp) from=linphone_address_new(tmp); tmp=lp_config_get_string(cfg,logsection,"to",NULL); if (tmp) to=linphone_address_new(tmp); if (!from || !to) continue; cl=linphone_call_log_new(lp_config_get_int(cfg,logsection,"dir",0),from,to); cl->status=lp_config_get_int(cfg,logsection,"status",0); 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); cl->quality=lp_config_get_float(cfg,logsection,"quality",-1); cl->video_enabled=lp_config_get_int(cfg,logsection,"video_enabled",0); tmp=lp_config_get_string(cfg,logsection,"call_id",NULL); if (tmp) cl->call_id=ms_strdup(tmp); lc->call_logs=ms_list_append(lc->call_logs,cl); }else break; } }