[ekiga] Added a find_presentity_for_uri method to Opal::Bank



commit d31641c8943aecd4d19188f699b2d11660d03e1a
Author: Julien Puydt <jpuydt free fr>
Date:   Sun Feb 16 18:01:07 2014 +0100

    Added a find_presentity_for_uri method to Opal::Bank
    
    It should be useful for the SIP chat code

 lib/engine/components/opal/opal-bank.cpp |   36 ++++++++++++++++++++++++++++++
 lib/engine/components/opal/opal-bank.h   |    4 ++-
 2 files changed, 39 insertions(+), 1 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-bank.cpp b/lib/engine/components/opal/opal-bank.cpp
index b4bd207..87f8a6b 100644
--- a/lib/engine/components/opal/opal-bank.cpp
+++ b/lib/engine/components/opal/opal-bank.cpp
@@ -46,6 +46,7 @@
 #include "form-request-simple.h"
 
 #include "opal-bank.h"
+#include "opal-presentity.h"
 #include "sip-endpoint.h"
 
 
@@ -471,6 +472,40 @@ Opal::Bank::existing_groups () const
   return result;
 }
 
+struct find_presentity_helper
+{
+  find_presentity_helper (const std::string uri_): uri(uri_)
+  {}
+
+  bool operator() (Ekiga::PresentityPtr pres)
+  {
+    Opal::PresentityPtr presentity = boost::dynamic_pointer_cast<Opal::Presentity> (pres);
+
+    if (presentity && presentity->get_uri () == uri)
+      result = presentity;
+
+    return !result;
+  }
+
+  std::string uri;
+  Ekiga::PresentityPtr result;
+};
+
+Ekiga::PresentityPtr
+Opal::Bank::find_presentity_for_uri (const std::string uri) const
+{
+  find_presentity_helper helper(uri);
+
+  for (const_iterator iter = begin ();
+       iter != end () && !helper.result;
+       ++iter) {
+
+    (*iter)->visit_presentities(boost::ref(helper));
+  }
+
+  return helper.result;
+}
+
 void
 Opal::Bank::migrate_from_gconf (const std::list<std::string> old)
 {
@@ -566,3 +601,4 @@ Opal::Bank::migrate_from_gconf (const std::list<std::string> old)
   delete settings;
   xmlFreeDoc (doc);
 }
+
diff --git a/lib/engine/components/opal/opal-bank.h b/lib/engine/components/opal/opal-bank.h
index 9cf3752..630b2b5 100644
--- a/lib/engine/components/opal/opal-bank.h
+++ b/lib/engine/components/opal/opal-bank.h
@@ -111,7 +111,6 @@ public:
      */
     AccountPtr find_account (const std::string& aor);
 
-
     void call_manager_ready ();
 
     /* this object is an Ekiga::Cluster */
@@ -119,6 +118,9 @@ public:
 
     const std::set<std::string> existing_groups () const;
 
+    /* this is useful when we want to do something with some uri and
+       would like to avoid creating a brand-new presentity on it */
+    Ekiga::PresentityPtr find_presentity_for_uri (const std::string uri) const;
 
     // FIXME: only here for the transition off gconf
     static void migrate_from_gconf (const std::list<std::string> old);


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