Commit fa861d55 authored by Ronan's avatar Ronan
Browse files

fix(core): add explicit on some constructors

parent f492097c
...@@ -55,7 +55,7 @@ LINPHONE_BEGIN_NAMESPACE ...@@ -55,7 +55,7 @@ LINPHONE_BEGIN_NAMESPACE
// TODO: This macro should be used but it is triggering a bug in doxygen that // TODO: This macro should be used but it is triggering a bug in doxygen that
// has been fixed in the 1.8.8 version. See https://bugzilla.gnome.org/show_bug.cgi?id=731985 // has been fixed in the 1.8.8 version. See https://bugzilla.gnome.org/show_bug.cgi?id=731985
// Meanwhile use 2 different macros // Meanwhile use 2 different macros.
#if 0 #if 0
#define L_DECLARE_C_ENUM(NAME, VALUES) \ #define L_DECLARE_C_ENUM(NAME, VALUES) \
typedef enum L_CONCAT(_, L_CONCAT(L_C_ENUM_PREFIX, NAME)) { \ typedef enum L_CONCAT(_, L_CONCAT(L_C_ENUM_PREFIX, NAME)) { \
......
...@@ -39,33 +39,33 @@ Address::Address (const string &address) : ClonableObject(*new AddressPrivate) { ...@@ -39,33 +39,33 @@ Address::Address (const string &address) : ClonableObject(*new AddressPrivate) {
} }
} }
Address::Address (const Address &src) : ClonableObject(*new AddressPrivate) { Address::Address (const IdentityAddress &identityAddress) : ClonableObject(*new AddressPrivate) {
L_D();
SalAddress *salAddress = src.getPrivate()->internalAddress;
if (salAddress)
d->internalAddress = sal_address_clone(salAddress);
}
Address::Address (const IdentityAddress &src) : ClonableObject(*new AddressPrivate) {
L_D(); L_D();
const string &username = src.getUsername(); const string &username = identityAddress.getUsername();
if (username.empty()) if (username.empty())
return; return;
const string &domain = src.getDomain(); const string &domain = identityAddress.getDomain();
if (domain.empty()) if (domain.empty())
return; return;
string uri = src.getScheme() + ":" + username + "@" + ( string uri = identityAddress.getScheme() + ":" + username + "@" + (
domain.find(':') != string::npos ? "[" + domain + "]" : domain domain.find(':') != string::npos ? "[" + domain + "]" : domain
); );
if (src.hasGruu()) if (identityAddress.hasGruu())
uri += ";gr=" + src.getGruu(); uri += ";gr=" + identityAddress.getGruu();
d->internalAddress = sal_address_new(L_STRING_TO_C(uri)); d->internalAddress = sal_address_new(L_STRING_TO_C(uri));
} }
Address::Address (const Address &src) : ClonableObject(*new AddressPrivate) {
L_D();
SalAddress *salAddress = src.getPrivate()->internalAddress;
if (salAddress)
d->internalAddress = sal_address_clone(salAddress);
}
Address::~Address () { Address::~Address () {
L_D(); L_D();
if (d->internalAddress) if (d->internalAddress)
......
...@@ -41,8 +41,8 @@ class LINPHONE_PUBLIC Address : public ClonableObject { ...@@ -41,8 +41,8 @@ class LINPHONE_PUBLIC Address : public ClonableObject {
public: public:
explicit Address (const std::string &address = ""); explicit Address (const std::string &address = "");
Address (const IdentityAddress &identityAddress);
Address (const Address &src); Address (const Address &src);
Address (const IdentityAddress &src);
~Address (); ~Address ();
Address &operator= (const Address &src); Address &operator= (const Address &src);
......
...@@ -42,20 +42,21 @@ IdentityAddress::IdentityAddress (const string &address) : ClonableObject(*new I ...@@ -42,20 +42,21 @@ IdentityAddress::IdentityAddress (const string &address) : ClonableObject(*new I
} }
} }
IdentityAddress::IdentityAddress (const IdentityAddress &src) : ClonableObject(*new IdentityAddressPrivate) { IdentityAddress::IdentityAddress (const Address &address) : ClonableObject(*new IdentityAddressPrivate) {
L_D(); L_D();
d->scheme = src.getScheme(); d->scheme = address.getScheme();
d->username = src.getUsername(); d->username = address.getUsername();
d->domain = src.getDomain(); d->domain = address.getDomain();
d->gruu = src.getGruu(); if (address.hasUriParam("gr"))
d->gruu = address.getUriParamValue("gr");
} }
IdentityAddress::IdentityAddress (const Address &src) : ClonableObject(*new IdentityAddressPrivate) { IdentityAddress::IdentityAddress (const IdentityAddress &src) : ClonableObject(*new IdentityAddressPrivate) {
L_D(); L_D();
d->scheme = src.getScheme(); d->scheme = src.getScheme();
d->username = src.getUsername(); d->username = src.getUsername();
d->domain = src.getDomain(); d->domain = src.getDomain();
d->gruu = src.getUriParamValue("gr"); d->gruu = src.getGruu();
} }
IdentityAddress &IdentityAddress::operator= (const IdentityAddress &src) { IdentityAddress &IdentityAddress::operator= (const IdentityAddress &src) {
......
...@@ -32,8 +32,8 @@ class IdentityAddressPrivate; ...@@ -32,8 +32,8 @@ class IdentityAddressPrivate;
class LINPHONE_PUBLIC IdentityAddress : public ClonableObject { class LINPHONE_PUBLIC IdentityAddress : public ClonableObject {
public: public:
explicit IdentityAddress (const std::string &address = ""); explicit IdentityAddress (const std::string &address = "");
IdentityAddress (const Address &address);
IdentityAddress (const IdentityAddress &src); IdentityAddress (const IdentityAddress &src);
IdentityAddress (const Address &src);
~IdentityAddress () = default; ~IdentityAddress () = default;
IdentityAddress &operator= (const IdentityAddress &src); IdentityAddress &operator= (const IdentityAddress &src);
......
...@@ -230,7 +230,9 @@ LinphoneChatRoomState linphone_chat_room_get_state (const LinphoneChatRoom *cr) ...@@ -230,7 +230,9 @@ LinphoneChatRoomState linphone_chat_room_get_state (const LinphoneChatRoom *cr)
} }
void linphone_chat_room_add_participant (LinphoneChatRoom *cr, const LinphoneAddress *addr) { void linphone_chat_room_add_participant (LinphoneChatRoom *cr, const LinphoneAddress *addr) {
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->addParticipant(*L_GET_CPP_PTR_FROM_C_OBJECT(addr), nullptr, false); L_GET_CPP_PTR_FROM_C_OBJECT(cr)->addParticipant(
LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(addr)), nullptr, false
);
} }
void linphone_chat_room_add_participants (LinphoneChatRoom *cr, const bctbx_list_t *addresses) { void linphone_chat_room_add_participants (LinphoneChatRoom *cr, const bctbx_list_t *addresses) {
...@@ -246,14 +248,16 @@ bool_t linphone_chat_room_can_handle_participants (const LinphoneChatRoom *cr) { ...@@ -246,14 +248,16 @@ bool_t linphone_chat_room_can_handle_participants (const LinphoneChatRoom *cr) {
} }
LinphoneParticipant *linphone_chat_room_find_participant (const LinphoneChatRoom *cr, const LinphoneAddress *addr) { LinphoneParticipant *linphone_chat_room_find_participant (const LinphoneChatRoom *cr, const LinphoneAddress *addr) {
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->findParticipant(*L_GET_CPP_PTR_FROM_C_OBJECT(addr))); return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->findParticipant(
LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(addr))
));
} }
const LinphoneAddress *linphone_chat_room_get_conference_address (const LinphoneChatRoom *cr) { const LinphoneAddress *linphone_chat_room_get_conference_address (const LinphoneChatRoom *cr) {
if (cr->conferenceAddressCache) if (cr->conferenceAddressCache)
linphone_address_unref(cr->conferenceAddressCache); linphone_address_unref(cr->conferenceAddressCache);
const LinphonePrivate::Address &address = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getConferenceAddress(); const LinphonePrivate::IdentityAddress &address = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getConferenceAddress();
if (address.isValid()) if (address.isValid())
cr->conferenceAddressCache = linphone_address_new(address.asString().c_str()); cr->conferenceAddressCache = linphone_address_new(address.asString().c_str());
else else
...@@ -356,7 +360,7 @@ LinphoneChatRoom *_linphone_client_group_chat_room_new (LinphoneCore *core, cons ...@@ -356,7 +360,7 @@ LinphoneChatRoom *_linphone_client_group_chat_room_new (LinphoneCore *core, cons
from = L_GET_CPP_PTR_FROM_C_OBJECT(linphone_proxy_config_get_identity_address(proxy))->asString(); from = L_GET_CPP_PTR_FROM_C_OBJECT(linphone_proxy_config_get_identity_address(proxy))->asString();
if (from.empty()) if (from.empty())
from = linphone_core_get_primary_contact(core); from = linphone_core_get_primary_contact(core);
LinphonePrivate::Address me(from); LinphonePrivate::IdentityAddress me(from);
LinphoneChatRoom *cr = L_INIT(ChatRoom); LinphoneChatRoom *cr = L_INIT(ChatRoom);
L_SET_CPP_PTR_FROM_C_OBJECT(cr, make_shared<LinphonePrivate::ClientGroupChatRoom>( L_SET_CPP_PTR_FROM_C_OBJECT(cr, make_shared<LinphonePrivate::ClientGroupChatRoom>(
core->cppCore, L_C_TO_STRING(uri), me, L_C_TO_STRING(subject)) core->cppCore, L_C_TO_STRING(uri), me, L_C_TO_STRING(subject))
......
...@@ -48,7 +48,7 @@ void linphone_participant_set_user_data(LinphoneParticipant *participant, void * ...@@ -48,7 +48,7 @@ void linphone_participant_set_user_data(LinphoneParticipant *participant, void *
} }
const LinphoneAddress *linphone_participant_get_address (const LinphoneParticipant *participant) { const LinphoneAddress *linphone_participant_get_address (const LinphoneParticipant *participant) {
LinphonePrivate::Address addr = L_GET_CPP_PTR_FROM_C_OBJECT(participant)->getAddress(); LinphonePrivate::Address addr(L_GET_CPP_PTR_FROM_C_OBJECT(participant)->getAddress());
if (participant->addressCache) if (participant->addressCache)
linphone_address_unref(participant->addressCache); linphone_address_unref(participant->addressCache);
participant->addressCache = linphone_address_new(addr.asString().c_str()); participant->addressCache = linphone_address_new(addr.asString().c_str());
......
...@@ -49,14 +49,14 @@ Content::Content (Content &&src) : ClonableObject(*new ContentPrivate), AppDataC ...@@ -49,14 +49,14 @@ Content::Content (Content &&src) : ClonableObject(*new ContentPrivate), AppDataC
d->contentDisposition = move(src.getPrivate()->contentDisposition); d->contentDisposition = move(src.getPrivate()->contentDisposition);
} }
Content::Content (ContentPrivate &p) : ClonableObject(p) { Content::Content (ContentPrivate &p) : ClonableObject(p) {}
}
Content::~Content () { Content::~Content () {
L_D(); L_D();
/* Fills the body with zeros before releasing since it may contain /*
private data like cipher keys or decoded messages. */ * Fills the body with zeros before releasing since it may contain
* private data like cipher keys or decoded messages.
*/
d->body.assign(d->body.size(), 0); d->body.assign(d->body.size(), 0);
} }
......
...@@ -42,7 +42,7 @@ shared_ptr<Core> Core::create (LinphoneCore *cCore) { ...@@ -42,7 +42,7 @@ shared_ptr<Core> Core::create (LinphoneCore *cCore) {
// Do not use `make_shared` => Private constructor. // Do not use `make_shared` => Private constructor.
shared_ptr<Core> core = shared_ptr<Core>(new Core); shared_ptr<Core> core = shared_ptr<Core>(new Core);
CorePrivate * const d = core->getPrivate(); CorePrivate *const d = core->getPrivate();
d->cCore = cCore; d->cCore = cCore;
d->mainDb.reset(new MainDb(core->getSharedFromThis())); d->mainDb.reset(new MainDb(core->getSharedFromThis()));
......
...@@ -50,14 +50,14 @@ public: ...@@ -50,14 +50,14 @@ public:
virtual std::string getConfigPath () = 0; virtual std::string getConfigPath () = 0;
protected: protected:
inline PlatformHelpers (LinphoneCore *lc) : mCore(lc) {} inline explicit PlatformHelpers (LinphoneCore *lc) : mCore(lc) {}
LinphoneCore *mCore; LinphoneCore *mCore;
}; };
class StubbedPlatformHelpers : public PlatformHelpers { class StubbedPlatformHelpers : public PlatformHelpers {
public: public:
StubbedPlatformHelpers (LinphoneCore *lc); explicit StubbedPlatformHelpers (LinphoneCore *lc);
virtual ~StubbedPlatformHelpers () = default; virtual ~StubbedPlatformHelpers () = default;
void setDnsServers () override; void setDnsServers () override;
......
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