[ekiga] Make sure the call history is always correctly ordered



commit d42a8e6b5854fb231251b01582606d553dc854c3
Author: Julien Puydt <jpuydt free fr>
Date:   Fri Oct 26 14:35:41 2012 +0200

    Make sure the call history is always correctly ordered
    
    History::Book was inheriting from Ekiga::BookImpl which is not ordered.
    Now it directly implements the Ekiga::Book interface, and keeps its
    contacts ordered.

 .../components/call-history/history-book.cpp       |   24 ++++++++++++++++++-
 lib/engine/components/call-history/history-book.h  |    4 ++-
 .../components/call-history/history-contact.h      |    4 ++-
 3 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/lib/engine/components/call-history/history-book.cpp b/lib/engine/components/call-history/history-book.cpp
index dde80a1..7ac45ed 100644
--- a/lib/engine/components/call-history/history-book.cpp
+++ b/lib/engine/components/call-history/history-book.cpp
@@ -104,6 +104,15 @@ History::Book::get_name () const
 }
 
 void
+History::Book::visit_contacts (boost::function1<bool, Ekiga::ContactPtr> visitor) const
+{
+  for (std::list<ContactPtr>::const_iterator iter = ordered_contacts.begin ();
+       iter != ordered_contacts.end();
+       ++iter)
+    visitor (*iter);
+}
+
+void
 History::Book::add (xmlNodePtr node)
 {
   common_add (ContactPtr (new Contact (core, doc, node)));
@@ -173,7 +182,12 @@ History::Book::clear ()
 {
   xmlNodePtr root = NULL;
 
-  remove_all_objects ();
+  std::list<ContactPtr> old_contacts = ordered_contacts;
+  ordered_contacts.clear ();
+  for (std::list<ContactPtr>::iterator iter = old_contacts.begin ();
+       iter != old_contacts.end();
+       ++iter)
+    contact_removed (*iter);
 
   doc = boost::shared_ptr<xmlDoc> (xmlNewDoc (BAD_CAST "1.0"), xmlFreeDoc);
   root = xmlNewDocNode (doc.get (), NULL, BAD_CAST "list", NULL);
@@ -209,8 +223,14 @@ History::Book::on_cleared_call (boost::shared_ptr<Ekiga::CallManager> /*manager*
 void
 History::Book::common_add (ContactPtr contact)
 {
-  add_contact (contact);
+  contact->questions.connect (boost::ref (questions));
+  /* nothing to do when the contact is updated or removed:
+   * they don't get updated and only get removed all at the same time
+   */
+
   ordered_contacts.push_back (contact);
+  contact_added (contact);
+  updated ();
 }
 
 void
diff --git a/lib/engine/components/call-history/history-book.h b/lib/engine/components/call-history/history-book.h
index bbda076..4c0b4f7 100644
--- a/lib/engine/components/call-history/history-book.h
+++ b/lib/engine/components/call-history/history-book.h
@@ -52,7 +52,7 @@ namespace History
  */
 
   class Book:
-    public Ekiga::BookImpl<Contact>,
+    public Ekiga::Book,
     public boost::signals::trackable
   {
   public:
@@ -63,6 +63,8 @@ namespace History
 
     ~Book ();
 
+    void visit_contacts (boost::function1<bool, Ekiga::ContactPtr>) const;
+
     const std::string get_name () const;
 
     bool populate_menu (Ekiga::MenuBuilder &);
diff --git a/lib/engine/components/call-history/history-contact.h b/lib/engine/components/call-history/history-contact.h
index 0245a91..d109f6b 100644
--- a/lib/engine/components/call-history/history-contact.h
+++ b/lib/engine/components/call-history/history-contact.h
@@ -59,7 +59,9 @@ namespace History
     MISSED
   } call_type;
 
-  class Contact: public Ekiga::Contact
+  class Contact:
+    public Ekiga::Contact,
+    public boost::signals::trackable
   {
   public:
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]