[ekiga] Added a SIP::Heap class so the SIP::Conversation now has a meaningful heap to show



commit 3eb457ca2f521834d49930ffcf92d28c5e4c3f51
Author: Julien Puydt <jpuydt free fr>
Date:   Sun Feb 16 15:48:57 2014 +0100

    Added a SIP::Heap class so the SIP::Conversation now has a meaningful heap to show
    
    Notice that the presentity starts by looking bad, and turns
    better with updates -- I shall fix that later on

 lib/Makefile.am                                 |    2 +
 lib/engine/components/opal/sip-conversation.cpp |   15 ++++++
 lib/engine/components/opal/sip-conversation.h   |   15 ++++--
 lib/engine/components/opal/sip-dialect.cpp      |    7 ++-
 lib/engine/components/opal/sip-dialect.h        |    4 +-
 lib/engine/components/opal/sip-endpoint.cpp     |    3 +-
 lib/engine/components/opal/sip-heap.cpp         |   55 +++++++++++++++++++++
 lib/engine/components/opal/sip-heap.h           |   58 +++++++++++++++++++++++
 8 files changed, 147 insertions(+), 12 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 3569c84..48bb0d0 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -437,6 +437,8 @@ libekiga_la_SOURCES += \
 endif
 
 libekiga_la_SOURCES += \
+       engine/components/opal/sip-heap.h \
+       engine/components/opal/sip-heap.cpp \
        engine/components/opal/sip-conversation.h \
        engine/components/opal/sip-conversation.cpp \
        engine/components/opal/sip-dialect.h \
diff --git a/lib/engine/components/opal/sip-conversation.cpp b/lib/engine/components/opal/sip-conversation.cpp
index 09ca21b..c4c60cd 100644
--- a/lib/engine/components/opal/sip-conversation.cpp
+++ b/lib/engine/components/opal/sip-conversation.cpp
@@ -34,6 +34,21 @@
  */
 
 #include "sip-conversation.h"
+#include "uri-presentity.h"
+
+SIP::Conversation::Conversation (boost::shared_ptr<Ekiga::PresenceCore> _core,
+                                const std::string _uri,
+                                const std::string _name,
+                                boost::function1<bool, const Ekiga::Message::payload_type&> _sender):
+  presence_core(_core), uri(_uri), title(_name), sender(_sender)
+{
+  // FIXME: this api isn't good: we obviously don't handle correctly Conversation with several people!
+  boost::shared_ptr<Ekiga::URIPresentity> presentity =
+    boost::shared_ptr<Ekiga::URIPresentity> (new Ekiga::URIPresentity (_core, title, uri,
+                                                                      std::set<std::string> ()));
+  heap  = boost::shared_ptr<Heap> (new Heap);
+  heap->add_presentity (boost::dynamic_pointer_cast<Ekiga::Presentity> (presentity));
+}
 
 void
 SIP::Conversation::visit_messages (boost::function1<bool, const Ekiga::Message&> visitor) const
diff --git a/lib/engine/components/opal/sip-conversation.h b/lib/engine/components/opal/sip-conversation.h
index 8ba9b28..5a91958 100644
--- a/lib/engine/components/opal/sip-conversation.h
+++ b/lib/engine/components/opal/sip-conversation.h
@@ -37,6 +37,9 @@
 #define __SIP_CONVERSATION_H__
 
 #include "conversation.h"
+#include "presence-core.h"
+
+#include "sip-heap.h"
 
 namespace SIP {
 
@@ -44,16 +47,15 @@ namespace SIP {
   {
   public:
 
-    Conversation (const std::string _uri,
+    Conversation (boost::shared_ptr<Ekiga::PresenceCore> _core,
+                 const std::string _uri,
                  const std::string _name,
-                 boost::function1<bool, const Ekiga::Message::payload_type&> _sender):
-      uri(_uri), title(_name), sender(_sender)
-    {}
+                 boost::function1<bool, const Ekiga::Message::payload_type&> _sender);
 
     // generic Ekiga::Conversation api:
 
     Ekiga::HeapPtr get_heap () const
-    { return heap; }
+    { return boost::dynamic_pointer_cast<Ekiga::Heap>(heap); }
 
     // FIXME: is that part of the api any good?!
     const std::string get_title () const
@@ -80,10 +82,11 @@ namespace SIP {
 
   private:
 
+    boost::weak_ptr<Ekiga::PresenceCore> presence_core;
     std::string uri;
     std::string title;
     boost::function1<bool, Ekiga::Message::payload_type> sender;
-    Ekiga::HeapPtr heap;
+    boost::shared_ptr<Heap> heap;
     std::string topic;
     int unreads;
     std::list<Ekiga::Message> messages;
diff --git a/lib/engine/components/opal/sip-dialect.cpp b/lib/engine/components/opal/sip-dialect.cpp
index ec879a4..6566100 100644
--- a/lib/engine/components/opal/sip-dialect.cpp
+++ b/lib/engine/components/opal/sip-dialect.cpp
@@ -39,9 +39,9 @@
 #include "presence-core.h"
 #include "personal-details.h"
 
-SIP::Dialect::Dialect (Ekiga::ServiceCore& core_,
+SIP::Dialect::Dialect (boost::shared_ptr<Ekiga::PresenceCore> core_,
                       boost::function2<bool, std::string, Ekiga::Message::payload_type> sender_):
-  core(core_),
+  presence_core(core_),
   sender(sender_)
 {
 }
@@ -92,7 +92,8 @@ SIP::Dialect::open_chat_with (std::string uri,
   if ( !result) {
 
     // FIXME: here find a better display_name
-    result = ConversationPtr (new Conversation(uri,
+    result = ConversationPtr (new Conversation(presence_core,
+                                              uri,
                                               display_name,
                                               boost::bind(sender, uri, _1)));
     add_conversation (result);
diff --git a/lib/engine/components/opal/sip-dialect.h b/lib/engine/components/opal/sip-dialect.h
index 7da62b2..2e94dd5 100644
--- a/lib/engine/components/opal/sip-dialect.h
+++ b/lib/engine/components/opal/sip-dialect.h
@@ -48,7 +48,7 @@ namespace SIP
   class Dialect: public Ekiga::DialectImpl<Conversation>
   {
   public:
-    Dialect (Ekiga::ServiceCore& core_,
+    Dialect (boost::shared_ptr<Ekiga::PresenceCore> core_,
             boost::function2<bool, std::string, Ekiga::Message::payload_type> sender_);
 
     ~Dialect ();
@@ -62,7 +62,7 @@ namespace SIP
                          std::string name);
 
   private:
-    Ekiga::ServiceCore& core;
+    boost::shared_ptr<Ekiga::PresenceCore> presence_core;
     boost::function2<bool, std::string, Ekiga::Message::payload_type> sender;
 
     ConversationPtr open_chat_with (std::string uri,
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/sip-endpoint.cpp
index 0f440b9..a74ca31 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/sip-endpoint.cpp
@@ -118,11 +118,12 @@ Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager,
   manager (_manager)
 {
   boost::shared_ptr<Ekiga::ChatCore> chat_core = core.get<Ekiga::ChatCore> ("chat-core");
+  boost::shared_ptr<Ekiga::PresenceCore> presence_core = core.get<Ekiga::PresenceCore> ("presence-core");
 
   protocol_name = "sip";
   uri_prefix = "sip:";
 
-  dialect = boost::shared_ptr<SIP::Dialect>(new SIP::Dialect (core, boost::bind 
(&Opal::Sip::EndPoint::send_message, this, _1, _2)));
+  dialect = boost::shared_ptr<SIP::Dialect>(new SIP::Dialect (presence_core, boost::bind 
(&Opal::Sip::EndPoint::send_message, this, _1, _2)));
   chat_core->add_dialect (dialect);
 
   /* Timeouts */
diff --git a/lib/engine/components/opal/sip-heap.cpp b/lib/engine/components/opal/sip-heap.cpp
new file mode 100644
index 0000000..a09302a
--- /dev/null
+++ b/lib/engine/components/opal/sip-heap.cpp
@@ -0,0 +1,55 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2014 Damien Sandras <dsandras seconix com>
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         sip-heap.cpp -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2014 by Julien Puydt
+ *   copyright            : (c) 2014 by Julien Puydt
+ *   description          : implementation of an Ekiga::Heap implementation for a SIP::Conversation
+ *
+ */
+
+#include "sip-heap.h"
+
+bool
+SIP::Heap::populate_menu (Ekiga::MenuBuilder& /*builder*/)
+{
+  return false;
+}
+
+const std::string
+SIP::Heap::get_name () const
+{
+  return ""; // FIXME?
+}
+
+bool
+SIP::Heap::populate_menu_for_group (const std::string /*name*/,
+                                   Ekiga::MenuBuilder& /*builder*/)
+{
+  return false;
+}
diff --git a/lib/engine/components/opal/sip-heap.h b/lib/engine/components/opal/sip-heap.h
new file mode 100644
index 0000000..15c876b
--- /dev/null
+++ b/lib/engine/components/opal/sip-heap.h
@@ -0,0 +1,58 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2014 Damien Sandras <dsandras seconix com>
+
+ * This program is free software; you can  redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Ekiga is licensed under the GPL license and as a special exception, you
+ * have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
+ * applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
+ * programs, as long as you do follow the requirements of the GNU GPL for all
+ * the rest of the software thus combined.
+ */
+
+
+/*
+ *                         sip-heap.h -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2014 by Julien Puydt
+ *   copyright            : (c) 2014 by Julien Puydt
+ *   description          : declaration of an Ekiga::Heap implementation for a SIP::Conversation
+ *
+ */
+
+#ifndef __SIP_HEAP_H__
+#define __SIP_HEAP_H__
+
+#include "heap-impl.h"
+
+namespace SIP
+{
+  class Heap: public Ekiga::HeapImpl<Ekiga::Presentity>
+  {
+  public:
+    // let's put everything in public so SIP::Conversation can control us fully!
+    using Ekiga::HeapImpl<Ekiga::Presentity>::add_presentity;
+    using Ekiga::HeapImpl<Ekiga::Presentity>::remove_presentity;
+    using Ekiga::HeapImpl<Ekiga::Presentity>::add_connection;
+
+    bool populate_menu (Ekiga::MenuBuilder& builder);
+    const std::string get_name () const;
+    bool populate_menu_for_group (const std::string name,
+                                 Ekiga::MenuBuilder& builder);
+  };
+};
+
+#endif


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