[ekiga] Added an api to SIP::Heap to find the name of an uri



commit 36d25c9a078f71d8b752d263eb85c9516dc49a45
Author: Julien Puydt <jpuydt free fr>
Date:   Fri Feb 21 22:56:12 2014 +0100

    Added an api to SIP::Heap to find the name of an uri

 lib/engine/components/opal/sip-heap.cpp |   22 ++++++++++++++++++++++
 lib/engine/components/opal/sip-heap.h   |    3 +++
 2 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/lib/engine/components/opal/sip-heap.cpp b/lib/engine/components/opal/sip-heap.cpp
index a09302a..7a8e0e9 100644
--- a/lib/engine/components/opal/sip-heap.cpp
+++ b/lib/engine/components/opal/sip-heap.cpp
@@ -34,6 +34,7 @@
  */
 
 #include "sip-heap.h"
+#include "uri-presentity.h"
 
 bool
 SIP::Heap::populate_menu (Ekiga::MenuBuilder& /*builder*/)
@@ -53,3 +54,24 @@ SIP::Heap::populate_menu_for_group (const std::string /*name*/,
 {
   return false;
 }
+
+const std::string
+SIP::Heap::get_name (const std::string uri) const
+{
+  bool found = false;
+  std::string result = uri; // sensible default
+
+  for (const_iterator iter = begin ();
+       iter != end () and not found;
+       ++iter) {
+
+    boost::shared_ptr<Ekiga::URIPresentity> pres
+      = boost::dynamic_pointer_cast<Ekiga::URIPresentity> (*iter);
+    if (pres and pres->get_uri () == uri) {
+      
+      found = true;
+      result = pres->get_name ();
+    }
+  }
+  return result;
+}
diff --git a/lib/engine/components/opal/sip-heap.h b/lib/engine/components/opal/sip-heap.h
index 15c876b..70e7811 100644
--- a/lib/engine/components/opal/sip-heap.h
+++ b/lib/engine/components/opal/sip-heap.h
@@ -49,7 +49,10 @@ namespace SIP
     using Ekiga::HeapImpl<Ekiga::Presentity>::add_connection;
 
     bool populate_menu (Ekiga::MenuBuilder& builder);
+    // this is the heap's name
     const std::string get_name () const;
+    // try to find a nice name to display from the uri of a presentity
+    const std::string get_name (const std::string uri) const;
     bool populate_menu_for_group (const std::string name,
                                  Ekiga::MenuBuilder& builder);
   };


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