Commit 29945cbc authored by François Grisez's avatar François Grisez

Prevent belle-sip version from being automatically added to User-agent header

(cherry picked from commit 5230527b)
parent 8d7cac3b
...@@ -18,6 +18,8 @@ along with this program; if not, write to the Free Software ...@@ -18,6 +18,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include <sstream>
#include "linphone/api/c-content.h" #include "linphone/api/c-content.h"
#include "linphone/core_utils.h" #include "linphone/core_utils.h"
#include "linphone/core.h" #include "linphone/core.h"
...@@ -3074,11 +3076,11 @@ static char _ua_name[64]="Linphone"; ...@@ -3074,11 +3076,11 @@ static char _ua_name[64]="Linphone";
static char _ua_version[64]=LIBLINPHONE_VERSION; static char _ua_version[64]=LIBLINPHONE_VERSION;
void linphone_core_set_user_agent(LinphoneCore *lc, const char *name, const char *ver){ void linphone_core_set_user_agent(LinphoneCore *lc, const char *name, const char *ver){
char ua_string[256]; ostringstream ua_string;
snprintf(ua_string, sizeof(ua_string) - 1, "%s/%s", name?name:"", ver?ver:""); ua_string << (name ? name : "");
if (ver) ua_string << "/" << ver;
if (lc->sal) { if (lc->sal) {
lc->sal->setUserAgent(ua_string); lc->sal->setUserAgent(ua_string.str());
lc->sal->appendStackStringToUserAgent();
} }
} }
const char *linphone_core_get_user_agent(LinphoneCore *lc){ const char *linphone_core_get_user_agent(LinphoneCore *lc){
......
...@@ -1123,10 +1123,15 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_remove_listener(LinphoneC ...@@ -1123,10 +1123,15 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_remove_listener(LinphoneC
LINPHONE_PUBLIC void linphone_core_remove_callbacks(LinphoneCore *lc, const LinphoneCoreCbs *cbs); LINPHONE_PUBLIC void linphone_core_remove_callbacks(LinphoneCore *lc, const LinphoneCoreCbs *cbs);
/** /**
* Sets the user agent string used in SIP messages, ideally called just after linphone_core_new() or linphone_core_init(). * @brief Set the user agent string used in SIP messages.
* @param[in] lc #LinphoneCore object *
* @param[in] ua_name The user agent name * Set the user agent string used in SIP messages as "[ua_name]/[version]". No slash character will be printed if NULL is given to "version".
* @param[in] version The user agent version * If NULL is given to "ua_name" and "version" both, the User-agent header will be empty.
*
* This function should be called just after linphone_factory_create_core() ideally.
* @param[in] lc The core.
* @param[in] ua_name Name of the user agent.
* @param[in] version Version of the user agent.
* @ingroup misc * @ingroup misc
**/ **/
LINPHONE_PUBLIC void linphone_core_set_user_agent(LinphoneCore *lc, const char *ua_name, const char *version); LINPHONE_PUBLIC void linphone_core_set_user_agent(LinphoneCore *lc, const char *ua_name, const char *version);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment