Commit 57948522 authored by Ghislain MARY's avatar Ghislain MARY

Remove C strings and bctoolbox lists where possible in the sal.

parent 044ad7be
......@@ -452,8 +452,6 @@ LinphoneAuthInfo * linphone_core_create_auth_info(LinphoneCore *lc, const char *
void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info){
LinphoneAuthInfo *ai;
bctbx_list_t *elem;
bctbx_list_t *l;
int restarted_op_count=0;
bool_t updating=FALSE;
......@@ -472,8 +470,8 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info)
lc->auth_info=bctbx_list_append(lc->auth_info,linphone_auth_info_clone(info));
/* retry pending authentication operations */
for(l=elem=lc->sal->getPendingAuths();elem!=NULL;elem=elem->next){
LinphonePrivate::SalOp *op= static_cast<LinphonePrivate::SalOp*>(elem->data);
auto pendingAuths = lc->sal->getPendingAuths();
for (const auto &op : pendingAuths) {
LinphoneAuthInfo *ai;
const SalAuthInfo *req_sai=op->getAuthRequested();
ai=(LinphoneAuthInfo*)_linphone_core_find_auth_info(lc,req_sai->realm,req_sai->username,req_sai->domain, FALSE);
......@@ -504,7 +502,7 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info)
restarted_op_count++;
}
}
if (l){
if (!pendingAuths.empty()) {
ms_message("linphone_core_add_auth_info(): restarted [%i] operation(s) after %s auth info for\n"
"\tusername: [%s]\n"
"\trealm [%s]\n"
......@@ -515,7 +513,6 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info)
info->realm ? info->realm : "",
info->domain ? info->domain : "");
}
bctbx_list_free(l);
write_auth_infos(lc);
}
......
......@@ -77,7 +77,7 @@ static void call_received(SalCallOp *h) {
if (pAssertedId) {
LinphoneAddress *pAssertedIdAddr = linphone_address_new(pAssertedId);
if (pAssertedIdAddr) {
ms_message("Using P-Asserted-Identity [%s] instead of from [%s] for op [%p]", pAssertedId, h->getFrom(), h);
ms_message("Using P-Asserted-Identity [%s] instead of from [%s] for op [%p]", pAssertedId, h->getFrom().c_str(), h);
fromAddr = pAssertedIdAddr;
} else
ms_warning("Unsupported P-Asserted-Identity header for op [%p] ", h);
......@@ -86,8 +86,8 @@ static void call_received(SalCallOp *h) {
}
if (!fromAddr)
fromAddr = linphone_address_new(h->getFrom());
LinphoneAddress *toAddr = linphone_address_new(h->getTo());
fromAddr = linphone_address_new(h->getFrom().c_str());
LinphoneAddress *toAddr = linphone_address_new(h->getTo().c_str());
if (_linphone_core_is_conference_creation(lc, toAddr)) {
linphone_address_unref(toAddr);
......@@ -136,7 +136,7 @@ static void call_received(SalCallOp *h) {
);
if (!chatRoom) {
chatRoom = L_GET_PRIVATE_FROM_C_OBJECT(lc)->createClientGroupChatRoom(
L_C_TO_STRING(h->getSubject()), h->getRemoteContact(), h->getRemoteBody(), false
h->getSubject(), h->getRemoteContact(), h->getRemoteBody(), false
);
}
L_GET_PRIVATE(static_pointer_cast<ClientGroupChatRoom>(chatRoom))->confirmJoining(h);
......@@ -218,7 +218,7 @@ static void call_rejected(SalCallOp *h){
LinphoneCore *lc = reinterpret_cast<LinphoneCore *>(h->getSal()->getUserPointer());
LinphoneErrorInfo *ei = linphone_error_info_new();
linphone_error_info_from_sal_op(ei, h);
linphone_core_report_early_failed_call(lc, LinphoneCallIncoming, linphone_address_new(h->getFrom()), linphone_address_new(h->getTo()), ei);
linphone_core_report_early_failed_call(lc, LinphoneCallIncoming, linphone_address_new(h->getFrom().c_str()), linphone_address_new(h->getTo().c_str()), ei);
}
static void call_ringing(SalOp *h) {
......
......@@ -124,8 +124,8 @@ LinphoneChatRoom *linphone_core_find_one_to_one_chat_room (
int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op, const SalMessage *sal_msg) {
LinphoneReason reason = LinphoneReasonNotAcceptable;
const char *peerAddress;
const char *localAddress;
std::string peerAddress;
std::string localAddress;
if (linphone_core_conference_server_enabled(lc)) {
localAddress = peerAddress = op->getTo();
} else {
......
......@@ -1305,7 +1305,7 @@ static void sip_config_read(LinphoneCore *lc) {
lc->sal->useNoInitialRoute(!!lp_config_get_int(lc->config,"sip","use_no_initial_route",0));
lc->sal->useRport(!!lp_config_get_int(lc->config,"sip","use_rport",1));
lc->sal->setContactLinphoneSpecs(lp_config_get_string(lc->config, "sip", "linphone_specs", NULL));
lc->sal->setContactLinphoneSpecs(lp_config_get_string(lc->config, "sip", "linphone_specs", ""));
if (!lp_config_get_int(lc->config,"sip","ipv6_migration_done",FALSE) && lp_config_has_entry(lc->config,"sip","use_ipv6")) {
lp_config_clean_entry(lc->config,"sip","use_ipv6");
......@@ -2233,7 +2233,7 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig
lc->sal=new Sal(NULL);
lc->sal->setRefresherRetryAfter(lp_config_get_int(lc->config, "sip", "refresher_retry_after", 60000));
lc->sal->setHttpProxyHost(linphone_core_get_http_proxy_host(lc));
lc->sal->setHttpProxyHost(L_C_TO_STRING(linphone_core_get_http_proxy_host(lc)));
lc->sal->setHttpProxyPort(linphone_core_get_http_proxy_port(lc));
lc->sal->setUserPointer(lc);
......@@ -2332,8 +2332,8 @@ void linphone_core_start (LinphoneCore *lc) {
}else if (strcmp(uuid,"0")!=0) /*to allow to disable sip.instance*/
lc->sal->setUuid(uuid);
if (lc->sal->getRootCa()) {
belle_tls_crypto_config_set_root_ca(lc->http_crypto_config, lc->sal->getRootCa());
if (!lc->sal->getRootCa().empty()) {
belle_tls_crypto_config_set_root_ca(lc->http_crypto_config, lc->sal->getRootCa().c_str());
belle_http_provider_set_tls_crypto_config(lc->http_provider, lc->http_crypto_config);
}
......@@ -2868,7 +2868,7 @@ void linphone_core_set_user_agent(LinphoneCore *lc, const char *name, const char
}
}
const char *linphone_core_get_user_agent(LinphoneCore *lc){
return lc->sal->getUserAgent();
return lc->sal->getUserAgent().c_str();
}
const char *linphone_core_get_user_agent_name(void){
......@@ -3554,7 +3554,7 @@ void linphone_configure_op_with_proxy(LinphoneCore *lc, SalOp *op, const Linphon
op->setToAddress(L_GET_PRIVATE_FROM_C_OBJECT(dest)->getInternalAddress());
op->setFrom(identity);
op->setSentCustomHeaders(headers);
op->setRealm(linphone_proxy_config_get_realm(proxy));
op->setRealm(L_C_TO_STRING(linphone_proxy_config_get_realm(proxy)));
if (with_contact && proxy && proxy->op){
const LinphoneAddress *contact = linphone_proxy_config_get_contact(proxy);
......@@ -4310,7 +4310,7 @@ const char *linphone_core_get_ring(const LinphoneCore *lc){
}
void linphone_core_set_root_ca(LinphoneCore *lc, const char *path) {
lc->sal->setRootCa(path);
lc->sal->setRootCa(L_C_TO_STRING(path));
if (lc->http_crypto_config) {
belle_tls_crypto_config_set_root_ca(lc->http_crypto_config, path);
}
......@@ -4318,8 +4318,8 @@ void linphone_core_set_root_ca(LinphoneCore *lc, const char *path) {
}
void linphone_core_set_root_ca_data(LinphoneCore *lc, const char *data) {
lc->sal->setRootCa(NULL);
lc->sal->setRootCaData(data);
lc->sal->setRootCa("");
lc->sal->setRootCaData(L_C_TO_STRING(data));
if (lc->http_crypto_config) {
belle_tls_crypto_config_set_root_ca_data(lc->http_crypto_config, data);
}
......@@ -6778,12 +6778,12 @@ const char * linphone_core_get_file_transfer_server(LinphoneCore *core) {
void linphone_core_add_supported_tag(LinphoneCore *lc, const char *tag){
lc->sal->addSupportedTag(tag);
lp_config_set_string(lc->config,"sip","supported",lc->sal->getSupportedTags());
lp_config_set_string(lc->config,"sip","supported",lc->sal->getSupportedTags().c_str());
}
void linphone_core_remove_supported_tag(LinphoneCore *lc, const char *tag){
lc->sal->removeSupportedTag(tag);
lp_config_set_string(lc->config,"sip","supported",lc->sal->getSupportedTags());
lp_config_set_string(lc->config,"sip","supported",lc->sal->getSupportedTags().c_str());
}
void linphone_core_set_avpf_mode(LinphoneCore *lc, LinphoneAVPFMode mode){
......@@ -7339,5 +7339,5 @@ const char *linphone_core_get_linphone_specs (const LinphoneCore *core) {
void linphone_core_set_linphone_specs (LinphoneCore *core, const char *specs) {
lp_config_set_string(linphone_core_get_config(core), "sip", "linphone_specs", specs);
core->sal->setContactLinphoneSpecs(specs);
core->sal->setContactLinphoneSpecs(L_C_TO_STRING(specs));
}
......@@ -2000,7 +2000,7 @@ void linphone_subscription_closed(LinphoneCore *lc, SalOp *op){
linphone_friend_remove_incoming_subscription(lf, op);
}else{
/*case of an op that we already released because the friend was destroyed*/
ms_message("Receiving unsuscribe for unknown in-subscribtion from %s", op->getFrom());
ms_message("Receiving unsuscribe for unknown in-subscribtion from %s", op->getFrom().c_str());
}
}
......
......@@ -505,13 +505,12 @@ void linphone_reporting_update_media_info(LinphoneCall * call, int stats_type) {
const LinphoneCallParams * current_params = linphone_call_get_current_params(call);
LinphoneCallLog *log = L_GET_CPP_PTR_FROM_C_OBJECT(call)->getLog();
reporting_session_report_t * report = log->reporting.reports[stats_type];
char * dialog_id;
// call->op might be already released if hanging up in state LinphoneCallOutgoingInit
if (!media_report_enabled(call, stats_type) || !L_GET_PRIVATE_FROM_C_OBJECT(call)->getOp())
return;
dialog_id = L_GET_PRIVATE_FROM_C_OBJECT(call)->getOp()->getDialogId();
std::string dialogId = L_GET_PRIVATE_FROM_C_OBJECT(call)->getOp()->getDialogId();
STR_REASSIGN(report->info.call_id, ms_strdup(log->call_id));
......@@ -521,13 +520,13 @@ void linphone_reporting_update_media_info(LinphoneCall * call, int stats_type) {
// RFC states: "LocalGroupID provides the identification for the purposes
// of aggregation for the local endpoint.".
STR_REASSIGN(report->info.local_addr.group, ms_strdup_printf("%s-%s-%s"
, dialog_id ? dialog_id : ""
, dialogId.c_str()
, "local"
, report->local_metrics.user_agent ? report->local_metrics.user_agent : ""
)
);
STR_REASSIGN(report->info.remote_addr.group, ms_strdup_printf("%s-%s-%s"
, dialog_id ? dialog_id : ""
, dialogId.c_str()
, "remote"
, report->remote_metrics.user_agent ? report->remote_metrics.user_agent : ""
)
......@@ -582,7 +581,7 @@ void linphone_reporting_update_media_info(LinphoneCall * call, int stats_type) {
}
}
STR_REASSIGN(report->dialog_id, ms_strdup_printf("%s;%u", dialog_id ? dialog_id : "", report->info.local_addr.ssrc));
STR_REASSIGN(report->dialog_id, ms_strdup_printf("%s;%u", dialogId.c_str(), report->info.local_addr.ssrc));
if (local_payload != NULL) {
report->local_metrics.session_description.payload_type = local_payload->type;
......@@ -597,8 +596,6 @@ void linphone_reporting_update_media_info(LinphoneCall * call, int stats_type) {
report->remote_metrics.session_description.sample_rate = remote_payload->clock_rate;
STR_REASSIGN(report->remote_metrics.session_description.fmtp, ms_strdup(remote_payload->recv_fmtp));
}
ms_free(dialog_id);
}
/* generate random float in interval ] 0.9 t ; 1.1 t [*/
......
......@@ -576,7 +576,7 @@ void linphone_call_ogl_render (const LinphoneCall *call) {
LinphoneStatus linphone_call_send_info_message (LinphoneCall *call, const LinphoneInfoMessage *info) {
SalBodyHandler *body_handler = sal_body_handler_from_content(linphone_info_message_get_content(info));
linphone_call_get_op(call)->setSentCustomHeaders(linphone_info_message_get_headers(info));
return linphone_call_get_op(call)->sendInfo(nullptr, nullptr, body_handler);
return linphone_call_get_op(call)->sendInfo(body_handler);
}
LinphoneCallStats *linphone_call_get_stats (LinphoneCall *call, LinphoneStreamType type) {
......
......@@ -177,11 +177,11 @@ bool CallSessionPrivate::startPing () {
pingReplied = false;
pingOp = new SalOp(q->getCore()->getCCore()->sal);
if (direction == LinphoneCallIncoming) {
const char *from = pingOp->getFrom();
const char *to = pingOp->getTo();
string from = pingOp->getFrom();
string to = pingOp->getTo();
linphone_configure_op(q->getCore()->getCCore(), pingOp, log->from, nullptr, false);
pingOp->setRoute(op->getNetworkOrigin());
pingOp->ping(from, to);
pingOp->ping(from.c_str(), to.c_str());
} else if (direction == LinphoneCallOutgoing) {
char *from = linphone_address_as_string(log->from);
char *to = linphone_address_as_string(log->to);
......@@ -786,12 +786,12 @@ void CallSessionPrivate::reinviteToRecoverFromConnectionLoss () {
void CallSessionPrivate::repairByInviteWithReplaces () {
L_Q();
const char *callId = op->getCallId();
string callId = op->getCallId();
const char *fromTag = op->getLocalTag();
const char *toTag = op->getRemoteTag();
op->killDialog();
createOp();
op->setReplaces(callId, fromTag, toTag);
op->setReplaces(callId.c_str(), fromTag, toTag);
q->startInvite(nullptr);
}
......@@ -937,7 +937,7 @@ void CallSession::configure (LinphoneCallDir direction, LinphoneProxyConfig *cfg
linphone_core_get_config(getCore()->getCCore()), "sip", "cnx_ip_to_0000_if_sendonly_enabled", 0
)
);
d->log->call_id = ms_strdup(op->getCallId()); /* Must be known at that time */
d->log->call_id = ms_strdup(op->getCallId().c_str()); /* Must be known at that time */
}
if (direction == LinphoneCallOutgoing) {
......@@ -1109,7 +1109,7 @@ int CallSession::startInvite (const Address *destination, const string &subject,
d->setState(CallSession::State::Error, "Call failed");
}
} else {
d->log->call_id = ms_strdup(d->op->getCallId()); /* Must be known at that time */
d->log->call_id = ms_strdup(d->op->getCallId().c_str()); /* Must be known at that time */
d->setState(CallSession::State::OutgoingProgress, "Outgoing call in progress");
}
return result;
......@@ -1326,7 +1326,7 @@ string CallSession::getToHeader (const string &name) const {
string CallSession::getRemoteUserAgent () const {
L_D();
if (d->op && d->op->getRemoteUserAgent())
if (d->op)
return d->op->getRemoteUserAgent();
return string();
}
......
......@@ -66,10 +66,8 @@ bool CorePrivate::inviteReplacesABrokenCall (SalCallOp *op) {
shared_ptr<CallSession> session = call->getPrivate()->getActiveSession();
if (session
&& ((session->getPrivate()->isBroken() && op->compareOp(session->getPrivate()->getOp()))
|| ((replacedSession == session.get())
&& (strcmp(op->getFrom(), replacedOp->getFrom()) == 0)
&& (strcmp(op->getTo(), replacedOp->getTo()) == 0)))
) {
|| (replacedSession == session.get() && op->getFrom() == replacedOp->getFrom() && op->getTo() == replacedOp->getTo())
)) {
session->getPrivate()->replaceOp(op);
return true;
}
......
......@@ -464,7 +464,7 @@ void SalCallOp::processResponseCb(void *op_base, const belle_sip_response_event_
belle_sip_object_unref(op->mSdpAnswer);
op->mSdpAnswer=NULL;
}
belle_sip_message_add_header(BELLE_SIP_MESSAGE(ack),BELLE_SIP_HEADER(op->mRoot->mUserAgent));
belle_sip_message_add_header(BELLE_SIP_MESSAGE(ack),BELLE_SIP_HEADER(op->mRoot->mUserAgentHeader));
op->mRoot->mCallbacks.call_accepted(op); /*INVITE*/
op->mRoot->mCallbacks.call_ack_being_sent(op, (SalCustomHeader*)ack);
belle_sip_dialog_send_ack(op->mDialog,ack);
......@@ -495,7 +495,7 @@ void SalCallOp::processResponseCb(void *op_base, const belle_sip_response_event_
break;
case State::Terminated:
default:
ms_error("Call op [%p] receives unexpected answer [%i] while in state [%s].",op,code, toString(op->mState));
lError() << "Call op [" << op << "] receives unexpected answer [" << code << "] while in state [" << toString(op->mState) << "]";
}
}
break;
......@@ -645,7 +645,7 @@ void SalCallOp::callTerminated(belle_sip_server_transaction_t* server_transactio
setReasonErrorInfo(BELLE_SIP_MESSAGE(cancel_request ? cancel_request : server_req));
resp=createResponseFromRequest(server_req,status_code);
belle_sip_server_transaction_send_response(server_transaction,resp);
mRoot->mCallbacks.call_terminated(this,mDir==Dir::Incoming?getFrom():getTo());
mRoot->mCallbacks.call_terminated(this,mDir==Dir::Incoming?getFrom().c_str():getTo().c_str());
}
void SalCallOp::resetDescriptions() {
......@@ -704,7 +704,7 @@ void SalCallOp::processRequestEventCb(void *op_base, const belle_sip_request_eve
if (!op->mDialog) {
op->setOrUpdateDialog(belle_sip_provider_create_dialog(op->mRoot->mProvider, BELLE_SIP_TRANSACTION(op->mPendingServerTransaction)));
ms_message("new incoming call from [%s] to [%s]",op->getFrom(),op->getTo());
ms_message("new incoming call from [%s] to [%s]",op->getFrom().c_str(),op->getTo().c_str());
}
dialog_state=belle_sip_dialog_get_state(op->mDialog);
switch(dialog_state) {
......@@ -874,7 +874,7 @@ void SalCallOp::processDialogTerminatedCb(void *ctx, const belle_sip_dialog_term
case BELLE_SIP_DIALOG_CONFIRMED:
if (op->mState!=State::Terminated && op->mState!=State::Terminating) {
/*this is probably a normal termination from a BYE*/
op->mRoot->mCallbacks.call_terminated(op,op->mDir==Dir::Incoming?op->getFrom():op->getTo());
op->mRoot->mCallbacks.call_terminated(op,op->mDir==Dir::Incoming?op->getFrom().c_str():op->getTo().c_str());
op->mState=State::Terminating;
}
break;
......@@ -1091,9 +1091,7 @@ int SalCallOp::update(const char *subject, bool no_user_consent) {
if (mDialog == NULL) {
/* If the dialog does not exist, this is that we are trying to recover from a connection loss
during a very early state of outgoing call initiation (the dialog has not been created yet). */
const char *from = getFrom();
const char *to = getTo();
return call(from, to, subject);
return call(mFrom.c_str(), mTo.c_str(), subject);
}
state = belle_sip_dialog_get_state(mDialog);
......@@ -1126,7 +1124,7 @@ int SalCallOp::update(const char *subject, bool no_user_consent) {
int SalCallOp::cancelInvite(const SalErrorInfo *info) {
belle_sip_request_t* cancel;
ms_message("Cancelling INVITE request from [%s] to [%s] ",getFrom(), getTo());
ms_message("Cancelling INVITE request from [%s] to [%s] ",getFrom().c_str(), getTo().c_str());
if (mPendingClientTransaction == NULL) {
ms_warning("There is no transaction to cancel.");
......@@ -1315,7 +1313,7 @@ int SalCallOp::terminate(const SalErrorInfo *info) {
p_sei = info;
}
if (mState==State::Terminating || mState==State::Terminated) {
ms_error("Cannot terminate op [%p] in state [%s]",this,toString(mState));
lError() << "Cannot terminate op [" << this << "] in state [" << toString(mState) << "]";
ret = -1;
goto end;
}
......@@ -1393,10 +1391,10 @@ void SalCallOp::sendVfuRequest() {
error=sendRequest(info);
}
if (error)
ms_warning("Cannot send vfu request to [%s] ", getTo());
ms_warning("Cannot send vfu request to [%s] ", getTo().c_str());
} else {
ms_warning("Cannot send vfu request to [%s] because dialog [%p] in wrong state [%s]",getTo()
ms_warning("Cannot send vfu request to [%s] because dialog [%p] in wrong state [%s]",getTo().c_str()
,mDialog
,belle_sip_dialog_state_to_string(dialog_state));
}
......@@ -1538,7 +1536,7 @@ int SalCallOp::sendMessage (const Content &content) {
}
bool SalCallOp::compareOp(const SalCallOp *op2) const {
return (strcmp(mCallId, op2->mCallId) == 0);
return mCallId == op2->mCallId;
}
void SalCallOp::handleOfferAnswerResponse(belle_sip_response_t* response) {
......
......@@ -80,7 +80,7 @@ void SalSubscribeOp::handleNotify(belle_sip_request_t *req, const char *eventnam
if (!subscription_state_header || strcasecmp(BELLE_SIP_SUBSCRIPTION_STATE_TERMINATED,belle_sip_header_subscription_state_get_state(subscription_state_header)) ==0) {
sub_state=SalSubscribeTerminated;
ms_message("Outgoing subscription terminated by remote [%s]",getTo());
ms_message("Outgoing subscription terminated by remote [%s]",getTo().c_str());
} else
sub_state=SalSubscribeActive;
ref();
......@@ -133,7 +133,7 @@ void SalSubscribeOp::subscribeProcessRequestEventCb(void *op_base, const belle_s
return;
}
op->setOrUpdateDialog(dialog);
ms_message("new incoming subscription from [%s] to [%s]",op->getFrom(),op->getTo());
ms_message("new incoming subscription from [%s] to [%s]",op->getFrom().c_str(),op->getTo().c_str());
}else{ /*this is a NOTIFY*/
op->handleNotify(req, eventname, (SalBodyHandler *)body_handler);
return;
......@@ -162,7 +162,7 @@ void SalSubscribeOp::subscribeProcessRequestEventCb(void *op_base, const belle_s
resp=op->createResponseFromRequest(req,200);
belle_sip_server_transaction_send_response(server_transaction,resp);
} else if(expires) {
ms_message("Unsubscribe received from [%s]",op->getFrom());
ms_message("Unsubscribe received from [%s]",op->getFrom().c_str());
resp=op->createResponseFromRequest(req,200);
belle_sip_server_transaction_send_response(server_transaction,resp);
op->mRoot->mCallbacks.incoming_subscribe_closed(op);
......@@ -366,16 +366,16 @@ void SalPublishOp::publishRefresherListenerCb (belle_sip_refresher_t* refresher,
SalPublishOp * op = (SalPublishOp *)user_pointer;
const belle_sip_client_transaction_t* last_publish_trans=belle_sip_refresher_get_transaction(op->mRefresher);
belle_sip_response_t *response=belle_sip_transaction_get_response(BELLE_SIP_TRANSACTION(last_publish_trans));
ms_message("Publish refresher [%i] reason [%s] for proxy [%s]",status_code,reason_phrase?reason_phrase:"none",op->getProxy());
ms_message("Publish refresher [%i] reason [%s] for proxy [%s]",status_code,reason_phrase?reason_phrase:"none",op->getProxy().c_str());
if (status_code==0){
op->mRoot->mCallbacks.on_expire(op);
}else if (status_code>=200){
belle_sip_header_t *sip_etag;
const char *sip_etag_string = NULL;
string sipEtagStr;
if (response && (sip_etag = belle_sip_message_get_header(BELLE_SIP_MESSAGE(response), "SIP-ETag"))) {
sip_etag_string = belle_sip_header_get_unparsed_value(sip_etag);
sipEtagStr = belle_sip_header_get_unparsed_value(sip_etag);
}
op->setEntityTag(sip_etag_string);
op->setEntityTag(sipEtagStr);
sal_error_info_set(&op->mErrorInfo,SalReasonUnknown, "SIP", (int)status_code, reason_phrase, NULL);
op->assignRecvHeaders((belle_sip_message_t*)response);
op->mRoot->mCallbacks.on_publish_response(op);
......@@ -395,11 +395,10 @@ int SalPublishOp::publish(const char *from, const char *to, const char *eventnam
if( req == NULL ){
return -1;
}
if (getEntityTag()) {
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),belle_sip_header_create("SIP-If-Match", getEntityTag()));
}
if (!mEntityTag.empty())
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req), belle_sip_header_create("SIP-If-Match", mEntityTag.c_str()));
if (getContactAddress()){
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(createContact()));
}
......
This diff is collapsed.
......@@ -44,25 +44,25 @@ public:
void setUserPointer (void *value) { mUserPointer = value; }
void *getUserPointer () const { return mUserPointer; }
void setSubject (const char *value);
const char *getSubject () const { return mSubject; }
void setSubject (const std::string &value) { mSubject = value; }
const std::string &getSubject () const { return mSubject; }
void setFrom (const char *value);
void setFrom (const std::string &value);
void setFromAddress (const SalAddress *value);
const char *getFrom () const { return mFrom; }
const std::string &getFrom () const { return mFrom; }
const SalAddress *getFromAddress () const { return mFromAddress; }
void setTo (const char *value);
void setTo (const std::string &value);
void setToAddress (const SalAddress *value);
const char *getTo () const { return mTo; }
const std::string &getTo () const { return mTo; }
const SalAddress *getToAddress () const { return mToAddress; }
void setContactAddress (const SalAddress* value);
const SalAddress *getContactAddress() const { return mContactAddress; }
void setRoute (const char *value);
void setRoute (const std::string &value);
void setRouteAddress (const SalAddress *value);
const bctbx_list_t *getRouteAddresses () const { return mRouteAddresses; }
const std::list<SalAddress *> &getRouteAddresses () const { return mRouteAddresses; }
void addRouteAddress (const SalAddress *address);
void setDiversionAddress (const SalAddress *value);
......@@ -73,30 +73,30 @@ public:
void setManualRefresherMode (bool value) { mManualRefresher = value; }
void setEntityTag (const char *value);
const char *getEntityTag() const { return mEntityTag; }
void setEntityTag (const std::string &value) { mEntityTag = value; }
const std::string &getEntityTag() const { return mEntityTag; }
void setEvent (const char *eventName);
void setEvent (const std::string &eventName);
void setPrivacy (SalPrivacyMask value) { mPrivacy = value; }
SalPrivacyMask getPrivacy() const { return mPrivacy; }
void setRealm (const char *value);
void setRealm (const std::string &value) { mRealm = value; }
void setSentCustomHeaders (SalCustomHeader *ch);
void enableCnxIpTo0000IfSendOnly (bool value) { mCnxIpTo0000IfSendOnlyEnabled = value; }
bool cnxIpTo0000IfSendOnlyEnabled () const { return mCnxIpTo0000IfSendOnlyEnabled; }
const char *getProxy () const { return mRoute; }
const char *getNetworkOrigin () const { return mOrigin; }
const char *getCallId () const { return mCallId; }
char *getDialogId () const;
const std::string &getProxy () const { return mRoute; }
const std::string &getNetworkOrigin () const { return mOrigin; }
const std::string &getCallId () const { return mCallId; }
std::string getDialogId () const;
int getAddressFamily () const;
const SalCustomHeader *getRecvCustomHeaders () const { return mRecvCustomHeaders; }
const char *getRemoteContact () const { return mRemoteContact; }
const std::string &getRemoteContact () const { return mRemoteContact; }
const SalAddress *getRemoteContactAddress () const { return mRemoteContactAddress; }
const char *getRemoteUserAgent () const { return mRemoteUserAgent; }
const std::string &getRemoteUserAgent () const { return mRemoteUserAgent; }
const char *getPublicAddress (int *port) {
return mRefresher ? belle_sip_refresher_get_public_address(mRefresher, port) : nullptr;
......@@ -109,7 +109,7 @@ public:
const SalErrorInfo *getReasonErrorInfo () const { return &mReasonErrorInfo; }
bool isForkedOf (const SalOp *op) const {
return mCallId && op->mCallId && strcmp(mCallId, op->mCallId) == 0;
return !mCallId.empty() && !op->mCallId.empty() && (mCallId == op->mCallId);
}
bool isIdle () const;
......@@ -126,8 +126,8 @@ public:
void cancelAuthentication () { lFatal() << "SalOp::cancelAuthentication not implemented yet"; }
SalAuthInfo *getAuthRequested () { return mAuthInfo; }
int ping (const char *from, const char *to);
int sendInfo (const char *from, const char *to, const SalBodyHandler *bodyHandler);
int ping (const std::string &from, const std::string &to);
int sendInfo (const SalBodyHandler *bodyHandler);
protected:
enum class State {
......@@ -137,7 +137,7 @@ protected:
Terminated
};
static const char *toString (const State value);
static std::string toString (const State value);
enum class Dir {
Incoming = 0,
......@@ -155,7 +155,7 @@ protected:
Refer // For out of dialog refer only
};
static const char *toString (const Type type);
static std::string toString (const Type type);
using ReleaseCb = void (*) (SalOp *op);
......@@ -164,7 +164,7 @@ protected:
void processAuthentication ();
int processRedirect ();
belle_sip_request_t *buildRequest (const char *method);
belle_sip_request_t *buildRequest (const std::string &method);
int sendRequest (belle_sip_request_t *request);
int sendRequestWithContact (belle_sip_request_t *request, bool addContact);
int sendRequestWithExpires (belle_sip_request_t *request, int expires);
......@@ -177,8 +177,8 @@ protected:
void setReferredBy (belle_sip_header_referred_by_t *referredByHeader);
void setReplaces (belle_sip_header_replaces_t *replacesHeader);
void setRemoteContact (const char *value);
void setNetworkOrigin (const char *value);
void setRemoteContact (const std::string &value);
void setNetworkOrigin (const std::string &value);
void setNetworkOriginAddress (SalAddress *value);
void setPrivacyFromMessage (belle_sip_message_t *message);
void setRemoteUserAgent (belle_sip_message_t *message);
......@@ -207,33 +207,32 @@ protected:
static bool isExternalBody (belle_sip_header_content_type_t* contentType);
static void assignAddress (SalAddress **address, const char *value);
static void assignString (char **str, const char *arg);
static void addInitialRouteSet (belle_sip_request_t *request, const MSList *list);
static void assignAddress (SalAddress **address, const std::string &value);
static void addInitialRouteSet (belle_sip_request_t *request, const std::list<SalAddress *> &routeAddresses);
// SalOpBase
Sal *mRoot = nullptr;
char *mRoute = nullptr; // Or request-uri for REGISTER
MSList *mRouteAddresses = nullptr; // List of SalAddress *
std::string mRoute; // Or request-uri for REGISTER
std::list<SalAddress *> mRouteAddresses;
SalAddress *mContactAddress = nullptr;
char *mSubject = nullptr;
char *mFrom = nullptr;
std::string mSubject;
std::string mFrom;
SalAddress* mFromAddress = nullptr;
char *mTo = nullptr;
std::string mTo;
SalAddress *mToAddress = nullptr;
char *mOrigin = nullptr;
std::string mOrigin;
SalAddress *mOriginAddress = nullptr;
SalAddress *mDiversionAddress = nullptr;
char *mRemoteUserAgent = nullptr;
std::string mRemoteUserAgent;
SalAddress *mRemoteContactAddress = nullptr;
char *mRemoteContact = nullptr;
std::string mRemoteContact;
void *mUserPointer = nullptr;
char *mCallId = nullptr;
char *mRealm = nullptr;
std::string mCallId;
std::string mRealm;
SalAddress *mServiceRoute = nullptr; // As defined by rfc3608, might be a list
SalCustomHeader *mSentCustomHeaders = nullptr;
SalCustomHeader *mRecvCustomHeaders = nullptr;
char *mEntityTag = nullptr; // As defined by rfc3903 (I.E publih)
std::string mEntityTag; // As defined by rfc3903 (I.E publih)
ReleaseCb mReleaseCb = nullptr;
const belle_sip_listener_callbacks_t *mCallbacks = nullptr;
......
......@@ -17,6 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "c-wrapper/internal/c-tools.h"
#include "sal/presence-op.h"
using namespace std;
......@@ -42,7 +43,7 @@ void SalPresenceOp::presenceProcessIoErrorCb(void *user_ctx, const belle_sip_io_
ms_warning("presence_process_io_error() refresher is present, should not happen");
return;
}
ms_message("subscription to [%s] io error",op->getTo());
ms_message("subscription to [%s] io error",op->getTo().c_str());
if (!op->mOpReleased){
op->mRoot->mCallbacks.notify_presence(op,SalSubscribeTerminated, NULL,NULL); /*NULL = offline*/
}
......@@ -90,7 +91,7 @@ void SalPresenceOp::presenceResponseEventCb(void *op_base, const belle_sip_respo
if (code>=300) {
if (strcmp("SUBSCRIBE",belle_sip_request_get_method(request))==0){
ms_message("subscription to [%s] rejected",op->getTo());
ms_message("subscription to [%s] rejected",op->getTo().c_str());
if (!op->mOpReleased){
op->mRoot->mCallbacks.notify_presence(op,SalSubscribeTerminated, NULL,NULL); /*NULL = offline*/
}
......@@ -121,7 +122,7 @@ void SalPresenceOp::presenceResponseEventCb(void *op_base, const belle_sip_respo
if ((expires != NULL) && (belle_sip_header_expires_get_expires(expires) > 0)) {
op->mRefresher=belle_sip_client_transaction_create_refresher(client_transaction);
belle_sip_refresher_set_listener(op->mRefresher,presenceRefresherListenerCb,op);
belle_sip_refresher_set_realm(op->mRefresher,op->mRealm);
belle_sip_refresher_set_realm(op->mRefresher,L_STRING_TO_C(op->mRealm));
}
}
break;
......@@ -143,7 +144,7 @@ void SalPresenceOp::presenceProcessTimeoutCb(void *user_ctx, const belle_sip_tim
request = belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(client_transaction));
if (strcmp("SUBSCRIBE",belle_sip_request_get_method(request))==0){
ms_message("subscription to [%s] timeout",op->getTo());
ms_message("subscription to [%s] timeout",op->getTo().c_str());
if (!op->mOpReleased){
op->mRoot->mCallbacks.notify_presence(op,SalSubscribeTerminated, NULL,NULL); /*NULL = offline*/
}
......@@ -192,7 +193,7 @@ void SalPresenceOp::handleNotify(belle_sip_request_t *req, belle_sip_dialog_t *d
}
if (!subscription_state_header || strcasecmp(BELLE_SIP_SUBSCRIPTION_STATE_TERMINATED,belle_sip_header_subscription_state_get_state(subscription_state_header)) ==0) {
sub_state=SalSubscribeTerminated;
ms_message("Outgoing subscription terminated by remote [%s]",getTo());
ms_message("Outgoing subscription terminated by remote [%s]",getTo().c_str());
} else {
sub_state=getSubscriptionState(BELLE_SIP_MESSAGE(req));
}
......@@ -249,7 +250,7 @@ void SalPresenceOp::presenceProcessRequestEventCb(void *op_base, const belle_sip
return;