From 2a6d11537c92e475d7ef3947097a20cad50607ac Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee <elv1313@gmail.com> Date: Tue, 9 May 2017 01:06:48 -0400 Subject: [PATCH] contactmethod: Add an `isDuplicate()` accessor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Will help makes some other algorithm saner Change-Id: I5fae9bab47c6b508a95cf318c1a5a9fdb26d4bb3 Reviewed-by: Nicolas Jäger <nicolas.jager@savoirfairelinux.com> --- src/contactmethod.cpp | 15 +++++++++++++++ src/contactmethod.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/contactmethod.cpp b/src/contactmethod.cpp index fd39ec80..5aa5fc9f 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 f7af5b61..bedf33b6 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 -- GitLab