diff --git a/include/linphone/utils/enum-generator.h b/include/linphone/utils/enum-generator.h index 09c04328f..9dbfbb49a 100644 --- a/include/linphone/utils/enum-generator.h +++ b/include/linphone/utils/enum-generator.h @@ -55,7 +55,7 @@ LINPHONE_BEGIN_NAMESPACE // 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 -// Meanwhile use 2 different macros +// Meanwhile use 2 different macros. #if 0 #define L_DECLARE_C_ENUM(NAME, VALUES) \ typedef enum L_CONCAT(_, L_CONCAT(L_C_ENUM_PREFIX, NAME)) { \ diff --git a/src/address/address.cpp b/src/address/address.cpp index 504c7986f..273fe0a20 100644 --- a/src/address/address.cpp +++ b/src/address/address.cpp @@ -39,6 +39,26 @@ Address::Address (const string &address) : ClonableObject(*new AddressPrivate) { } } +Address::Address (const IdentityAddress &identityAddress) : ClonableObject(*new AddressPrivate) { + L_D(); + + const string &username = identityAddress.getUsername(); + if (username.empty()) + return; + const string &domain = identityAddress.getDomain(); + if (domain.empty()) + return; + + string uri = identityAddress.getScheme() + ":" + username + "@" + ( + domain.find(':') != string::npos ? "[" + domain + "]" : domain + ); + + if (identityAddress.hasGruu()) + uri += ";gr=" + identityAddress.getGruu(); + + 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; @@ -46,26 +66,6 @@ Address::Address (const Address &src) : ClonableObject(*new AddressPrivate) { d->internalAddress = sal_address_clone(salAddress); } -Address::Address (const IdentityAddress &src) : ClonableObject(*new AddressPrivate) { - L_D(); - - const string &username = src.getUsername(); - if (username.empty()) - return; - const string &domain = src.getDomain(); - if (domain.empty()) - return; - - string uri = src.getScheme() + ":" + username + "@" + ( - domain.find(':') != string::npos ? "[" + domain + "]" : domain - ); - - if (src.hasGruu()) - uri += ";gr=" + src.getGruu(); - - d->internalAddress = sal_address_new(L_STRING_TO_C(uri)); -} - Address::~Address () { L_D(); if (d->internalAddress) diff --git a/src/address/address.h b/src/address/address.h index 718273731..a34a0081a 100644 --- a/src/address/address.h +++ b/src/address/address.h @@ -41,8 +41,8 @@ class LINPHONE_PUBLIC Address : public ClonableObject { public: explicit Address (const std::string &address = ""); + Address (const IdentityAddress &identityAddress); Address (const Address &src); - Address (const IdentityAddress &src); ~Address (); Address &operator= (const Address &src); diff --git a/src/address/identity-address.cpp b/src/address/identity-address.cpp index 982c55a69..b4cd58714 100644 --- a/src/address/identity-address.cpp +++ b/src/address/identity-address.cpp @@ -42,6 +42,15 @@ IdentityAddress::IdentityAddress (const string &address) : ClonableObject(*new I } } +IdentityAddress::IdentityAddress (const Address &address) : ClonableObject(*new IdentityAddressPrivate) { + L_D(); + d->scheme = address.getScheme(); + d->username = address.getUsername(); + d->domain = address.getDomain(); + if (address.hasUriParam("gr")) + d->gruu = address.getUriParamValue("gr"); +} + IdentityAddress::IdentityAddress (const IdentityAddress &src) : ClonableObject(*new IdentityAddressPrivate) { L_D(); d->scheme = src.getScheme(); @@ -50,14 +59,6 @@ IdentityAddress::IdentityAddress (const IdentityAddress &src) : ClonableObject(* d->gruu = src.getGruu(); } -IdentityAddress::IdentityAddress (const Address &src) : ClonableObject(*new IdentityAddressPrivate) { - L_D(); - d->scheme = src.getScheme(); - d->username = src.getUsername(); - d->domain = src.getDomain(); - d->gruu = src.getUriParamValue("gr"); -} - IdentityAddress &IdentityAddress::operator= (const IdentityAddress &src) { L_D(); if (this != &src) { diff --git a/src/address/identity-address.h b/src/address/identity-address.h index 5587bb0c1..2d131623e 100644 --- a/src/address/identity-address.h +++ b/src/address/identity-address.h @@ -32,8 +32,8 @@ class IdentityAddressPrivate; class LINPHONE_PUBLIC IdentityAddress : public ClonableObject { public: explicit IdentityAddress (const std::string &address = ""); + IdentityAddress (const Address &address); IdentityAddress (const IdentityAddress &src); - IdentityAddress (const Address &src); ~IdentityAddress () = default; IdentityAddress &operator= (const IdentityAddress &src); diff --git a/src/c-wrapper/api/c-chat-room.cpp b/src/c-wrapper/api/c-chat-room.cpp index f2a0da4b5..5f81c0f7b 100644 --- a/src/c-wrapper/api/c-chat-room.cpp +++ b/src/c-wrapper/api/c-chat-room.cpp @@ -230,7 +230,9 @@ LinphoneChatRoomState linphone_chat_room_get_state (const LinphoneChatRoom *cr) } 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) { @@ -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) { - 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) { if (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()) cr->conferenceAddressCache = linphone_address_new(address.asString().c_str()); else @@ -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(); if (from.empty()) from = linphone_core_get_primary_contact(core); - LinphonePrivate::Address me(from); + LinphonePrivate::IdentityAddress me(from); LinphoneChatRoom *cr = L_INIT(ChatRoom); L_SET_CPP_PTR_FROM_C_OBJECT(cr, make_shared( core->cppCore, L_C_TO_STRING(uri), me, L_C_TO_STRING(subject)) diff --git a/src/c-wrapper/api/c-participant.cpp b/src/c-wrapper/api/c-participant.cpp index 783c92ca3..af6fc1815 100644 --- a/src/c-wrapper/api/c-participant.cpp +++ b/src/c-wrapper/api/c-participant.cpp @@ -48,7 +48,7 @@ void linphone_participant_set_user_data(LinphoneParticipant *participant, void * } 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) linphone_address_unref(participant->addressCache); participant->addressCache = linphone_address_new(addr.asString().c_str()); diff --git a/src/content/content.cpp b/src/content/content.cpp index 359d70fb4..1033332f9 100644 --- a/src/content/content.cpp +++ b/src/content/content.cpp @@ -49,14 +49,14 @@ Content::Content (Content &&src) : ClonableObject(*new ContentPrivate), AppDataC d->contentDisposition = move(src.getPrivate()->contentDisposition); } -Content::Content (ContentPrivate &p) : ClonableObject(p) { - -} +Content::Content (ContentPrivate &p) : ClonableObject(p) {} Content::~Content () { 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); } diff --git a/src/core/core.cpp b/src/core/core.cpp index 4e294ec3f..3f68e32d9 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -42,7 +42,7 @@ shared_ptr Core::create (LinphoneCore *cCore) { // Do not use `make_shared` => Private constructor. shared_ptr core = shared_ptr(new Core); - CorePrivate * const d = core->getPrivate(); + CorePrivate *const d = core->getPrivate(); d->cCore = cCore; d->mainDb.reset(new MainDb(core->getSharedFromThis())); diff --git a/src/core/platform-helpers/platform-helpers.h b/src/core/platform-helpers/platform-helpers.h index 25bd23852..e41bf9fae 100644 --- a/src/core/platform-helpers/platform-helpers.h +++ b/src/core/platform-helpers/platform-helpers.h @@ -50,14 +50,14 @@ public: virtual std::string getConfigPath () = 0; protected: - inline PlatformHelpers (LinphoneCore *lc) : mCore(lc) {} + inline explicit PlatformHelpers (LinphoneCore *lc) : mCore(lc) {} LinphoneCore *mCore; }; class StubbedPlatformHelpers : public PlatformHelpers { public: - StubbedPlatformHelpers (LinphoneCore *lc); + explicit StubbedPlatformHelpers (LinphoneCore *lc); virtual ~StubbedPlatformHelpers () = default; void setDnsServers () override;