...
 
Commits (12)
......@@ -96,9 +96,9 @@ 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) {
if (creator->username && creator->domain) {
char *url = ms_strdup_printf("sip:%s@%s", creator->username, creator->domain);
if (addr == NULL || (creator->domain && strcmp(linphone_address_get_domain(addr), creator->domain) != 0)) {
if ((creator->username || creator->phone_number) && creator->domain) {
char *url = ms_strdup_printf("sip:%s@%s", creator->username ? creator->username : creator->phone_number, creator->domain);
addr = linphone_address_new(url);
ms_free(url);
if (addr == NULL) {
......@@ -117,6 +117,13 @@ static char* _get_identity(const LinphoneAccountCreator *creator) {
return identity;
}
static inline void resetField (char **field) {
if (*field) {
bctbx_free(*field);
*field = nullptr;
}
}
LinphoneProxyConfig * linphone_account_creator_create_proxy_config(const LinphoneAccountCreator *creator) {
LinphoneAuthInfo *info;
LinphoneProxyConfig *cfg = linphone_core_create_proxy_config(creator->core);
......@@ -158,6 +165,7 @@ LinphoneProxyConfig * linphone_account_creator_create_proxy_config(const Linphon
}
linphone_core_remove_auth_info(creator->core, info);
linphone_auth_info_unref(info);
return NULL;
}
......@@ -279,7 +287,7 @@ static void _linphone_account_creator_destroy(LinphoneAccountCreator *creator) {
linphone_account_creator_service_get_destructor_cb(creator->service)(creator);
linphone_account_creator_service_unref(creator->service);
}
linphone_account_creator_cbs_unref(creator->cbs);
linphone_proxy_config_unref(creator->proxy_cfg);
linphone_account_creator_reset(creator);
......@@ -317,28 +325,20 @@ LinphoneAccountCreator * linphone_account_creator_new(LinphoneCore *core, const
return _linphone_account_creator_new(core, xmlrpc_url);
}
#define _reset_field(field) \
if (field) { \
ms_free(field); \
field = NULL; \
}
void linphone_account_creator_reset(LinphoneAccountCreator *creator) {
_reset_field(creator->username);
_reset_field(creator->display_name);
_reset_field(creator->password);
_reset_field(creator->ha1);
_reset_field(creator->phone_number);
_reset_field(creator->phone_country_code);
_reset_field(creator->email);
_reset_field(creator->language);
_reset_field(creator->activation_code);
_reset_field(creator->domain);
_reset_field(creator->route);
resetField(&creator->username);
resetField(&creator->display_name);
resetField(&creator->password);
resetField(&creator->ha1);
resetField(&creator->phone_number);
resetField(&creator->phone_country_code);
resetField(&creator->email);
resetField(&creator->language);
resetField(&creator->activation_code);
resetField(&creator->domain);
resetField(&creator->route);
}
#undef _reset_field
LinphoneAccountCreator * linphone_core_create_account_creator(LinphoneCore *core, const char *xmlrpc_url) {
return _linphone_account_creator_new(core, xmlrpc_url);
}
......@@ -366,7 +366,7 @@ LinphoneAccountCreatorUsernameStatus linphone_account_creator_set_username(Linph
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;
resetField(&creator->username);
return LinphoneAccountCreatorUsernameStatusOk;
} else if (min_length > 0 && strlen(username) < (size_t)min_length) {
return LinphoneAccountCreatorUsernameStatusTooShort;
......@@ -441,7 +441,7 @@ LinphoneAccountCreatorPasswordStatus linphone_account_creator_set_password(Linph
int min_length = lp_config_get_int(creator->core->config, "assistant", "password_min_length", -1);
int max_length = lp_config_get_int(creator->core->config, "assistant", "password_max_length", -1);
if (!password) {
creator->password = NULL;
resetField(&creator->password);
return LinphoneAccountCreatorPasswordStatusTooShort;
}
if (min_length > 0 && strlen(password) < (size_t)min_length) {
......@@ -984,7 +984,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_link_phone_number_with_acc
}
return LinphoneAccountCreatorStatusMissingArguments;
}
if (creator->xmlrpc_session) {
ms_debug("Account creator: link_phone_number_with_account (phone number=%s, username=%s, domain=%s, language=%s)",
creator->phone_number,
......@@ -1172,6 +1172,7 @@ LinphoneAccountCreatorStatus linphone_account_creator_update_password_linphone(L
}
return LinphoneAccountCreatorStatusMissingArguments;
}
bctbx_free(identity);
if (creator->xmlrpc_session) {
const char *username = creator->username ? creator->username : creator->phone_number;
......
......@@ -152,7 +152,7 @@ static LinphoneFriendPresence * find_presence_model_for_uri_or_tel(const Linphon
static void add_presence_model_for_uri_or_tel(LinphoneFriend *lf, const char *uri_or_tel, LinphonePresenceModel *presence) {
LinphoneFriendPresence *lfp = ms_new0(LinphoneFriendPresence, 1);
lfp->uri_or_tel = ms_strdup(uri_or_tel);
lfp->presence = presence;
lfp->presence = linphone_presence_model_ref(presence);
lf->presence_models = bctbx_list_append(lf->presence_models, lfp);
}
......@@ -730,7 +730,7 @@ void linphone_friend_set_presence_model_for_uri_or_tel(LinphoneFriend *lf, const
LinphoneFriendPresence *lfp = find_presence_model_for_uri_or_tel(lf, uri_or_tel);
if (lfp) {
if (lfp->presence) linphone_presence_model_unref(lfp->presence);
lfp->presence = presence;
lfp->presence = linphone_presence_model_ref(presence);
} else {
add_presence_model_for_uri_or_tel(lf, uri_or_tel, presence);
}
......
This diff is collapsed.
......@@ -1981,6 +1981,7 @@ void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, Sa
ms_free(tmp);
}
linphone_friend_set_presence_model(lf, presence);
linphone_presence_model_unref(presence);
lf->subscribe_active=TRUE;
lf->presence_received = TRUE;
lf->out_sub_state = linphone_subscription_state_from_sal(ss);
......
......@@ -260,8 +260,6 @@ LINPHONE_PUBLIC void linphone_friend_set_user_data(LinphoneFriend *lf, void *dat
**/
LINPHONE_PUBLIC void* linphone_friend_get_user_data(const LinphoneFriend *lf);
LINPHONE_PUBLIC BuddyInfo * linphone_friend_get_info(const LinphoneFriend *lf);
/**
* Set the reference key of a friend.
* @param[in] lf #LinphoneFriend object.
......
......@@ -632,6 +632,7 @@ void ChatMessagePrivate::send () {
int errorCode = 0;
currentSendStep |= ChatMessagePrivate::Step::Started;
imdnId.clear();
if (toBeStored && currentSendStep == (ChatMessagePrivate::Step::Started | ChatMessagePrivate::Step::None))
storeInDb();
......@@ -791,6 +792,7 @@ void ChatMessagePrivate::send () {
if (imdnId.empty())
setImdnMessageId(op->getCallId()); /* must be known at that time */
updateInDb(); // Update IMDN message ID in DB, TODO: update only the message ID, do not rewrite the contents
if (lcall && linphone_call_get_op(lcall) == op) {
/* In this case, chat delivery status is not notified, so unrefing chat message right now */
......
......@@ -147,7 +147,7 @@ const list<DialPlan> DialPlanPrivate::DialPlans = {
{ "Kyrgyzstan", "KG", "996", 9, "00" },
{ "Laos", "LA", "856", 10, "00" },
{ "Latvia", "LV", "371", 8, "00" },
{ "Lebanon", "LB", "961", 7, "00" },
{ "Lebanon", "LB", "961", 8, "00" },
{ "Lesotho", "LS", "266", 8, "00" },
{ "Liberia", "LR", "231", 8, "00" },
{ "Libya", "LY", "218", 8, "00" },
......
This diff is collapsed.
......@@ -141,11 +141,11 @@ private:
void setSearchCache (std::list<SearchResult> *cache) const;
/**
* Get all address from call log
* Get all addresses from call log
* @param[in] filter word we search
* @param[in] withDomain domain which we want to search only
* @param[in] currentList current list where we will check if address already exist
* @return all address from call log which match in a SearchResult list
* @return all addresses from call log which match in a SearchResult list
* @private
**/
std::list<SearchResult> getAddressFromCallLog (
......@@ -154,6 +154,20 @@ private:
const std::list<SearchResult> &currentList
) const;
/**
* Get all addresses from chat rooms participants
* @param[in] filter word we search
* @param[in] withDomain domain which we want to search only
* @param[in] currentList current list where we will check if address already exist
* @return all address from chat rooms participants which match in a SearchResult list
* @private
**/
std::list<SearchResult> getAddressFromGroupChatRoomParticipants (
const std::string &filter,
const std::string &withDomain,
const std::list<SearchResult> &currentList
) const;
/**
* Get all friends as SearchResult
* @param[in] withDomain domain which we want to search only
......
......@@ -18,16 +18,22 @@
*/
#include "linphone/api/c-address.h"
#include "linphone/friend.h"
#include "linphone/presence.h"
#include "object/clonable-object-p.h"
#include "search-result.h"
// =============================================================================
using namespace std;
LINPHONE_BEGIN_NAMESPACE
class SearchResultPrivate : public ClonableObjectPrivate {
private:
void updateCapabilities ();
const LinphoneFriend *mFriend;
const LinphoneAddress *mAddress;
std::string mPhoneNumber;
......@@ -36,64 +42,72 @@ private:
L_DECLARE_PUBLIC(SearchResult);
};
using namespace std;
// ------------------------------------------------------------------------------
SearchResult::SearchResult(const unsigned int weight, const LinphoneAddress *a, const string &pn, const LinphoneFriend *f) : ClonableObject(*new SearchResultPrivate) {
SearchResult::SearchResult (
const unsigned int weight,
const LinphoneAddress *address,
const string &phoneNumber,
const LinphoneFriend *linphoneFriend
) : ClonableObject(*new SearchResultPrivate) {
L_D();
d->mWeight = weight;
d->mAddress = a;
d->mAddress = address;
if (d->mAddress) linphone_address_ref(const_cast<LinphoneAddress *>(d->mAddress));
d->mFriend = f;
d->mPhoneNumber = pn;
d->mPhoneNumber = phoneNumber;
d->mFriend = linphoneFriend;
if (d->mFriend) linphone_friend_ref(const_cast<LinphoneFriend *>(d->mFriend));
}
SearchResult::SearchResult(const SearchResult &sr) : ClonableObject(*new SearchResultPrivate) {
SearchResult::SearchResult (const SearchResult &sr) : ClonableObject(*new SearchResultPrivate) {
L_D();
d->mWeight = sr.getWeight();
d->mAddress = sr.getAddress();
if (d->mAddress) linphone_address_ref(const_cast<LinphoneAddress *>(d->mAddress));
d->mFriend = sr.getFriend();
d->mPhoneNumber = sr.getPhoneNumber();
d->mFriend = sr.getFriend();
if (d->mFriend) linphone_friend_ref(const_cast<LinphoneFriend *>(d->mFriend));
}
SearchResult::~SearchResult() {
SearchResult::~SearchResult () {
L_D();
// FIXME: Ugly temporary workaround to solve weak. Remove me later.
if (d->mAddress) linphone_address_unref(const_cast<LinphoneAddress *>(d->mAddress));
if (d->mFriend) linphone_friend_unref(const_cast<LinphoneFriend *>(d->mFriend));
};
bool SearchResult::operator<(const SearchResult &other) const {
bool SearchResult::operator< (const SearchResult &other) const {
return getWeight() < other.getWeight();
}
bool SearchResult::operator>(const SearchResult &other) const {
bool SearchResult::operator> (const SearchResult &other) const {
return getWeight() > other.getWeight();
}
bool SearchResult::operator>=(const SearchResult &other) const {
bool SearchResult::operator>= (const SearchResult &other) const {
return getWeight() >= other.getWeight();
}
bool SearchResult::operator=(const SearchResult &other) const {
bool SearchResult::operator= (const SearchResult &other) const {
return getWeight() == other.getWeight();
}
const LinphoneFriend *SearchResult::getFriend() const {
const LinphoneFriend *SearchResult::getFriend () const {
L_D();
return d->mFriend;
}
const LinphoneAddress *SearchResult::getAddress() const {
const LinphoneAddress *SearchResult::getAddress () const {
L_D();
return d->mAddress;
}
const string &SearchResult::getPhoneNumber() const {
const string &SearchResult::getPhoneNumber () const {
L_D();
return d->mPhoneNumber;
}
unsigned int SearchResult::getWeight() const {
unsigned int SearchResult::getWeight () const {
L_D();
return d->mWeight;
}
......
......@@ -20,8 +20,8 @@
#ifndef _L_SEARCH_RESULT_H_
#define _L_SEARCH_RESULT_H_
#include "linphone/utils/general.h"
#include "linphone/types.h"
#include "linphone/utils/general.h"
#include "object/clonable-object.h"
......@@ -34,38 +34,38 @@ class SearchResultPrivate;
class LINPHONE_PUBLIC SearchResult : public ClonableObject {
public:
// TODO: Use C++ Address! Not LinphoneAddress.
SearchResult(const unsigned int weight, const LinphoneAddress *a, const std::string &pn, const LinphoneFriend *f = nullptr);
SearchResult(const SearchResult &other);
~SearchResult();
SearchResult (const unsigned int weight, const LinphoneAddress *a, const std::string &pn, const LinphoneFriend *f = nullptr);
SearchResult (const SearchResult &other);
~SearchResult ();
SearchResult* clone () const override {
return new SearchResult(*this);
}
bool operator<(const SearchResult &other) const;
bool operator>(const SearchResult &other) const;
bool operator>=(const SearchResult &other) const;
bool operator=(const SearchResult &other) const;
bool operator< (const SearchResult &other) const;
bool operator> (const SearchResult &other) const;
bool operator>= (const SearchResult &other) const;
bool operator= (const SearchResult &other) const;
/**
* @return LinphoneFriend associed
**/
const LinphoneFriend *getFriend()const;
const LinphoneFriend *getFriend ()const;
/**
* @return LinphoneAddress associed
**/
const LinphoneAddress *getAddress() const;
const LinphoneAddress *getAddress () const;
/**
* @return Phone Number associed
**/
const std::string &getPhoneNumber() const;
const std::string &getPhoneNumber () const;
/**
* @return the result weight
**/
unsigned int getWeight() const;
unsigned int getWeight () const;
private:
L_DECLARE_PRIVATE(SearchResult);
......
......@@ -382,6 +382,7 @@ static void test_presence_list_base(bool_t enable_compression) {
const char *rls_uri = "sip:rls@sip.example.org";
LinphoneFriendList *lfl;
LinphoneFriend *lf;
LinphoneFriend *pauline1, *pauline2;
const char *laure_identity;
const char *marie_identity;
const char *pauline_identity;
......@@ -410,12 +411,13 @@ static void test_presence_list_base(bool_t enable_compression) {
lf = linphone_core_create_friend_with_address(laure->lc, marie_identity);
linphone_friend_list_add_friend(lfl, lf);
linphone_friend_unref(lf);
lf = linphone_core_create_friend_with_address(laure->lc, pauline_identity);
linphone_friend_list_add_friend(lfl, lf);
linphone_friend_unref(lf);
pauline1 = linphone_core_create_friend_with_address(laure->lc, pauline_identity);
linphone_friend_list_add_friend(lfl, pauline1);
lf = linphone_core_create_friend_with_address(laure->lc, "sip:michelle@sip.inexistentdomain.com");
linphone_friend_list_add_friend(lfl, lf);
linphone_friend_unref(lf);
pauline2 = linphone_core_create_friend_with_address(laure->lc, pauline_identity);
linphone_friend_list_add_friend(lfl, pauline2);
linphone_core_remove_friend_list(laure->lc, linphone_core_get_default_friend_list(laure->lc));
linphone_core_add_friend_list(laure->lc, lfl);
linphone_friend_list_unref(lfl);
......@@ -437,9 +439,12 @@ static void test_presence_list_base(bool_t enable_compression) {
if (!BC_ASSERT_PTR_NOT_NULL(lf)) goto end;
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusBusy, int, "%d");
if (!BC_ASSERT_TRUE(linphone_friend_is_presence_received(lf))) goto end;
lf = linphone_friend_list_find_friend_by_address(linphone_core_get_default_friend_list(laure->lc), get_identity_address(pauline));
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusVacation, int, "%d");
if (!BC_ASSERT_TRUE(linphone_friend_is_presence_received(lf))) goto end;
BC_ASSERT_EQUAL(linphone_friend_get_status(pauline1), LinphoneStatusVacation, int, "%d");
BC_ASSERT_EQUAL(linphone_friend_get_status(pauline2), LinphoneStatusVacation, int, "%d");
if (!BC_ASSERT_TRUE(linphone_friend_is_presence_received(pauline1))) goto end;
if (!BC_ASSERT_TRUE(linphone_friend_is_presence_received(pauline2))) goto end;
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), "sip:michelle@sip.inexistentdomain.com");
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
BC_ASSERT_FALSE(linphone_friend_is_presence_received(lf));
......@@ -532,6 +537,8 @@ static void test_presence_list_base(bool_t enable_compression) {
, LinphonePresenceActivityOnline, int, "%d"); fixme, should be LinphonePresenceActivityUnknown*/
end:
linphone_friend_unref(pauline1);
linphone_friend_unref(pauline2);
bctbx_list_free(lcs);
linphone_core_manager_destroy(laure);
linphone_core_manager_destroy(marie);
......
......@@ -664,6 +664,7 @@ static void search_friend_with_domain_without_filter(void) {
linphone_friend_list_remove_friend(lfl, fr);
if (chloeFriend) linphone_friend_unref(chloeFriend);
linphone_presence_model_unref(chloePresence);
linphone_magic_search_unref(magicSearch);
linphone_core_manager_destroy(manager);
......@@ -945,6 +946,7 @@ static void search_friend_with_presence(void) {
LinphoneFriend *fr = linphone_friend_list_find_friend_by_uri(lfl, chloeSipUri);
linphone_friend_list_remove_friend(lfl, fr);
linphone_presence_model_unref(chloePresence);
if (chloeFriend) linphone_friend_unref(chloeFriend);
linphone_magic_search_unref(magicSearch);
......@@ -1065,6 +1067,7 @@ static void search_friend_in_call_log_already_exist(void) {
if (chloeAddress) linphone_address_unref(chloeAddress);
if (ronanAddress) linphone_address_unref(ronanAddress);
linphone_presence_model_unref(chloePresence);
linphone_magic_search_unref(magicSearch);
linphone_core_manager_destroy(manager);
......@@ -1372,7 +1375,6 @@ static void search_friend_large_database(void) {
free(dbPath);
}
/*the webrtc AEC implementation is brought to mediastreamer2 by a plugin.
* We finally check here that if the plugin is correctly loaded and the right choice of echo canceller implementation is made*/
static void echo_canceller_check(void){
......