void linphone_core_store_call_log(LinphoneCore *lc, LinphoneCallLog *log) { if (lc && lc->logs_db){ char *from, *to; char *buf; from = linphone_address_as_string(log->from); to = linphone_address_as_string(log->to); buf = sqlite3_mprintf("INSERT INTO call_history VALUES(NULL,%Q,%Q,%i,%i,%lld,%lld,%i,%i,%f,%Q,%Q);", from, to, log->dir, log->duration, (int64_t)log->start_date_time, (int64_t)log->connected_date_time, log->status, log->video_enabled ? 1 : 0, log->quality, log->call_id, log->refkey ); linphone_sql_request_generic(lc->logs_db, buf); sqlite3_free(buf); ms_free(from); ms_free(to); log->storage_id = (unsigned int)sqlite3_last_insert_rowid(lc->logs_db); } if (lc) { lc->call_logs = bctbx_list_prepend(lc->call_logs, linphone_call_log_ref(log)); } }
bctbx_list_t* bctbx_list_insert(bctbx_list_t* list, bctbx_list_t* before, void *data) { bctbx_list_t* elem; if (list==NULL || before==NULL) return bctbx_list_append(list,data); for(elem=list; elem!=NULL; elem=bctbx_list_next(elem)) { if (elem==before) { if (elem->prev==NULL) return bctbx_list_prepend(list,data); else { bctbx_list_t* nelem=bctbx_list_new(data); nelem->prev=elem->prev; nelem->next=elem; elem->prev->next=nelem; elem->prev=nelem; } } } return list; }
static void print_graph(MSFilter *f, MSTicker *s, bctbx_list_t **unschedulable, bool_t force_schedule){ int i; MSQueue *l; if (f->last_tick!=s->ticks ){ if (filter_can_process(f,s->ticks) || force_schedule) { /* this is a candidate */ f->last_tick=s->ticks; ms_message("print_graphs: %s", f->desc->name); /* now recurse to next filters */ for(i=0;i<f->desc->noutputs;i++){ l=f->outputs[i]; if (l!=NULL){ print_graph(l->next.filter,s,unschedulable, force_schedule); } } }else{ /* this filter has not all inputs that have been filled by filters before it. */ *unschedulable=bctbx_list_prepend(*unschedulable,f); } } }
/* DB layout: * | 0 | storage_id * | 1 | localContact * | 2 | remoteContact * | 3 | direction flag * | 4 | message * | 5 | time (unused now, used to be string-based timestamp) * | 6 | read flag * | 7 | status * | 8 | external body url * | 9 | utc timestamp * | 10 | app data text * | 11 | linphone content id */ static int create_chat_message(void *data, int argc, char **argv, char **colName){ LinphoneChatRoom *cr = (LinphoneChatRoom *)data; unsigned int storage_id = (unsigned int)atoi(argv[0]); // check if the message exists in the transient list, in which case we should return that one. LinphoneChatMessage* new_message = get_transient_message(cr, storage_id); if( new_message == NULL ){ LinphoneAddress *local_addr=linphone_address_new(argv[1]); new_message = linphone_chat_room_create_message(cr, argv[4]); if(atoi(argv[3])==LinphoneChatMessageIncoming){ new_message->dir=LinphoneChatMessageIncoming; linphone_chat_message_set_from(new_message,linphone_chat_room_get_peer_address(cr)); new_message->to = local_addr; /*direct assignation to avoid a copy*/ } else { new_message->dir=LinphoneChatMessageOutgoing; new_message->from = local_addr; /*direct assignation to avoid a copy*/ linphone_chat_message_set_to(new_message,linphone_chat_room_get_peer_address(cr)); } new_message->time = (time_t)atol(argv[9]); new_message->is_read=atoi(argv[6]); new_message->state=atoi(argv[7]); new_message->storage_id=storage_id; new_message->external_body_url= ms_strdup(argv[8]); new_message->appdata = ms_strdup(argv[10]); if (argv[11] != NULL) { int id = atoi(argv[11]); if (id >= 0) { fetch_content_from_database(cr->lc->db, new_message, id); } } } cr->messages_hist=bctbx_list_prepend(cr->messages_hist,new_message); return 0; }