[ekiga] Simplified loudmouth's chat code
- From: Julien Puydt <jpuydt src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [ekiga] Simplified loudmouth's chat code
- Date: Sun, 13 Dec 2009 16:51:04 +0000 (UTC)
commit 3c69700d0e4cd1c18833220991be10e960433dd8
Author: Julien Puydt <jpuydt gnome org>
Date: Fri Dec 11 16:04:42 2009 +0100
Simplified loudmouth's chat code
Removed the has_chat from the presentity code to push in the dialect.
That gives a bug in the chat view... which I'll have to fix.
plugins/loudmouth/loudmouth-chat-simple.cpp | 2 -
plugins/loudmouth/loudmouth-dialect.cpp | 42 +++++++++++++++++++++++++-
plugins/loudmouth/loudmouth-dialect.h | 2 +
plugins/loudmouth/loudmouth-presentity.cpp | 5 +--
plugins/loudmouth/loudmouth-presentity.h | 2 -
5 files changed, 43 insertions(+), 10 deletions(-)
---
diff --git a/plugins/loudmouth/loudmouth-chat-simple.cpp b/plugins/loudmouth/loudmouth-chat-simple.cpp
index 0f884a1..f691e3e 100644
--- a/plugins/loudmouth/loudmouth-chat-simple.cpp
+++ b/plugins/loudmouth/loudmouth-chat-simple.cpp
@@ -43,12 +43,10 @@ LM::SimpleChat::SimpleChat (Ekiga::ServiceCore& core_,
PresentityPtr presentity_):
core(core_), presentity(presentity_)
{
- presentity->has_chat = true;
}
LM::SimpleChat::~SimpleChat ()
{
- presentity->has_chat = false;
}
const std::string
diff --git a/plugins/loudmouth/loudmouth-dialect.cpp b/plugins/loudmouth/loudmouth-dialect.cpp
index 231c80d..c78d2a4 100644
--- a/plugins/loudmouth/loudmouth-dialect.cpp
+++ b/plugins/loudmouth/loudmouth-dialect.cpp
@@ -74,11 +74,49 @@ LM::Dialect::push_message (PresentityPtr presentity,
void
LM::Dialect::open_chat (PresentityPtr presentity)
{
- SimpleChatPtr chat(new SimpleChat (core, presentity));
- add_simple_chat (chat);
+ 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_):
+ presentity(presentity_)
+ {}
+
+ bool test (Ekiga::SimpleChatPtr chat_)
+ {
+ LM::SimpleChatPtr chat = boost::dynamic_pointer_cast<LM::SimpleChat> (chat_);
+
+ if (chat->get_presentity () == presentity) {
+
+ answer = chat;
+ }
+
+ return !answer;
+ }
+
+ Ekiga::PresentityPtr presentity;
+ LM::SimpleChatPtr answer;
+};
+
+LM::SimpleChatPtr
+LM::Dialect::find_chat (PresentityPtr presentity) const
+{
+ find_chat_helper helper (presentity);
+
+ visit_simple_chats (boost::bind (&find_chat_helper::test, helper, _1));
+
+ return helper.answer;
+}
+
bool
LM::Dialect::populate_menu (Ekiga::MenuBuilder& /*builder*/)
{
diff --git a/plugins/loudmouth/loudmouth-dialect.h b/plugins/loudmouth/loudmouth-dialect.h
index 2d91c51..bede947 100644
--- a/plugins/loudmouth/loudmouth-dialect.h
+++ b/plugins/loudmouth/loudmouth-dialect.h
@@ -61,6 +61,8 @@ namespace LM
private:
+ SimpleChatPtr find_chat (PresentityPtr presentity) const;
+
Ekiga::ServiceCore& core;
};
diff --git a/plugins/loudmouth/loudmouth-presentity.cpp b/plugins/loudmouth/loudmouth-presentity.cpp
index 8bfcfbb..c7f990a 100644
--- a/plugins/loudmouth/loudmouth-presentity.cpp
+++ b/plugins/loudmouth/loudmouth-presentity.cpp
@@ -173,10 +173,7 @@ LM::Presentity::populate_menu (Ekiga::MenuBuilder& builder)
builder.add_action ("stop", _("Stop getting his/her status"), boost::bind (&LM::Presentity::stop_to, this));
}
- if ( !has_chat) {
-
- builder.add_action ("chat", _("Start chat"), boost::ref (chat_requested));
- }
+ builder.add_action ("chat", _("Start chat"), boost::ref (chat_requested));
builder.add_action ("remove", _("_Remove"),
boost::bind (&LM::Presentity::remove_presentity, this));
diff --git a/plugins/loudmouth/loudmouth-presentity.h b/plugins/loudmouth/loudmouth-presentity.h
index a50def4..a764266 100644
--- a/plugins/loudmouth/loudmouth-presentity.h
+++ b/plugins/loudmouth/loudmouth-presentity.h
@@ -74,8 +74,6 @@ namespace LM
void push_presence (const std::string resource,
LmMessageNode* presence);
- bool has_chat;
-
boost::signal0<void> chat_requested;
private:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]