[ekiga] Simplified the initialization code of a few components and plugins



commit 42db01f9d3cf4ccd985760a05c02331070f7de8a
Author: Snark <jpuydt gnome org>
Date:   Thu Oct 21 20:08:08 2010 +0200

    Simplified the initialization code of a few components and plugins
    
    The main goal is to make the Ekiga::ServiceCore spit a nicer output in
    debug mode. The secondary goal is to make startup a very very very very
    little faster (I'm sure I only gained an $\epsilon$!)

 .../avahi-publisher/avahi-publisher-main.cpp       |   11 ++++++-----
 lib/engine/components/avahi/avahi-main.cpp         |   11 ++++++-----
 .../components/call-history/history-main.cpp       |   11 ++++++-----
 .../local-roster/local-roster-bridge.cpp           |   11 ++++++-----
 .../components/local-roster/local-roster-main.cpp  |   13 +++++++------
 plugins/gstreamer/gst-main.cpp                     |   17 +++++++++--------
 plugins/loudmouth/loudmouth-main.cpp               |   15 ++++++++-------
 7 files changed, 48 insertions(+), 41 deletions(-)
---
diff --git a/lib/engine/components/avahi-publisher/avahi-publisher-main.cpp b/lib/engine/components/avahi-publisher/avahi-publisher-main.cpp
index eb10935..537a08d 100644
--- a/lib/engine/components/avahi-publisher/avahi-publisher-main.cpp
+++ b/lib/engine/components/avahi-publisher/avahi-publisher-main.cpp
@@ -47,17 +47,18 @@ struct AVAHIPUBSpark: public Ekiga::Spark
 			    int* /*argc*/,
 			    char** /*argv*/[])
   {
-    Ekiga::ServicePtr service = core.get ("avahi-presence-publisher");
     boost::shared_ptr<Ekiga::PresenceCore> presence_core = core.get<Ekiga::PresenceCore> ("presence-core");
     boost::shared_ptr<Ekiga::CallCore> call_core = core.get<Ekiga::CallCore> ("call-core");
     boost::shared_ptr<Ekiga::PersonalDetails> details = core.get<Ekiga::PersonalDetails> ("personal-details");
 
-    if (presence_core && call_core && details && !service) {
+    if (presence_core && call_core && details) {
 
       boost::shared_ptr<Avahi::PresencePublisher> publisher (new Avahi::PresencePublisher (core, *details, *call_core));
-      presence_core->add_presence_publisher (publisher);
-      core.add (publisher);
-      result = true;
+      if (core.add (publisher)) {
+
+	presence_core->add_presence_publisher (publisher);
+	result = true;
+      }
     }
 
     return result;
diff --git a/lib/engine/components/avahi/avahi-main.cpp b/lib/engine/components/avahi/avahi-main.cpp
index 0e08887..30f0f51 100644
--- a/lib/engine/components/avahi/avahi-main.cpp
+++ b/lib/engine/components/avahi/avahi-main.cpp
@@ -48,15 +48,16 @@ struct AVAHISpark: public Ekiga::Spark
 			    int* /*argc*/,
 			    char** /*argv*/[])
   {
-    Ekiga::ServicePtr service = core.get ("avahi-core");
     boost::shared_ptr<Ekiga::PresenceCore> presence_core = core.get<Ekiga::PresenceCore> ("presence-core");
 
-    if ( !service && presence_core) {
+    if (presence_core) {
 
       boost::shared_ptr<Avahi::Cluster> cluster (new Avahi::Cluster (core));
-      core.add (cluster);
-      presence_core->add_cluster (cluster);
-      result = true;
+      if (core.add (cluster)) {
+
+	presence_core->add_cluster (cluster);
+	result = true;
+      }
     }
 
     return result;
diff --git a/lib/engine/components/call-history/history-main.cpp b/lib/engine/components/call-history/history-main.cpp
index 6a5e21c..b84a2f6 100644
--- a/lib/engine/components/call-history/history-main.cpp
+++ b/lib/engine/components/call-history/history-main.cpp
@@ -49,16 +49,17 @@ struct HISTORYSpark: public Ekiga::Spark
 			    int* /*argc*/,
 			    char** /*argv*/[])
   {
-    Ekiga::ServicePtr service = core.get ("call-history-store");
     boost::shared_ptr<Ekiga::ContactCore> contact_core = core.get<Ekiga::ContactCore> ("contact-core");
     boost::shared_ptr<Ekiga::CallCore> call_core = core.get<Ekiga::CallCore> ("call-core");
 
-    if (contact_core && call_core && !service) {
+    if (contact_core && call_core) {
 
       boost::shared_ptr<History::Source> source (new History::Source (core));
-      core.add (source);
-      contact_core->add_source (source);
-      result = true;
+      if (core.add (source)) {
+
+	contact_core->add_source (source);
+	result = true;
+      }
     }
 
     return result;
diff --git a/lib/engine/components/local-roster/local-roster-bridge.cpp b/lib/engine/components/local-roster/local-roster-bridge.cpp
index ebd15eb..1517f61 100644
--- a/lib/engine/components/local-roster/local-roster-bridge.cpp
+++ b/lib/engine/components/local-roster/local-roster-bridge.cpp
@@ -112,16 +112,17 @@ struct LOCALROSTERBRIDGESpark: public Ekiga::Spark
 			    int* /*argc*/,
 			    char** /*argv*/[])
   {
-    Ekiga::ServicePtr service = core.get ("local-roster-bridge");
     boost::shared_ptr<Ekiga::ContactCore> contact_core = core.get<Ekiga::ContactCore> ("contact-core");
     boost::shared_ptr<Local::Cluster> cluster = core.get<Local::Cluster> ("local-cluster");
 
-    if (cluster && contact_core && !service) {
+    if (cluster && contact_core) {
 
       boost::shared_ptr<Local::ContactDecorator> decorator (new Local::ContactDecorator (cluster));
-      core.add (decorator);
-      contact_core->add_contact_decorator (decorator);
-      result = true;
+      if (core.add (decorator)) {
+
+	contact_core->add_contact_decorator (decorator);
+	result = true;
+      }
     }
 
     return result;
diff --git a/lib/engine/components/local-roster/local-roster-main.cpp b/lib/engine/components/local-roster/local-roster-main.cpp
index 659407d..8b2174a 100644
--- a/lib/engine/components/local-roster/local-roster-main.cpp
+++ b/lib/engine/components/local-roster/local-roster-main.cpp
@@ -49,17 +49,18 @@ struct LOCALROSTERSpark: public Ekiga::Spark
 			    int* /*argc*/,
 			    char** /*argv*/[])
   {
-    Ekiga::ServicePtr service = core.get ("local-cluster");
     boost::shared_ptr<Ekiga::PresenceCore> presence_core = core.get<Ekiga::PresenceCore> ("presence-core");
     boost::shared_ptr<Ekiga::FriendOrFoe> iff = core.get<Ekiga::FriendOrFoe> ("friend-or-foe");
 
-    if (presence_core && iff && !service) {
+    if (presence_core && iff) {
 
       boost::shared_ptr<Local::Cluster> cluster (new Local::Cluster (core));
-      core.add (cluster);
-      iff->add_helper (cluster->get_heap ());
-      presence_core->add_cluster (cluster);
-      result = true;
+      if (core.add (cluster)) {
+
+	iff->add_helper (cluster->get_heap ());
+	presence_core->add_cluster (cluster);
+	result = true;
+      }
     }
 
     return result;
diff --git a/plugins/gstreamer/gst-main.cpp b/plugins/gstreamer/gst-main.cpp
index e33239b..8ddbeeb 100644
--- a/plugins/gstreamer/gst-main.cpp
+++ b/plugins/gstreamer/gst-main.cpp
@@ -74,22 +74,23 @@ struct GSTSpark: public Ekiga::Spark
     boost::shared_ptr<Ekiga::AudioInputCore> audioinput_core = core.get<Ekiga::AudioInputCore> ("audioinput-core");
     boost::shared_ptr<Ekiga::AudioOutputCore> audiooutput_core = core.get<Ekiga::AudioOutputCore> ("audiooutput-core");
     boost::shared_ptr<Ekiga::VideoInputCore> videoinput_core = core.get<Ekiga::VideoInputCore> ("videoinput-core");
-    Ekiga::ServicePtr service = core.get ("gstreamer");
 
-    if (audioinput_core && audiooutput_core && videoinput_core && !service) {
+    if (audioinput_core && audiooutput_core && videoinput_core) {
 
       if (gst_init_check (argc, argv, NULL)) {
 
 	GST::VideoInputManager* video = new GST::VideoInputManager ();
 	GST::AudioInputManager* audioin = new GST::AudioInputManager ();
 	GST::AudioOutputManager* audioout = new GST::AudioOutputManager ();
-	service = Ekiga::ServicePtr (new GStreamerService);
+	Ekiga::ServicePtr service (new GStreamerService);
 
-	core.add (service);
-	audioinput_core->add_manager (*audioin);
-	audiooutput_core->add_manager (*audioout);
-	videoinput_core->add_manager (*video);
-	result = true;
+	if (core.add (service)) {
+
+	  audioinput_core->add_manager (*audioin);
+	  audiooutput_core->add_manager (*audioout);
+	  videoinput_core->add_manager (*video);
+	  result = true;
+	}
       } else {
 
 	std::cout << "gst_init_check failed" << std::endl; // FIXME: remove
diff --git a/plugins/loudmouth/loudmouth-main.cpp b/plugins/loudmouth/loudmouth-main.cpp
index 20624ee..311ebc5 100644
--- a/plugins/loudmouth/loudmouth-main.cpp
+++ b/plugins/loudmouth/loudmouth-main.cpp
@@ -54,22 +54,23 @@ struct LOUDMOUTHSpark: public Ekiga::Spark
 			    int* /*argc*/,
 			    char** /*argv*/[])
   {
-    Ekiga::ServicePtr service = core.get ("loudmouth-bank");
     boost::shared_ptr<Ekiga::PresenceCore> presence = core.get<Ekiga::PresenceCore> ("presence-core");
     boost::shared_ptr<Ekiga::AccountCore> account = core.get<Ekiga::AccountCore> ("account-core");
     boost::shared_ptr<Ekiga::ChatCore> chat = core.get<Ekiga::ChatCore> ("chat-core");
     boost::shared_ptr<Ekiga::PersonalDetails> details = core.get<Ekiga::PersonalDetails> ("personal-details");
 
-    if ( !service && presence && account && chat && details) {
+    if (presence && account && chat && details) {
 
       LM::DialectPtr dialect(new LM::Dialect (core));
       LM::ClusterPtr cluster(new LM::Cluster);
       LM::BankPtr bank (new LM::Bank (details, dialect, cluster));
-      core.add (bank);
-      chat->add_dialect (dialect);
-      account->add_bank (bank);
-      presence->add_cluster (cluster);
-      result = true;
+      if (core.add (bank)) {
+
+	chat->add_dialect (dialect);
+	account->add_bank (bank);
+	presence->add_cluster (cluster);
+	result = true;
+      }
     }
 
     return result;



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