Commit b2a0cd77 authored by Ronan's avatar Ronan

fix(core): deal with new cpp flags

parent 8ae87e2f
......@@ -348,7 +348,7 @@ void linphone_account_creator_set_user_data(LinphoneAccountCreator *creator, voi
LinphoneAccountCreatorUsernameStatus linphone_account_creator_set_username(LinphoneAccountCreator *creator, const char *username) {
int min_length = lp_config_get_int(creator->core->config, "assistant", "username_min_length", -1);
int max_length = lp_config_get_int(creator->core->config, "assistant", "username_max_length", -1);
bool_t use_phone_number = lp_config_get_int(creator->core->config, "assistant", "use_phone_number", 0);
bool_t use_phone_number = !!lp_config_get_int(creator->core->config, "assistant", "use_phone_number", 0);
const char* regex = lp_config_get_string(creator->core->config, "assistant", "username_regex", 0);
if (!username) {
creator->username = NULL;
......
......@@ -219,7 +219,7 @@ void linphone_auth_info_destroy(LinphoneAuthInfo *obj){
void linphone_auth_info_write_config(LpConfig *config, LinphoneAuthInfo *obj, int pos) {
char key[50];
bool_t store_ha1_passwd = lp_config_get_int(config, "sip", "store_ha1_passwd", 1);
bool_t store_ha1_passwd = !!lp_config_get_int(config, "sip", "store_ha1_passwd", 1);
sprintf(key, "auth_info_%i", pos);
lp_config_clean_section(config, key);
......
......@@ -58,7 +58,7 @@ void sal_address_set_secure(SalAddress *addr, bool_t enabled){
bool_t sal_address_is_secure(const SalAddress *addr){
belle_sip_header_address_t* header_addr = BELLE_SIP_HEADER_ADDRESS(addr);
belle_sip_uri_t* uri = belle_sip_header_address_get_uri(header_addr);
if (uri) return belle_sip_uri_is_secure(uri);
if (uri) return !!belle_sip_uri_is_secure(uri);
return FALSE;
}
......@@ -199,7 +199,7 @@ void sal_address_set_param(SalAddress *addr,const char* name,const char* value){
bool_t sal_address_has_param(const SalAddress *addr, const char *name){
belle_sip_parameters_t* parameters = BELLE_SIP_PARAMETERS(addr);
return belle_sip_parameters_has_parameter(parameters, name);
return !!belle_sip_parameters_has_parameter(parameters, name);
}
const char * sal_address_get_param(const SalAddress *addr, const char *name) {
......@@ -224,7 +224,7 @@ void sal_address_set_uri_params(SalAddress *addr, const char *params){
bool_t sal_address_has_uri_param(const SalAddress *addr, const char *name){
belle_sip_parameters_t* parameters = BELLE_SIP_PARAMETERS(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(addr)));
return belle_sip_parameters_has_parameter(parameters, name);
return !!belle_sip_parameters_has_parameter(parameters, name);
}
const char * sal_address_get_uri_param(const SalAddress *addr, const char *name) {
......
......@@ -84,7 +84,7 @@ void sal_set_log_level(OrtpLogLevel level) {
if (((level&ORTP_DEBUG) != 0) || ((level&ORTP_TRACE) != 0)) {
belle_sip_level = BELLE_SIP_LOG_DEBUG;
}
belle_sip_set_log_level(belle_sip_level);
}
static BctbxLogFunc _belle_sip_log_handler = bctbx_logv_out;
......@@ -215,7 +215,7 @@ static void process_request_event(void *ud, const belle_sip_request_event_t *eve
if (dialog) {
op=(SalOp*)belle_sip_dialog_get_application_data(dialog);
if (op == NULL && strcmp("NOTIFY",method) == 0) {
/*special case for Dialog created by notify mathing subscribe*/
belle_sip_transaction_t * sub_trans = belle_sip_dialog_get_last_transaction(dialog);
......@@ -658,7 +658,7 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i
sal_address_set_domain(sal_addr,addr);
sal_address_set_port(sal_addr,port);
sal_address_set_transport(sal_addr,tr);
result = sal_add_listen_port(ctx, sal_addr, is_tunneled);
result = sal_add_listen_port(ctx, sal_addr, !!is_tunneled);
sal_address_destroy(sal_addr);
return result;
}
......@@ -986,7 +986,7 @@ const char *sal_custom_header_find(const SalCustomHeader *ch, const char *name){
SalCustomHeader *sal_custom_header_remove(SalCustomHeader *ch, const char *name) {
belle_sip_message_t *msg=(belle_sip_message_t*)ch;
if (msg==NULL) return NULL;
belle_sip_message_remove_header(msg, name);
return (SalCustomHeader*)msg;
}
......@@ -1066,9 +1066,9 @@ int sal_generate_uuid(char *uuid, size_t len) {
if (len==0) return -1;
/*create an UUID as described in RFC4122, 4.4 */
belle_sip_random_bytes((unsigned char*)&uuid_struct, sizeof(sal_uuid_t));
uuid_struct.clock_seq_hi_and_reserved&=~(1<<6);
uuid_struct.clock_seq_hi_and_reserved&=(unsigned char)~(1<<6);
uuid_struct.clock_seq_hi_and_reserved|=1<<7;
uuid_struct.time_hi_and_version&=~(0xf<<12);
uuid_struct.time_hi_and_version&=(short unsigned int)~(0xf<<12);
uuid_struct.time_hi_and_version|=4<<12;
written=snprintf(uuid,len,"%8.8x-%4.4x-%4.4x-%2.2x%2.2x-", uuid_struct.time_low, uuid_struct.time_mid,
......
......@@ -327,7 +327,7 @@ static void call_process_response(void *op_base, const belle_sip_response_event_
&& (header_content_type = belle_sip_message_get_header_by_type(req,belle_sip_header_content_type_t))
&& strcmp("application",belle_sip_header_content_type_get_type(header_content_type))==0
&& strcmp("media_control+xml",belle_sip_header_content_type_get_subtype(header_content_type))==0) {
unsigned int retry_in = (unsigned int)(1000*((float)rand()/RAND_MAX));
unsigned int retry_in = (unsigned int)(1000*((float)rand()/(float)RAND_MAX));
belle_sip_source_t *s=sal_create_timer(op->base.root,vfu_retry,sal_op_ref(op), retry_in, "vfu request retry");
ms_message("Rejected vfu request on op [%p], just retry in [%ui] ms",op,retry_in);
belle_sip_object_unref(s);
......
......@@ -150,25 +150,25 @@ static void add_rtcp_fb_attributes(belle_sdp_media_description_t *media_desc, co
/* Add trr-int if not set generally. */
if (general_trr_int != TRUE && trr_int != 0) {
add_rtcp_fb_trr_int_attribute(media_desc, payload_type_get_number(pt), avpf_params.trr_interval);
add_rtcp_fb_trr_int_attribute(media_desc, (int8_t)payload_type_get_number(pt), avpf_params.trr_interval);
}
/* Add rtcp-fb attributes according to the AVPF features of the payload types. */
if (avpf_params.features & PAYLOAD_TYPE_AVPF_PLI) {
add_rtcp_fb_nack_attribute(media_desc, payload_type_get_number(pt), BELLE_SDP_RTCP_FB_PLI);
add_rtcp_fb_nack_attribute(media_desc, (int8_t)payload_type_get_number(pt), BELLE_SDP_RTCP_FB_PLI);
}
if (avpf_params.features & PAYLOAD_TYPE_AVPF_SLI) {
add_rtcp_fb_nack_attribute(media_desc, payload_type_get_number(pt), BELLE_SDP_RTCP_FB_SLI);
add_rtcp_fb_nack_attribute(media_desc, (int8_t)payload_type_get_number(pt), BELLE_SDP_RTCP_FB_SLI);
}
if (avpf_params.features & PAYLOAD_TYPE_AVPF_RPSI) {
if (avpf_params.rpsi_compatibility == TRUE) {
add_rtcp_fb_nack_attribute(media_desc, payload_type_get_number(pt), BELLE_SDP_RTCP_FB_RPSI);
add_rtcp_fb_nack_attribute(media_desc, (int8_t)payload_type_get_number(pt), BELLE_SDP_RTCP_FB_RPSI);
} else {
add_rtcp_fb_ack_attribute(media_desc, payload_type_get_number(pt), BELLE_SDP_RTCP_FB_RPSI);
add_rtcp_fb_ack_attribute(media_desc, (int8_t)payload_type_get_number(pt), BELLE_SDP_RTCP_FB_RPSI);
}
}
if (avpf_params.features & PAYLOAD_TYPE_AVPF_FIR) {
add_rtcp_fb_ccm_attribute(media_desc, payload_type_get_number(pt), BELLE_SDP_RTCP_FB_FIR);
add_rtcp_fb_ccm_attribute(media_desc, (int8_t)payload_type_get_number(pt), BELLE_SDP_RTCP_FB_FIR);
}
}
}
......@@ -263,9 +263,9 @@ static void stream_description_to_sdp ( belle_sdp_session_description_t *session
if (ms_crypto_suite_to_name_params(stream->crypto[j].algo,&desc)==0){
if (desc.params)
snprintf ( buffer, sizeof ( buffer )-1, "%d %s inline:%s %s", stream->crypto[j].tag, desc.name, stream->crypto[j].master_key,desc.params);
else
else
snprintf ( buffer, sizeof ( buffer )-1, "%d %s inline:%s", stream->crypto[j].tag, desc.name, stream->crypto[j].master_key );
belle_sdp_media_description_add_attribute( media_desc,belle_sdp_attribute_create ("crypto", buffer));
}else break;
}
......@@ -314,11 +314,11 @@ static void stream_description_to_sdp ( belle_sdp_session_description_t *session
break;
}
if ( dir ) belle_sdp_media_description_add_attribute ( media_desc,belle_sdp_attribute_create ( dir,NULL ) );
if (stream->rtcp_mux){
belle_sdp_media_description_add_attribute(media_desc, belle_sdp_attribute_create ("rtcp-mux",NULL ) );
}
if (rtp_port != 0) {
different_rtp_and_rtcp_addr = (rtcp_addr[0] != '\0') && (strcmp(rtp_addr, rtcp_addr) != 0);
if ((rtcp_port != (rtp_port + 1)) || (different_rtp_and_rtcp_addr == TRUE)) {
......@@ -337,7 +337,7 @@ static void stream_description_to_sdp ( belle_sdp_session_description_t *session
belle_sdp_media_description_add_attribute(media_desc,belle_sdp_attribute_create ("ice-mismatch",NULL));
} else {
if (rtp_port != 0) {
if (stream->ice_pwd[0] != '\0')
if (stream->ice_pwd[0] != '\0')
belle_sdp_media_description_add_attribute(media_desc,belle_sdp_attribute_create ("ice-pwd",stream->ice_pwd));
if (stream->ice_ufrag[0] != '\0')
belle_sdp_media_description_add_attribute(media_desc,belle_sdp_attribute_create ("ice-ufrag",stream->ice_ufrag));
......@@ -432,7 +432,7 @@ belle_sdp_session_description_t * media_description_to_sdp ( const SalMediaDescr
if ( desc->bandwidth>0 ) {
belle_sdp_session_description_set_bandwidth ( session_desc,"AS",desc->bandwidth );
}
if (desc->set_nortpproxy == TRUE) belle_sdp_session_description_add_attribute(session_desc, belle_sdp_attribute_create("nortpproxy","yes"));
if (desc->ice_pwd[0] != '\0') belle_sdp_session_description_add_attribute(session_desc, belle_sdp_attribute_create("ice-pwd",desc->ice_pwd));
if (desc->ice_ufrag[0] != '\0') belle_sdp_session_description_add_attribute(session_desc, belle_sdp_attribute_create("ice-ufrag",desc->ice_ufrag));
......@@ -501,7 +501,7 @@ static void sdp_parse_media_crypto_parameters(belle_sdp_media_description_t *med
&stream->crypto[valid_count].tag,
tmp,
tmp2, parameters );
if ( nb >= 3 ) {
MSCryptoSuite cs;
MSCryptoSuiteNameParams np;
......@@ -651,7 +651,7 @@ static bool_t sdp_parse_rtcp_fb_parameters(belle_sdp_media_description_t *media_
PayloadType *pt;
int8_t pt_num;
bool_t retval = FALSE;
/* Handle rtcp-fb attributes that concern all payload types. */
for (it = belle_sdp_media_description_get_attributes(media_desc); it != NULL; it = it->next) {
attribute = BELLE_SDP_ATTRIBUTE(it->data);
......@@ -805,7 +805,7 @@ static SalStreamDescription * sdp_to_stream_description(SalMediaDescription *md,
}
stream->rtcp_mux = belle_sdp_media_description_get_attribute(media_desc, "rtcp-mux") != NULL;
/* Get media payload types */
sdp_parse_payload_types(media_desc, stream);
......@@ -857,7 +857,7 @@ static SalStreamDescription * sdp_to_stream_description(SalMediaDescription *md,
/* Get ICE candidate attributes if any */
sdp_parse_media_ice_parameters(media_desc, stream);
has_avpf_attributes = sdp_parse_rtcp_fb_parameters(media_desc, stream);
/* Get RTCP-FB attributes if any */
......@@ -892,7 +892,7 @@ int sdp_to_media_description ( belle_sdp_session_description_t *session_desc, S
const char* value;
SalDtlsRole session_role=SalDtlsRoleInvalid;
int i;
desc->nb_streams = 0;
desc->dir = SalStreamSendRecv;
......@@ -902,11 +902,11 @@ int sdp_to_media_description ( belle_sdp_session_description_t *session_desc, S
if ( (sname=belle_sdp_session_description_get_session_name(session_desc)) && belle_sdp_session_name_get_value(sname) ){
strncpy(desc->name,belle_sdp_session_name_get_value(sname),sizeof(desc->name) - 1);
}
if ( belle_sdp_session_description_get_bandwidth ( session_desc,"AS" ) >0 ) {
desc->bandwidth=belle_sdp_session_description_get_bandwidth ( session_desc,"AS" );
}
/*in some very rare case, session attribute may set stream dir*/
if ( belle_sdp_session_description_get_attribute ( session_desc,"sendrecv" ) ) {
desc->dir=SalStreamSendRecv;
......@@ -940,10 +940,10 @@ int sdp_to_media_description ( belle_sdp_session_description_t *session_desc, S
/* Get ICE remote ufrag and remote pwd, and ice_lite flag */
value=belle_sdp_session_description_get_attribute_value(session_desc,"ice-ufrag");
if (value) strncpy(desc->ice_ufrag, value, sizeof(desc->ice_ufrag) - 1);
value=belle_sdp_session_description_get_attribute_value(session_desc,"ice-pwd");
if (value) strncpy(desc->ice_pwd, value, sizeof(desc->ice_pwd)-1);
value=belle_sdp_session_description_get_attribute_value(session_desc,"ice-lite");
if (value) desc->ice_lite = TRUE;
......
......@@ -153,7 +153,7 @@ bctbx_list_t * call_logs_read_from_config_file(LinphoneCore *lc){
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);
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);
call_logs=bctbx_list_append(call_logs,cl);
......
......@@ -169,23 +169,25 @@ public:
LocalConference(LinphoneCore *core, LinphoneConference *conf, const Params *params = NULL);
virtual ~LocalConference();
virtual int inviteAddresses(const list<const LinphoneAddress*> &addresses, const LinphoneCallParams *params);
virtual int addParticipant(LinphoneCall *call);
virtual int removeParticipant(LinphoneCall *call);
virtual int removeParticipant(const LinphoneAddress *uri);
virtual int terminate();
virtual int enter();
virtual int leave();
virtual bool isIn() const {return m_localParticipantStream!=NULL;}
virtual int getSize() const;
virtual int inviteAddresses(const list<const LinphoneAddress*> &addresses, const LinphoneCallParams *params) override;
virtual int addParticipant(LinphoneCall *call) override;
virtual int removeParticipant(LinphoneCall *call) override;
virtual int removeParticipant(const LinphoneAddress *uri) override;
virtual int terminate() override;
virtual int enter() override;
virtual int leave() override;
virtual bool isIn() const override {
return m_localParticipantStream!=NULL;
}
virtual int getSize() const override;
virtual int startRecording(const char *path);
virtual int stopRecording();
virtual int startRecording(const char *path) override;
virtual int stopRecording() override;
virtual void onCallStreamStarting(LinphoneCall *call, bool isPausedByRemote);
virtual void onCallStreamStopping(LinphoneCall *call);
virtual void onCallTerminating(LinphoneCall *call);
virtual void onCallStreamStarting(LinphoneCall *call, bool isPausedByRemote) override;
virtual void onCallStreamStopping(LinphoneCall *call) override;
virtual void onCallTerminating(LinphoneCall *call) override;
private:
void addLocalEndpoint();
......@@ -207,18 +209,24 @@ public:
RemoteConference(LinphoneCore *core, LinphoneConference *conf, const Params *params = NULL);
virtual ~RemoteConference();
virtual int inviteAddresses(const list<const LinphoneAddress*> &addresses, const LinphoneCallParams *params);
virtual int addParticipant(LinphoneCall *call);
virtual int removeParticipant(LinphoneCall *call) {return -1;}
virtual int removeParticipant(const LinphoneAddress *uri);
virtual int terminate();
virtual int inviteAddresses(const list<const LinphoneAddress*> &addresses, const LinphoneCallParams *params) override;
virtual int addParticipant(LinphoneCall *call) override;
virtual int removeParticipant(LinphoneCall *call) override {
return -1;
}
virtual int removeParticipant(const LinphoneAddress *uri) override;
virtual int terminate() override;
virtual int enter();
virtual int leave();
virtual bool isIn() const;
virtual int enter() override;
virtual int leave() override;
virtual bool isIn() const override;
virtual int startRecording(const char *path) {return 0;}
virtual int stopRecording() {return 0;}
virtual int startRecording (const char *path) override {
return 0;
}
virtual int stopRecording() override {
return 0;
}
private:
bool focusIsReady() const;
......
......@@ -47,8 +47,8 @@ static void ecc_init_filters(EcCalibrator *ecc){
ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&ecc->rate);
ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_NCHANNELS,&channels);
ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_OUTPUT_NCHANNELS,&ecc_channels);
ecc->det=ms_factory_create_filter(ecc->factory, MS_TONE_DETECTOR_ID);
ms_filter_call_method(ecc->det,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ecc->rec=ms_factory_create_filter(ecc->factory, MS_VOID_SINK_ID);
......@@ -62,7 +62,7 @@ static void ecc_init_filters(EcCalibrator *ecc){
ms_filter_call_method(ecc->gen,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ecc->write_resampler=ms_factory_create_filter(ecc->factory, MS_RESAMPLE_ID);
ecc->sndwrite=ms_snd_card_create_writer(ecc->play_card);
ms_filter_call_method(ecc->sndwrite,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ms_filter_call_method(ecc->sndwrite,MS_FILTER_GET_SAMPLE_RATE,&rate);
ms_filter_call_method(ecc->sndwrite,MS_FILTER_SET_NCHANNELS,&ecc_channels);
......@@ -153,37 +153,37 @@ static void on_tone_received(void *data, MSFilter *f, unsigned int event_id, voi
static void ecc_play_tones(EcCalibrator *ecc){
MSDtmfGenCustomTone tone;
MSToneDetectorDef expected_tone;
memset(&tone,0,sizeof(tone));
memset(&expected_tone,0,sizeof(expected_tone));
ms_filter_add_notify_callback(ecc->det,on_tone_received,ecc,TRUE);
/* configure the tones to be scanned */
strncpy(expected_tone.tone_name,"freq1",sizeof(expected_tone.tone_name));
expected_tone.frequency=(int)2349.32;
expected_tone.min_duration=40;
expected_tone.min_amplitude=0.1f;
ms_filter_call_method (ecc->det,MS_TONE_DETECTOR_ADD_SCAN,&expected_tone);
strncpy(expected_tone.tone_name,"freq2",sizeof(expected_tone.tone_name));
expected_tone.frequency=(int)2637.02;
expected_tone.min_duration=40;
expected_tone.min_amplitude=0.1f;
ms_filter_call_method (ecc->det,MS_TONE_DETECTOR_ADD_SCAN,&expected_tone);
strncpy(expected_tone.tone_name,"freq3",sizeof(expected_tone.tone_name));
expected_tone.frequency=(int)2093;
expected_tone.min_duration=40;
expected_tone.min_amplitude=0.1f;
ms_filter_call_method (ecc->det,MS_TONE_DETECTOR_ADD_SCAN,&expected_tone);
/*play an initial tone to startup the audio playback/capture*/
tone.frequencies[0]=140;
tone.duration=1000;
tone.amplitude=0.5;
......@@ -192,23 +192,23 @@ static void ecc_play_tones(EcCalibrator *ecc){
ms_sleep(2);
ms_filter_add_notify_callback(ecc->gen,on_tone_sent,ecc,TRUE);
/* play the three tones*/
if (ecc->play_cool_tones){
strncpy(tone.tone_name, "D", sizeof(tone.tone_name));
tone.frequencies[0]=(int)2349.32;
tone.duration=100;
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
ms_usleep(300000);
strncpy(tone.tone_name, "E", sizeof(tone.tone_name));
tone.frequencies[0]=(int)2637.02;
tone.duration=100;
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
ms_usleep(300000);
strncpy(tone.tone_name, "C", sizeof(tone.tone_name));
tone.frequencies[0]=(int)2093;
tone.duration=100;
......@@ -220,20 +220,20 @@ static void ecc_play_tones(EcCalibrator *ecc){
tone.duration=100;
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
ms_usleep(300000);
strncpy(tone.tone_name, "D", sizeof(tone.tone_name));
tone.frequencies[0]=(int)2349.32;
tone.duration=100;
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
ms_usleep(300000);
strncpy(tone.tone_name, "E", sizeof(tone.tone_name));
tone.frequencies[0]=(int)2637.02;
tone.duration=100;
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
ms_usleep(300000);
}
/*these two next ones are for lyrism*/
if (ecc->play_cool_tones){
tone.tone_name[0]='\0';
......@@ -241,15 +241,15 @@ static void ecc_play_tones(EcCalibrator *ecc){
tone.duration=400;
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
ms_usleep(300000);
tone.tone_name[0]='\0';
tone.frequencies[0]=(int)1567.98;
tone.duration=400;
ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone);
}
ms_sleep(1);
if (ecc->freq1 && ecc->freq2 && ecc->freq3) {
int delay=(int)(ecc->acc/3);
if (delay<0){
......@@ -274,7 +274,7 @@ static void ecc_play_tones(EcCalibrator *ecc){
static void * ecc_thread(void *p){
EcCalibrator *ecc=(EcCalibrator*)p;
ecc_init_filters(ecc);
ecc_play_tones(ecc);
ecc_deinit_filters(ecc);
......@@ -320,8 +320,7 @@ int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibration
}
rate = lp_config_get_int(lc->config,"sound","echo_cancellation_rate",8000);
lc->ecc=ec_calibrator_new(lc->factory, lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard,rate,cb,audio_init_cb,audio_uninit_cb,cb_data);
lc->ecc->play_cool_tones = lp_config_get_int(lc->config, "sound", "ec_calibrator_cool_tones", 0);
lc->ecc->play_cool_tones = !!lp_config_get_int(lc->config, "sound", "ec_calibrator_cool_tones", 0);
ec_calibrator_start(lc->ecc);
return 0;
}
......@@ -291,7 +291,7 @@ static LinphoneEvent *_linphone_core_create_publish(LinphoneCore *core, Linphone
resource = linphone_proxy_config_get_identity_address(cfg);
lev = linphone_event_new(lc,LinphoneSubscriptionInvalidDir, event,expires);
linphone_configure_op_with_proxy(lc,lev->op,resource,NULL,lp_config_get_int(lc->config,"sip","publish_msg_with_contact",0),cfg);
linphone_configure_op_with_proxy(lc,lev->op,resource,NULL, !!lp_config_get_int(lc->config,"sip","publish_msg_with_contact",0),cfg);
sal_op_set_manual_refresher_mode(lev->op,!lp_config_get_int(lc->config,"sip","refresh_generic_publish",1));
return lev;
}
......
......@@ -889,7 +889,7 @@ void linphone_core_update_friends_subscriptions(LinphoneCore *lc) {
}
bool_t linphone_core_should_subscribe_friends_only_when_registered(const LinphoneCore *lc){
return lp_config_get_int(lc->config,"sip","subscribe_presence_only_when_registered",1);
return !!lp_config_get_int(lc->config,"sip","subscribe_presence_only_when_registered",1);
}
void linphone_core_send_initial_subscribes(LinphoneCore *lc) {
......@@ -1030,7 +1030,7 @@ LinphoneFriend * linphone_friend_new_from_config_file(LinphoneCore *lc, int inde
linphone_friend_set_inc_subscribe_policy(lf,__policy_str_to_enum(tmp));
}
a=lp_config_get_int(config,item,"subscribe",0);
linphone_friend_send_subscribe(lf,a);
linphone_friend_send_subscribe(lf,!!a);
a = lp_config_get_int(config, item, "presence_received", 0);
lf->presence_received = (bool_t)a;
......@@ -1156,7 +1156,7 @@ bool_t linphone_friend_create_vcard(LinphoneFriend *fr, const char *name) {
lc = fr->friend_list->lc;
}
if (lc) {
skip = 1 - lp_config_get_int(fr->lc->config, "misc", "store_friends", 1);
skip = !lp_config_get_int(fr->lc->config, "misc", "store_friends", 1);
linphone_vcard_set_skip_validation(vcard, skip);
}
linphone_vcard_set_full_name(vcard, name);
......@@ -1410,9 +1410,9 @@ static int create_friend(void *data, int argc, char **argv, char **colName) {
}
}
linphone_friend_set_inc_subscribe_policy(lf, static_cast<LinphoneSubscribePolicy>(atoi(argv[3])));
linphone_friend_send_subscribe(lf, atoi(argv[4]));
linphone_friend_send_subscribe(lf, !!atoi(argv[4]));
linphone_friend_set_ref_key(lf, ms_strdup(argv[5]));
lf->presence_received = atoi(argv[9]);
lf->presence_received = !!atoi(argv[9]);
lf->storage_id = storage_id;
*list = bctbx_list_append(*list, linphone_friend_ref(lf));
......
......@@ -144,7 +144,7 @@ int lime_getCachedSndKeysByURI(void *cachedb, limeURIKeys_t *associatedKeys) {
/* check validity */
bctbx_get_utc_cur_time(&currentTimeSpec);
if (validityTimeSpec.tv_sec == 0 || bctbx_timespec_compare(&currentTimeSpec, &validityTimeSpec)<0) {
associatedKeys->associatedZIDNumber +=1;
associatedKeys->associatedZIDNumber++;
/* extend array of pointer to limeKey_t structures to add the one we found */
associatedKeys->peerKeys = (limeKey_t **)bctbx_realloc(associatedKeys->peerKeys, (associatedKeys->associatedZIDNumber)*sizeof(limeKey_t *));
......@@ -257,14 +257,14 @@ int lime_setCachedKey(void *cachedb, limeKey_t *associatedKey, uint8_t role, uin
uint8_t *colValues[4];
uint8_t sessionIndex[4]; /* buffer to hold the uint32_t buffer index in big endian */
size_t colLength[] = {32, 32, 4, 8}; /* data length: keys and session ID : 32 bytes, Index: 4 bytes(uint32_t), validity : 8 bytes(UTC time as int64_t) */
int colNums;
uint8_t colNums;
if (cachedb == NULL || associatedKey == NULL) { /* there is no cache return error */
return LIME_INVALID_CACHE;
}
/* wrap values to be written */
sessionIndex[0] = (associatedKey->sessionIndex>>24)&0xFF;
sessionIndex[0] = (uint8_t)((associatedKey->sessionIndex>>24)&0xFF);
sessionIndex[1] = (associatedKey->sessionIndex>>16)&0xFF;
sessionIndex[2] = (associatedKey->sessionIndex>>8)&0xFF;
sessionIndex[3] = (associatedKey->sessionIndex)&0xFF;
......@@ -277,14 +277,14 @@ int lime_setCachedKey(void *cachedb, limeKey_t *associatedKey, uint8_t role, uin
bctbx_get_utc_cur_time(&currentTime);
bctbx_timespec_add(&currentTime, validityTimeSpan);
/* store the int64_t in big endian in the cache(cache is not typed, all data seen as blob) */
colValues[3][0] = (currentTime.tv_sec>>56)&0xFF;
colValues[3][1] = (currentTime.tv_sec>>48)&0xFF;
colValues[3][2] = (currentTime.tv_sec>>40)&0xFF;
colValues[3][3] = (currentTime.tv_sec>>32)&0xFF;
colValues[3][4] = (currentTime.tv_sec>>24)&0xFF;
colValues[3][5] = (currentTime.tv_sec>>16)&0xFF;
colValues[3][6] = (currentTime.tv_sec>>8)&0xFF;
colValues[3][7] = (currentTime.tv_sec)&0xFF;
colValues[3][0] = (uint8_t)((currentTime.tv_sec>>56)&0xFF);
colValues[3][1] = (uint8_t)((currentTime.tv_sec>>48)&0xFF);
colValues[3][2] = (uint8_t)((currentTime.tv_sec>>40)&0xFF);
colValues[3][3] = (uint8_t)((currentTime.tv_sec>>32)&0xFF);
colValues[3][4] = (uint8_t)((currentTime.tv_sec>>24)&0xFF);
colValues[3][5] = (uint8_t)((currentTime.tv_sec>>16)&0xFF);
colValues[3][6] = (uint8_t)((currentTime.tv_sec>>8)&0xFF);
colValues[3][7] = (uint8_t)((currentTime.tv_sec)&0xFF);
colNums = 4;
} else {
......@@ -292,7 +292,11 @@ int lime_setCachedKey(void *cachedb, limeKey_t *associatedKey, uint8_t role, uin
}
/* update cache */
return bzrtp_cache_write(cachedb, associatedKey->zuid, "lime", role==LIME_SENDER?colNamesSender:colNamesReceiver, colValues, colLength, colNums);
return bzrtp_cache_write(
cachedb, associatedKey->zuid, "lime",
role == LIME_SENDER ? colNamesSender : colNamesReceiver,
colValues, colLength, colNums
);
}
/**
......@@ -596,7 +600,7 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
/* retrieve selfZID from cache, and convert it to an Hexa buffer to easily match it against hex string containg in xml message as pzid */
if (bzrtp_getSelfZID(cachedb, selfURI, selfZid, NULL) != 0) {
ms_error("[LIME] Couldn't get self ZID");
ms_error("[LIME] Couldn't get self ZID");
return LIME_UNABLE_TO_DECRYPT_MESSAGE;
}
bctbx_int8_to_str(selfZidHex, selfZid, 12);
......@@ -606,13 +610,13 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
xmlSetGenericErrorFunc(xml_ctx, linphone_xmlparsing_genericxml_error);
xml_ctx->doc = xmlReadDoc((const unsigned char*)message, 0, NULL, 0);
if (xml_ctx->doc == NULL) {
ms_error("[LIME] XML doc is null");
ms_error("[LIME] XML doc is null");
retval = LIME_INVALID_ENCRYPTED_MESSAGE;
goto error;
}
if (linphone_create_xml_xpath_context(xml_ctx) < 0) {
ms_error("[LIME] Couldn't create xml xpath context");
ms_error("[LIME] Couldn't create xml xpath context");
retval = LIME_INVALID_ENCRYPTED_MESSAGE;
goto error;
}
......@@ -627,7 +631,7 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
/* Get the matching key from cache */
retval = lime_getCachedRcvKeyByZid(cachedb, &associatedKey, selfURI, peerURI);
if (retval != 0) {
ms_error("[LIME] Couldn't get cache rcv key by ZID");
ms_error("[LIME] Couldn't get cache rcv key by ZID");
goto error;
}
......@@ -636,7 +640,7 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
if ((msg_object != NULL) && (msg_object->nodesetval != NULL)) {
for (i = 1; i <= msg_object->nodesetval->nodeNr; i++) {
char *currentZidHex;
char *encryptedMessageb64;
char *encryptedContentTypeb64;
snprintf(xpath_str, sizeof(xpath_str), "/doc/msg[%i]/pzid", i);
......@@ -674,7 +678,7 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
/* do we have retrieved correctly all the needed data */
if (encryptedMessage == NULL) {
ms_error("[LIME] Encrypted message is null, something went wrong...");
ms_error("[LIME] Encrypted message is null, something went wrong...");
retval = LIME_UNABLE_TO_DECRYPT_MESSAGE;
goto error;
}
......@@ -684,7 +688,7 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
/* something wen't wrong with the cache, this shall never happen */
uint8_t associatedKeyIndexHex[9];
bctbx_uint32_to_str(associatedKeyIndexHex, associatedKey.sessionIndex);
ms_error("[LIME] Session index [%s] < associated key's session index [%s], should not happen !", sessionIndexHex, associatedKeyIndexHex);
ms_error("[LIME] Session index [%s] < associated key's session index [%s], should not happen !", sessionIndexHex, associatedKeyIndexHex);
ms_free(encryptedMessage);
retval = LIME_UNABLE_TO_DECRYPT_MESSAGE;
goto error;
......@@ -692,7 +696,7 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
if ((usedSessionIndex - associatedKey.sessionIndex > MAX_DERIVATION_NUMBER) ) {
/* we missed to many messages, ask for a cache reset via a ZRTP call */
ms_error("[LIME] Too many messages missed (%i), cache should be reset by ZRTP call", usedSessionIndex - associatedKey.sessionIndex);
ms_error("[LIME] Too many messages missed (%i), cache should be reset by ZRTP call", usedSessionIndex - associatedKey.sessionIndex);
ms_free(encryptedMessage);
retval = LIME_UNABLE_TO_DECRYPT_MESSAGE;
goto error;
......@@ -701,7 +705,7 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
if (associatedKey.sessionIndex != usedSessionIndex) {
uint8_t associatedKeyIndexHex[9];
bctbx_uint32_to_str(associatedKeyIndexHex, associatedKey.sessionIndex);
ms_warning("LIME] unexpected session index [%s] received from [%s] (expected [%s]), [%i] messages will be discarded",
ms_warning("LIME] unexpected session index [%s] received from [%s] (expected [%s]), [%i] messages will be discarded",
sessionIndexHex, peerURI, associatedKeyIndexHex, usedSessionIndex-associatedKey.sessionIndex);
}
......@@ -716,7 +720,7 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
if (retval != 0) {
ms_free(*output);
*output = NULL;
ms_error("[LIME] Couldn't decrypt message");
ms_error("[LIME] Couldn't decrypt message");
retval = LIME_UNABLE_TO_DECRYPT_MESSAGE;
goto error;
}
......@@ -729,7 +733,7 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
if (retval != 0) {
ms_free(*content_type);
*content_type = NULL;
ms_error("[LIME] Couldn't decrypt content type");
ms_error("[LIME] Couldn't decrypt content type");
retval = LIME_UNABLE_TO_DECRYPT_MESSAGE;
goto error;
}
......@@ -758,7 +762,7 @@ bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr) {
bool_t res;
limeURIKeys_t associatedKeys;
char *peer = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));
/* retrieve keys associated to the peer URI */
associatedKeys.peerURI = bctbx_strdup(peer);
associatedKeys.selfURI = NULL; /* TODO : there is no sender associated to chatroom so check for any local URI available, shall we add sender to chatroom? */
......@@ -798,7 +802,7 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn
}
peerUri = linphone_address_as_string_uri_only(msg->from);
selfUri = linphone_address_as_string_uri_only(msg->to);
retval = lime_decryptMultipartMessage(zrtp_cache_db, (uint8_t *)msg->message, selfUri, peerUri, &decrypted_body, &decrypted_content_type,
retval = lime_decryptMultipartMessage(zrtp_cache_db, (uint8_t *)msg->message, selfUri, peerUri, &decrypted_body, &decrypted_content_type,
bctbx_time_string_to_sec(lp_config_get_string(lc->config, "sip", "lime_key_validity", "0")));
ms_free(peerUri);
ms_free(selfUri);
......@@ -887,11 +891,11 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryptionEn