diff --git a/src/contactmethod.cpp b/src/contactmethod.cpp index fd39ec8031ccb52b589f5828997303f8c2420aa1..5aa5fc9f9225fa6ae9ebe8495d22a68ee45d98d9 100644 --- a/src/contactmethod.cpp +++ b/src/contactmethod.cpp @@ -439,6 +439,21 @@ QString ContactMethod::getBestId() const return d_ptr->m_RegisteredName.isEmpty() ? d_ptr->m_Uri : d_ptr->m_RegisteredName; } +/** + * Return if this ContactMethod pointer is the `master` one or a deduplicated + * proxy. + * + * Contact methods can be merged over time to avoid both the memory overhead + * and diverging statistics / presence / messaging. As explained in `merge()`, + * the old pointers are kept alive as they are proxies to the real object + * (d_ptr). This accessor helps some algorithm detect if they can safely get + * rid of this CM as a "better" one already exists (assuming the track all CMs). + */ +bool ContactMethod::isDuplicate() const +{ + return d_ptr->m_lParents.first() != this; +} + ///Is this number bookmarked bool ContactMethod::isBookmarked() const { diff --git a/src/contactmethod.h b/src/contactmethod.h index f7af5b610363171da5d7507664b571b2fcb60cf0..bedf33b682a8e096011635b9218daccf53baa482 100644 --- a/src/contactmethod.h +++ b/src/contactmethod.h @@ -133,6 +133,7 @@ public: Certificate* certificate () const; QString registeredName () const; QString getBestId () const; + bool isDuplicate () const; /* * Returns roles associated on ContactMethod based on Call::Roles