[ekiga] Made starting&continuing chats work with the loudmouth code



commit 13581e7b6952dcb5d3f0366f7839c576b4f9b528
Author: Julien Puydt <jpuydt gnome org>
Date:   Tue Dec 15 21:55:34 2009 +0100

    Made starting&continuing chats work with the loudmouth code
    
    It was opening a new chat every time the user asked... now it shows the existing one.

 plugins/loudmouth/loudmouth-dialect.cpp |   43 +++++++++++++------------------
 plugins/loudmouth/loudmouth-dialect.h   |    2 -
 2 files changed, 18 insertions(+), 27 deletions(-)
---
diff --git a/plugins/loudmouth/loudmouth-dialect.cpp b/plugins/loudmouth/loudmouth-dialect.cpp
index c78d2a4..50742f9 100644
--- a/plugins/loudmouth/loudmouth-dialect.cpp
+++ b/plugins/loudmouth/loudmouth-dialect.cpp
@@ -71,50 +71,43 @@ LM::Dialect::push_message (PresentityPtr presentity,
   }
 }
 
-void
-LM::Dialect::open_chat (PresentityPtr presentity)
+struct open_chat_helper
 {
-  SimpleChatPtr chat = find_chat (presentity);
-  if ( !chat) {
-
-    chat = SimpleChatPtr (new SimpleChat (core, presentity));
-    add_simple_chat (chat);
-  }
-
-  chat->user_requested ();
-}
 
-struct find_chat_helper
-{
-
-  find_chat_helper (Ekiga::PresentityPtr presentity_):
+  open_chat_helper (Ekiga::PresentityPtr presentity_):
     presentity(presentity_)
-  {}
+  { }
 
-  bool test (Ekiga::SimpleChatPtr chat_)
+  bool test (Ekiga::SimpleChatPtr chat_) const
   {
     LM::SimpleChatPtr chat = boost::dynamic_pointer_cast<LM::SimpleChat> (chat_);
+    bool go_on = true;
 
     if (chat->get_presentity () == presentity) {
 
-      answer = chat;
+      chat->user_requested ();      
+      go_on = false;
     }
 
-    return !answer;
+    return go_on;
   }
 
   Ekiga::PresentityPtr presentity;
-  LM::SimpleChatPtr answer;
 };
 
-LM::SimpleChatPtr
-LM::Dialect::find_chat (PresentityPtr presentity) const
+void
+LM::Dialect::open_chat (PresentityPtr presentity)
 {
-  find_chat_helper helper (presentity);
+  if ( !presentity->has_chat) {
 
-  visit_simple_chats (boost::bind (&find_chat_helper::test, helper, _1));
+    LM::SimpleChatPtr chat(new SimpleChat (core, presentity));
+    add_simple_chat (chat);
+    chat->user_requested ();
+  } else {
 
-  return helper.answer;
+    open_chat_helper helper(presentity);
+    visit_simple_chats (boost::bind (&open_chat_helper::test, helper, _1));
+  }
 }
 
 bool
diff --git a/plugins/loudmouth/loudmouth-dialect.h b/plugins/loudmouth/loudmouth-dialect.h
index bede947..2d91c51 100644
--- a/plugins/loudmouth/loudmouth-dialect.h
+++ b/plugins/loudmouth/loudmouth-dialect.h
@@ -61,8 +61,6 @@ namespace LM
 
   private:
 
-    SimpleChatPtr find_chat (PresentityPtr presentity) const;
-
     Ekiga::ServiceCore& core;
   };
 



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