diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 59d4bd5e3..0a73468af 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -85,6 +85,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES event-log/conference-participant-event.h event-log/event-log-p.h event-log/event-log.h + hacks/hacks.h logger/logger.h nat/ice-agent.h nat/stun-client.h @@ -152,6 +153,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES event-log/conference-event.cpp event-log/conference-participant-event.cpp event-log/event-log.cpp + hacks/hacks.cpp logger/logger.cpp nat/ice-agent.cpp nat/stun-client.cpp diff --git a/src/hacks/hacks.cpp b/src/hacks/hacks.cpp new file mode 100644 index 000000000..b5caeadc7 --- /dev/null +++ b/src/hacks/hacks.cpp @@ -0,0 +1,45 @@ +/* + * hacks.cpp + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY {} without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include + +#include "hacks.h" + +// ============================================================================= + +using namespace std; + +LINPHONE_BEGIN_NAMESPACE + +// ----------------------------------------------------------------------------- + +bool Hacks::contactHasParam(const string &contact, const string ¶mName) { + // This is very ugly!!! The handling of Contact headers and addresses is a real + // crap that really needs to be reworked. Meanwhile, we cannot get the params on the + // remote contact address and need to forge and parse a contact header. + ostringstream os; + os << "Contact: " << contact; + belle_sip_header_contact_t *contactHeader = belle_sip_header_contact_parse(os.str().c_str()); + bool result = belle_sip_parameters_has_parameter(BELLE_SIP_PARAMETERS(contactHeader), paramName.c_str()); + belle_sip_object_unref(contactHeader); + return result; +} + +LINPHONE_END_NAMESPACE diff --git a/src/hacks/hacks.h b/src/hacks/hacks.h new file mode 100644 index 000000000..dfef46ba9 --- /dev/null +++ b/src/hacks/hacks.h @@ -0,0 +1,39 @@ +/* + * hacks.h + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _HACKS_H_ +#define _HACKS_H_ + +#include + +#include "linphone/utils/general.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +// This class has the purpose to centralize the temporary hacks so that they +// can be located more easily. +class Hacks { +public: + static bool contactHasParam(const std::string &contact, const std::string ¶mName); +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _HACKS_H_