[ekiga] Made some code more widely shared



commit 08716296366719c0b19d4aa01b5ae031b8a34c18
Author: Julien Puydt <jpuydt gnome org>
Date:   Sun Aug 30 09:40:21 2009 +0200

    Made some code more widely shared
    
    Created the notion of LiveObject and made use of it in the
    presence and contact stacks (the goal of course is to make
    it easier to fix bug #556634)

 lib/engine/addressbook/book.h      |   26 +-----------
 lib/engine/addressbook/contact.h   |   34 ++-------------
 lib/engine/addressbook/source.h    |   15 +------
 lib/engine/framework/Makefile.am   |    3 +-
 lib/engine/framework/live-object.h |   81 ++++++++++++++++++++++++++++++++++++
 lib/engine/presence/cluster.h      |   12 +----
 lib/engine/presence/heap.h         |   22 +---------
 lib/engine/presence/presentity.h   |   25 +----------
 8 files changed, 98 insertions(+), 120 deletions(-)
---
diff --git a/lib/engine/addressbook/book.h b/lib/engine/addressbook/book.h
index e2a32a2..9e7bae2 100644
--- a/lib/engine/addressbook/book.h
+++ b/lib/engine/addressbook/book.h
@@ -40,7 +40,8 @@
 
 namespace Ekiga {
 
-  class Book
+  class Book:
+    public virtual LiveObject
   {
 
   public:
@@ -66,14 +67,6 @@ namespace Ekiga {
     virtual void visit_contacts (boost::function1<bool, ContactPtr>) = 0;
 
 
-    /** Create the menu for that book and its actions.
-     * This function is purely virtual and should be implemented by
-     * the descendant of the Ekiga::Book, ie BookImpl.
-     * @param A MenuBuilder object to populate.
-     */
-    virtual bool populate_menu (MenuBuilder &) = 0;
-
-
     /** Set the search filter.
      * This function is purely virtual and should be implemented by
      * the descendant of the Ekiga::Book, ie BookImpl or one
@@ -106,16 +99,6 @@ namespace Ekiga {
      * Signals on that object
      */
 
-    /** This signal is emitted when the Book has been updated.
-     */
-    boost::signal0<void> updated;
-
-
-    /** This signal is emitted when the Book has been removed from the Source.
-     */
-    boost::signal0<void> removed;
-
-
     /** This signal is emitted when a Contact has been added to the Book.
      */
     boost::signal1<void, ContactPtr > contact_added;
@@ -129,11 +112,6 @@ namespace Ekiga {
     /** This signal is emitted when a Contact has been updated in the Book.
      */
     boost::signal1<void, ContactPtr > contact_updated;
-
-
-    /** This chain allows the Book to present forms to the user
-     */
-    ChainOfResponsibility<FormRequestPtr> questions;
   };
 
   typedef boost::shared_ptr<Book> BookPtr;
diff --git a/lib/engine/addressbook/contact.h b/lib/engine/addressbook/contact.h
index 20ea0ba..e562152 100644
--- a/lib/engine/addressbook/contact.h
+++ b/lib/engine/addressbook/contact.h
@@ -42,9 +42,8 @@
 #include <string>
 
 #include <boost/smart_ptr.hpp>
-#include "chain-of-responsibility.h"
-#include "form-request.h"
-#include "menu-builder.h"
+
+#include "live-object.h"
 
 namespace Ekiga
 {
@@ -54,7 +53,8 @@ namespace Ekiga
  * @{
  */
 
-  class Contact
+  class Contact:
+    public virtual LiveObject
   {
   public:
 
@@ -75,32 +75,6 @@ namespace Ekiga
      * @return True if the contact has been found.
      */
     virtual bool is_found (const std::string) const = 0;
-
-
-    /** Create the menu for that contact and its actions.
-     * This function is purely virtual and should be implemented by
-     * the descendant of the Ekiga::Contact.
-     * @param A MenuBuilder object to populate.
-     */
-    virtual bool populate_menu (MenuBuilder &) = 0;
-
-
-    /**
-     * Signals on that object
-     */
-
-    /** This signal is emitted when the Contact has been updated.
-     */
-    boost::signal0<void> updated;
-
-
-    /** This signal is emitted when the Contact has been removed.
-     */
-    boost::signal0<void> removed;
-
-    /** This chain allows the Contact to present forms to the user
-     */
-    ChainOfResponsibility<FormRequestPtr> questions;
   };
 
 
diff --git a/lib/engine/addressbook/source.h b/lib/engine/addressbook/source.h
index dd895d4..3997271 100644
--- a/lib/engine/addressbook/source.h
+++ b/lib/engine/addressbook/source.h
@@ -41,7 +41,8 @@
 
 namespace Ekiga {
 
-  class Source
+  class Source:
+    public virtual LiveObject
   {
   public:
 
@@ -60,14 +61,6 @@ namespace Ekiga {
     virtual void visit_books (boost::function1<bool, BookPtr >) = 0;
 
 
-    /** Create the menu for that source and its actions.
-     * This function is purely virtual and should be implemented by
-     * the descendant of the Ekiga::Source.
-     * @param A MenuBuilder object to populate.
-     */
-    virtual bool populate_menu (MenuBuilder &) = 0;
-
-
     /** This signal is emitted when a Book has been added to the Source.
      */
     boost::signal1<void, BookPtr > book_added;
@@ -96,10 +89,6 @@ namespace Ekiga {
      *  this source
      */
     boost::signal2<void, BookPtr, ContactPtr > contact_updated;
-
-    /** This chain allows the Source to present forms to the user
-     */
-    ChainOfResponsibility<FormRequestPtr> questions;
   };
 
   typedef boost::shared_ptr<Source> SourcePtr;
diff --git a/lib/engine/framework/Makefile.am b/lib/engine/framework/Makefile.am
index a6fe21e..fea1caa 100644
--- a/lib/engine/framework/Makefile.am
+++ b/lib/engine/framework/Makefile.am
@@ -45,7 +45,8 @@ libgmframework_la_SOURCES = \
 	$(framework_dir)/personal-details.h \
 	$(framework_dir)/ptr_array.h \
 	$(framework_dir)/ptr_array_iterator.h \
-	$(framework_dir)/ptr_array_const_iterator.h
+	$(framework_dir)/ptr_array_const_iterator.h \
+	$(framework_dir)/live-object.h
 
 
 libgmframework_la_LDFLAGS = $(STACKLIB_LDFLAGS)
diff --git a/lib/engine/framework/live-object.h b/lib/engine/framework/live-object.h
new file mode 100644
index 0000000..c672ad3
--- /dev/null
+++ b/lib/engine/framework/live-object.h
@@ -0,0 +1,81 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2009 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.
+ */
+
+
+/*
+ *                         live-object.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2009 by Julien Puydt
+ *   copyright            : (c) 2009 by Julien Puydt
+ *   description          : common class for objects which are somehow 'live'
+ *
+ */
+
+#ifndef __LIVE_OBJECT_H__
+#define __LIVE_OBJECT_H__
+
+#include <boost/smart_ptr.hpp>
+#include "chain-of-responsibility.h"
+#include "form-request.h"
+#include "menu-builder.h"
+
+namespace Ekiga
+{
+
+  class LiveObject
+  {
+  public:
+
+    virtual ~LiveObject () { }
+
+    /** Populate a menu with the action available on that object
+     * @param A MenuBuilder object to populate.
+     */
+    virtual bool populate_menu (MenuBuilder &) = 0;
+
+
+    /**
+     * Signals on that object
+     */
+
+    /** This signal is emitted when the object has been updated.
+     */
+    boost::signal0<void> updated;
+
+
+    /** This signal is emitted when the object has been removed.
+     */
+    boost::signal0<void> removed;
+
+    /** This chain allows the object to present forms to the user
+     */
+    ChainOfResponsibility<FormRequestPtr> questions;
+  };
+
+
+  typedef boost::shared_ptr<LiveObject> LiveObjectPtr;
+
+};
+#endif
diff --git a/lib/engine/presence/cluster.h b/lib/engine/presence/cluster.h
index 6995ede..dc1fad4 100644
--- a/lib/engine/presence/cluster.h
+++ b/lib/engine/presence/cluster.h
@@ -47,7 +47,8 @@ namespace Ekiga
  * @{
  */
 
-  class Cluster
+  class Cluster:
+    public virtual LiveObject
   {
 
   public:
@@ -61,11 +62,6 @@ namespace Ekiga
      */
     virtual void visit_heaps (boost::function1<bool, HeapPtr >) = 0;
 
-    /** Populates a menu with the actions possible on the Cluster.
-     * @param The builder to populate.
-     */
-    virtual bool populate_menu (MenuBuilder &) = 0;
-
     /** Those signals are emitted whenever a new Heap is added or removed
      * from the Cluster.
      * @param The Heap in question.
@@ -80,10 +76,6 @@ namespace Ekiga
     boost::signal2<void, HeapPtr , PresentityPtr > presentity_added;
     boost::signal2<void, HeapPtr , PresentityPtr > presentity_updated;
     boost::signal2<void, HeapPtr , PresentityPtr > presentity_removed;
-
-    /** This chain allows the Cluster to present forms to the user.
-     */
-    ChainOfResponsibility<FormRequestPtr> questions;
   };
 
   typedef boost::shared_ptr<Cluster> ClusterPtr;
diff --git a/lib/engine/presence/heap.h b/lib/engine/presence/heap.h
index b52abb3..b888723 100644
--- a/lib/engine/presence/heap.h
+++ b/lib/engine/presence/heap.h
@@ -38,8 +38,6 @@
 #ifndef __HEAP_H__
 #define __HEAP_H__
 
-#include <boost/smart_ptr.hpp>
-
 #include "presentity.h"
 
 namespace Ekiga
@@ -50,7 +48,8 @@ namespace Ekiga
  * @{
  */
 
-  class Heap
+  class Heap:
+    public virtual LiveObject
   {
 
   public:
@@ -70,11 +69,6 @@ namespace Ekiga
      */
     virtual void visit_presentities (boost::function1<bool, PresentityPtr >) = 0;
 
-    /** Populates a menu with the actions possible on the Heap.
-     * @param The builder to populate.
-     */
-    virtual bool populate_menu (MenuBuilder &) = 0;
-
     /** Populates a menu with the actions possible on the given group
      * of the Heap.
      * @param The name of the group on which to act.
@@ -87,14 +81,6 @@ namespace Ekiga
      * Signals on that object
      */
 
-    /** This signal is emitted when the Heap has been updated.
-     */
-    boost::signal0<void> updated;
-
-    /** This signal is emitted when the Heap has been removed.
-     */
-    boost::signal0<void> removed;
-
     /** This signal is emitted  when a Presentity has been added to the Heap.
      */
     boost::signal1<void, PresentityPtr > presentity_added;
@@ -106,10 +92,6 @@ namespace Ekiga
     /** This signal is emitted when a Presentity has been removed from the Heap.
      */
     boost::signal1<void, PresentityPtr > presentity_removed;
-
-    /** This chain allows the Heap to present forms to the user
-     */
-    ChainOfResponsibility<FormRequestPtr> questions;
   };
 
   typedef boost::shared_ptr<Heap> HeapPtr;
diff --git a/lib/engine/presence/presentity.h b/lib/engine/presence/presentity.h
index 8b54255..e0840ee 100644
--- a/lib/engine/presence/presentity.h
+++ b/lib/engine/presence/presentity.h
@@ -39,10 +39,7 @@
 #include <set>
 #include <string>
 
-#include <boost/smart_ptr.hpp>
-#include "chain-of-responsibility.h"
-#include "form-request.h"
-#include "menu-builder.h"
+#include "live-object.h"
 
 namespace Ekiga
 {
@@ -54,7 +51,8 @@ namespace Ekiga
 
   /** A presentity is a piece of presence information for a single URI.
    */
-  class Presentity
+  class Presentity:
+    public virtual LiveObject
   {
   public:
 
@@ -86,23 +84,6 @@ namespace Ekiga
      * @return The Presentity's set of groups.
      */
     virtual const std::set<std::string> get_groups () const = 0;
-
-    /** Populates a menu with the actions possible on the Presentity.
-     * @param The builder to populate.
-     */
-    virtual bool populate_menu (MenuBuilder &) = 0;
-
-    /** This signal is emitted when the Presentity has been updated.
-     */
-    boost::signal0<void> updated;
-
-    /** This signal is emitted when the Presentity has been removed.
-     */
-    boost::signal0<void> removed;
-
-    /** This chain allows the Presentity to present forms to the user
-     */
-    ChainOfResponsibility<FormRequestPtr> questions;
   };
 
   typedef boost::shared_ptr<Presentity> PresentityPtr;



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