ekiga r7531 - in trunk/lib/engine: . components/evolution components/ldap framework
- From: jpuydt svn gnome org
- To: svn-commits-list gnome org
- Subject: ekiga r7531 - in trunk/lib/engine: . components/evolution components/ldap framework
- Date: Wed, 7 Jan 2009 16:28:49 +0000 (UTC)
Author: jpuydt
Date: Wed Jan 7 16:28:49 2009
New Revision: 7531
URL: http://svn.gnome.org/viewvc/ekiga?rev=7531&view=rev
Log:
Merge branch 'kickstart'
* kickstart:
Made the evolution code use the new kickstart scheme
Don't loop if it's unnecessary
Made the LDAP code use the new kickstart scheme
Added a missing const
Made the kickstarter dump a log when it is finished
Added debug output to the engine kickstarter
Added simple kickstarting call
Added:
trunk/lib/engine/framework/kickstart.cpp
trunk/lib/engine/framework/kickstart.h
Modified:
trunk/lib/engine/components/evolution/evolution-main.cpp
trunk/lib/engine/components/evolution/evolution-main.h
trunk/lib/engine/components/ldap/ldap-main.cpp
trunk/lib/engine/components/ldap/ldap-main.h
trunk/lib/engine/engine.cpp
trunk/lib/engine/framework/Makefile.am
Modified: trunk/lib/engine/components/evolution/evolution-main.cpp
==============================================================================
--- trunk/lib/engine/components/evolution/evolution-main.cpp (original)
+++ trunk/lib/engine/components/evolution/evolution-main.cpp Wed Jan 7 16:28:49 2009
@@ -35,25 +35,43 @@
*
*/
-#include "evolution-main.h"
+#include "services.h"
#include "contact-core.h"
+
+#include "evolution-main.h"
#include "evolution-source.h"
-bool
-evolution_init (Ekiga::ServiceCore &services,
- int */*argc*/,
- char **/*argv*/[])
+struct EVOSpark: public Ekiga::Spark
{
- bool result = false;
- gmref_ptr<Ekiga::ContactCore> core = services.get ("contact-core");
+ bool try_initialize_more (Ekiga::ServiceCore &services,
+ int */*argc*/,
+ char **/*argv*/[])
+ {
+ gmref_ptr<Ekiga::ContactCore> core = services.get ("contact-core");
+
+ if (core) {
- if (core) {
+ gmref_ptr<Evolution::Source> source (new Evolution::Source (services));
+ services.add (source);
+ core->add_source (source);
+ result = true;
+ }
- gmref_ptr<Evolution::Source> source (new Evolution::Source (services));
- services.add (source);
- core->add_source (source);
- result = true;
+ return result;
}
- return result;
+ Ekiga::Spark::state get_state () const
+ { return result?FULL:BLANK; }
+
+ const std::string get_name () const
+ { return "EVOLUTION"; }
+
+ bool result;
+};
+
+void
+evolution_init (Ekiga::KickStart& kickstart)
+{
+ gmref_ptr<Ekiga::Spark> spark(new EVOSpark);
+ kickstart.add_spark (spark);
}
Modified: trunk/lib/engine/components/evolution/evolution-main.h
==============================================================================
--- trunk/lib/engine/components/evolution/evolution-main.h (original)
+++ trunk/lib/engine/components/evolution/evolution-main.h Wed Jan 7 16:28:49 2009
@@ -38,16 +38,14 @@
#ifndef __EVOLUTION_MAIN_H__
#define __EVOLUTION_MAIN_H__
-#include "services.h"
+#include "kickstart.h"
/**
* @addtogroup contacts
* @{
*/
-bool evolution_init (Ekiga::ServiceCore &services,
- int *argc,
- char **argv[]);
+void evolution_init (Ekiga::KickStart& kickstart);
/**
* @}
Modified: trunk/lib/engine/components/ldap/ldap-main.cpp
==============================================================================
--- trunk/lib/engine/components/ldap/ldap-main.cpp (original)
+++ trunk/lib/engine/components/ldap/ldap-main.cpp Wed Jan 7 16:28:49 2009
@@ -35,6 +35,7 @@
*
*/
+#include "services.h"
#include "contact-core.h"
#include "ldap-main.h"
@@ -42,23 +43,39 @@
#include <sasl/sasl.h>
-bool
-ldap_init (Ekiga::ServiceCore &core,
- int */*argc*/,
- char **/*argv*/[])
+struct LDAPSpark: public Ekiga::Spark
{
- bool result = false;
- gmref_ptr<Ekiga::ContactCore> contact_core = core.get ("contact-core");
- gmref_ptr<Ekiga::Runtime> runtime = core.get ("runtime");
-
- if (contact_core && runtime) {
-
- gmref_ptr<OPENLDAP::Source> service (new OPENLDAP::Source (core));
- core.add (service);
- contact_core->add_source (service);
- sasl_client_init (NULL); // FIXME: shouldn't it be done by the source!?
- result = true;
+ bool try_initialize_more (Ekiga::ServiceCore& core,
+ int* /*argc*/,
+ char** /*argv*/[])
+ {
+ gmref_ptr<Ekiga::ContactCore> contact_core = core.get ("contact-core");
+ gmref_ptr<Ekiga::Runtime> runtime = core.get ("runtime");
+
+ if (contact_core && runtime) {
+
+ gmref_ptr<OPENLDAP::Source> service (new OPENLDAP::Source (core));
+ core.add (service);
+ contact_core->add_source (service);
+ sasl_client_init (NULL); // FIXME: shouldn't it be done by the source!?
+ result = true;
+ }
+
+ return result;
}
- return result;
+ Ekiga::Spark::state get_state () const
+ { return result?FULL:BLANK; }
+
+ const std::string get_name () const
+ { return "LDAP"; }
+
+ bool result;
+};
+
+void
+ldap_init (Ekiga::KickStart& kickstart)
+{
+ gmref_ptr<Ekiga::Spark> spark(new LDAPSpark);
+ kickstart.add_spark (spark);
}
Modified: trunk/lib/engine/components/ldap/ldap-main.h
==============================================================================
--- trunk/lib/engine/components/ldap/ldap-main.h (original)
+++ trunk/lib/engine/components/ldap/ldap-main.h Wed Jan 7 16:28:49 2009
@@ -38,16 +38,14 @@
#ifndef __LDAP_MAIN_H__
#define __LDAP_MAIN_H__
-#include "services.h"
+#include "kickstart.h"
/**
* @addtogroup contacts
* @{
*/
-bool ldap_init (Ekiga::ServiceCore &core,
- int *argc,
- char **argv[]);
+void ldap_init (Ekiga::KickStart& kickstart);
/**
* @}
Modified: trunk/lib/engine/engine.cpp
==============================================================================
--- trunk/lib/engine/engine.cpp (original)
+++ trunk/lib/engine/engine.cpp Wed Jan 7 16:28:49 2009
@@ -40,6 +40,7 @@
#include "engine.h"
#include "services.h"
+#include "kickstart.h"
#include "presence-core.h"
#include "account-core.h"
@@ -119,6 +120,7 @@
Ekiga::Runtime* runtime)
{
service_core = new Ekiga::ServiceCore;
+ Ekiga::KickStart kickstart;
/* VideoInputCore depends on VideoOutputCore and must this *
* be constructed thereafter */
@@ -237,17 +239,11 @@
#endif
#ifdef HAVE_EDS
- if (!evolution_init (*service_core, &argc, &argv)) {
- delete service_core;
- return;
- }
+ evolution_init (kickstart);
#endif
#ifdef HAVE_LDAP
- if (!ldap_init (*service_core, &argc, &argv)) {
- delete service_core;
- return;
- }
+ ldap_init (kickstart);
#endif
#ifdef HAVE_KDE
@@ -268,6 +264,10 @@
return;
}
+ /* FIXME: this one should go away -- but if I don't put it here, the GUI
+ * doesn't work correctly */
+ kickstart.kick (*service_core, &argc, &argv);
+
if (!gtk_core_init (*service_core, &argc, &argv)) {
delete service_core;
return;
@@ -288,6 +288,8 @@
return;
}
+ kickstart.kick (*service_core, &argc, &argv);
+
videooutput_core->setup_conf_bridge();
videoinput_core->setup_conf_bridge();
audiooutput_core->setup_conf_bridge();
Modified: trunk/lib/engine/framework/Makefile.am
==============================================================================
--- trunk/lib/engine/framework/Makefile.am (original)
+++ trunk/lib/engine/framework/Makefile.am Wed Jan 7 16:28:49 2009
@@ -42,6 +42,8 @@
$(framework_dir)/trigger.h \
$(framework_dir)/menu-xml.h \
$(framework_dir)/menu-xml.cpp \
+ $(framework_dir)/kickstart.h \
+ $(framework_dir)/kickstart.cpp \
$(framework_dir)/personal-details.h \
$(framework_dir)/ptr_array.h \
$(framework_dir)/ptr_array_iterator.h \
Added: trunk/lib/engine/framework/kickstart.cpp
==============================================================================
--- (empty file)
+++ trunk/lib/engine/framework/kickstart.cpp Wed Jan 7 16:28:49 2009
@@ -0,0 +1,232 @@
+
+/*
+ * 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.
+ */
+
+
+/*
+ * kickstart.cpp - description
+ * ------------------------------------------
+ * begin : written in 2009 by Julien Puydt
+ * copyright : (c) 2009 by Julien Puydt
+ * description : implementation of a kickstart object
+ *
+ */
+
+#include "kickstart.h"
+
+#define KICKSTART_DEBUG 1
+
+#if KICKSTART_DEBUG
+#include <iostream>
+#endif
+
+Ekiga::KickStart::KickStart ()
+{
+}
+
+Ekiga::KickStart::~KickStart ()
+{
+#if KICKSTART_DEBUG
+ std::cout << "KickStart(final log):"
+ << std::endl;
+
+ std::cout << "\tBLANK: ";
+ for (std::list<gmref_ptr<Spark> >::iterator iter = blanks.begin ();
+ iter != blanks.end ();
+ ++iter) {
+ std::cout << (*iter)->get_name () << ", ";
+ }
+ std::cout << std::endl;
+
+ std::cout << "\tPARTIAL: ";
+ for (std::list<gmref_ptr<Spark> >::iterator iter = partials.begin ();
+ iter != partials.end ();
+ ++iter) {
+ std::cout << (*iter)->get_name () << ", ";
+ }
+ std::cout << std::endl;
+#endif
+}
+
+void
+Ekiga::KickStart::add_spark (gmref_ptr<Ekiga::Spark>& spark)
+{
+ blanks.push_back (spark);
+#if KICKSTART_DEBUG
+ std::cout << "KickStart(add_spark): " << spark->get_name () << std::endl;
+#endif
+}
+
+void
+Ekiga::KickStart::kick (Ekiga::ServiceCore& core,
+ int* argc,
+ char** argv[])
+{
+ bool went_on;
+
+ // this makes sure we loop only if something needs to be done
+ went_on = !(blanks.empty () && partials.empty ());
+
+ // we are going to try things as long as something happens
+ while (went_on) {
+
+ went_on = false;
+#if KICKSTART_DEBUG
+ std::cout << "KickStart(kick): starting a loop" << std::endl;
+#endif
+
+ { // first try the blanks
+ std::list<gmref_ptr<Spark> > temp;
+ temp.swap (blanks);
+
+#if KICKSTART_DEBUG
+ std::cout << "KickStart(kick): looping on BLANK sparks" << std::endl;
+#endif
+
+ for (std::list<gmref_ptr<Spark> >::iterator iter = temp.begin ();
+ iter != temp.end ();
+ ++iter) {
+
+ bool result = (*iter)->try_initialize_more (core, argc, argv);
+
+ if (result) {
+
+ went_on = true;
+ switch ((*iter)->get_state ()) {
+
+ case Spark::BLANK:
+
+ // shouldn't happen!
+ blanks.push_back (*iter);
+ break;
+ case Spark::PARTIAL:
+
+#if KICKSTART_DEBUG
+ std::cout << "KickStart(kick): "
+ << (*iter)->get_name ()
+ << " was promoted to PARTIAL"
+ << std::endl;
+#endif
+ partials.push_back (*iter);
+ break;
+
+ case Spark::FULL:
+
+ // good!
+#if KICKSTART_DEBUG
+ std::cout << "KickStart(kick): "
+ << (*iter)->get_name ()
+ << " was promoted to FULL"
+ << std::endl;
+#endif
+ break;
+
+ default:
+
+ // shouldn't happen
+ break;
+ }
+
+ } else {
+
+#if KICKSTART_DEBUG
+ std::cout << "KickStart(kick): "
+ << (*iter)->get_name ()
+ << " is still BLANK"
+ << std::endl;
+#endif
+ blanks.push_back (*iter);
+ }
+ }
+ }
+
+ { // then try the partials
+ std::list<gmref_ptr<Spark> > temp;
+ temp.swap (partials);
+
+#if KICKSTART_DEBUG
+ std::cout << "KickStart(kick): looping on PARTIAL sparks" << std::endl;
+#endif
+
+ for (std::list<gmref_ptr<Spark> >::iterator iter = temp.begin ();
+ iter != temp.end ();
+ ++iter) {
+
+ bool result = (*iter)->try_initialize_more (core, argc, argv);
+
+ if (result) {
+
+ went_on = true;
+ switch ((*iter)->get_state ()) {
+
+ case Spark::BLANK:
+
+ // can't happen unless it went back
+ break;
+ case Spark::PARTIAL:
+
+#if KICKSTART_DEBUG
+ std::cout << "KickStart(kick): "
+ << (*iter)->get_name ()
+ << " was promoted to PARTIAL"
+ << std::endl;
+#endif
+ partials.push_back (*iter);
+ break;
+
+ case Spark::FULL:
+
+ // good!
+#if KICKSTART_DEBUG
+ std::cout << "KickStart(kick): "
+ << (*iter)->get_name ()
+ << " was promoted to FULL"
+ << std::endl;
+#endif
+ break;
+
+ default:
+
+ // shouldn't happen
+ break;
+ }
+
+ } else {
+
+#if KICKSTART_DEBUG
+ std::cout << "KickStart(kick): "
+ << (*iter)->get_name ()
+ << " is still PARTIAL"
+ << std::endl;
+#endif
+ partials.push_back (*iter);
+ }
+ }
+ }
+
+#if KICKSTART_DEBUG
+ std::cout << "KickStart(kick): ending a loop" << std::endl;
+#endif
+ }
+}
Added: trunk/lib/engine/framework/kickstart.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/framework/kickstart.h Wed Jan 7 16:28:49 2009
@@ -0,0 +1,106 @@
+
+/*
+ * 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.
+ */
+
+
+/*
+ * kickstart.h - description
+ * ------------------------------------------
+ * begin : written in 2009 by Julien Puydt
+ * copyright : (c) 2009 by Julien Puydt
+ * description : declaration of a kickstart object
+ *
+ */
+
+#ifndef __KICKSTART_H__
+#define __KICKSTART_H__
+
+/* We want the engine startup to be as automatic as possible -- in particular,
+ * it should handle dependancies as transparently as possible (external plugins
+ * may come at one point).
+ *
+ * This kickstart object works like this : some objects are registered to it,
+ * and are responsible of initializing a portion of code. Those objects are
+ * called sparks, and have basically three states :
+ * - blank -- they haven't managed to initialize anything yet ;
+ * - partial -- they have initialized something, but could do more ;
+ * - full -- they have initialized all they could.
+ *
+ * This means that a spark object will have a method which will try to
+ * initialize more, and a method which will tell in which state it is : indeed,
+ * the kickstart object will need to know when it reached a point where all
+ * sparks have done as much as they could, so we need a strictly increasing
+ * function up until then.
+ *
+ * We want the following to be guaranteed by each Spark implementation :
+ * - if try_initialize_more returns 'true', then the state should be at least
+ * partial ;
+ * - try_initialize_more shouldn't return 'true' if no new service could be
+ * registered ;
+ * - states should always evolve as BLANK -> PARTIAL -> FULL : no coming back!
+ */
+
+#include "services.h"
+
+namespace Ekiga
+{
+
+ struct Spark: public virtual GmRefCounted
+ {
+ typedef enum { BLANK, PARTIAL, FULL } state;
+
+ virtual ~Spark () {}
+
+ virtual bool try_initialize_more (ServiceCore& core,
+ int* argc,
+ char** argv[]) = 0;
+
+ virtual state get_state () const = 0;
+
+ // this method is useful for debugging purposes
+ virtual const std::string get_name () const = 0;
+ };
+
+ class KickStart
+ {
+ public:
+
+ KickStart ();
+
+ ~KickStart ();
+
+ void add_spark (gmref_ptr<Spark>& spark);
+
+ /* try to do more with the known blank/partial sparks */
+ void kick (Ekiga::ServiceCore& core,
+ int* argc,
+ char** argv[]);
+
+ private:
+ std::list<gmref_ptr<Spark> > blanks;
+ std::list<gmref_ptr<Spark> > partials;
+ };
+};
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]