From 0d89d690e0e192340a34f65ab8ccf5b6d4f1fbeb Mon Sep 17 00:00:00 2001
From: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
Date: Thu, 8 Sep 2016 14:12:43 -0400
Subject: [PATCH] person: forward callAdded signal

ContactMethod objects emit a callAdded signal when a new call is
created that ContactMethod. This patch forwards that signal to
the Person object which contains that ContactMethod, so that the
Person object can also emit a callAdded signal.

Change-Id: I913035e0610349ad810e8e29b0b585b19e05ee85
Tuleap: #956
---
 src/person.cpp         | 10 ++++++++++
 src/person.h           |  2 ++
 src/private/person_p.h |  2 +-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/person.cpp b/src/person.cpp
index 7b4d43f2..56430ceb 100644
--- a/src/person.cpp
+++ b/src/person.cpp
@@ -184,6 +184,7 @@ void PersonPrivate::registerContactMethod(ContactMethod* m)
 {
    m_HiddenContactMethods << m;
    connect(m, &ContactMethod::lastUsedChanged, this, &PersonPrivate::slotLastUsedTimeChanged);
+   connect(m, &ContactMethod::callAdded, this, &PersonPrivate::slotCallAdded);
 
    if (m->lastUsed() > m_LastUsed)
       slotLastUsedTimeChanged(m->lastUsed());
@@ -360,6 +361,7 @@ void Person::setContactMethods(ContactMethods numbers)
       disconnect(n,SIGNAL(presentChanged(bool)),this,SLOT(slotPresenceChanged()));
       disconnect(n, &ContactMethod::lastUsedChanged, d_ptr, &PersonPrivate::slotLastUsedTimeChanged);
       disconnect(n, &ContactMethod::unreadTextMessageCountChanged, d_ptr, &PersonPrivate::changed);
+      disconnect(n, &ContactMethod::callAdded, d_ptr, &PersonPrivate::slotCallAdded);
    }
    d_ptr->m_Numbers = numbers;
 
@@ -367,6 +369,7 @@ void Person::setContactMethods(ContactMethods numbers)
       connect(n,SIGNAL(presentChanged(bool)),this,SLOT(slotPresenceChanged()));
       connect(n, &ContactMethod::lastUsedChanged, d_ptr, &PersonPrivate::slotLastUsedTimeChanged);
       connect(n, &ContactMethod::unreadTextMessageCountChanged, d_ptr, &PersonPrivate::changed);
+      connect(n, &ContactMethod::callAdded, d_ptr, &PersonPrivate::slotCallAdded);
    }
 
    d_ptr->phoneNumbersChanged();
@@ -747,3 +750,10 @@ void PersonPrivate::slotLastUsedTimeChanged(::time_t t)
       emit c->lastUsedTimeChanged(t);
    }
 }
+
+void PersonPrivate::slotCallAdded(Call *call)
+{
+    foreach (Person* c,m_lParents) {
+        emit c->callAdded(call);
+    }
+}
diff --git a/src/person.h b/src/person.h
index ea236a75..8520a382 100644
--- a/src/person.h
+++ b/src/person.h
@@ -196,6 +196,8 @@ Q_SIGNALS:
    void rebased                   ( Person*        );
    ///The last time there was an interaction with this person changed
    void lastUsedTimeChanged       ( long long      ) const;
+   ///A new call used a ContactMethod associated with this Person
+   void callAdded                 ( Call*          );
 
 protected:
    //Presence secret methods
diff --git a/src/private/person_p.h b/src/private/person_p.h
index 1dea83e9..9ed62aaf 100644
--- a/src/private/person_p.h
+++ b/src/private/person_p.h
@@ -84,5 +84,5 @@ public:
 
 public Q_SLOTS:
    void slotLastUsedTimeChanged(::time_t t);
+   void slotCallAdded          (Call *call);
 };
-
-- 
GitLab