Commit cdee1e04 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Merge branch 'dev_refactor_cpp' into dev_group_chat

parents 8c9022e5 43a62dc8
......@@ -91,7 +91,18 @@ static char* _get_identity(const LinphoneAccountCreator *creator) {
LinphoneAddress* addr;
addr = linphone_proxy_config_normalize_sip_uri(proxy, creator->username ? creator->username : creator->phone_number);
if (addr == NULL) goto end;
if (addr == NULL) {
if (creator->username && creator->domain) {
char *url = ms_strdup_printf("sip:%s@%s", creator->username, creator->domain);
addr = linphone_address_new(url);
ms_free(url);
if (addr == NULL) {
goto end;
}
} else {
goto end;
}
}
identity = linphone_address_as_string(addr);
linphone_address_unref(addr);
......@@ -139,6 +150,9 @@ LinphoneProxyConfig * linphone_account_creator_create_proxy_config(const Linphon
snprintf(buff, sizeof(buff), "%d", dial_prefix_number);
linphone_proxy_config_set_dial_prefix(cfg, buff);
}
if (linphone_proxy_config_get_server_addr(cfg) == NULL && creator->domain != NULL) {
linphone_proxy_config_set_server_addr(cfg, creator->domain);
}
linphone_proxy_config_enable_register(cfg, TRUE);
......
......@@ -413,7 +413,7 @@ void linphone_friend_add_phone_number(LinphoneFriend *lf, const char *phone) {
}
}
bctbx_list_t* linphone_friend_get_phone_numbers(LinphoneFriend *lf) {
bctbx_list_t* linphone_friend_get_phone_numbers(const LinphoneFriend *lf) {
if (!lf || !lf->vcard) return NULL;
if (linphone_core_vcard_supported()) {
......
......@@ -634,10 +634,13 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie
list->friends = bctbx_list_erase_link(list->friends, elem);
if(lf->refkey) {
bctbx_iterator_t * it = bctbx_map_cchar_find_key(list->friends_map, lf->refkey);
if (!bctbx_iterator_cchar_equals(it, bctbx_map_cchar_end(list->friends_map))){
bctbx_iterator_t * end = bctbx_map_cchar_end(list->friends_map);
if (!bctbx_iterator_cchar_equals(it, end)){
linphone_friend_unref((LinphoneFriend*)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it)));
bctbx_map_cchar_erase(list->friends_map, it);
}
if (it) bctbx_iterator_cchar_delete(it);
if (end) bctbx_iterator_cchar_delete(end);
}
phone_numbers = linphone_friend_get_phone_numbers(lf);
......@@ -647,14 +650,17 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie
const char *uri = linphone_friend_phone_number_to_sip_uri(lf, number);
if(uri) {
bctbx_iterator_t * it = bctbx_map_cchar_find_key(list->friends_map_uri, uri);
if (!bctbx_iterator_cchar_equals(it, bctbx_map_cchar_end(list->friends_map_uri))){
bctbx_iterator_t * end = bctbx_map_cchar_end(list->friends_map_uri);
if (!bctbx_iterator_cchar_equals(it, end)){
linphone_friend_unref((LinphoneFriend*)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it)));
bctbx_map_cchar_erase(list->friends_map_uri, it);
}
bctbx_iterator_cchar_delete(it);
if (it) bctbx_iterator_cchar_delete(it);
if (end) bctbx_iterator_cchar_delete(end);
}
iterator = bctbx_list_next(iterator);
}
if (phone_numbers) bctbx_list_free(phone_numbers);
addresses = linphone_friend_get_addresses(lf);
iterator = (bctbx_list_t *)addresses;
......@@ -663,13 +669,16 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie
char *uri = linphone_address_as_string_uri_only(lfaddr);
if(uri) {
bctbx_iterator_t * it = bctbx_map_cchar_find_key(list->friends_map_uri, uri);
if (!bctbx_iterator_cchar_equals(it, bctbx_map_cchar_end(list->friends_map_uri))){
bctbx_iterator_t * end = bctbx_map_cchar_end(list->friends_map_uri);
if (!bctbx_iterator_cchar_equals(it, end)){
linphone_friend_unref((LinphoneFriend*)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it)));
bctbx_map_cchar_erase(list->friends_map_uri, it);
}
bctbx_iterator_cchar_delete(it);
if (it) bctbx_iterator_cchar_delete(it);
if (end) bctbx_iterator_cchar_delete(end);
ms_free(uri);
}
iterator = bctbx_list_next(iterator);
}
......
......@@ -6709,11 +6709,13 @@ int linphone_core_get_video_dscp(const LinphoneCore *lc){
void linphone_core_set_chat_database_path (LinphoneCore *lc, const char *path) {
if (!linphone_core_conference_server_enabled(lc)) {
auto &mainDb = L_GET_PRIVATE(lc->cppPtr)->mainDb;
if (mainDb)
auto &mainDb = L_GET_PRIVATE_FROM_C_OBJECT(lc)->mainDb;
if (mainDb) {
mainDb->import(LinphonePrivate::MainDb::Sqlite3, path);
else
L_GET_PRIVATE_FROM_C_OBJECT(lc)->loadChatRooms();
} else {
ms_warning("linphone_core_set_chat_database_path() needs to be called once linphone_core_start() has been called");
}
}
}
......
......@@ -106,6 +106,7 @@ struct _LinphoneProxyConfig
LinphoneRegistrationState state;
LinphoneAVPFMode avpf_mode;
LinphoneNatPolicy *nat_policy;
int quality_reporting_interval;
bool_t commit;
bool_t reg_sendregister;
......@@ -115,15 +116,14 @@ struct _LinphoneProxyConfig
bool_t send_publish;
bool_t quality_reporting_enabled;
uint8_t avpf_rr_interval;
uint8_t quality_reporting_interval;
bool_t register_changed;
time_t deletion_date;
LinphonePrivacyMask privacy;
/*use to check if server config has changed between edit() and done()*/
LinphoneAddress *saved_proxy;
LinphoneAddress *saved_identity;
bool_t register_changed;
bool_t unused[3];
/*---*/
LinphoneAddress *pending_contact; /*use to store previous contact in case of network failure*/
LinphoneEvent *presence_publish_event;
......
......@@ -133,7 +133,7 @@ static void linphone_proxy_config_init(LinphoneCore* lc, LinphoneProxyConfig *cf
cfg->realm = realm ? ms_strdup(realm) : NULL;
cfg->quality_reporting_enabled = lc ? !!lp_config_get_default_int(lc->config, "proxy", "quality_reporting_enabled", 0) : 0;
cfg->quality_reporting_collector = quality_reporting_collector ? ms_strdup(quality_reporting_collector) : NULL;
cfg->quality_reporting_interval = lc ? !!lp_config_get_default_int(lc->config, "proxy", "quality_reporting_interval", 0) : 0;
cfg->quality_reporting_interval = lc ? lp_config_get_default_int(lc->config, "proxy", "quality_reporting_interval", 0) : 0;
cfg->contact_params = contact_params ? ms_strdup(contact_params) : NULL;
cfg->contact_uri_params = contact_uri_params ? ms_strdup(contact_uri_params) : NULL;
cfg->avpf_mode = lc ? static_cast<LinphoneAVPFMode>(lp_config_get_default_int(lc->config, "proxy", "avpf", LinphoneAVPFDefault)) : LinphoneAVPFDefault;
......@@ -565,7 +565,7 @@ bool_t linphone_proxy_config_quality_reporting_enabled(LinphoneProxyConfig *cfg)
}
void linphone_proxy_config_set_quality_reporting_interval(LinphoneProxyConfig *cfg, int interval) {
cfg->quality_reporting_interval = !!interval;
cfg->quality_reporting_interval = interval;
}
int linphone_proxy_config_get_quality_reporting_interval(LinphoneProxyConfig *cfg) {
......
......@@ -86,7 +86,9 @@ set(C_API_HEADER_FILES
c-chat-room.h
c-dial-plan.h
c-event-log.h
c-magic-search.h
c-participant.h
c-search-result.h
c-types.h
)
......
......@@ -34,6 +34,8 @@
#include "linphone/api/c-dial-plan.h"
#include "linphone/api/c-event-log.h"
#include "linphone/api/c-participant.h"
#include "linphone/api/c-magic-search.h"
#include "linphone/api/c-search-result.h"
#include "linphone/api/c-types.h"
#endif // ifndef _L_C_API_H_
/*
* c-magic-search.h
* Copyright (C) 2010-2018 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _L_C_MAGIC_SEARCH_H_
#define _L_C_MAGIC_SEARCH_H_
#include "linphone/api/c-types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @addtogroup misc
* @{
*/
/**
* Constructs a LinphoneMagicSearch object
**/
LINPHONE_PUBLIC LinphoneMagicSearch *linphone_magic_search_new(LinphoneCore *lc);
/**
* Increment reference count of LinphoneMagicSearch object.
**/
LINPHONE_PUBLIC LinphoneMagicSearch *linphone_magic_search_ref(LinphoneMagicSearch *magicSearch);
/**
* Decrement reference count of LinphoneMagicSearch object. When dropped to zero, memory is freed.
**/
LINPHONE_PUBLIC void linphone_magic_search_unref(LinphoneMagicSearch *magicSearch);
/**
* Set the minimum value used to calculate the weight in search
* @param[in] weight minimum weight
**/
LINPHONE_PUBLIC void linphone_magic_search_set_min_weight(LinphoneMagicSearch *magicSearch, const unsigned int weight);
/**
* @return the minimum value used to calculate the weight in search
**/
LINPHONE_PUBLIC unsigned int linphone_magic_search_get_min_weight(const LinphoneMagicSearch *magicSearch);
/**
* Set the maximum value used to calculate the weight in search
* @param[in] weight maximum weight
**/
LINPHONE_PUBLIC void linphone_magic_search_set_max_weight(LinphoneMagicSearch *magicSearch, const unsigned int weight);
/**
* @return the maximum value used to calculate the weight in search
**/
LINPHONE_PUBLIC unsigned int linphone_magic_search_get_max_weight(const LinphoneMagicSearch *magicSearch);
/**
* @return the delimiter used to find matched filter word
**/
LINPHONE_PUBLIC const char *linphone_magic_search_get_delimiter(const LinphoneMagicSearch *magicSearch);
/**
* Set the delimiter used to find matched filter word
* @param[in] delimiter delimiter (example "-_.,")
**/
LINPHONE_PUBLIC void linphone_magic_search_set_delimiter(LinphoneMagicSearch *magicSearch, const char *delimiter);
/**
* @return if the delimiter search is used
**/
LINPHONE_PUBLIC bool_t linphone_magic_search_get_use_delimiter(LinphoneMagicSearch *magicSearch);
/**
* Enable or disable the delimiter in search
* @param[in] enable
**/
LINPHONE_PUBLIC void linphone_magic_search_set_use_delimiter(LinphoneMagicSearch *magicSearch, bool_t enable);
/**
* @return the number of the maximum SearchResult which will be return
**/
LINPHONE_PUBLIC unsigned int linphone_magic_search_get_search_limit(const LinphoneMagicSearch *magicSearch);
/**
* Set the number of the maximum SearchResult which will be return
* @param[in] limit
**/
LINPHONE_PUBLIC void linphone_magic_search_set_search_limit(LinphoneMagicSearch *magicSearch, const unsigned int limit);
/**
* @return if the search is limited
**/
LINPHONE_PUBLIC bool_t linphone_magic_search_get_limited_search(const LinphoneMagicSearch *magicSearch);
/**
* Enable or disable the limited search
* @param[in] limited
**/
LINPHONE_PUBLIC void linphone_magic_search_set_limited_search(LinphoneMagicSearch *magicSearch, const bool_t limited);
/**
* Reset the cache to begin a new search
**/
LINPHONE_PUBLIC void linphone_magic_search_reset_search_cache(LinphoneMagicSearch *magicSearch);
/**
* Create a sorted list of SearchResult from SipUri, Contact name,
* Contact displayname, Contact phone number, which match with a filter word
* During the first search, a cache is created and used for the next search and so on
* Use linphone_magic_search_reset_search_cache() to begin a new search
* @param[in] filter word we search
* @param[in] withDomain domain which we want to search only
* - "" for searching in all contact
* - "*" for searching in contact with sip SipUri
* - "yourdomain" for searching in contact from "yourdomain" domain
* @return sorted list of \bctbx_list{LinphoneSearchResult}
**/
LINPHONE_PUBLIC bctbx_list_t* linphone_magic_search_get_contact_list_from_filter(LinphoneMagicSearch *magicSearch, const char *filter, const char *withDomain);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif // _L_C_MAGIC_SEARCH_H_
/*
* c-search-result.h
* Copyright (C) 2010-2018 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _L_C_SEARCH_RESULT_H_
#define _L_C_SEARCH_RESULT_H_
#include "linphone/api/c-types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @addtogroup misc
* @{
*/
/**
* Increment reference count of LinphoneSearchResult object.
**/
LINPHONE_PUBLIC LinphoneSearchResult *linphone_search_result_ref(LinphoneSearchResult *searchResult);
/**
* Decrement reference count of LinphoneSearchResult object. When dropped to zero, memory is freed.
**/
LINPHONE_PUBLIC void linphone_search_result_unref(LinphoneSearchResult *searchResult);
/**
* @return LinphoneFriend associed
**/
LINPHONE_PUBLIC const LinphoneFriend* linphone_search_result_get_friend(const LinphoneSearchResult *searchResult);
/**
* @return LinphoneAddress associed
**/
LINPHONE_PUBLIC const LinphoneAddress* linphone_search_result_get_address(const LinphoneSearchResult *searchResult);
/**
* @return the result weight
**/
LINPHONE_PUBLIC unsigned int linphone_search_result_get_weight(const LinphoneSearchResult *searchResult);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif // _L_C_SEARCH_RESULT_H_
......@@ -150,12 +150,24 @@ typedef struct _LinphoneEventLog LinphoneEventLog;
**/
typedef struct _LinphoneDialPlan LinphoneDialPlan;
/**
* A LinphoneMagicSearch is used to do specifics searchs
* @ingroup misc
**/
typedef struct _LinphoneMagicSearch LinphoneMagicSearch;
/**
* The LinphoneParticipant object represents a participant of a conference.
* @ingroup misc
**/
typedef struct _LinphoneParticipant LinphoneParticipant;
/**
* The LinphoneSearchResult object represents a result of a search
* @ingroup misc
**/
typedef struct _LinphoneSearchResult LinphoneSearchResult;
// =============================================================================
// C Enums.
// =============================================================================
......
......@@ -116,7 +116,7 @@ LINPHONE_PUBLIC void linphone_friend_add_phone_number(LinphoneFriend *lf, const
* @param lf #LinphoneFriend object
* @return \bctbx_list{const char *}
*/
LINPHONE_PUBLIC bctbx_list_t* linphone_friend_get_phone_numbers(LinphoneFriend *lf);
LINPHONE_PUBLIC bctbx_list_t* linphone_friend_get_phone_numbers(const LinphoneFriend *lf);
/**
* Removes a phone number in this friend
......
......@@ -21,7 +21,9 @@
#define _L_UTILS_H_
#include <ctime>
#include <list>
#include <string>
#include <utility>
#include <vector>
#include "linphone/utils/enum-generator.h"
......
......@@ -23,7 +23,6 @@
set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
address/address-p.h
address/address.h
address/identity-address-p.h
address/identity-address.h
c-wrapper/c-wrapper.h
c-wrapper/internal/c-sal.h
......@@ -93,9 +92,9 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
conference/session/media-session.h
conference/session/port-config.h
content/content-manager.h
content/content-p.h
content/content-type.h
content/content.h
content/content-p.h
content/file-content.h
content/file-transfer-content.h
core/core-accessor.h
......@@ -137,6 +136,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
object/base-object.h
object/clonable-object-p.h
object/clonable-object.h
object/clonable-shared-pointer.h
object/object-head-p.h
object/object-head.h
object/object-p.h
......@@ -144,6 +144,10 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
object/property-container.h
object/singleton.h
sal/sal.h
search/magic-search-p.h
search/magic-search.h
search/search-result-p.h
search/search-result.h
utils/background-task.h
utils/payload-type-handler.h
variant/variant.h
......@@ -167,7 +171,9 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
c-wrapper/api/c-core.cpp
c-wrapper/api/c-dial-plan.cpp
c-wrapper/api/c-event-log.cpp
c-wrapper/api/c-magic-search.cpp
c-wrapper/api/c-participant.cpp
c-wrapper/api/c-search-result.cpp
c-wrapper/internal/c-sal.cpp
c-wrapper/internal/c-tools.cpp
call/call.cpp
......@@ -249,6 +255,8 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
sal/refer-op.cpp
sal/register-op.cpp
sal/sal.cpp
search/magic-search.cpp
search/search-result.cpp
utils/background-task.cpp
utils/fs.cpp
utils/general.cpp
......@@ -264,15 +272,12 @@ set(LINPHONE_OBJC_SOURCE_FILES)
if (APPLE)
list(APPEND LINPHONE_OBJC_SOURCE_FILES core/paths/paths-apple.mm)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-apple.h)
elseif (ANDROID)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES core/paths/paths-android.cpp core/platform-helpers/android-platform-helpers.cpp)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-android.h)
elseif (WIN32)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES core/paths/paths-windows.cpp)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-windows.h)
elseif (UNIX)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES core/paths/paths-linux.cpp)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-linux.h)
......@@ -285,6 +290,15 @@ set(LINPHONE_CXX_OBJECTS_INCLUDE_DIRS ${BELR_INCLUDE_DIRS})
if (SOCI_FOUND)
list(APPEND LINPHONE_CXX_OBJECTS_INCLUDE_DIRS ${SOCI_INCLUDE_DIRS} ${SOCI_MYSQL_INCLUDES})
add_definitions(-DSOCI_ENABLED)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
db/internal/safe-transaction.h
db/internal/statements.h
)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES
db/internal/statements.cpp
)
endif ()
set(LINPHONE_PRIVATE_HEADER_FILES)
......
......@@ -68,9 +68,9 @@ Address::Address (const IdentityAddress &identityAddress) : ClonableObject(*new
d->internalAddress = sal_address_new(L_STRING_TO_C(uri));
}
Address::Address (const Address &src) : ClonableObject(*new AddressPrivate) {
Address::Address (const Address &other) : ClonableObject(*new AddressPrivate) {
L_D();
SalAddress *salAddress = src.getPrivate()->internalAddress;
SalAddress *salAddress = other.getPrivate()->internalAddress;
if (salAddress)
d->internalAddress = sal_address_clone(salAddress);
}
......@@ -81,28 +81,28 @@ Address::~Address () {
sal_address_destroy(d->internalAddress);
}
Address &Address::operator= (const Address &src) {
Address &Address::operator= (const Address &other) {
L_D();
if (this != &src) {
if (this != &other) {
if (d->internalAddress)
sal_address_destroy(d->internalAddress);
SalAddress *salAddress = src.getPrivate()->internalAddress;
SalAddress *salAddress = other.getPrivate()->internalAddress;
d->internalAddress = salAddress ? sal_address_clone(salAddress) : nullptr;
}
return *this;
}
bool Address::operator== (const Address &address) const {
return asString() == address.asString();
bool Address::operator== (const Address &other) const {
return asString() == other.asString();
}
bool Address::operator!= (const Address &address) const {
return !(*this == address);
bool Address::operator!= (const Address &other) const {
return !(*this == other);
}
bool Address::operator< (const Address &address) const {
return asString() < address.asString();
bool Address::operator< (const Address &other) const {
return asString() < other.asString();
}
bool Address::isValid () const {
......
......@@ -42,15 +42,15 @@ class LINPHONE_PUBLIC Address : public ClonableObject {
public:
explicit Address (const std::string &address = "");
Address (const IdentityAddress &identityAddress);
Address (const Address &src);
Address (const Address &other);
~Address ();
Address &operator= (const Address &src);
Address &operator= (const Address &other);
bool operator== (const Address &address) const;
bool operator!= (const Address &address) const;
bool operator== (const Address &other) const;
bool operator!= (const Address &other) const;
bool operator< (const Address &address) const;
bool operator< (const Address &other) const;
bool isValid () const;
......
......@@ -20,10 +20,10 @@
#include "linphone/utils/utils.h"