[ekiga] Simplified the engine initialization a bit



commit aff7288b977bc12fe61a24565234316d4373fb47
Author: Julien Puydt <jpuydt free fr>
Date:   Fri Jun 21 23:12:13 2013 +0200

    Simplified the engine initialization a bit
    
    (and pushed a dependency from an implicit "keep those lines in that
    very order or everything breaks" to an explicit argument call which
    makes it explicit)

 lib/Makefile.am                                    |    4 +-
 .../gmconf-personal-details-main.cpp               |   47 ----------
 .../gmconf-personal-details-main.h                 |   47 ----------
 lib/engine/engine.cpp                              |   93 ++++++++++----------
 lib/engine/presence/presence-core.cpp              |    7 +-
 lib/engine/presence/presence-core.h                |    5 +-
 6 files changed, 53 insertions(+), 150 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 0a6f3f5..69abe22 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -562,9 +562,7 @@ libekiga_la_SOURCES += \
 
 libekiga_la_SOURCES += \
        $(components_dir)/gmconf-personal-details/gmconf-personal-details.cpp \
-       $(components_dir)/gmconf-personal-details/gmconf-personal-details.h \
-       $(components_dir)/gmconf-personal-details/gmconf-personal-details-main.cpp \
-       $(components_dir)/gmconf-personal-details/gmconf-personal-details-main.h
+       $(components_dir)/gmconf-personal-details/gmconf-personal-details.h
 
 ##
 # Sources of the local roster component
diff --git a/lib/engine/engine.cpp b/lib/engine/engine.cpp
index 87be276..bae12d0 100644
--- a/lib/engine/engine.cpp
+++ b/lib/engine/engine.cpp
@@ -60,7 +60,7 @@
 #include "local-roster-bridge.h"
 #include "gtk-core-main.h"
 #include "gtk-frontend.h"
-#include "gmconf-personal-details-main.h"
+#include "gmconf-personal-details.h"
 
 #ifndef WIN32
 #include "videooutput-main-x.h"
@@ -95,48 +95,24 @@ engine_init (Ekiga::ServiceCorePtr service_core,
             int argc,
              char *argv [])
 {
-  Ekiga::KickStart kickstart;
-
-  audioinput_null_init (kickstart);
-  audiooutput_null_init (kickstart);
-
-  videoinput_ptlib_init (kickstart);
-
-  audioinput_ptlib_init (kickstart);
-  audiooutput_ptlib_init (kickstart);
-
-#ifdef HAVE_DBUS
-  hal_dbus_init (kickstart);
-#endif
-
-  opal_init (kickstart);
-
-  history_init (kickstart);
-
-  local_roster_init (kickstart);
-
-  local_roster_bridge_init (kickstart);
-
-  plugin_init (kickstart);
-
-  service_core->add (Ekiga::ServicePtr(new Ekiga::NotificationCore));
+  // FIRST we add a few things by hand
+  // (for speed and because that's less code)
 
+  Ekiga::ServicePtr notification_core(new Ekiga::NotificationCore);
   boost::shared_ptr<Ekiga::AccountCore> account_core (new Ekiga::AccountCore);
   boost::shared_ptr<Ekiga::ContactCore> contact_core (new Ekiga::ContactCore);
   boost::shared_ptr<Ekiga::CallCore> call_core (new Ekiga::CallCore);
   boost::shared_ptr<Ekiga::ChatCore> chat_core (new Ekiga::ChatCore);
   boost::shared_ptr<Ekiga::VideoOutputCore> videooutput_core (new Ekiga::VideoOutputCore);
-  boost::shared_ptr<Ekiga::VideoInputCore> videoinput_core (new Ekiga::VideoInputCore ((*service_core.get 
()), videooutput_core));
-  boost::shared_ptr<Ekiga::AudioOutputCore> audiooutput_core (new Ekiga::AudioOutputCore ((*service_core.get 
())));
-  boost::shared_ptr<Ekiga::AudioInputCore> audioinput_core (new Ekiga::AudioInputCore ((*service_core.get 
())));
+  boost::shared_ptr<Ekiga::VideoInputCore> videoinput_core (new Ekiga::VideoInputCore (*service_core, 
videooutput_core));
+  boost::shared_ptr<Ekiga::AudioOutputCore> audiooutput_core (new Ekiga::AudioOutputCore (*service_core));
+  boost::shared_ptr<Ekiga::AudioInputCore> audioinput_core (new Ekiga::AudioInputCore(*service_core));
   boost::shared_ptr<Ekiga::HalCore> hal_core (new Ekiga::HalCore);
   boost::shared_ptr<Ekiga::FriendOrFoe> friend_or_foe (new Ekiga::FriendOrFoe);
+  boost::shared_ptr<Gmconf::PersonalDetails> details(new Gmconf::PersonalDetails);
+  boost::shared_ptr<Ekiga::PresenceCore> presence_core(new Ekiga::PresenceCore (details));
 
-
-  /* The last item in the following list will be destroyed first.   *
-   * - VideoInputCore must be destroyed before VideoOutputCore since its  *
-   *   PreviewManager may call functions of VideoOutputCore.            */
-
+  service_core->add (notification_core);
   service_core->add (contact_core);
   service_core->add (chat_core);
   service_core->add (friend_or_foe);
@@ -147,13 +123,8 @@ engine_init (Ekiga::ServiceCorePtr service_core,
   service_core->add (hal_core);
   service_core->add (call_core);
   service_core->add (account_core);
-
-  if (!gmconf_personal_details_init (*service_core, &argc, &argv)) {
-
-    return;
-  }
-
-  service_core->add (boost::shared_ptr<Ekiga::PresenceCore> (new Ekiga::PresenceCore (*service_core)));
+  service_core->add (details);
+  service_core->add (presence_core);
 
 #ifndef WIN32
   if (!videooutput_x_init (*service_core, &argc, &argv)) {
@@ -174,13 +145,43 @@ engine_init (Ekiga::ServiceCorePtr service_core,
     return;
   }
 
-  /* FIXME: the gui needs to have many things ready to work before it
-   * starts, but this way of doing things will prevent plugins to
-   * access it ; the proper fix would be to have the gui handled
-   * through the kickstart scheme
-   */
+  // THEN we use the kickstart scheme
+
+  Ekiga::KickStart kickstart;
+
+  audioinput_null_init (kickstart);
+  audiooutput_null_init (kickstart);
+
+  videoinput_ptlib_init (kickstart);
+
+  audioinput_ptlib_init (kickstart);
+  audiooutput_ptlib_init (kickstart);
+
+#ifdef HAVE_DBUS
+  hal_dbus_init (kickstart);
+#endif
+
+  opal_init (kickstart);
+
+  history_init (kickstart);
+
+  local_roster_init (kickstart);
+
+  local_roster_bridge_init (kickstart);
+
+  plugin_init (kickstart);
+
+  // FIXME: Some parts in the kickstart need the gui.  The gui needs
+  //  some parts in the kickstart.  So we will kick a first time to
+  //  get things not needing the gui up and running, then start the
+  //  gui (which will hence find what it needs) and kick a second time
+  //  to really make the engine go vroom. It would be nicer to either
+  //  push the parts needed by the gui in the hand-crafted part of
+  //  this initialization, or put the gui in the kickstart too.
+
   kickstart.kick (*service_core, &argc, &argv);
 
+  // FIXME: can't we have a single function for the whole gui?
   gtk_core_init (*service_core, &argc, &argv);
 
   if (!gtk_frontend_init (*service_core, &argc, &argv)) {
diff --git a/lib/engine/presence/presence-core.cpp b/lib/engine/presence/presence-core.cpp
index 61bda5d..725d5a8 100644
--- a/lib/engine/presence/presence-core.cpp
+++ b/lib/engine/presence/presence-core.cpp
@@ -39,12 +39,9 @@
 #include "personal-details.h"
 
 
-Ekiga::PresenceCore::PresenceCore (Ekiga::ServiceCore& core)
+Ekiga::PresenceCore::PresenceCore ( boost::shared_ptr<Ekiga::PersonalDetails> _details): details(_details)
 {
-  boost::shared_ptr<Ekiga::PersonalDetails> details = core.get<Ekiga::PersonalDetails> ("personal-details");
-
-  if (details)
-    conns.add (details->updated.connect (boost::bind (boost::bind (&Ekiga::PresenceCore::publish, this, _1), 
details)));
+  conns.add (details->updated.connect (boost::bind (boost::bind (&Ekiga::PresenceCore::publish, this, _1), 
details)));
 }
 
 void
diff --git a/lib/engine/presence/presence-core.h b/lib/engine/presence/presence-core.h
index 3c70873..3ccfbb0 100644
--- a/lib/engine/presence/presence-core.h
+++ b/lib/engine/presence/presence-core.h
@@ -42,10 +42,10 @@
 #include "scoped-connections.h"
 #include "cluster.h"
 #include "account-core.h"
+#include "personal-details.h"
 
 namespace Ekiga
 {
-  class PersonalDetails;
 
 /**
  * @defgroup presence Presence
@@ -139,7 +139,7 @@ namespace Ekiga
 
     /** The constructor.
      */
-    PresenceCore (ServiceCore& core);
+    PresenceCore (boost::shared_ptr<PersonalDetails> details);
 
     /*** Service Implementation ***/
   public:
@@ -314,6 +314,7 @@ namespace Ekiga
 
   private:
 
+    boost::shared_ptr<PersonalDetails> details;
     Ekiga::scoped_connections conns;
   };
 


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