[ekiga/gnome-2-26] Major rewrite of the runtime system -- preliminary fix for bug #557889



commit f6bce8a4a6e1635dfb02b2383d1a75895bf3b611
Author: Julien Puydt <jpuydt src gnome org>
Date:   Mon Mar 23 20:40:41 2009 +0000

    Major rewrite of the runtime system -- preliminary fix for bug #557889
    
    svn path=/trunk/; revision=7804
---
 lib/engine/audioinput/audioinput-core.cpp          |    5 +-
 lib/engine/audioinput/audioinput-core.h            |    4 +-
 lib/engine/audiooutput/audiooutput-core.cpp        |    5 +-
 lib/engine/audiooutput/audiooutput-core.h          |    4 +-
 .../videooutput-manager-common.cpp                 |    8 +--
 .../videooutput-manager-common.h                   |    1 -
 .../dx-videooutput/videooutput-manager-dx.cpp      |   18 ++--
 lib/engine/components/ldap/ldap-book.cpp           |   14 ++--
 lib/engine/components/ldap/ldap-main.cpp           |    3 +-
 .../mlogo-videoinput/videoinput-manager-mlogo.cpp  |    8 +--
 .../mlogo-videoinput/videoinput-manager-mlogo.h    |    1 -
 .../null-audioinput/audioinput-manager-null.cpp    |    8 +--
 .../null-audioinput/audioinput-manager-null.h      |    1 -
 .../null-audiooutput/audiooutput-manager-null.cpp  |    8 +--
 .../null-audiooutput/audiooutput-manager-null.h    |    1 -
 lib/engine/components/opal/h323-endpoint.cpp       |   13 +---
 lib/engine/components/opal/h323-endpoint.h         |    1 -
 lib/engine/components/opal/opal-call-manager.cpp   |   20 ++---
 lib/engine/components/opal/opal-call-manager.h     |    1 -
 lib/engine/components/opal/opal-call.cpp           |   28 +++----
 lib/engine/components/opal/opal-call.h             |    1 -
 lib/engine/components/opal/sip-endpoint.cpp        |   22 ++----
 lib/engine/components/opal/sip-endpoint.h          |    1 -
 .../components/ptlib/audioinput-manager-ptlib.cpp  |   12 +--
 .../components/ptlib/audioinput-manager-ptlib.h    |    1 -
 .../components/ptlib/audiooutput-manager-ptlib.cpp |   12 +--
 .../components/ptlib/audiooutput-manager-ptlib.h   |    1 -
 .../components/ptlib/videoinput-manager-ptlib.cpp  |   10 +--
 .../components/ptlib/videoinput-manager-ptlib.h    |    1 -
 .../x-videooutput/videooutput-manager-x.cpp        |   16 ++--
 lib/engine/engine.cpp                              |   15 +---
 lib/engine/engine.h                                |    3 +-
 lib/engine/framework/Makefile.am                   |    1 -
 lib/engine/framework/runtime-glib.cpp              |   34 ++++-----
 lib/engine/framework/runtime-glib.h                |   79 --------------------
 lib/engine/framework/runtime.h                     |   54 +++++---------
 lib/engine/videoinput/videoinput-core.cpp          |    5 +-
 lib/engine/videoinput/videoinput-core.h            |    4 +-
 src/ekiga.cpp                                      |    7 +-
 src/ekiga.h                                        |    2 +-
 40 files changed, 129 insertions(+), 304 deletions(-)

diff --git a/lib/engine/audioinput/audioinput-core.cpp b/lib/engine/audioinput/audioinput-core.cpp
index 90addf9..94ab55d 100644
--- a/lib/engine/audioinput/audioinput-core.cpp
+++ b/lib/engine/audioinput/audioinput-core.cpp
@@ -108,9 +108,8 @@ void AudioInputCore::AudioPreviewManager::Main ()
   }*/
 }
 
-AudioInputCore::AudioInputCore (Ekiga::Runtime & _runtime, AudioOutputCore& _audio_output_core)
-:  runtime (_runtime),
-   preview_manager(*this, _audio_output_core)
+AudioInputCore::AudioInputCore (AudioOutputCore& _audio_output_core)
+:  preview_manager(*this, _audio_output_core)
 
 {
   PWaitAndSignal m_var(core_mutex);
diff --git a/lib/engine/audioinput/audioinput-core.h b/lib/engine/audioinput/audioinput-core.h
index 52b3f59..3758562 100644
--- a/lib/engine/audioinput/audioinput-core.h
+++ b/lib/engine/audioinput/audioinput-core.h
@@ -95,10 +95,9 @@ namespace Ekiga
   public:
 
       /** The constructor
-       * @param _runtime reference to Ekiga runtime.
        * @param _videooutput_core reference ot the audio output core.
        */
-      AudioInputCore (Ekiga::Runtime & _runtime, AudioOutputCore& _audio_output_core);
+      AudioInputCore (AudioOutputCore& _audio_output_core);
 
       /** The destructor
       */
@@ -325,7 +324,6 @@ namespace Ekiga
 
   private:
 
-      Ekiga::Runtime & runtime;
       std::set<AudioInputManager *> managers;
 
       DeviceConfig preview_config;
diff --git a/lib/engine/audiooutput/audiooutput-core.cpp b/lib/engine/audiooutput/audiooutput-core.cpp
index f0288d4..4283267 100644
--- a/lib/engine/audiooutput/audiooutput-core.cpp
+++ b/lib/engine/audiooutput/audiooutput-core.cpp
@@ -40,9 +40,8 @@
 
 using namespace Ekiga;
 
-AudioOutputCore::AudioOutputCore (Ekiga::Runtime & _runtime)
-:  runtime (_runtime),
-   audio_event_scheduler(*this)
+AudioOutputCore::AudioOutputCore ()
+:  audio_event_scheduler(*this)
 {
   PWaitAndSignal m_pri(core_mutex[primary]);
   PWaitAndSignal m_sec(core_mutex[secondary]);
diff --git a/lib/engine/audiooutput/audiooutput-core.h b/lib/engine/audiooutput/audiooutput-core.h
index d8685e5..2d4c827 100644
--- a/lib/engine/audiooutput/audiooutput-core.h
+++ b/lib/engine/audiooutput/audiooutput-core.h
@@ -88,9 +88,8 @@ namespace Ekiga
   public:
 
       /** The constructor
-       * @param _runtime reference to Ekiga runtime.
        */
-      AudioOutputCore (Ekiga::Runtime & _runtime);
+      AudioOutputCore ();
 
       /** The destructor
       */
@@ -337,7 +336,6 @@ namespace Ekiga
       void calculate_average_level (const short *buffer, unsigned size);
 
       std::set<AudioOutputManager *> managers;
-      Ekiga::Runtime & runtime;
 
       typedef struct DeviceConfig {
         bool active;
diff --git a/lib/engine/components/common-videooutput/videooutput-manager-common.cpp b/lib/engine/components/common-videooutput/videooutput-manager-common.cpp
index cba0104..5ea7717 100644
--- a/lib/engine/components/common-videooutput/videooutput-manager-common.cpp
+++ b/lib/engine/components/common-videooutput/videooutput-manager-common.cpp
@@ -50,14 +50,10 @@ GMVideoOutputManager::GMVideoOutputManager(Ekiga::ServiceCore & _core)
   : PThread (1000, NoAutoDeleteThread, HighestPriority, "GMVideoOutputManager"),
     core (_core)
 {
-  gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
-  smart->reference (); // take a reference on smart in the main thread
-  runtime = smart.get ();
 }
 
 GMVideoOutputManager::~GMVideoOutputManager ()
 {
-  runtime->unreference (); // leave a reference on smart in the main thread
 }
 
 void GMVideoOutputManager::open ()
@@ -254,8 +250,8 @@ void GMVideoOutputManager::uninit ()
 void GMVideoOutputManager::update_gui_device ()
 {
   last_frame.both_streams_active = current_frame.both_streams_active;
-  runtime->run_in_main (device_closed.make_slot ());
-  runtime->run_in_main (sigc::bind (device_opened.make_slot (), current_frame.accel, current_frame.mode, current_frame.zoom, current_frame.both_streams_active));
+  Ekiga::Runtime::run_in_main (device_closed.make_slot ());
+  Ekiga::Runtime::run_in_main (sigc::bind (device_opened.make_slot (), current_frame.accel, current_frame.mode, current_frame.zoom, current_frame.both_streams_active));
 
 }
 
diff --git a/lib/engine/components/common-videooutput/videooutput-manager-common.h b/lib/engine/components/common-videooutput/videooutput-manager-common.h
index 4c062ce..106c277 100644
--- a/lib/engine/components/common-videooutput/videooutput-manager-common.h
+++ b/lib/engine/components/common-videooutput/videooutput-manager-common.h
@@ -257,7 +257,6 @@
                               from various threads */
   
     Ekiga::ServiceCore & core;
-    Ekiga::Runtime* runtime;
   };
 
 /**
diff --git a/lib/engine/components/dx-videooutput/videooutput-manager-dx.cpp b/lib/engine/components/dx-videooutput/videooutput-manager-dx.cpp
index bbd51c7..e997aa3 100644
--- a/lib/engine/components/dx-videooutput/videooutput-manager-dx.cpp
+++ b/lib/engine/components/dx-videooutput/videooutput-manager-dx.cpp
@@ -76,21 +76,21 @@ GMVideoOutputManager_dx::setup_frame_display ()
     
   get_display_info(local_display_info);
 
-//  runtime->run_in_main (force_redraw.make_slot ()); //FIXME: check
+//  Ekiga::Runtime::run_in_main (force_redraw.make_slot ()); //FIXME: check
 
   switch (current_frame.mode) {
   case Ekiga::VO_MODE_LOCAL:
-    runtime->run_in_main (sigc::bind (size_changed.make_slot (), (unsigned) (current_frame.local_width * current_frame.zoom / 100), (unsigned) (current_frame.local_height * current_frame.zoom / 100)));
+    Ekiga::Runtime::run_in_main (sigc::bind (size_changed.make_slot (), (unsigned) (current_frame.local_width * current_frame.zoom / 100), (unsigned) (current_frame.local_height * current_frame.zoom / 100)));
     break;
   case Ekiga::VO_MODE_REMOTE:
   case Ekiga::VO_MODE_PIP:
-    runtime->run_in_main (sigc::bind (size_changed.make_slot (), (unsigned) (current_frame.remote_width * current_frame.zoom / 100), (unsigned) (current_frame.remote_height * current_frame.zoom / 100)));
+    Ekiga::Runtime::run_in_main (sigc::bind (size_changed.make_slot (), (unsigned) (current_frame.remote_width * current_frame.zoom / 100), (unsigned) (current_frame.remote_height * current_frame.zoom / 100)));
     break;
   case Ekiga::VO_MODE_FULLSCREEN:
-    runtime->run_in_main (sigc::bind (size_changed.make_slot (), 176, 144));
+    Ekiga::Runtime::run_in_main (sigc::bind (size_changed.make_slot (), 176, 144));
     break;
   case Ekiga::VO_MODE_PIP_WINDOW:
-    runtime->run_in_main (sigc::bind (size_changed.make_slot (), 176, 144));
+    Ekiga::Runtime::run_in_main (sigc::bind (size_changed.make_slot (), 176, 144));
     break;
   case Ekiga::VO_MODE_UNSET:
   default:
@@ -199,18 +199,18 @@ GMVideoOutputManager_dx::setup_frame_display ()
   if (video_disabled) {
     delete dxWindow;
     dxWindow = NULL;
-    runtime->run_in_main (sigc::bind (device_error.make_slot (), Ekiga::VO_ERROR));
+    Ekiga::Runtime::run_in_main (sigc::bind (device_error.make_slot (), Ekiga::VO_ERROR));
   }
   else {
     current_frame.accel = Ekiga::VO_ACCEL_ALL; 
-    runtime->run_in_main (sigc::bind (device_opened.make_slot (), current_frame.accel, current_frame.mode, current_frame.zoom, current_frame.both_streams_active));
+    Ekiga::Runtime::run_in_main (sigc::bind (device_opened.make_slot (), current_frame.accel, current_frame.mode, current_frame.zoom, current_frame.both_streams_active));
   }
 }
 
 void
 GMVideoOutputManager_dx::close_frame_display ()
 {
-  runtime->run_in_main (device_closed.make_slot ());
+  Ekiga::Runtime::run_in_main (device_closed.make_slot ());
 
   if (dxWindow) {
 
@@ -242,7 +242,7 @@ GMVideoOutputManager_dx::display_pip_frames (const char *local_frame,
     dxWindow->ProcessEvents(); 
 
   if (current_frame.mode == Ekiga::VO_MODE_FULLSCREEN && dxWindow && !dxWindow->IsFullScreen ())
-    runtime->run_in_main (sigc::bind (fullscreen_mode_changed.make_slot (), Ekiga::VO_FS_OFF));
+    Ekiga::Runtime::run_in_main (sigc::bind (fullscreen_mode_changed.make_slot (), Ekiga::VO_FS_OFF));
 
   if (dxWindow) {
     if (update_required.remote || (!update_required.remote && !update_required.local)) {
diff --git a/lib/engine/components/ldap/ldap-book.cpp b/lib/engine/components/ldap/ldap-book.cpp
index 47bf059..7e64868 100644
--- a/lib/engine/components/ldap/ldap-book.cpp
+++ b/lib/engine/components/ldap/ldap-book.cpp
@@ -760,18 +760,17 @@ OPENLDAP::Book::refresh_bound ()
 
   if (result <= 0) {
 
-    gmref_ptr<Ekiga::Runtime> runtime = core.get ("runtime");
     if (patience == 3) {
       patience--;
-      runtime->run_in_main (sigc::mem_fun (this, &OPENLDAP::Book::refresh_bound), 12);
+      Ekiga::Runtime::run_in_main (sigc::mem_fun (this, &OPENLDAP::Book::refresh_bound), 12);
     } else if (patience == 2) {
 
       patience--;
-      runtime->run_in_main (sigc::mem_fun (this, &OPENLDAP::Book::refresh_bound), 21);
+      Ekiga::Runtime::run_in_main (sigc::mem_fun (this, &OPENLDAP::Book::refresh_bound), 21);
     } else if (patience == 1) {
 
       patience--;
-      runtime->run_in_main (sigc::mem_fun (this, &OPENLDAP::Book::refresh_bound), 30);
+      Ekiga::Runtime::run_in_main (sigc::mem_fun (this, &OPENLDAP::Book::refresh_bound), 30);
     } else { // patience == 0
 
       status = std::string (_("Could not connect to server"));
@@ -854,21 +853,20 @@ OPENLDAP::Book::refresh_result ()
 
   if (result <= 0) {
 
-    gmref_ptr<Ekiga::Runtime> runtime = core.get ("runtime");
     if (patience == 3) {
 
       patience--;
-      runtime->run_in_main (sigc::mem_fun (this, &OPENLDAP::Book::refresh_result),
+      Ekiga::Runtime::run_in_main (sigc::mem_fun (this, &OPENLDAP::Book::refresh_result),
 			    12);
     } else if (patience == 2) {
 
       patience--;
-      runtime->run_in_main (sigc::mem_fun (this, &OPENLDAP::Book::refresh_result),
+      Ekiga::Runtime::run_in_main (sigc::mem_fun (this, &OPENLDAP::Book::refresh_result),
 			    21);
     } else if (patience == 1) {
 
       patience--;
-      runtime->run_in_main (sigc::mem_fun (this, &OPENLDAP::Book::refresh_result),
+      Ekiga::Runtime::run_in_main (sigc::mem_fun (this, &OPENLDAP::Book::refresh_result),
 			    30);
     } else { // patience == 0
 
diff --git a/lib/engine/components/ldap/ldap-main.cpp b/lib/engine/components/ldap/ldap-main.cpp
index 3ab8146..f06d3b5 100644
--- a/lib/engine/components/ldap/ldap-main.cpp
+++ b/lib/engine/components/ldap/ldap-main.cpp
@@ -53,9 +53,8 @@ struct LDAPSpark: public Ekiga::Spark
 			    char** /*argv*/[])
   {
     gmref_ptr<Ekiga::ContactCore> contact_core = core.get ("contact-core");
-    gmref_ptr<Ekiga::Runtime> runtime = core.get ("runtime");
 
-    if (contact_core && runtime) {
+    if (contact_core) {
 
       gmref_ptr<OPENLDAP::Source> service (new OPENLDAP::Source (core));
       core.add (service);
diff --git a/lib/engine/components/mlogo-videoinput/videoinput-manager-mlogo.cpp b/lib/engine/components/mlogo-videoinput/videoinput-manager-mlogo.cpp
index 4eba7ec..50282a4 100644
--- a/lib/engine/components/mlogo-videoinput/videoinput-manager-mlogo.cpp
+++ b/lib/engine/components/mlogo-videoinput/videoinput-manager-mlogo.cpp
@@ -44,15 +44,11 @@
 GMVideoInputManager_mlogo::GMVideoInputManager_mlogo (Ekiga::ServiceCore & _core)
 : core (_core)
 {
-  gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
-  smart->reference (); // keep a reference in the main thread
-  runtime = smart.get ();
   current_state.opened  = false;
 }
 
 GMVideoInputManager_mlogo::~GMVideoInputManager_mlogo ()
 {
-  runtime->unreference ();
 }
 
 void GMVideoInputManager_mlogo::get_devices(std::vector <Ekiga::VideoInputDevice> & devices)
@@ -110,7 +106,7 @@ bool GMVideoInputManager_mlogo::open (unsigned width, unsigned height, unsigned
   settings.colour = 127;
   settings.contrast = 127;
   settings.modifyable = false;
-  runtime->run_in_main (sigc::bind (device_opened.make_slot (), current_state.device, settings));
+  Ekiga::Runtime::run_in_main (sigc::bind (device_opened.make_slot (), current_state.device, settings));
   
   return true;
 }
@@ -120,7 +116,7 @@ void GMVideoInputManager_mlogo::close()
   PTRACE(4, "GMVideoInputManager_mlogo\tClosing Moving Logo");
   free (background_frame);
   current_state.opened  = false;
-  runtime->run_in_main (sigc::bind (device_closed.make_slot (), current_state.device));
+  Ekiga::Runtime::run_in_main (sigc::bind (device_closed.make_slot (), current_state.device));
 }
 
 bool GMVideoInputManager_mlogo::get_frame_data (char *data)
diff --git a/lib/engine/components/mlogo-videoinput/videoinput-manager-mlogo.h b/lib/engine/components/mlogo-videoinput/videoinput-manager-mlogo.h
index 53634f1..2c70021 100644
--- a/lib/engine/components/mlogo-videoinput/videoinput-manager-mlogo.h
+++ b/lib/engine/components/mlogo-videoinput/videoinput-manager-mlogo.h
@@ -87,7 +87,6 @@
       unsigned increment;
 
       Ekiga::ServiceCore & core;
-      Ekiga::Runtime* runtime;
 
       PAdaptiveDelay adaptive_delay;
   };
diff --git a/lib/engine/components/null-audioinput/audioinput-manager-null.cpp b/lib/engine/components/null-audioinput/audioinput-manager-null.cpp
index 24a678b..6da39f2 100644
--- a/lib/engine/components/null-audioinput/audioinput-manager-null.cpp
+++ b/lib/engine/components/null-audioinput/audioinput-manager-null.cpp
@@ -42,15 +42,11 @@
 GMAudioInputManager_null::GMAudioInputManager_null (Ekiga::ServiceCore & _core)
 :    core (_core)
 {
-  gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
-  smart->reference (); // take a reference in the main thread
-  runtime = smart.get ();
   current_state.opened = false;
 }
 
 GMAudioInputManager_null::~GMAudioInputManager_null ()
 {
-  runtime->unreference (); // leave a reference in the main thread
 }
 
 void GMAudioInputManager_null::get_devices(std::vector <Ekiga::AudioInputDevice> & devices)
@@ -90,7 +86,7 @@ bool GMAudioInputManager_null::open (unsigned channels, unsigned samplerate, uns
   Ekiga::AudioInputSettings settings;
   settings.volume = 0;
   settings.modifyable = false;
-  runtime->run_in_main (sigc::bind (device_opened.make_slot (), current_state.device, settings));
+  Ekiga::Runtime::run_in_main (sigc::bind (device_opened.make_slot (), current_state.device, settings));
 
   return true;
 }
@@ -98,7 +94,7 @@ bool GMAudioInputManager_null::open (unsigned channels, unsigned samplerate, uns
 void GMAudioInputManager_null::close()
 {
   current_state.opened = false;
-  runtime->run_in_main (sigc::bind (device_closed.make_slot (), current_state.device));
+  Ekiga::Runtime::run_in_main (sigc::bind (device_closed.make_slot (), current_state.device));
 }
 
 
diff --git a/lib/engine/components/null-audioinput/audioinput-manager-null.h b/lib/engine/components/null-audioinput/audioinput-manager-null.h
index 6d63423..5761455 100644
--- a/lib/engine/components/null-audioinput/audioinput-manager-null.h
+++ b/lib/engine/components/null-audioinput/audioinput-manager-null.h
@@ -75,7 +75,6 @@
 
   protected:
       Ekiga::ServiceCore & core;
-      Ekiga::Runtime* runtime;
 
       PAdaptiveDelay adaptive_delay;
   };
diff --git a/lib/engine/components/null-audiooutput/audiooutput-manager-null.cpp b/lib/engine/components/null-audiooutput/audiooutput-manager-null.cpp
index 40b2496..85cf1c0 100644
--- a/lib/engine/components/null-audiooutput/audiooutput-manager-null.cpp
+++ b/lib/engine/components/null-audiooutput/audiooutput-manager-null.cpp
@@ -41,16 +41,12 @@
 GMAudioOutputManager_null::GMAudioOutputManager_null (Ekiga::ServiceCore & _core)
 : core (_core)
 {
-  gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
-  smart->reference (); // take a reference in the main thread
-  runtime = smart.get ();
   current_state[Ekiga::primary].opened = false;
   current_state[Ekiga::secondary].opened = false;
 }
 
 GMAudioOutputManager_null::~GMAudioOutputManager_null ()
 {
-  runtime->unreference (); // leave a reference in the main thread
 }
 
 void GMAudioOutputManager_null::get_devices(std::vector <Ekiga::AudioOutputDevice> & devices)
@@ -91,7 +87,7 @@ bool GMAudioOutputManager_null::open (Ekiga::AudioOutputPS ps, unsigned channels
   Ekiga::AudioOutputSettings settings;
   settings.volume = 0;
   settings.modifyable = false;
-  runtime->run_in_main (sigc::bind (device_opened.make_slot (), ps, current_state[ps].device, settings));
+  Ekiga::Runtime::run_in_main (sigc::bind (device_opened.make_slot (), ps, current_state[ps].device, settings));
 
   return true;
 }
@@ -99,7 +95,7 @@ bool GMAudioOutputManager_null::open (Ekiga::AudioOutputPS ps, unsigned channels
 void GMAudioOutputManager_null::close(Ekiga::AudioOutputPS ps)
 {
   current_state[ps].opened = false;
-  runtime->run_in_main (sigc::bind (device_closed.make_slot (), ps, current_state[ps].device));
+  Ekiga::Runtime::run_in_main (sigc::bind (device_closed.make_slot (), ps, current_state[ps].device));
 }
 
 
diff --git a/lib/engine/components/null-audiooutput/audiooutput-manager-null.h b/lib/engine/components/null-audiooutput/audiooutput-manager-null.h
index 0e6c8bf..333cee5 100644
--- a/lib/engine/components/null-audiooutput/audiooutput-manager-null.h
+++ b/lib/engine/components/null-audiooutput/audiooutput-manager-null.h
@@ -74,7 +74,6 @@
 
     protected:
       Ekiga::ServiceCore & core;
-      Ekiga::Runtime* runtime;
 
       PAdaptiveDelay adaptive_delay[2];
   };
diff --git a/lib/engine/components/opal/h323-endpoint.cpp b/lib/engine/components/opal/h323-endpoint.cpp
index 6639c19..09b4264 100644
--- a/lib/engine/components/opal/h323-endpoint.cpp
+++ b/lib/engine/components/opal/h323-endpoint.cpp
@@ -93,12 +93,6 @@ Opal::H323::EndPoint::EndPoint (Opal::CallManager & _manager, Ekiga::ServiceCore
   uri_prefix = "h323:";
   listen_port = (_listen_port > 0 ? _listen_port : 1720);
 
-  {
-    gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
-    smart->reference (); // take a reference in the main thread
-    runtime = smart.get ();
-  }
-
   /* Initial requested bandwidth */
   SetInitialBandwidth (40000);
 
@@ -112,7 +106,6 @@ Opal::H323::EndPoint::EndPoint (Opal::CallManager & _manager, Ekiga::ServiceCore
 
 Opal::H323::EndPoint::~EndPoint ()
 {
-  runtime->unreference ();
 }
 
 bool Opal::H323::EndPoint::populate_menu (gmref_ptr<Ekiga::Contact> contact,
@@ -332,14 +325,14 @@ void Opal::H323::EndPoint::Register (const Opal::Account & account)
         info = _("Failed");
 
       /* Signal */
-      runtime->run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
+      Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
 					account.registration_event.make_slot (),
 					Ekiga::AccountCore::RegistrationFailed,
 					info));
     }
     else {
 
-      runtime->run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
+      Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
 					account.registration_event.make_slot (),
 					Ekiga::AccountCore::Registered,
 					std::string ()));
@@ -351,7 +344,7 @@ void Opal::H323::EndPoint::Register (const Opal::Account & account)
     RemoveAliasName (account.get_username ());
 
     /* Signal */
-    runtime->run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
+    Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
 				      account.registration_event.make_slot (),
 				      Ekiga::AccountCore::Unregistered,
 				      std::string ()));
diff --git a/lib/engine/components/opal/h323-endpoint.h b/lib/engine/components/opal/h323-endpoint.h
index 40bcce7..bdf8497 100644
--- a/lib/engine/components/opal/h323-endpoint.h
+++ b/lib/engine/components/opal/h323-endpoint.h
@@ -126,7 +126,6 @@ namespace Opal {
 
       CallManager & manager;
       Ekiga::ServiceCore & core;
-      Ekiga::Runtime* runtime;
 
       PMutex gk_name_mutex;
       PString gk_name;
diff --git a/lib/engine/components/opal/opal-call-manager.cpp b/lib/engine/components/opal/opal-call-manager.cpp
index 35c4628..9296cf0 100644
--- a/lib/engine/components/opal/opal-call-manager.cpp
+++ b/lib/engine/components/opal/opal-call-manager.cpp
@@ -141,11 +141,6 @@ CallManager::CallManager (Ekiga::ServiceCore & _core)
   SetMediaFormatMask (PStringArray ());
 
   call_core = core.get ("call-core");
-  {
-    gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
-    smart->reference (); // take a reference in the main thread
-    runtime = smart.get ();
-  }
 
   // used to communicate with the StunDetector
 #if GLIB_CHECK_VERSION(2,16,0)
@@ -163,7 +158,6 @@ CallManager::~CallManager ()
   ClearAllCalls (OpalConnection::EndedByLocalUser, true);
 
   g_async_queue_unref (queue);
-  runtime->unreference ();
 }
 
 
@@ -174,7 +168,7 @@ void CallManager::start ()
     // Ready
     new StunDetector (stun_server, *this, queue);
     patience = 20;
-    runtime->run_in_main (sigc::mem_fun (this, &CallManager::HandleSTUNResult), 1);
+    Ekiga::Runtime::run_in_main (sigc::mem_fun (this, &CallManager::HandleSTUNResult), 1);
   } else
     ready.emit ();
 }
@@ -651,7 +645,7 @@ CallManager::DestroyCall (OpalCall *_call)
 {
   Ekiga::Call *call = dynamic_cast<Ekiga::Call *> (_call);
 
-  runtime->emit_signal_in_main(call->removed);
+  Ekiga::Runtime::emit_signal_in_main(call->removed);
 }
 
 
@@ -746,8 +740,8 @@ CallManager::HandleSTUNResult ()
   else {
 
       patience--;
-      runtime->run_in_main (sigc::mem_fun (this, &CallManager::HandleSTUNResult),
-			    1);
+      Ekiga::Runtime::run_in_main (sigc::mem_fun (this, &CallManager::HandleSTUNResult),
+				   1);
   }
 }
 
@@ -757,8 +751,8 @@ CallManager::ReportSTUNError (const std::string error)
   // notice we're in for an infinite loop if nobody ever reports to the user!
   if ( !call_core->errors.handle_request (error)) {
 
-    runtime->run_in_main (sigc::bind (sigc::mem_fun (this, &CallManager::ReportSTUNError),
-				      error),
-			  10);
+    Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &CallManager::ReportSTUNError),
+					     error),
+				 10);
   }
 }
diff --git a/lib/engine/components/opal/opal-call-manager.h b/lib/engine/components/opal/opal-call-manager.h
index 404398b..3c15cde 100644
--- a/lib/engine/components/opal/opal-call-manager.h
+++ b/lib/engine/components/opal/opal-call-manager.h
@@ -177,7 +177,6 @@ private:
        variables */
     PMutex manager_access_mutex;
 
-    Ekiga::Runtime *runtime;
     Ekiga::ServiceCore & core;
     Ekiga::CodecList codecs; 
     gmref_ptr<Ekiga::CallCore> call_core; // FIXME: is it threaded in there?
diff --git a/lib/engine/components/opal/opal-call.cpp b/lib/engine/components/opal/opal-call.cpp
index 155c3fe..dd0ff2e 100644
--- a/lib/engine/components/opal/opal-call.cpp
+++ b/lib/engine/components/opal/opal-call.cpp
@@ -77,11 +77,6 @@ Opal::Call::Call (OpalManager & _manager, Ekiga::ServiceCore & _core)
   : OpalCall (_manager), Ekiga::Call (), core (_core),
     call_setup(false),outgoing(true),jitter(0)
 {
-  {
-    gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
-    smart->reference (); // take a reference in the main thread
-    runtime = smart.get ();
-  }
   re_a_bytes = tr_a_bytes = re_v_bytes = tr_v_bytes = 0.0;
   last_v_tick = last_a_tick = PTime ();
   total_a =
@@ -101,7 +96,6 @@ Opal::Call::Call (OpalManager & _manager, Ekiga::ServiceCore & _core)
 
 Opal::Call::~Call ()
 {
-  runtime->unreference (); // leave a reference in the main thead
 }
 
 
@@ -208,9 +202,9 @@ Opal::Call::toggle_stream_pause (StreamType type)
       stream->SetPaused (!paused);
 
       if (paused)
-        runtime->run_in_main (sigc::bind (stream_resumed, stream_name, type));
+	Ekiga::Runtime::run_in_main (sigc::bind (stream_resumed, stream_name, type));
       else
-        runtime->run_in_main (sigc::bind (stream_paused, stream_name, type));
+	Ekiga::Runtime::run_in_main (sigc::bind (stream_paused, stream_name, type));
     }
   }
 }
@@ -376,7 +370,7 @@ Opal::Call::OnEstablished (OpalConnection & connection)
   if (!PIsDescendant(&connection, OpalPCSSConnection)) {
 
     parse_info (connection);
-    runtime->emit_signal_in_main (established);
+    Ekiga::Runtime::emit_signal_in_main (established);
   }
 
   if (PIsDescendant(&connection, OpalRTPConnection)) {
@@ -434,7 +428,7 @@ Opal::Call::OnCleared ()
       && !is_outgoing ()
       && GetCallEndReason () != OpalConnection::EndedByAnswerDenied) {
 
-    runtime->emit_signal_in_main (missed);
+    Ekiga::Runtime::emit_signal_in_main (missed);
   }
   else {
 
@@ -516,7 +510,7 @@ Opal::Call::OnCleared ()
       reason = _("Call completed");
     }
 
-    runtime->emit_signal_in_main (cleared, reason);
+    Ekiga::Runtime::emit_signal_in_main (cleared, reason);
   }
 }
 
@@ -538,7 +532,7 @@ Opal::Call::OnSetUp (OpalConnection & connection)
 {
   parse_info (connection);
 
-  runtime->emit_signal_in_main (setup);
+  Ekiga::Runtime::emit_signal_in_main (setup);
   call_setup = true;
 
   cleared.connect (sigc::mem_fun (this, &Opal::Call::on_cleared_call));
@@ -554,7 +548,7 @@ PBoolean
 Opal::Call::OnAlerting (OpalConnection & connection)
 {
   if (!PIsDescendant(&connection, OpalPCSSConnection))
-    runtime->emit_signal_in_main (ringing);
+    Ekiga::Runtime::emit_signal_in_main (ringing);
 
   return OpalCall::OnAlerting (connection);
 }
@@ -566,9 +560,9 @@ Opal::Call::OnHold (OpalConnection & /*connection*/,
                     bool on_hold)
 {
   if (on_hold)
-    runtime->emit_signal_in_main (held);
+    Ekiga::Runtime::emit_signal_in_main (held);
   else
-    runtime->emit_signal_in_main (retrieved);
+    Ekiga::Runtime::emit_signal_in_main (retrieved);
 }
 
 
@@ -583,7 +577,7 @@ Opal::Call::OnOpenMediaStream (OpalMediaStream & stream)
   std::transform (stream_name.begin (), stream_name.end (), stream_name.begin (), (int (*) (int)) toupper);
   is_transmitting = !stream.IsSource ();
 
-  runtime->run_in_main (sigc::bind (stream_opened, stream_name, type, is_transmitting));
+  Ekiga::Runtime::run_in_main (sigc::bind (stream_opened, stream_name, type, is_transmitting));
 }
 
 
@@ -598,7 +592,7 @@ Opal::Call::OnClosedMediaStream (OpalMediaStream & stream)
   std::transform (stream_name.begin (), stream_name.end (), stream_name.begin (), (int (*) (int)) toupper);
   is_transmitting = !stream.IsSource ();
 
-  runtime->run_in_main (sigc::bind (stream_closed, stream_name, type, is_transmitting));
+  Ekiga::Runtime::run_in_main (sigc::bind (stream_closed, stream_name, type, is_transmitting));
 }
 
 
diff --git a/lib/engine/components/opal/opal-call.h b/lib/engine/components/opal/opal-call.h
index 9dd407e..d5f9c31 100644
--- a/lib/engine/components/opal/opal-call.h
+++ b/lib/engine/components/opal/opal-call.h
@@ -205,7 +205,6 @@ private:
      * Variables
      */
     Ekiga::ServiceCore & core;
-    Ekiga::Runtime* runtime;
 
 
     bool call_setup;
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/sip-endpoint.cpp
index 764deb2..b1d0ed1 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/sip-endpoint.cpp
@@ -132,11 +132,6 @@ Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager,
   gmref_ptr<Ekiga::ChatCore> chat_core = core.get ("chat-core");
 
   {
-    gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
-    smart->reference (); // take a reference in the main thread
-    runtime = smart.get ();
-  }
-  {
     gmref_ptr<Opal::Bank> smart = core.get ("opal-account-store");
     smart->reference (); // take a reference in the main thread
     bank = smart.get ();
@@ -176,7 +171,6 @@ Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager,
 
 Opal::Sip::EndPoint::~EndPoint ()
 {
-  runtime->unreference (); // leave a reference in the main thread
   bank->unreference (); // leave a reference in the main thread
   dialect->unreference (); // leave a reference in the main thread
 }
@@ -684,7 +678,7 @@ void Opal::Sip::EndPoint::OnRegistered (const PString & _aor,
   /* Signal */
   Opal::Account *account = bank->find_account (strm.str ());
   if (account)
-    runtime->run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
+    Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
 				      account->registration_event.make_slot (),
 				      was_registering ? Ekiga::AccountCore::Registered : Ekiga::AccountCore::Unregistered,
 				      std::string ()));
@@ -918,7 +912,7 @@ void Opal::Sip::EndPoint::OnRegistrationFailed (const PString & _aor,
   /* Signal */
   Opal::Account *account = bank->find_account (strm.str ());
   if (account)
-    runtime->run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
+    Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
 				      account->registration_event.make_slot (),
 				      wasRegistering ? Ekiga::AccountCore::RegistrationFailed : Ekiga::AccountCore::UnregistrationFailed,
 				      info));
@@ -935,7 +929,7 @@ void Opal::Sip::EndPoint::OnMWIReceived (const PString & party, OpalManager::Mes
   /* Signal */
   Opal::Account *account = bank->find_account (party);
   if (account)
-    runtime->run_in_main (sigc::bind (account->mwi_event.make_slot (), info));
+    Ekiga::Runtime::run_in_main (sigc::bind (account->mwi_event.make_slot (), info));
 }
 
 
@@ -1000,7 +994,7 @@ bool Opal::Sip::EndPoint::OnReceivedMESSAGE (OpalTransport & transport,
     std::string message_uri = (const char *) uri.AsString ();
     std::string _message = (const char *) pdu.GetEntityBody ();
 
-    runtime->run_in_main (sigc::bind (sigc::ptr_fun (push_message_in_main), dialect, message_uri, display_name, _message));
+    Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun (push_message_in_main), dialect, message_uri, display_name, _message));
   }
 
   return SIPEndPoint::OnReceivedMESSAGE (transport, pdu);
@@ -1015,7 +1009,7 @@ void Opal::Sip::EndPoint::OnMessageFailed (const SIPURL & messageUrl,
   std::string uri = (const char *) to.AsString ();
   std::string display_name = (const char *) to.GetDisplayName ();
 
-  runtime->run_in_main (sigc::bind (sigc::ptr_fun (push_notice_in_main),
+  Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun (push_notice_in_main),
 				    dialect, uri, display_name,
 				    _("Could not send message")));
 }
@@ -1112,7 +1106,7 @@ Opal::Sip::EndPoint::OnPresenceInfoReceived (const PString & user,
   if (presence != "unknown" && (old_presence != presence || old_status != status)) {
     presence_infos[_uri].presence = presence;
     presence_infos[_uri].status = status;
-    runtime->run_in_main (sigc::bind (sigc::ptr_fun (presence_status_in_main), this, _uri, presence_infos[_uri].presence, presence_infos[_uri].status));
+    Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun (presence_status_in_main), this, _uri, presence_infos[_uri].presence, presence_infos[_uri].status));
   }
 }
 
@@ -1155,9 +1149,9 @@ Opal::Sip::EndPoint::OnDialogInfoReceived (const SIPDialogNotification & info)
   dialog_infos[uri].status = status;
 
   if (_status)
-    runtime->run_in_main (sigc::bind (sigc::ptr_fun (presence_status_in_main), this, uri, dialog_infos[uri].presence, dialog_infos[uri].status));
+    Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun (presence_status_in_main), this, uri, dialog_infos[uri].presence, dialog_infos[uri].status));
   else
-    runtime->run_in_main (sigc::bind (sigc::ptr_fun (presence_status_in_main), this, uri, presence_infos[uri].presence, presence_infos[uri].status));
+    Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun (presence_status_in_main), this, uri, presence_infos[uri].presence, presence_infos[uri].status));
 }
 
 
diff --git a/lib/engine/components/opal/sip-endpoint.h b/lib/engine/components/opal/sip-endpoint.h
index 009aee4..56ad061 100644
--- a/lib/engine/components/opal/sip-endpoint.h
+++ b/lib/engine/components/opal/sip-endpoint.h
@@ -194,7 +194,6 @@ namespace Opal {
       std::list<std::string> subscribed_uris;    // List of subscribed uris
       std::list<std::string> aors;               // List of registered aor
       Ekiga::ServiceCore & core;
-      Ekiga::Runtime* runtime;
       Opal::Bank* bank;
 
       Ekiga::CallProtocolManager::Interface listen_iface;
diff --git a/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp b/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp
index 7f1a216..e76f021 100644
--- a/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp
+++ b/lib/engine/components/ptlib/audioinput-manager-ptlib.cpp
@@ -45,9 +45,6 @@
 GMAudioInputManager_ptlib::GMAudioInputManager_ptlib (Ekiga::ServiceCore & _core)
 : core (_core)
 {
-  gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
-  smart->reference (); // take a reference in the main thread
-  runtime = smart.get ();
   current_state.opened = false;
   input_device = NULL;
   expectedFrameSize = 0;
@@ -55,7 +52,6 @@ GMAudioInputManager_ptlib::GMAudioInputManager_ptlib (Ekiga::ServiceCore & _core
 
 GMAudioInputManager_ptlib::~GMAudioInputManager_ptlib ()
 {
-  runtime->unreference (); // leave a reference in the main thread
 }
 
 void GMAudioInputManager_ptlib::get_devices(std::vector <Ekiga::AudioInputDevice> & devices)
@@ -133,7 +129,7 @@ bool GMAudioInputManager_ptlib::open (unsigned channels, unsigned samplerate, un
 
   if (error_code != Ekiga::AI_ERROR_NONE) {
     PTRACE(1, "GMAudioInputManager_ptlib\tEncountered error " << error_code << " while opening device ");
-    runtime->run_in_main (sigc::bind (device_error.make_slot (), current_state.device, error_code));
+    Ekiga::Runtime::run_in_main (sigc::bind (device_error.make_slot (), current_state.device, error_code));
     return false;
   }
 
@@ -144,7 +140,7 @@ bool GMAudioInputManager_ptlib::open (unsigned channels, unsigned samplerate, un
   Ekiga::AudioInputSettings settings;
   settings.volume = volume;
   settings.modifyable = true;
-  runtime->run_in_main (sigc::bind (device_opened.make_slot (), current_state.device, settings));
+  Ekiga::Runtime::run_in_main (sigc::bind (device_opened.make_slot (), current_state.device, settings));
 
   return true;
 }
@@ -157,7 +153,7 @@ void GMAudioInputManager_ptlib::close()
      input_device = NULL;
   }
   current_state.opened = false;
-  runtime->run_in_main (sigc::bind (device_closed.make_slot (), current_state.device));
+  Ekiga::Runtime::run_in_main (sigc::bind (device_closed.make_slot (), current_state.device));
 }
 
 void GMAudioInputManager_ptlib::set_buffer_size (unsigned buffer_size, unsigned num_buffers)
@@ -188,7 +184,7 @@ bool GMAudioInputManager_ptlib::get_frame_data (char *data,
     }
     if (bytes_read != size) {
       PTRACE(1, "GMAudioInputManager_ptlib\tEncountered error while trying to read data");
-      runtime->run_in_main (sigc::bind (device_error.make_slot (), current_state.device, Ekiga::AI_ERROR_READ));
+      Ekiga::Runtime::run_in_main (sigc::bind (device_error.make_slot (), current_state.device, Ekiga::AI_ERROR_READ));
     }
   }
 
diff --git a/lib/engine/components/ptlib/audioinput-manager-ptlib.h b/lib/engine/components/ptlib/audioinput-manager-ptlib.h
index 64525ab..4f525b2 100644
--- a/lib/engine/components/ptlib/audioinput-manager-ptlib.h
+++ b/lib/engine/components/ptlib/audioinput-manager-ptlib.h
@@ -78,7 +78,6 @@
 
   protected:
       Ekiga::ServiceCore & core;
-      Ekiga::Runtime* runtime;
       unsigned expectedFrameSize;
 
       PSoundChannel *input_device;
diff --git a/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp b/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
index fda5b21..9d60dd3 100644
--- a/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
+++ b/lib/engine/components/ptlib/audiooutput-manager-ptlib.cpp
@@ -44,9 +44,6 @@
 GMAudioOutputManager_ptlib::GMAudioOutputManager_ptlib (Ekiga::ServiceCore & _core)
 : core (_core)
 {
-  gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
-  smart->reference (); // take a reference in the main thread
-  runtime = smart.get ();
   current_state[Ekiga::primary].opened = false;
   current_state[Ekiga::secondary].opened = false;
   output_device[Ekiga::primary] = NULL;
@@ -55,7 +52,6 @@ GMAudioOutputManager_ptlib::GMAudioOutputManager_ptlib (Ekiga::ServiceCore & _co
 
 GMAudioOutputManager_ptlib::~GMAudioOutputManager_ptlib ()
 {
-  runtime->unreference (); // leave a reference in the main thread
 }
 
 void GMAudioOutputManager_ptlib::get_devices(std::vector <Ekiga::AudioOutputDevice> & devices)
@@ -133,7 +129,7 @@ bool GMAudioOutputManager_ptlib::open (Ekiga::AudioOutputPS ps, unsigned channel
 
   if (error_code != Ekiga::AO_ERROR_NONE) {
     PTRACE(1, "GMAudioOutputManager_ptlib\tEncountered error " << error_code << " while opening device[" << ps << "]");
-    runtime->run_in_main (sigc::bind (device_error.make_slot (), ps, current_state[ps].device, error_code));
+    Ekiga::Runtime::run_in_main (sigc::bind (device_error.make_slot (), ps, current_state[ps].device, error_code));
     return false;
   }
 
@@ -144,7 +140,7 @@ bool GMAudioOutputManager_ptlib::open (Ekiga::AudioOutputPS ps, unsigned channel
   Ekiga::AudioOutputSettings settings;
   settings.volume = volume;
   settings.modifyable = true;
-  runtime->run_in_main (sigc::bind (device_opened.make_slot (), ps, current_state[ps].device, settings));
+  Ekiga::Runtime::run_in_main (sigc::bind (device_opened.make_slot (), ps, current_state[ps].device, settings));
 
   return true;
 }
@@ -157,7 +153,7 @@ void GMAudioOutputManager_ptlib::close(Ekiga::AudioOutputPS ps)
      output_device[ps] = NULL;
   }
   current_state[ps].opened = false;
-  runtime->run_in_main (sigc::bind (device_closed.make_slot (), ps, current_state[ps].device));
+  Ekiga::Runtime::run_in_main (sigc::bind (device_closed.make_slot (), ps, current_state[ps].device));
 }
 
 void GMAudioOutputManager_ptlib::set_buffer_size (Ekiga::AudioOutputPS ps, unsigned buffer_size, unsigned num_buffers)
@@ -190,7 +186,7 @@ bool GMAudioOutputManager_ptlib::set_frame_data (Ekiga::AudioOutputPS ps,
     }
     if (bytes_written != size) {
       PTRACE(1, "GMAudioOutputManager_ptlib\tEncountered error while trying to write data");
-      runtime->run_in_main (sigc::bind (device_error.make_slot (), ps, current_state[ps].device, Ekiga::AO_ERROR_WRITE));
+      Ekiga::Runtime::run_in_main (sigc::bind (device_error.make_slot (), ps, current_state[ps].device, Ekiga::AO_ERROR_WRITE));
     }
   }
 
diff --git a/lib/engine/components/ptlib/audiooutput-manager-ptlib.h b/lib/engine/components/ptlib/audiooutput-manager-ptlib.h
index 1f0e488..c473a7c 100644
--- a/lib/engine/components/ptlib/audiooutput-manager-ptlib.h
+++ b/lib/engine/components/ptlib/audiooutput-manager-ptlib.h
@@ -79,7 +79,6 @@
 
     protected:
       Ekiga::ServiceCore & core;
-      Ekiga::Runtime* runtime;
 
       PSoundChannel *output_device[2];
   };
diff --git a/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp b/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp
index 79ca94e..87ec2ee 100644
--- a/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp
+++ b/lib/engine/components/ptlib/videoinput-manager-ptlib.cpp
@@ -44,9 +44,6 @@
 GMVideoInputManager_ptlib::GMVideoInputManager_ptlib (Ekiga::ServiceCore & _core)
 : core (_core)
 {
-  gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
-  smart->reference (); // take a reference in the main thread
-  runtime = smart.get ();
   current_state.opened = false;
   input_device = NULL;
   expectedFrameSize = 0;
@@ -54,7 +51,6 @@ GMVideoInputManager_ptlib::GMVideoInputManager_ptlib (Ekiga::ServiceCore & _core
 
 GMVideoInputManager_ptlib::~GMVideoInputManager_ptlib ()
 {
-  runtime->unreference (); // leave a reference in the main thread
 }
 
 void GMVideoInputManager_ptlib::get_devices(std::vector <Ekiga::VideoInputDevice> & devices)
@@ -147,7 +143,7 @@ bool GMVideoInputManager_ptlib::open (unsigned width, unsigned height, unsigned
 
   if (error_code != Ekiga::VI_ERROR_NONE) {
     PTRACE(1, "GMVideoInputManager_ptlib\tEncountered error " << error_code << " while opening device ");
-    runtime->run_in_main (sigc::bind (device_error.make_slot (), current_state.device, error_code));
+    Ekiga::Runtime::run_in_main (sigc::bind (device_error.make_slot (), current_state.device, error_code));
     return false;
   }
 
@@ -162,7 +158,7 @@ bool GMVideoInputManager_ptlib::open (unsigned width, unsigned height, unsigned
   settings.contrast = contrast >> 8;
   settings.modifyable = true;
 
-  runtime->run_in_main (sigc::bind (device_opened.make_slot (), current_state.device, settings));
+  Ekiga::Runtime::run_in_main (sigc::bind (device_opened.make_slot (), current_state.device, settings));
 
   return true;
 }
@@ -175,7 +171,7 @@ void GMVideoInputManager_ptlib::close()
     input_device = NULL;
   }
   current_state.opened = false;
-  runtime->run_in_main (sigc::bind (device_closed.make_slot (), current_state.device));
+  Ekiga::Runtime::run_in_main (sigc::bind (device_closed.make_slot (), current_state.device));
 }
 
 bool GMVideoInputManager_ptlib::get_frame_data (char *data)
diff --git a/lib/engine/components/ptlib/videoinput-manager-ptlib.h b/lib/engine/components/ptlib/videoinput-manager-ptlib.h
index 78848e6..3d0e089 100644
--- a/lib/engine/components/ptlib/videoinput-manager-ptlib.h
+++ b/lib/engine/components/ptlib/videoinput-manager-ptlib.h
@@ -77,7 +77,6 @@
 
   protected:
       Ekiga::ServiceCore & core;
-      Ekiga::Runtime* runtime;
       unsigned expectedFrameSize;
 
       PVideoInputDevice *input_device;
diff --git a/lib/engine/components/x-videooutput/videooutput-manager-x.cpp b/lib/engine/components/x-videooutput/videooutput-manager-x.cpp
index 6f6aa7e..3346b8f 100644
--- a/lib/engine/components/x-videooutput/videooutput-manager-x.cpp
+++ b/lib/engine/components/x-videooutput/videooutput-manager-x.cpp
@@ -114,17 +114,17 @@ GMVideoOutputManager_x::setup_frame_display ()
 
   switch (current_frame.mode) {
   case Ekiga::VO_MODE_LOCAL:
-    runtime->run_in_main (sigc::bind (size_changed.make_slot (), (unsigned) (current_frame.local_width * current_frame.zoom / 100), (unsigned) (current_frame.local_height * current_frame.zoom / 100)));
+    Ekiga::Runtime::run_in_main (sigc::bind (size_changed.make_slot (), (unsigned) (current_frame.local_width * current_frame.zoom / 100), (unsigned) (current_frame.local_height * current_frame.zoom / 100)));
     break;
   case Ekiga::VO_MODE_REMOTE:
   case Ekiga::VO_MODE_PIP:
-    runtime->run_in_main (sigc::bind (size_changed.make_slot (), (unsigned) (current_frame.remote_width * current_frame.zoom / 100), (unsigned) (current_frame.remote_height * current_frame.zoom / 100)));
+    Ekiga::Runtime::run_in_main (sigc::bind (size_changed.make_slot (), (unsigned) (current_frame.remote_width * current_frame.zoom / 100), (unsigned) (current_frame.remote_height * current_frame.zoom / 100)));
     break;
   case Ekiga::VO_MODE_FULLSCREEN:
-    runtime->run_in_main (sigc::bind (size_changed.make_slot (), 176, 144));
+    Ekiga::Runtime::run_in_main (sigc::bind (size_changed.make_slot (), 176, 144));
     break;
   case Ekiga::VO_MODE_PIP_WINDOW:
-    runtime->run_in_main (sigc::bind (size_changed.make_slot (), 176, 144));
+    Ekiga::Runtime::run_in_main (sigc::bind (size_changed.make_slot (), 176, 144));
     break;
   case Ekiga::VO_MODE_UNSET:
   default:
@@ -421,17 +421,17 @@ GMVideoOutputManager_x::setup_frame_display ()
   last_frame.both_streams_active = current_frame.both_streams_active;
 
   if (video_disabled) {
-    runtime->run_in_main (sigc::bind (device_error.make_slot (), Ekiga::VO_ERROR));
+    Ekiga::Runtime::run_in_main (sigc::bind (device_error.make_slot (), Ekiga::VO_ERROR));
   }
   else {
-    runtime->run_in_main (sigc::bind (device_opened.make_slot (), current_frame.accel, current_frame.mode, current_frame.zoom, current_frame.both_streams_active));
+    Ekiga::Runtime::run_in_main (sigc::bind (device_opened.make_slot (), current_frame.accel, current_frame.mode, current_frame.zoom, current_frame.both_streams_active));
   }
 }
 
 void
 GMVideoOutputManager_x::close_frame_display ()
 {
-  runtime->run_in_main (device_closed.make_slot ());
+  Ekiga::Runtime::run_in_main (device_closed.make_slot ());
 
   if (rxWindow) 
     rxWindow->RegisterSlave (NULL);
@@ -482,7 +482,7 @@ GMVideoOutputManager_x::display_pip_frames (const char *local_frame,
     lxWindow->ProcessEvents();
 
   if (current_frame.mode == Ekiga::VO_MODE_FULLSCREEN && rxWindow && !rxWindow->IsFullScreen ())
-    runtime->run_in_main (sigc::bind (fullscreen_mode_changed.make_slot (), Ekiga::VO_FS_OFF));
+    Ekiga::Runtime::run_in_main (sigc::bind (fullscreen_mode_changed.make_slot (), Ekiga::VO_FS_OFF));
 
   if (rxWindow && (update_required.remote || (!update_required.remote && !update_required.local)))
     rxWindow->PutFrame ((uint8_t *) remote_frame, rf_width, rf_height);
diff --git a/lib/engine/engine.cpp b/lib/engine/engine.cpp
index 787bd2e..3f96ffa 100644
--- a/lib/engine/engine.cpp
+++ b/lib/engine/engine.cpp
@@ -130,8 +130,7 @@ static Ekiga::ServiceCore *service_core = NULL;
 
 void
 engine_init (int argc,
-             char *argv [],
-             Ekiga::Runtime* runtime)
+             char *argv [])
 {
   service_core = new Ekiga::ServiceCore;
   Ekiga::KickStart kickstart;
@@ -147,20 +146,16 @@ engine_init (int argc,
   gmref_ptr<Ekiga::CallCore> call_core (new Ekiga::CallCore);
   gmref_ptr<Ekiga::ChatCore> chat_core (new Ekiga::ChatCore);
   gmref_ptr<Ekiga::VideoOutputCore> videooutput_core (new Ekiga::VideoOutputCore);
-  gmref_ptr<Ekiga::VideoInputCore> videoinput_core (new Ekiga::VideoInputCore(*runtime, *videooutput_core));
-  gmref_ptr<Ekiga::AudioOutputCore> audiooutput_core (new Ekiga::AudioOutputCore(*runtime));
-  gmref_ptr<Ekiga::AudioInputCore> audioinput_core (new Ekiga::AudioInputCore(*runtime, *audiooutput_core));
+  gmref_ptr<Ekiga::VideoInputCore> videoinput_core (new Ekiga::VideoInputCore(*videooutput_core));
+  gmref_ptr<Ekiga::AudioOutputCore> audiooutput_core (new Ekiga::AudioOutputCore);
+  gmref_ptr<Ekiga::AudioInputCore> audioinput_core (new Ekiga::AudioInputCore(*audiooutput_core));
   gmref_ptr<Ekiga::HalCore> hal_core (new Ekiga::HalCore);
 
 
   /* 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.            *
-   * - The runtime should be destroyed last since other core        *
-   *   components may still call runtime functions until destroyed  *
-   *   (e.g. VideoOutputCore).                                          */
+   *   PreviewManager may call functions of VideoOutputCore.            */
 
-  service_core->add (gmref_ptr<Ekiga::Runtime>(runtime));
   service_core->add (account_core);
   service_core->add (contact_core);
   service_core->add (chat_core);
diff --git a/lib/engine/engine.h b/lib/engine/engine.h
index f6f509a..3237f14 100644
--- a/lib/engine/engine.h
+++ b/lib/engine/engine.h
@@ -46,8 +46,7 @@
  */
 
 void engine_init (int argc,
-		  char *argv[],
-		  Ekiga::Runtime *runtime);
+		  char *argv[]);
 
 Ekiga::ServiceCore* engine_get_service_core ();
 
diff --git a/lib/engine/framework/Makefile.am b/lib/engine/framework/Makefile.am
index b724a73..9ff3751 100644
--- a/lib/engine/framework/Makefile.am
+++ b/lib/engine/framework/Makefile.am
@@ -36,7 +36,6 @@ libgmframework_la_SOURCES = \
 	$(framework_dir)/form-builder.cpp \
 	$(framework_dir)/form-dumper.cpp \
 	$(framework_dir)/form-request-simple.cpp \
-	$(framework_dir)/runtime-glib.h \
 	$(framework_dir)/runtime-glib.cpp \
 	$(framework_dir)/services.cpp \
 	$(framework_dir)/trigger.h \
diff --git a/lib/engine/framework/runtime-glib.cpp b/lib/engine/framework/runtime-glib.cpp
index 948e146..4b2d58f 100644
--- a/lib/engine/framework/runtime-glib.cpp
+++ b/lib/engine/framework/runtime-glib.cpp
@@ -33,7 +33,11 @@
  *
  */
 
-#include "runtime-glib.h"
+#include "runtime.h"
+
+#include <glib.h>
+
+static GAsyncQueue* queue;
 
 /* implementation of the helper functions
  *
@@ -126,39 +130,33 @@ static GSourceFuncs source_funcs = {
   NULL
 };
 
-Ekiga::GlibRuntime::GlibRuntime ()
+void
+Ekiga::Runtime::init ()
 {
-  struct source *source  = NULL;
+  queue = g_async_queue_new (); // here we get a ref to the queue
 
-  queue = g_async_queue_new (); // this object owns a ref on it
-
-  source = (struct source *)g_source_new (&source_funcs,
+  struct source* source = (struct source *)g_source_new (&source_funcs,
 					  sizeof (struct source));
   source->queue = queue;
-  g_async_queue_ref (source->queue); // the source owns another ref on it
-
+  g_async_queue_ref (queue); // give a ref to the source
   g_source_attach ((GSource *)source, g_main_context_default ());
 }
 
-Ekiga::GlibRuntime::~GlibRuntime ()
-{
-  quit ();
-  g_async_queue_unref (queue);
-}
-
 void
-Ekiga::GlibRuntime::run ()
+Ekiga::Runtime::run ()
 {
 }
 
 void
-Ekiga::GlibRuntime::quit ()
+Ekiga::Runtime::quit ()
 {
+  g_async_queue_unref (queue);
+  queue = NULL;
 }
 
 void
-Ekiga::GlibRuntime::run_in_main (sigc::slot0<void> action,
-				 unsigned int seconds)
+Ekiga::Runtime::run_in_main (sigc::slot0<void> action,
+			     unsigned int seconds)
 {
   g_async_queue_push (queue, (gpointer)(new struct message (action, seconds)));
 }
diff --git a/lib/engine/framework/runtime-glib.h b/lib/engine/framework/runtime-glib.h
deleted file mode 100644
index 75482a6..0000000
--- a/lib/engine/framework/runtime-glib.h
+++ /dev/null
@@ -1,79 +0,0 @@
-
-/*
- * 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.
- */
-
-
-/*
- *                         runtime-glib.h  -  description
- *                         ------------------------------------------
- *   begin                : written in 2007 by Julien Puydt
- *   copyright            : (c) 2007 by Julien Puydt
- *                          (c) 2007 by Damien Sandras
- *   description          : Threading helper functions -- glib version
- *
- */
-
-#include <glib.h>
-
-#include "runtime.h"
-
-#ifndef __RUNTIME_GLIB_H__
-#define __RUNTIME_GLIB_H__
-
-namespace Ekiga
-{
-
-/**
- * @addtogroup services
- * @{
- */
-
-  class GlibRuntime
-    : public Runtime
-  {
-  public:
-
-    GlibRuntime ();
-
-    ~GlibRuntime ();
-
-    void run ();
-
-    void quit ();
-
-    void run_in_main (sigc::slot0<void> action,
-                      unsigned int seconds);
-
-  private:
-
-    GAsyncQueue *queue;
-  };
-
-/**
- * @}
- */
-
-};
-
-#endif
diff --git a/lib/engine/framework/runtime.h b/lib/engine/framework/runtime.h
index 7ab254e..126a412 100644
--- a/lib/engine/framework/runtime.h
+++ b/lib/engine/framework/runtime.h
@@ -57,52 +57,38 @@ static void emit_signal_in_main_helper (sigc::signal0<void> sign)
 namespace Ekiga
 {
 
-/**
- * @addtogroup services
- * @{
- */
+  /**
+   * @addtogroup services
+   * @{
+   */
 
-  class Runtime
-    : public Service
+  namespace Runtime
   {
-  public:
-
-    Runtime ()
-      {}
-
-    virtual ~Runtime ()
-      {}
+    void init (); // depends on the implementation
 
-    const std::string get_name () const
-      { return "runtime"; }
+    void run (); // depends on the implementation
 
-    const std::string get_description () const
-      { return "\tObject bringing in the runtime"; }
+    void quit (); // depends on the implementation
 
-    virtual void run () = 0;
+    void run_in_main (sigc::slot0<void> action,
+		      unsigned int seconds = 0); // depends on the implementation
 
-    virtual void quit () = 0;
-
-    virtual void run_in_main (sigc::slot0<void> action,
-			      unsigned int seconds = 0) = 0;
-    
-
-    void emit_signal_in_main (sigc::signal0<void> sign)
-      {
-        run_in_main (sigc::bind (sigc::ptr_fun (emit_signal_in_main_helper), sign));
-      }
+    inline void emit_signal_in_main (sigc::signal0<void> sign)
+    {
+      run_in_main (sigc::bind (sigc::ptr_fun (emit_signal_in_main_helper), sign));
+    }
 
     template<typename data_type>
     void emit_signal_in_main (sigc::signal1<void, data_type> sign,
                               data_type data)
-      {
-        run_in_main (sigc::bind (sigc::ptr_fun (emit_signal_in_main_helper1<data_type>), sign, data));
-      }
+    {
+      run_in_main (sigc::bind (sigc::ptr_fun (emit_signal_in_main_helper1<data_type>), sign, data));
+    }
   };
 
-/**
- * @}
- */
+  /**
+   * @}
+   */
 
 };
 
diff --git a/lib/engine/videoinput/videoinput-core.cpp b/lib/engine/videoinput/videoinput-core.cpp
index 30a72b1..b9d3730 100644
--- a/lib/engine/videoinput/videoinput-core.cpp
+++ b/lib/engine/videoinput/videoinput-core.cpp
@@ -121,9 +121,8 @@ void VideoInputCore::VideoPreviewManager::Main ()
   }
 }
 
-VideoInputCore::VideoInputCore (Ekiga::Runtime & _runtime, VideoOutputCore& _videooutput_core)
-:  runtime (_runtime),
-   preview_manager(*this, _videooutput_core)
+VideoInputCore::VideoInputCore (VideoOutputCore& _videooutput_core)
+:  preview_manager(*this, _videooutput_core)
 {
   PWaitAndSignal m_var(core_mutex);
   PWaitAndSignal m_set(settings_mutex);
diff --git a/lib/engine/videoinput/videoinput-core.h b/lib/engine/videoinput/videoinput-core.h
index 0c83ed5..ab15e54 100644
--- a/lib/engine/videoinput/videoinput-core.h
+++ b/lib/engine/videoinput/videoinput-core.h
@@ -104,7 +104,7 @@ namespace Ekiga
        * @param _runtime reference to Ekiga runtime.
        * @param _videooutput_core reference ot the video output core.
        */
-      VideoInputCore (Ekiga::Runtime & _runtime, VideoOutputCore& _videooutput_core);
+      VideoInputCore (VideoOutputCore& _videooutput_core);
 
       /** The destructor
        */
@@ -419,8 +419,6 @@ private:
 private:
       std::set<VideoInputManager *> managers;
 
-      Ekiga::Runtime & runtime;
-
       VideoDeviceConfig       preview_config;
       VideoDeviceConfig       stream_config;
 
diff --git a/src/ekiga.cpp b/src/ekiga.cpp
index 82f800a..6f4b1b4 100644
--- a/src/ekiga.cpp
+++ b/src/ekiga.cpp
@@ -235,8 +235,9 @@ GnomeMeeting::InitEngine (int argc,
 {
   PWaitAndSignal m(ep_var_mutex);
 
-  Ekiga::Runtime *runtime = new Ekiga::GlibRuntime;
-  engine_init (argc, argv, runtime);
+  Ekiga::Runtime::init ();
+
+  engine_init (argc, argv);
 }
 
 void
@@ -245,4 +246,6 @@ GnomeMeeting::StopEngine ()
   PWaitAndSignal m(ep_var_mutex);
 
   engine_stop ();
+
+  Ekiga::Runtime::quit ();
 }
diff --git a/src/ekiga.h b/src/ekiga.h
index c4f17ba..e81fe28 100644
--- a/src/ekiga.h
+++ b/src/ekiga.h
@@ -44,7 +44,7 @@
 #include "common.h"
 
 #include "services.h"
-#include "runtime-glib.h"
+#include "runtime.h"
 
 #include "statusicon.h"
 



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