[ekiga/ds-opal-refactoring: 3/3] Opal: Started a big refactoring.



commit 322a0aa66437c1b6b4154fe7ebafd35e56760f5e
Author: Damien Sandras <dsandras seconix com>
Date:   Sun Mar 15 17:49:01 2015 +0100

    Opal: Started a big refactoring.
    
    This commit is still incomplete. Some features do not work yet, and some
    methods are not where they should be.
    
    The idea behind this refactoring is that we now have a separate OPAL
    process, with separate H.323 and SIP endpoints. They are running in
    standalone mode.
    
    However, the engine requires CallManagers in order to place calls. Those
    engine SIP and H.323 CallManagers will use the relevant OPAL process to
    implement actions.
    
    The reason behind this change is that both parts (the engine and the
    opal part) manage memory differently. Moreover, our code was becoming
    really big with a single endpoint implementing various parts of the
    engine. Things are now more modular and easier to maintain and
    understand.
    
    The CallProtocolManager was removed as part of this change!

 lib/Makefile.am                                    |   31 +-
 lib/engine/components/opal/h323-call-manager.cpp   |  173 ++++
 lib/engine/components/opal/h323-call-manager.h     |   92 ++
 lib/engine/components/opal/opal-call-manager.cpp   | 1006 +++-----------------
 lib/engine/components/opal/opal-call-manager.h     |  207 +----
 lib/engine/components/opal/opal-call.cpp           |    9 +-
 lib/engine/components/opal/opal-call.h             |    4 +-
 lib/engine/components/opal/opal-main.cpp           |   37 +-
 lib/engine/components/opal/opal-main.h             |    7 +-
 .../opal/{ => process}/h323-endpoint.cpp           |   81 +--
 .../components/opal/{ => process}/h323-endpoint.h  |   24 +-
 .../components/opal/process/opal-endpoint.cpp      |  794 +++++++++++++++
 lib/engine/components/opal/process/opal-endpoint.h |  203 ++++
 .../components/opal/{ => process}/opal-process.cpp |   54 +-
 .../components/opal/{ => process}/opal-process.h   |   10 +-
 .../opal/{ => process}/pcss-endpoint.cpp           |   10 +-
 .../components/opal/{ => process}/pcss-endpoint.h  |    6 +-
 .../components/opal/{ => process}/sip-endpoint.cpp |   77 +--
 .../components/opal/{ => process}/sip-endpoint.h   |   27 +-
 lib/engine/components/opal/sip-call-manager.cpp    |  136 +++
 lib/engine/components/opal/sip-call-manager.h      |   90 ++
 lib/engine/protocol/call-core.cpp                  |   11 +-
 lib/engine/protocol/call-core.h                    |   12 +-
 lib/engine/protocol/call-manager.cpp               |  121 ---
 lib/engine/protocol/call-manager.h                 |   67 +-
 lib/engine/protocol/call-protocol-manager.h        |  140 ---
 lib/settings/ekiga-settings.h                      |   14 +
 plugins/avahi/avahi-publisher.cpp                  |   12 +-
 28 files changed, 1861 insertions(+), 1594 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index b96b3d6..8fcbf5f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -43,6 +43,7 @@ AM_CPPFLAGS = \
        -I$(top_srcdir)/lib/engine/components/null-audioinput \
        -I$(top_srcdir)/lib/engine/components/null-audiooutput \
        -I$(top_srcdir)/lib/engine/components/opal \
+       -I$(top_srcdir)/lib/engine/components/opal/process \
        -I$(top_srcdir)/lib/engine/components/ptlib
 
 AM_CFLAGS = \
@@ -271,10 +272,8 @@ libekiga_la_SOURCES += \
 libekiga_la_SOURCES += \
        engine/protocol/call-core.h \
        engine/protocol/call-manager.h \
-       engine/protocol/call-manager.cpp \
        engine/protocol/call.h \
        engine/protocol/call-core.cpp \
-       engine/protocol/call-protocol-manager.h \
        engine/protocol/codec-description.h \
        engine/protocol/codec-description.cpp
 
@@ -412,8 +411,8 @@ libekiga_la_LDFLAGS += $(PTLIB_LIBS)
 libekiga_la_SOURCES += \
        engine/components/opal/opal-call-manager.h \
        engine/components/opal/opal-call-manager.cpp \
-       engine/components/opal/pcss-endpoint.h \
-       engine/components/opal/pcss-endpoint.cpp \
+       engine/components/opal/sip-call-manager.h \
+       engine/components/opal/sip-call-manager.cpp \
        engine/components/opal/opal-account.h \
        engine/components/opal/opal-account.cpp \
        engine/components/opal/opal-bank.h \
@@ -433,14 +432,24 @@ libekiga_la_SOURCES += \
        engine/components/opal/opal-plugins-hook.h \
        engine/components/opal/opal-plugins-hook.cpp \
        engine/components/opal/opal-presentity.h \
-       engine/components/opal/opal-presentity.cpp \
-       engine/components/opal/opal-process.h \
-       engine/components/opal/opal-process.cpp
+        engine/components/opal/opal-presentity.cpp
+
+libekiga_la_SOURCES += \
+       engine/components/opal/process/pcss-endpoint.h \
+       engine/components/opal/process/pcss-endpoint.cpp \
+       engine/components/opal/process/opal-process.h \
+       engine/components/opal/process/opal-process.cpp \
+       engine/components/opal/process/opal-endpoint.h \
+       engine/components/opal/process/opal-endpoint.cpp \
+       engine/components/opal/process/sip-endpoint.h \
+       engine/components/opal/process/sip-endpoint.cpp
 
 if HAVE_H323
 libekiga_la_SOURCES += \
-       engine/components/opal/h323-endpoint.h \
-       engine/components/opal/h323-endpoint.cpp
+       engine/components/opal/h323-call-manager.h \
+       engine/components/opal/h323-call-manager.cpp \
+       engine/components/opal/process/h323-endpoint.h \
+       engine/components/opal/process/h323-endpoint.cpp
 endif
 
 libekiga_la_SOURCES += \
@@ -449,9 +458,7 @@ libekiga_la_SOURCES += \
        engine/components/opal/sip-conversation.h \
        engine/components/opal/sip-conversation.cpp \
        engine/components/opal/sip-dialect.h \
-       engine/components/opal/sip-dialect.cpp \
-       engine/components/opal/sip-endpoint.h \
-       engine/components/opal/sip-endpoint.cpp
+       engine/components/opal/sip-dialect.cpp
 
 libekiga_la_LDFLAGS += $(OPAL_LIBS)
 
diff --git a/lib/engine/components/opal/h323-call-manager.cpp 
b/lib/engine/components/opal/h323-call-manager.cpp
new file mode 100644
index 0000000..35f3c30
--- /dev/null
+++ b/lib/engine/components/opal/h323-call-manager.cpp
@@ -0,0 +1,173 @@
+
+/* 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.
+ */
+
+
+/*
+ *                         h323-call-manager.cpp  -  description
+ *                         -------------------------------------
+ *   begin                : Sun Mar 15 2014
+ *   authors              : Damien Sandras
+ *   description          : This file contains the engine H.323 CallManager.
+ *
+ */
+
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include "h323-call-manager.h"
+#include "h323-endpoint.h"
+
+
+/* The engine class */
+Opal::H323::CallManager::CallManager (Ekiga::ServiceCore& _core,
+                                      Opal::EndPoint& _endpoint) : Opal::CallManager (_core, _endpoint), 
protocol_name ("h323")
+{
+  /* Setup things */
+  Ekiga::SettingsCallback setup_cb = boost::bind (&Opal::H323::CallManager::setup, this, _1);
+  h323_settings = Ekiga::SettingsPtr (new Ekiga::Settings (H323_SCHEMA, setup_cb));
+  video_codecs_settings = Ekiga::SettingsPtr (new Ekiga::Settings (VIDEO_CODECS_SCHEMA));
+
+  setup ();
+  std::cout << "hey: Created Opal::H323::CallManager" << std::endl;
+}
+
+
+Opal::H323::CallManager::~CallManager ()
+{
+  std::cout << "hey: Destroyed Opal::H323::CallManager" << std::endl;
+}
+
+
+/* URIActionProvider Methods */
+void Opal::H323::CallManager::pull_actions (Ekiga::Actor & actor,
+                                            G_GNUC_UNUSED const std::string & name,
+                                            const std::string & uri)
+{
+  if (is_supported_uri (uri)) {
+    add_action (actor, Ekiga::ActionPtr (new Ekiga::Action ("call", _("Call"), boost::bind 
(&Opal::H323::CallManager::dial, this, uri))));
+  }
+}
+
+
+const std::string & Opal::H323::CallManager::get_protocol_name () const
+{
+  return protocol_name;
+}
+
+
+const Ekiga::CallManager::InterfaceList Opal::H323::CallManager::get_interfaces () const
+{
+  Ekiga::CallManager::InterfaceList ilist;
+
+  boost::shared_ptr<Opal::H323::EndPoint> h323_endpoint = endpoint.get_h323_endpoint ();
+  if (!h323_endpoint)
+    return ilist;
+
+  OpalListenerList listeners = h323_endpoint->GetListeners ();
+  for (int i = 0 ; i < listeners.GetSize () ; i++) {
+    Ekiga::CallManager::Interface iface;
+    PIPSocket::Address address;
+    WORD port;
+    PString proto_prefix = listeners[i].GetLocalAddress ().GetProtoPrefix ();
+    listeners[i].GetLocalAddress ().GetIpAndPort (address, port);
+
+    iface.voip_protocol = get_protocol_name ();
+    iface.id = "*";
+    iface.protocol = (const char*) proto_prefix.Left (proto_prefix.GetLength () - 1); // Strip final $ 
delimiter
+    iface.port = (unsigned int) port;
+
+    ilist.push_back (iface);
+  }
+
+  return ilist;
+}
+
+
+void Opal::H323::CallManager::setup (const std::string & setting)
+{
+  std::cout << "In Opal::H323::EndPoint::setup " << std::endl;
+  boost::shared_ptr<Opal::H323::EndPoint> h323_endpoint = endpoint.get_h323_endpoint ();
+  if (h323_endpoint) {
+
+    if (setting.empty () || setting == "listen-port") {
+
+      h323_endpoint->set_listen_port (h323_settings->get_int ("listen-port"));
+    }
+    if (setting.empty () || setting == "maximum-video-tx-bitrate") {
+
+      int maximum_video_tx_bitrate = video_codecs_settings->get_int ("maximum-video-tx-bitrate");
+      // maximum_video_tx_bitrate is the max video bitrate specified by the user
+      // add to it 10% (approx.) accounting for audio,
+      // and multiply it by 10 as needed by SetInitialBandwidth
+      h323_endpoint->set_initial_bandwidth (maximum_video_tx_bitrate * 11);
+    }
+    if (setting.empty () || setting == "enable-h245-tunneling") {
+
+      h323_endpoint->DisableH245Tunneling (!h323_settings->get_bool ("enable-h245-tunneling"));
+      PTRACE (4, "Opal::H323::EndPoint\tH.245 Tunneling: " << h323_settings->get_bool 
("enable-h245-tunneling"));
+    }
+    if (setting.empty () || setting == "enable-early-h245") {
+
+      h323_endpoint->DisableH245inSetup (!h323_settings->get_bool ("enable-early-h245"));
+      PTRACE (4, "Opal::H323::EndPoint\tEarly H.245: " << h323_settings->get_bool ("enable-early-h245"));
+    }
+    if (setting.empty () || setting == "enable-fast-connect") {
+
+      h323_endpoint->DisableFastStart (!h323_settings->get_bool ("enable-fast-connect"));
+      PTRACE (4, "Opal::H323::EndPoint\tFast Connect: " << h323_settings->get_bool ("enable-fast-connect"));
+    }
+    if (setting.empty () || setting == "dtmf-mode") {
+
+      h323_endpoint->set_dtmf_mode (h323_settings->get_enum ("dtmf-mode"));
+    }
+    if (setting.empty () || setting == "forward-host") {
+
+      h323_endpoint->set_forward_uri (h323_settings->get_string ("forward-host"));
+    }
+    if (setting.empty () || setting == "video-role") {
+
+      /*
+         CallManager::VideoOptions options;
+         endpoint.get_video_options (options);
+         options.extended_video_roles = h323_settings->get_enum ("video-role");
+         endpoint.set_video_options (options);
+       */
+
+      std::cout << "FIXME" << std::endl;
+    }
+    if (setting.empty () || setting == "enable-h239") {
+      h323_endpoint->SetDefaultH239Control(h323_settings->get_bool ("enable-h239"));
+      PTRACE (4, "Opal::H323::EndPoint\tH.239 Control: " << h323_settings->get_bool ("enable-h239"));
+    }
+
+  }
+
+  // We do not call the parent setup () method as it is also handled
+  // by our Opal::Sip::CallManager
+}
diff --git a/lib/engine/components/opal/h323-call-manager.h b/lib/engine/components/opal/h323-call-manager.h
new file mode 100644
index 0000000..fb852e6
--- /dev/null
+++ b/lib/engine/components/opal/h323-call-manager.h
@@ -0,0 +1,92 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2015 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.
+ */
+
+
+/*
+ *                         h323-call-manager.h  -  description
+ *                         ----------------------------------
+ *   begin                : Sun Mar 15 2014
+ *   authors              : Damien Sandras
+ *   description          : This file contains the engine H.323 CallManager.
+ *
+ */
+
+
+#ifndef __H323_CALL_MANAGER_H_
+#define __H323_CALL_MANAGER_H_
+
+#include "opal-call-manager.h"
+#include "opal-endpoint.h"
+
+#include "ekiga-settings.h"
+
+namespace Opal {
+
+  namespace H323 {
+
+    /* This is the engine CallManager implementation.
+     * It uses the Opal::Manager object to implement the engine
+     * CallManager interface.
+     */
+    class CallManager :
+        public Opal::CallManager,
+        public Ekiga::URIActionProvider
+    {
+  public:
+      CallManager (Ekiga::ServiceCore& core,
+                   Opal::EndPoint& endpoint);
+      ~CallManager ();
+
+      /* URIActionProvider Methods */
+      void pull_actions (Ekiga::Actor & actor,
+                         const std::string & name,
+                         const std::string & uri);
+
+      /* CallManager methods we implement */
+      const std::string & get_protocol_name () const;
+
+      const Ekiga::CallManager::InterfaceList get_interfaces () const;
+
+      /*
+         void set_dtmf_mode (unsigned mode);
+         unsigned get_dtmf_mode ();
+         bool set_listen_port (unsigned port);
+         const InterfaceList & get_interfaces () const;
+       */
+
+      /* Set up endpoint: all options or a specific setting */
+      void setup (const std::string & setting = "");
+
+  private:
+      Ekiga::SettingsPtr h323_settings;
+      Ekiga::SettingsPtr video_codecs_settings;
+
+      std::string protocol_name;
+    };
+  };
+};
+#endif
diff --git a/lib/engine/components/opal/opal-call-manager.cpp 
b/lib/engine/components/opal/opal-call-manager.cpp
index 4d62376..708eb65 100644
--- a/lib/engine/components/opal/opal-call-manager.cpp
+++ b/lib/engine/components/opal/opal-call-manager.cpp
@@ -27,977 +27,232 @@
 
 /*
  *                         opal-call-manager.cpp  -  description
- *                         ---------------------------
+ *                         -------------------------------------
  *   begin                : Sat Dec 23 2000
- *   copyright            : (C) 2000-2006 by Damien Sandras
- *   description          : This file contains the Endpoint class.
+ *   authors              : Damien Sandras
+ *   description          : This file contains the engine CallManager.
  *
  */
 
-#include <algorithm>
+#include "config.h"
+
 #include <glib/gi18n.h>
 
 #include "opal-call-manager.h"
-
-#include "pcss-endpoint.h"
+#include "null-deleter.h"
 
 #include "call-core.h"
-#include "opal-codec-description.h"
-#include "videoinput-info.h"
-
-#include "call-manager.h"
-
-#include "sip-endpoint.h"
-#ifdef HAVE_H323
-#include "h323-endpoint.h"
-#endif
-
-#include <opal/transcoders.h>
-
-#include <stdlib.h>
-
-// opal manages its endpoints itself, so we must be wary
-struct null_deleter
-{
-  void operator()(void const *) const
-    { }
-};
 
 
-class StunDetector : public PThread
+/* The engine class */
+Opal::CallManager::CallManager (Ekiga::ServiceCore& _core,
+                                Opal::EndPoint& _endpoint) : core(_core), endpoint(_endpoint)
 {
-  PCLASSINFO(StunDetector, PThread);
-
-public:
-
-  StunDetector (const std::string & _server,
-                Opal::CallManager& _manager,
-                GAsyncQueue* _queue)
-    : PThread (1000, AutoDeleteThread),
-    server (_server),
-    manager (_manager),
-    queue (_queue)
-  {
-    PTRACE (3, "Ekiga\tStarted STUN detector");
-    g_async_queue_ref (queue);
-    this->Resume ();
-  };
-
-  ~StunDetector ()
-    {
-      g_async_queue_unref (queue);
-      PTRACE (3, "Ekiga\tStopped STUN detector");
-    }
-
-  void Main ()
-    {
-      PSTUNClient::NatTypes result = manager.SetSTUNServer (server);
-
-      g_async_queue_push (queue, GUINT_TO_POINTER ((guint)result + 1));
-    };
-
-private:
-  const std::string server;
-  Opal::CallManager & manager;
-  GAsyncQueue* queue;
-};
-
-
-using namespace Opal;
-
+  endpoint.created_call.connect (boost::bind (&Opal::CallManager::on_created_call, this, _1));
 
-/* The class */
-CallManager::CallManager (Ekiga::ServiceCore& core)
-{
-  call_core = core.get<Ekiga::CallCore> ("call-core");
-  notification_core = core.get<Ekiga::NotificationCore> ("notification-core");
-
-  stun_thread = 0;
-
-  /* Initialise the endpoint parameters */
-#if P_HAS_IPV6
-  char * ekiga_ipv6 = getenv("EKIGA_IPV6");
-  // use IPv6 instead of IPv4 if EKIGA_IPV6 env var is set
-  if (ekiga_ipv6 && PIPSocket::IsIpAddressFamilyV6Supported())
-    PIPSocket::SetDefaultIpAddressFamilyV6();
-  else
-    PIPSocket::SetDefaultIpAddressFamilyV4();
-#else
-  PIPSocket::SetDefaultIpAddressFamilyV4();
-#endif
-  PIPSocket::SetSuppressCanonicalName (true);  // avoid long delays
-  SetAutoStartTransmitVideo (true);
-  SetAutoStartReceiveVideo (true);
-  SetUDPPorts (5000, 5100);
-  SetTCPPorts (30000, 30100);
-  SetRtpIpPorts (5000, 5100);
-
-  pcssEP = NULL;
-
-  forward_on_no_answer = false;
-  forward_on_busy = false;
-  unconditional_forward = false;
-  stun_enabled = false;
-  auto_answer = false;
-
-  // Create video devices
-  PVideoDevice::OpenArgs video = GetVideoOutputDevice();
-  video.deviceName = "EKIGAOUT";
-  SetVideoOutputDevice (video);
-
-  video = GetVideoOutputDevice();
-  video.deviceName = "EKIGAIN";
-  SetVideoPreviewDevice (video);
-
-  video = GetVideoInputDevice();
-  video.deviceName = "EKIGA";
-  SetVideoInputDevice (video);
-
-  // Media formats
-  SetMediaFormatOrder (PStringArray ());
-  SetMediaFormatMask (PStringArray ());
-
-  // used to communicate with the StunDetector
-  queue = g_async_queue_new ();
-
-  PInterfaceMonitor::GetInstance().SetRefreshInterval (15000);
-
-  nat_settings =
-    boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (NAT_SCHEMA));
-  nat_settings->changed.connect (boost::bind (&CallManager::setup, this, _1));
-
-  audio_codecs_settings =
-    boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (AUDIO_CODECS_SCHEMA));
-  audio_codecs_settings->changed.connect (boost::bind (&CallManager::setup, this, _1));
-
-  video_codecs_settings =
-    boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (VIDEO_CODECS_SCHEMA));
-  video_codecs_settings->changed.connect (boost::bind (&CallManager::setup, this, _1));
-
-  video_devices_settings =
-    boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (VIDEO_DEVICES_SCHEMA));
-  video_devices_settings->changed.connect (boost::bind (&CallManager::setup, this, _1));
-
-  ports_settings =
-    boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (PORTS_SCHEMA));
-  ports_settings->changed.connect (boost::bind (&CallManager::setup, this, _1));
-
-  protocols_settings =
-    boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (PROTOCOLS_SCHEMA));
-  protocols_settings->changed.connect (boost::bind (&CallManager::setup, this, _1));
-
-  call_options_settings =
-    boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (CALL_OPTIONS_SCHEMA));
-  call_options_settings->changed.connect (boost::bind (&CallManager::setup, this, _1));
-
-  call_forwarding_settings =
-    boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (CALL_FORWARDING_SCHEMA));
-  call_forwarding_settings->changed.connect (boost::bind (&CallManager::setup, this, _1));
-
-  personal_data_settings =
-    boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (PERSONAL_DATA_SCHEMA));
-  personal_data_settings->changed.connect (boost::bind (&CallManager::setup, this, _1));
-
-  /* ContactActor & PresenceCore registration */
-  // FIXME could move to CallCore
-  boost::shared_ptr<Ekiga::ContactCore> contact_core = core.get< Ekiga::ContactCore > ("contact-core");
-  contact_core->push_back (Ekiga::URIActionProviderPtr (this));
-
-  boost::shared_ptr<Ekiga::PresenceCore> presence_core = core.get< Ekiga::PresenceCore > ("presence-core");
-  presence_core->push_back (Ekiga::URIActionProviderPtr (this));
-
-  // Create endpoints / CallProtocolManagers
-  pcssEP = new GMPCSSEndpoint (*this, core);
-  pcssEP->SetSoundChannelPlayDevice("EKIGA");
-  pcssEP->SetSoundChannelRecordDevice("EKIGA");
-
-  sip_endpoint = boost::shared_ptr<Sip::EndPoint> (new Sip::EndPoint (*this, core), null_deleter ());
-  add_protocol_manager (sip_endpoint);
-
-#ifdef HAVE_H323
-  h323_endpoint= boost::shared_ptr<H323::EndPoint>(new H323::EndPoint (*this, core), null_deleter ());
-  add_protocol_manager (h323_endpoint);
-#endif
+  /* Setup things */
+  Ekiga::SettingsCallback setup_cb = boost::bind (&Opal::CallManager::setup, this, _1);
+  nat_settings = Ekiga::SettingsPtr (new Ekiga::Settings (NAT_SCHEMA, setup_cb));
+  audio_codecs_settings = Ekiga::SettingsPtr (new Ekiga::Settings (AUDIO_CODECS_SCHEMA, setup_cb));
+  video_codecs_settings = Ekiga::SettingsPtr (new Ekiga::Settings (VIDEO_CODECS_SCHEMA, setup_cb));
+  video_devices_settings = Ekiga::SettingsPtr (new Ekiga::Settings (VIDEO_DEVICES_SCHEMA, setup_cb));
+  ports_settings = Ekiga::SettingsPtr (new Ekiga::Settings (PORTS_SCHEMA, setup_cb));
+  protocols_settings = Ekiga::SettingsPtr (new Ekiga::Settings (PROTOCOLS_SCHEMA, setup_cb));
+  call_options_settings = Ekiga::SettingsPtr (new Ekiga::Settings (CALL_OPTIONS_SCHEMA, setup_cb));
+  call_forwarding_settings = Ekiga::SettingsPtr (new Ekiga::Settings (CALL_FORWARDING_SCHEMA, setup_cb));
+  personal_data_settings = Ekiga::SettingsPtr (new Ekiga::Settings (PERSONAL_DATA_SCHEMA, setup_cb));
 }
 
 
-CallManager::~CallManager ()
+Opal::CallManager::~CallManager ()
 {
-  remove_protocol_manager (sip_endpoint);
-#ifdef HAVE_H323
-  remove_protocol_manager (h323_endpoint);
-#endif
-  if (stun_thread)
-    stun_thread->WaitForTermination ();
-  ClearAllCalls (OpalConnection::EndedByLocalUser, true);
-
-  g_async_queue_unref (queue);
+  std::cout << "hey" << std::endl;
 }
 
 
-void CallManager::pull_actions (Ekiga::Actor & actor,
-                                const std::string & name,
-                                const std::string & uri)
+/* CallManager Methods */
+bool Opal::CallManager::dial (const std::string & uri)
 {
-  if (is_supported_uri (uri)) {
-
-    add_action (actor,
-                Ekiga::ActionPtr (new Ekiga::Action ("call", _("Call"), boost::bind (&CallManager::dial, 
this, uri))));
-  }
+  return endpoint.dial (uri);
 }
 
 
-void CallManager::set_display_name (const std::string & name)
+void Opal::CallManager::hang_up ()
 {
-  display_name = name;
-
-  SetDefaultDisplayName (display_name);
+  endpoint.ClearAllCalls (OpalConnection::EndedByLocalUser, FALSE);
 }
 
 
-const std::string & CallManager::get_display_name () const
+bool Opal::CallManager::is_supported_uri (const std::string & uri)
 {
-  return display_name;
+  return endpoint.is_supported_uri (uri);
 }
 
 
-void CallManager::set_echo_cancellation (bool enabled)
+void Opal::CallManager::set_codecs (Ekiga::CodecList & codecs)
 {
-  OpalEchoCanceler::Params ec;
-
-  // General settings
-  ec = GetEchoCancelParams ();
-  ec.m_enabled = enabled;
-  SetEchoCancelParams (ec);
-
-  // Adjust setting for all connections of all calls
-  for (PSafePtr<OpalCall> call = activeCalls;
-       call != NULL;
-       ++call) {
-
-    for (int i = 0;
-         i < 2;
-         i++) {
-
-      PSafePtr<OpalConnection> connection = call->GetConnection (i);
-      if (connection) {
-
-        OpalEchoCanceler *echo_canceler = connection->GetEchoCanceler ();
-
-        if (echo_canceler)
-          echo_canceler->SetParameters (ec);
-      }
-    }
-  }
-
-  PTRACE (4, "Opal::CallManager\tEcho Cancellation: " << enabled);
+  endpoint.set_codecs (codecs);
 }
 
 
-bool CallManager::get_echo_cancellation () const
+const Ekiga::CodecList& Opal::CallManager::get_codecs () const
 {
-  OpalEchoCanceler::Params ec = GetEchoCancelParams ();
-
-  return ec.m_enabled;
-}
-
-
-void CallManager::set_maximum_jitter (unsigned max_val)
-{
-  unsigned val = std::min (std::max (max_val, (unsigned) 20), (unsigned) 1000);
-
-  SetAudioJitterDelay (20, val);
-
-  // Adjust setting for all sessions of all connections of all calls
-  for (PSafePtr<OpalCall> call = activeCalls;
-       call != NULL;
-       ++call) {
-
-    for (int i = 0;
-         i < 2;
-         i++) {
-
-      PSafePtr<OpalRTPConnection> connection = PSafePtrCast<OpalConnection, OpalRTPConnection> 
(call->GetConnection (i));
-      if (connection) {
-
-        OpalMediaStreamPtr stream = connection->GetMediaStream (OpalMediaType::Audio (), false);
-        if (stream != NULL) {
-
-          OpalRTPSession *session = (OpalRTPSession*)connection->GetMediaSession (stream->GetSessionID ());
-          if (session != NULL) {
-
-            unsigned units = session->GetJitterTimeUnits ();
-            OpalJitterBuffer::Init init;
-            init.m_minJitterDelay = 20 * units;
-            init.m_maxJitterDelay = val * units;
-            init.m_timeUnits = units;
-            session->SetJitterBufferSize (init);
-          }
-        }
-      }
-    }
-  }
-
-  PTRACE (4, "Opal::CallManager\tSet Maximum Jitter to " << val);
+  return endpoint.get_codecs ();
 }
 
 
-unsigned CallManager::get_maximum_jitter () const
+void Opal::CallManager::set_display_name (const std::string & name)
 {
-  return GetMaxAudioJitterDelay ();
-}
-
-
-void CallManager::set_silence_detection (bool enabled)
-{
-  OpalSilenceDetector::Params sd;
-
-  // General settings
-  sd = GetSilenceDetectParams ();
-  if (enabled)
-    sd.m_mode = OpalSilenceDetector::AdaptiveSilenceDetection;
-  else
-    sd.m_mode = OpalSilenceDetector::NoSilenceDetection;
-  SetSilenceDetectParams (sd);
-
-  // Adjust setting for all connections of all calls
-  for (PSafePtr<OpalCall> call = activeCalls;
-       call != NULL;
-       ++call) {
-
-    for (int i = 0;
-         i < 2;
-         i++) {
-
-      PSafePtr<OpalConnection> connection = call->GetConnection (i);
-      if (connection) {
-
-        OpalSilenceDetector *silence_detector = connection->GetSilenceDetector ();
-
-        if (silence_detector)
-          silence_detector->SetParameters (sd);
-      }
-    }
-  }
-
-  PTRACE (4, "Opal::CallManager\tSilence Detection: " << enabled);
-}
-
-
-bool CallManager::get_silence_detection () const
-{
-  OpalSilenceDetector::Params sd;
-
-  sd = GetSilenceDetectParams ();
-
-  return (sd.m_mode != OpalSilenceDetector::NoSilenceDetection);
-}
-
-
-void CallManager::set_reject_delay (unsigned delay)
-{
-  reject_delay = std::max ((unsigned) 5, delay);
-}
-
-
-unsigned CallManager::get_reject_delay () const
-{
-  return reject_delay;
-}
-
-
-void CallManager::set_auto_answer (bool enabled)
-{
-  auto_answer = enabled;
-}
-
-
-bool CallManager::get_auto_answer (void) const
-{
-  return auto_answer;
-}
-
-
-const Ekiga::CodecList & CallManager::get_codecs () const
-{
-  return codecs;
-}
-
-
-void CallManager::set_codecs (Ekiga::CodecList & _codecs)
-{
-  PStringArray mask, order;
-  OpalMediaFormatList formats;
-  OpalMediaFormat::GetAllRegisteredMediaFormats (formats);
-
-  codecs = _codecs;
-
-  for (Ekiga::CodecList::const_iterator iter = codecs.begin ();
-       iter != codecs.end ();
-       iter++)
-    if ((*iter).active)
-      order += (*iter).name;
-
-  formats.Remove (order);
-
-  for (int i = 0 ; i < formats.GetSize () ; i++)
-    mask += (const char *) formats[i];
-
-  SetMediaFormatOrder (order);
-  SetMediaFormatMask (mask);
-  PTRACE (4, "Ekiga\tSet codecs: " << setfill(';') << GetMediaFormatOrder ());
-  PTRACE (4, "Ekiga\tDisabled codecs: " << setfill(';') << GetMediaFormatMask ());
-}
-
-
-void CallManager::set_forward_on_no_answer (bool enabled)
-{
-  forward_on_no_answer = enabled;
-}
-
-bool CallManager::get_forward_on_no_answer ()
-{
-  return forward_on_no_answer;
-}
-
-void CallManager::set_forward_on_busy (bool enabled)
-{
-  forward_on_busy = enabled;
-}
-
-bool CallManager::get_forward_on_busy ()
-{
-  return forward_on_busy;
-}
-
-void CallManager::set_unconditional_forward (bool enabled)
-{
-  unconditional_forward = enabled;
-}
-
-bool CallManager::get_unconditional_forward ()
-{
-  return unconditional_forward;
-}
-
-void CallManager::set_udp_ports (unsigned min_port,
-                                 unsigned max_port)
-{
-  if (min_port < max_port) {
-
-    SetUDPPorts (min_port, max_port);
-    SetRtpIpPorts (min_port, max_port);
-  }
-}
-
-
-void CallManager::get_udp_ports (unsigned & min_port,
-                                 unsigned & max_port) const
-{
-  min_port = GetUDPPortBase ();
-  max_port = GetUDPPortMax ();
-}
-
-void CallManager::set_tcp_ports (unsigned min_port,
-                                 unsigned max_port)
-{
-  if (min_port < max_port)
-    SetTCPPorts (min_port, max_port);
-}
-
-
-void CallManager::get_tcp_ports (unsigned & min_port,
-                                 unsigned & max_port) const
-{
-  min_port = GetTCPPortBase ();
-  max_port = GetTCPPortMax ();
+  display_name = name;
+  endpoint.SetDefaultDisplayName (name);
 }
 
-void
-CallManager::get_rtp_tos (unsigned &tos) const
-{
-  tos = GetMediaTypeOfService ();
-}
 
-void
-CallManager::set_rtp_tos (unsigned tos)
+const std::string & Opal::CallManager::get_display_name () const
 {
-  SetMediaTypeOfService (tos);
-}
-
-void CallManager::set_stun_server (const std::string & server)
-{
-  if (server.empty ())
-    stun_server = "stun.ekiga.net";
-
-  stun_server = server;
-  PTRACE (4, "Opal::CallManager\tSet STUN Server to " << stun_server);
+  return display_name;
 }
 
 
-void CallManager::set_stun_enabled (bool enabled)
+void Opal::CallManager::set_echo_cancellation (bool enabled)
 {
-  stun_enabled = enabled;
-  if (stun_enabled && !stun_thread) {
-
-    // Ready
-    stun_thread = new StunDetector (stun_server, *this, queue);
-    patience = 20;
-    Ekiga::Runtime::run_in_main (boost::bind (&CallManager::HandleSTUNResult, this), 1);
-  }
-  else {
-    ready ();
-  }
-
-  PTRACE (4, "Opal::CallManager\tSTUN Detection: " << enabled);
+  endpoint.SetEchoCancellation (enabled);
 }
 
 
-bool CallManager::dial (const std::string & uri)
+bool Opal::CallManager::get_echo_cancellation () const
 {
-  for (Ekiga::CallManager::iterator iter = Ekiga::CallManager::begin ();
-       iter != Ekiga::CallManager::end ();
-       iter++)
-    if ((*iter)->dial (uri))
-      return true;
-
-  return false;
+  return endpoint.GetEchoCancellation ();
 }
 
 
-void CallManager::hang_up ()
+void Opal::CallManager::set_silence_detection (bool enabled)
 {
-  ClearAllCalls (OpalConnection::EndedByLocalUser, true);
+  endpoint.SetSilenceDetection (enabled);
 }
 
 
-bool CallManager::is_supported_uri (const std::string & uri)
+bool Opal::CallManager::get_silence_detection () const
 {
-  for (Ekiga::CallManager::iterator iter = Ekiga::CallManager::begin ();
-       iter != Ekiga::CallManager::end ();
-       iter++)
-    if ((*iter)->is_supported_uri (uri))
-      return true;
-
-  return false;
+  return endpoint.GetSilenceDetection ();
 }
 
 
-void CallManager::set_video_options (const CallManager::VideoOptions & options)
+void Opal::CallManager::set_maximum_jitter (unsigned max_val)
 {
-  OpalMediaFormatList media_formats_list;
-  OpalMediaFormat::GetAllRegisteredMediaFormats (media_formats_list);
-
-  int maximum_frame_rate = std::min (std::max ((signed) options.maximum_frame_rate, 1), 30);
-  int maximum_bitrate = (options.maximum_bitrate > 0 ? options.maximum_bitrate : 16384);
-  int maximum_transmitted_bitrate = (options.maximum_transmitted_bitrate > 0 ? 
options.maximum_transmitted_bitrate : 256);
-  int temporal_spatial_tradeoff = (options.temporal_spatial_tradeoff > 0 ? options.temporal_spatial_tradeoff 
: 12);
-  // Configure all mediaOptions of all Video MediaFormats
-  for (int i = 0 ; i < media_formats_list.GetSize () ; i++) {
-
-    OpalMediaFormat media_format = media_formats_list [i];
-    if (media_format.GetMediaType() == OpalMediaType::Video ()) {
-
-      media_format.SetOptionInteger (OpalVideoFormat::FrameWidthOption (), Ekiga::VideoSizes 
[options.size].width);
-      media_format.SetOptionInteger (OpalVideoFormat::FrameHeightOption (), Ekiga::VideoSizes 
[options.size].height);
-      media_format.SetOptionInteger (OpalVideoFormat::FrameTimeOption (), (int) (media_format.GetClockRate 
() / maximum_frame_rate));
-      media_format.SetOptionInteger (OpalVideoFormat::MaxBitRateOption (), maximum_bitrate * 1000);
-      media_format.SetOptionInteger (OpalVideoFormat::TargetBitRateOption (), maximum_transmitted_bitrate * 
1000);
-      media_format.SetOptionInteger (OpalVideoFormat::MinRxFrameWidthOption(), GM_QSIF_WIDTH);
-      media_format.SetOptionInteger (OpalVideoFormat::MinRxFrameHeightOption(), GM_QSIF_HEIGHT);
-      media_format.SetOptionInteger (OpalVideoFormat::MaxRxFrameWidthOption(), GM_1080P_WIDTH);
-      media_format.SetOptionInteger (OpalVideoFormat::MaxRxFrameHeightOption(), GM_1080P_HEIGHT);
-      media_format.AddOption(new OpalMediaOptionUnsigned (OpalVideoFormat::TemporalSpatialTradeOffOption (), 
true, OpalMediaOption::NoMerge, temporal_spatial_tradeoff));
-      media_format.SetOptionInteger (OpalVideoFormat::TemporalSpatialTradeOffOption(), 
temporal_spatial_tradeoff);
-
-      if (media_format.GetName() != "YUV420P" &&
-          media_format.GetName() != "RGB32" &&
-          media_format.GetName() != "RGB24")
-        media_format.SetOptionInteger (OpalVideoFormat::RateControlPeriodOption(), 300);
-
-      switch (options.extended_video_roles) {
-      case 0 :
-        media_format.SetOptionInteger(OpalVideoFormat::ContentRoleMaskOption(), 0);
-        break;
-
-      case 2 : // Force Presentation (slides)
-        media_format.SetOptionInteger(OpalVideoFormat::ContentRoleMaskOption(),
-                                      OpalVideoFormat::ContentRoleBit(OpalVideoFormat::ePresentation));
-        break;
-
-      case 3 : // Force Live (main)
-        media_format.SetOptionInteger(OpalVideoFormat::ContentRoleMaskOption(),
-                                      OpalVideoFormat::ContentRoleBit(OpalVideoFormat::eMainRole));
-        break;
-
-        default :
-          break;
-      }
-
-      OpalMediaFormat::SetRegisteredMediaFormat(media_format);
-    }
-  }
-
-  // Adjust setting for all sessions of all connections of all calls
-  for (PSafePtr<OpalCall> call = activeCalls;
-       call != NULL;
-       ++call) {
-
-    for (int i = 0;
-         i < 2;
-         i++) {
-
-      PSafePtr<OpalRTPConnection> connection = PSafePtrCast<OpalConnection, OpalRTPConnection> 
(call->GetConnection (i));
-      if (connection) {
-
-        OpalMediaStreamPtr stream = connection->GetMediaStream (OpalMediaType::Video (), false);
-        if (stream != NULL) {
-
-          OpalMediaFormat mediaFormat = stream->GetMediaFormat ();
-          mediaFormat.SetOptionInteger (OpalVideoFormat::TemporalSpatialTradeOffOption(),
-                                        temporal_spatial_tradeoff);
-          mediaFormat.SetOptionInteger (OpalVideoFormat::TargetBitRateOption (),
-                                        maximum_transmitted_bitrate * 1000);
-          mediaFormat.ToNormalisedOptions();
-          stream->UpdateMediaFormat (mediaFormat);
-        }
-      }
-    }
-  }
-
-  PTRACE (4, "Opal::CallManager\tVideo Max Bitrate: " << maximum_bitrate);
-  PTRACE (4, "Opal::CallManager\tVideo Max Tx Bitrate: " << maximum_transmitted_bitrate);
-  PTRACE (4, "Opal::CallManager\tVideo Temporal Spatial Tradeoff: " << temporal_spatial_tradeoff);
-  PTRACE (4, "Opal::CallManager\tVideo Size: " << options.size);
-  PTRACE (4, "Opal::CallManager\tVideo Max Frame Rate: " << maximum_frame_rate);
+  endpoint.SetMaximumJitter (max_val);
 }
 
 
-void CallManager::get_video_options (CallManager::VideoOptions & options) const
+unsigned Opal::CallManager::get_maximum_jitter () const
 {
-  OpalMediaFormatList media_formats_list;
-  OpalMediaFormat::GetAllRegisteredMediaFormats (media_formats_list);
-
-  for (int i = 0 ; i < media_formats_list.GetSize () ; i++) {
-
-    OpalMediaFormat media_format = media_formats_list [i];
-    if (media_format.GetMediaType () == OpalMediaType::Video ()) {
-
-      int j;
-      for (j = 0; j < NB_VIDEO_SIZES; j++) {
-
-        if (Ekiga::VideoSizes [j].width == media_format.GetOptionInteger (OpalVideoFormat::FrameWidthOption 
())
-            && Ekiga::VideoSizes [j].height == media_format.GetOptionInteger 
(OpalVideoFormat::FrameHeightOption ()))
-          break;
-      }
-      if (j >= NB_VIDEO_SIZES)
-        g_error ("Cannot find video size");
-      options.size = j;
-
-      options.maximum_frame_rate = (int) (media_format.GetClockRate () / media_format.GetFrameTime ());
-      options.maximum_bitrate = (int) (media_format.GetOptionInteger (OpalVideoFormat::MaxBitRateOption ()) 
/ 1000);
-      options.maximum_transmitted_bitrate = (int) (media_format.GetOptionInteger 
(OpalVideoFormat::TargetBitRateOption ()) / 1000);
-      options.temporal_spatial_tradeoff = media_format.GetOptionInteger 
(OpalVideoFormat::TemporalSpatialTradeOffOption ());
-
-      int evr = media_format.GetOptionInteger (OpalVideoFormat::OpalVideoFormat::ContentRoleMaskOption ());
-      switch (evr) {
-      case 0: // eNoRole
-        options.extended_video_roles = 0;
-        break;
-      case 1: // ePresentation
-        options.extended_video_roles = 2;
-        break;
-      case 2: // eMainRole
-        options.extended_video_roles = 3;
-        break;
-      default:
-        options.extended_video_roles = 1;
-        break;
-      }
-
-      break;
-    }
-  }
+  return endpoint.GetMaximumJitter ();
 }
 
-void
-CallManager::create_call_in_main (Opal::Call* _call)
-{
-  // beware that opal puts calls in PSafePtr objects,
-  // and hence we must not delete them ourselves
-  boost::shared_ptr<Opal::Call> call(_call, null_deleter ());
-
-  // FIXME: we should check it worked, but what do we do if it doesn't?
-  boost::shared_ptr<Ekiga::CallCore> ccore = call_core.lock ();
 
-  call->set_engine_services (notification_core, ccore);
-
-  ccore->add_call (call);
-}
-
-OpalCall *CallManager::CreateCall (void *uri)
+void Opal::CallManager::set_reject_delay (unsigned delay)
 {
-  Opal::Call* call = 0;
-
-  if (uri != 0)
-    call = new Opal::Call (*this, (const char *) uri);
-  else
-    call = new Opal::Call (*this, "");
-
-  Ekiga::Runtime::run_in_main (boost::bind (&CallManager::create_call_in_main, this, call));
-
-  return call;
-}
-
-void
-CallManager::DestroyCall (OpalCall* call)
-{
-  delete call;
+  endpoint.set_reject_delay (delay);
 }
 
 
-void
-CallManager::OnClosedMediaStream (const OpalMediaStream & stream)
+unsigned Opal::CallManager::get_reject_delay () const
 {
-  OpalMediaFormatList list = pcssEP->GetMediaFormats ();
-  OpalManager::OnClosedMediaStream (stream);
-
-  if (list.FindFormat(stream.GetMediaFormat()) != list.end ())
-    dynamic_cast <Opal::Call &> (stream.GetConnection ().GetCall ()).OnClosedMediaStream ((OpalMediaStream 
&) stream);
+  return endpoint.get_reject_delay ();
 }
 
 
-bool
-CallManager::OnOpenMediaStream (OpalConnection & connection,
-                               OpalMediaStream & stream)
+void Opal::CallManager::set_auto_answer (bool enabled)
 {
-  OpalMediaFormatList list = pcssEP->GetMediaFormats ();
-  if (!OpalManager::OnOpenMediaStream (connection, stream))
-    return FALSE;
-
-  if (list.FindFormat(stream.GetMediaFormat()) == list.end ())
-    dynamic_cast <Opal::Call &> (connection.GetCall ()).OnOpenMediaStream (stream);
-
-  return TRUE;
+  endpoint.set_auto_answer (enabled);
 }
 
 
-void CallManager::GetAllowedFormats (OpalMediaFormatList & full_list)
-{
-  OpalMediaFormatList list = OpalTranscoder::GetPossibleFormats (pcssEP->GetMediaFormats ());
-  list.RemoveNonTransportable ();
-  std::list<std::string> black_list;
-
-  black_list.push_back ("GSM-AMR");
-  black_list.push_back ("Linear-16-Stereo-48kHz");
-  black_list.push_back ("LPC-10");
-  black_list.push_back ("SpeexIETFNarrow-11k");
-  black_list.push_back ("SpeexIETFNarrow-15k");
-  black_list.push_back ("SpeexIETFNarrow-18.2k");
-  black_list.push_back ("SpeexIETFNarrow-24.6k");
-  black_list.push_back ("SpeexIETFNarrow-5.95k");
-  black_list.push_back ("iLBC-13k3");
-  black_list.push_back ("iLBC-15k2");
-  black_list.push_back ("RFC4175_YCbCr-4:2:0");
-  black_list.push_back ("RFC4175_RGB");
-
-  // Disable T.140 chat for now
-  black_list.push_back ("T.140");
-
-  // Disable CISCO NSE
-  black_list.push_back ("NamedSignalEvent");
-
-  // Disable Far-End Camera Control for now.
-  black_list.push_back ("FECC-RTP");
-  black_list.push_back ("FECC-HDLC");
-
-
-  // Purge blacklisted codecs
-  for (PINDEX i = 0 ; i < list.GetSize () ; i++) {
-
-    std::list<std::string>::iterator it = find (black_list.begin (), black_list.end (), (const char *) list 
[i]);
-    if (it == black_list.end ()) {
-      if (list [i].GetMediaType () == OpalMediaType::Audio () || list [i].GetMediaType () == 
OpalMediaType::Video ())
-        full_list += list [i];
-    }
-  }
-
-  PTRACE(4, "Ekiga\tAll available formats: " << setfill (',') << full_list);
-}
-
-void
-CallManager::HandleSTUNResult ()
+bool Opal::CallManager::get_auto_answer () const
 {
-  gboolean error = false;
-  gboolean got_answer = false;
-
-  if (g_async_queue_length (queue) > 0) {
-
-    PSTUNClient::NatTypes result
-      = (PSTUNClient::NatTypes)(GPOINTER_TO_UINT (g_async_queue_pop (queue))-1);
-    got_answer = true;
-    stun_thread = 0;
-
-    if (result == PSTUNClient::SymmetricNat
-       || result == PSTUNClient::BlockedNat
-       || result == PSTUNClient::PartiallyBlocked) {
-
-      error = true;
-    }
-    else {
-
-      ready ();
-    }
-  }
-  else if (patience == 0) {
-
-    error = true;
-  }
-
-  if (error) {
-
-    ReportSTUNError (_("Ekiga did not manage to configure your network settings automatically. You can"
-                      " still use it, but you need to configure your network settings manually.\n\n"
-                      "Please see http://wiki.ekiga.org/index.php/Enable_port_forwarding_manually for"
-                      " instructions"));
-    ready ();
-  }
-  else if (!got_answer) {
-
-    patience--;
-    Ekiga::Runtime::run_in_main (boost::bind (&CallManager::HandleSTUNResult, this), 1);
-  }
+  return endpoint.get_auto_answer ();
 }
 
-void
-CallManager::ReportSTUNError (const std::string error)
-{
-  boost::shared_ptr<Ekiga::CallCore> ccore = call_core.lock ();
-  if (!ccore)
-    return;
-
-  // notice we're in for an infinite loop if nobody ever reports to the user!
-  if ( !ccore->errors (error)) {
 
-    Ekiga::Runtime::run_in_main (boost::bind (&CallManager::ReportSTUNError, this, error),
-                                10);
-  }
-}
-
-PBoolean
-CallManager::CreateVideoOutputDevice(const OpalConnection & connection,
-                                     const OpalMediaFormat & media_fmt,
-                                     PBoolean preview,
-                                     PVideoOutputDevice * & device,
-                                     PBoolean & auto_delete)
+void Opal::CallManager::setup (const std::string & setting)
 {
-  PVideoDevice::OpenArgs videoArgs;
-  PString title;
-
-  videoArgs = preview ?
-    GetVideoPreviewDevice() : GetVideoOutputDevice();
-
-  if (!preview) {
-    unsigned openChannelCount = 0;
-    OpalMediaStreamPtr mediaStream;
+  std::cout << "IN Opal::CallManager::setup" << std::endl;
+  if (setting.empty () || setting == "stun-server")
+    endpoint.set_stun_server (nat_settings->get_string ("stun-server"));
 
-    while ((mediaStream = connection.GetMediaStream(OpalMediaType::Video(),
-                                                    preview, mediaStream)) != NULL)
-      ++openChannelCount;
+  if (setting.empty () || setting == "enable-stun")
+    endpoint.set_stun_enabled (nat_settings->get_bool ("enable-stun"));
 
-    videoArgs.deviceName += psprintf(" ID=%u", openChannelCount);
-  }
+  if (setting.empty () || setting == "maximum-jitter-buffer")
+    set_maximum_jitter (audio_codecs_settings->get_int ("maximum-jitter-buffer"));
 
-  media_fmt.AdjustVideoArgs(videoArgs);
+  if (setting.empty () || setting == "enable-silence-detection")
+    set_silence_detection (audio_codecs_settings->get_bool ("enable-silence-detection"));
 
-  auto_delete = true;
-  device = PVideoOutputDevice::CreateOpenedDevice(videoArgs, false);
-  return device != NULL;
-}
+  if (setting.empty () || setting == "enable-echo-cancellation")
+    set_echo_cancellation (audio_codecs_settings->get_bool ("enable-echo-cancellation"));
 
+  if (setting.empty () || setting == "rtp-tos-field")
+    endpoint.SetMediaTypeOfService (protocols_settings->get_int ("rtp-tos-field"));
 
-void
-CallManager::setup (const std::string & setting)
-{
-  if (setting.empty () || setting == "stun-server") {
+  if (setting.empty () || setting == "no-answer-timeout")
+    endpoint.set_reject_delay (call_options_settings->get_int ("no-answer-timeout"));
 
-    set_stun_server (nat_settings->get_string ("stun-server"));
-  }
-  if (setting.empty () || setting == "enable-stun") {
+  if (setting.empty () || setting == "auto-answer")
+    endpoint.set_auto_answer (call_options_settings->get_bool ("auto-answer"));
 
-    set_stun_enabled (nat_settings->get_bool ("enable-stun"));
-  }
-  if (setting.empty () || setting == "maximum-jitter-buffer") {
+  if (setting.empty () || setting == "forward-on-no-anwer")
+    endpoint.set_forward_on_no_answer (call_forwarding_settings->get_bool ("forward-on-no-answer"));
 
-    set_maximum_jitter (audio_codecs_settings->get_int ("maximum-jitter-buffer"));
-  }
-  if (setting.empty () || setting == "enable-silence-detection") {
+  if (setting.empty () || setting == "forward-on-busy")
+    endpoint.set_forward_on_busy (call_forwarding_settings->get_bool ("forward-on-busy"));
 
-    set_silence_detection (audio_codecs_settings->get_bool ("enable-silence-detection"));
-  }
-  if (setting.empty () || setting == "enable-echo-cancellation") {
+  if (setting.empty () || setting == "always-forward")
+    endpoint.set_unconditional_forward (call_forwarding_settings->get_bool ("always-forward"));
 
-    set_echo_cancellation (audio_codecs_settings->get_bool ("enable-echo-cancellation"));
-  }
-  if (setting.empty () || setting == "rtp-tos-field") {
-    set_rtp_tos (protocols_settings->get_int ("rtp-tos-field"));
-  }
-  if (setting.empty () || setting == "no-answer-timeout") {
+  if (setting.empty () || setting == "full-name")
+    set_display_name (personal_data_settings->get_string ("full-name"));
 
-    set_reject_delay (call_options_settings->get_int ("no-answer-timeout"));
-  }
-  if (setting.empty () || setting == "auto-answer") {
-    set_auto_answer (call_options_settings->get_bool ("auto-answer"));
-  }
-  if (setting.empty () || setting == "forward-on-no-anwer") {
-    set_forward_on_no_answer (call_forwarding_settings->get_bool ("forward-on-no-answer"));
-  }
-  if (setting.empty () || setting == "forward-on-busy") {
-    set_forward_on_busy (call_forwarding_settings->get_bool ("forward-on-busy"));
-  }
-  if (setting.empty () || setting == "always-forward") {
-    set_unconditional_forward (call_forwarding_settings->get_bool ("always-forward"));
-  }
-  if (setting.empty () || setting == "full-name") {
-    std::string full_name = personal_data_settings->get_string ("full-name");
-    if (!full_name.empty ())
-      set_display_name (full_name);
-  }
   if (setting.empty () || setting == "maximum-video-tx-bitrate") {
 
-    CallManager::VideoOptions options;
-    get_video_options (options);
+    Opal::EndPoint::VideoOptions options;
+    endpoint.GetVideoOptions (options);
     options.maximum_transmitted_bitrate = video_codecs_settings->get_int ("maximum-video-tx-bitrate");
-    set_video_options (options);
+    endpoint.SetVideoOptions (options);
   }
+
   if (setting.empty () || setting == "temporal-spatial-tradeoff") {
 
-    CallManager::VideoOptions options;
-    get_video_options (options);
+    Opal::EndPoint::VideoOptions options;
+    endpoint.GetVideoOptions (options);
     options.temporal_spatial_tradeoff = video_codecs_settings->get_int ("temporal-spatial-tradeoff");
-    set_video_options (options);
+    endpoint.SetVideoOptions (options);
   }
+
   if (setting.empty () || setting == "size") {
 
-    CallManager::VideoOptions options;
-    get_video_options (options);
+    Opal::EndPoint::VideoOptions options;
+    endpoint.GetVideoOptions (options);
     options.size = video_devices_settings->get_enum ("size");
-    set_video_options (options);
+    endpoint.SetVideoOptions (options);
   }
+
   if (setting.empty () || setting == "max-frame-rate") {
 
-    CallManager::VideoOptions options;
-    get_video_options (options);
+    Opal::EndPoint::VideoOptions options;
+    endpoint.GetVideoOptions (options);
     options.maximum_frame_rate = video_codecs_settings->get_int ("max-frame-rate");
-    set_video_options (options);
+    endpoint.SetVideoOptions (options);
   }
+
   if (setting.empty () || setting == "maximum-video-bitrate") {
 
-    CallManager::VideoOptions options;
-    get_video_options (options);
+    Opal::EndPoint::VideoOptions options;
+    endpoint.GetVideoOptions (options);
     options.maximum_bitrate = video_codecs_settings->get_int ("maximum-video-bitrate");
-    set_video_options (options);
+    endpoint.SetVideoOptions (options);
   }
+
   if (setting.empty () || setting == "media-list") {
 
     std::list<std::string> config_codecs = audio_codecs_settings->get_string_list ("media-list");
@@ -1012,29 +267,34 @@ CallManager::setup (const std::string & setting)
     // Update the manager codecs
     set_codecs (all_codecs);
   }
-  if (setting.empty () || setting == "udp-port-range" || setting == "tcp-port-range") {
-
-    std::string ports;
-    gchar **couple = NULL;
-    unsigned min_port = 0;
-    unsigned max_port = 0;
-    const char *key[2] = { "udp-port-range", "tcp-port-range" };
-
-    for (int i = 0 ; i < 2 ; i++) {
-      ports = ports_settings->get_string (key[i]);
-      if (!ports.empty ())
-        couple = g_strsplit (ports.c_str (), ":", 2);
-      if (couple && couple [0])
-        min_port = atoi (couple [0]);
-      if (couple && couple [1])
-        max_port = atoi (couple [1]);
-
-      if (i == 0)
-        set_udp_ports (min_port, max_port);
-      else
-        set_tcp_ports (min_port, max_port);
-
-      g_strfreev (couple);
+
+  if (setting.empty () || setting == "udp-port-range") {
+
+    int min_port, max_port = 0;
+    ports_settings->get_int_tuple ("udp-port-range", min_port, max_port);
+    if (min_port < max_port) {
+      endpoint.SetUDPPorts (min_port, max_port);
+      endpoint.SetRtpIpPorts (min_port, max_port);
+    }
+  }
+
+  if (setting.empty () || setting == "tcp-port-range") {
+
+    int min_port, max_port = 0;
+    ports_settings->get_int_tuple ("tcp-port-range", min_port, max_port);
+    if (min_port < max_port) {
+      endpoint.SetTCPPorts (min_port, max_port);
     }
   }
 }
+
+
+void Opal::CallManager::on_created_call (Opal::Call *_call)
+{
+  boost::shared_ptr<Ekiga::CallCore> call_core = core.get<Ekiga::CallCore> ("call-core");
+  // beware that opal puts calls in PSafePtr objects,
+  // and hence we must not delete them ourselves
+
+  boost::shared_ptr<Opal::Call> call(_call, null_deleter2 ());
+  call_core->add_call (call);
+}
diff --git a/lib/engine/components/opal/opal-call-manager.h b/lib/engine/components/opal/opal-call-manager.h
index 20afd6d..3543989 100644
--- a/lib/engine/components/opal/opal-call-manager.h
+++ b/lib/engine/components/opal/opal-call-manager.h
@@ -1,5 +1,5 @@
 /* Ekiga -- A VoIP and Video-Conferencing application
- * Copyright (C) 2000-2009 Damien Sandras <dsandras seconix com>
+ * Copyright (C) 2000-2015 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
@@ -26,207 +26,82 @@
 
 
 /*
- *                         endpoint.h  -  description
- *                         --------------------------
+ *                         opal-call-manager.h  -  description
+ *                         -----------------------------------
  *   begin                : Sat Dec 23 2000
- *   copyright            : (C) 2000-2006 by Damien Sandras
- *   description          : This file contains the Endpoint class.
+ *   authors              : Damien Sandras
+ *   description          : This file contains the engine CallManager.
  *
  */
 
 
-#ifndef _ENDPOINT_H_
-#define _ENDPOINT_H_
-
-#include "config.h"
-
-#include <ptlib.h>
-
-#include <h323/h323.h>
-#include <sip/sip.h>
-
-#include "menu-builder.h"
-
-#include "opal-call.h"
+#ifndef __OPAL_CALL_MANAGER_H_
+#define __OPAL_CALL_MANAGER_H_
 
 #include "call-manager.h"
-#include "contact-core.h"
+#include "opal-endpoint.h"
 
 #include "ekiga-settings.h"
 
-#include "actor.h"
-#include "opal-codec-description.h"
-
-class GMPCSSEndpoint;
-
 namespace Opal {
 
-  class Account;
-  namespace Sip { class EndPoint; };
-  namespace H323 { class EndPoint; };
-
-  class CallManager :
-    public Ekiga::CallManager,
-    public Ekiga::URIActionProvider,
-    public OpalManager
+  /* This is the engine CallManager implementation.
+   * It uses the Opal::Manager object to implement the engine
+   * CallManager interface.
+   */
+  class CallManager : public Ekiga::CallManager
   {
-    PCLASSINFO(CallManager, OpalManager);
-
 public:
-
-    CallManager (Ekiga::ServiceCore & _core);
-
+    CallManager (Ekiga::ServiceCore& _core,
+                 Opal::EndPoint& _manager);
     ~CallManager ();
 
-    /* URIActionProvider stuff */
-    void pull_actions (Ekiga::Actor & actor,
-                       const std::string & name,
-                       const std::string & uri);
-
-
-    /* Set up endpoint: all options or a specific setting */
-    void setup (const std::string & setting = "");
-
-
-    /** Call Manager **/
+    /* CallManager Methods */
     bool dial (const std::string & uri);
     void hang_up ();
     bool is_supported_uri (const std::string & uri);
-
+    void set_codecs (Ekiga::CodecList & codecs);
+    const Ekiga::CodecList & get_codecs () const;
     void set_display_name (const std::string & name);
     const std::string & get_display_name () const;
 
     void set_echo_cancellation (bool enabled);
     bool get_echo_cancellation () const;
-
-    void set_maximum_jitter (unsigned max_val);
-    unsigned get_maximum_jitter () const;
-
     void set_silence_detection (bool enabled);
     bool get_silence_detection () const;
-
+    void set_maximum_jitter (unsigned max_val);
+    unsigned get_maximum_jitter () const;
     void set_reject_delay (unsigned delay);
     unsigned get_reject_delay () const;
-
     void set_auto_answer (bool enabled);
     bool get_auto_answer () const;
 
-    void set_codecs (Ekiga::CodecList & codecs);
-    const Ekiga::CodecList & get_codecs () const;
-
-
-    /* Extended stuff, OPAL CallManager specific */
-
-    void set_forward_on_busy (bool enabled);
-    bool get_forward_on_busy ();
-
-    void set_forward_on_no_answer (bool enabled);
-    bool get_forward_on_no_answer ();
-
-    void set_unconditional_forward (bool enabled);
-    bool get_unconditional_forward ();
-
-    void set_udp_ports (unsigned min_port, 
-                        unsigned max_port);
-
-    void get_udp_ports (unsigned & min_port, 
-                        unsigned & max_port) const;
-
-    void set_tcp_ports (unsigned min_port, 
-                        unsigned max_port);
-
-    void get_tcp_ports (unsigned & min_port, 
-                        unsigned & max_port) const;
-
-    void get_rtp_tos (unsigned &tos) const;
-    void set_rtp_tos (unsigned tos);
-
-    void set_stun_server (const std::string & server);
-    void set_stun_enabled (bool);
-
-    /**/
-    struct VideoOptions
-      {
-        VideoOptions ()
-          : size (0),
-          maximum_frame_rate (0),
-          temporal_spatial_tradeoff (0),
-          maximum_bitrate (0),
-          maximum_transmitted_bitrate (0),
-          extended_video_roles (0) {};
-
-        unsigned size;
-        unsigned maximum_frame_rate;
-        unsigned temporal_spatial_tradeoff;
-        unsigned maximum_bitrate;
-        unsigned maximum_transmitted_bitrate;
-        unsigned extended_video_roles;
-      };
-
-    void set_video_options (const VideoOptions & options);
-    void get_video_options (VideoOptions & options) const;
+    /* Set up endpoint: all options or a specific setting */
+    virtual void setup (const std::string & setting = "");
 
 private:
-    boost::weak_ptr<Ekiga::CallCore> call_core;
-    boost::shared_ptr<Ekiga::NotificationCore> notification_core;
-
-    void create_call_in_main (Opal::Call* call);
-    OpalCall *CreateCall (void *uri);
-    virtual void DestroyCall (OpalCall *);
-
-    virtual bool OnOpenMediaStream (OpalConnection &,
-                                    OpalMediaStream &);
-
-    virtual void OnClosedMediaStream (const OpalMediaStream &);
-
-    void GetAllowedFormats (OpalMediaFormatList & full_list);
-
-    PThread* stun_thread;
-    void HandleSTUNResult ();
-
-    void ReportSTUNError (const std::string error);
-
-    virtual PBoolean CreateVideoOutputDevice(const OpalConnection & connection,
-                                             const OpalMediaFormat & media_fmt,
-                                             PBoolean preview,
-                                             PVideoOutputDevice * & device,
-                                             PBoolean & auto_delete);
-
-    /* The various related endpoints */
-    GMPCSSEndpoint *pcssEP;
-
-    /* Various mutexes to ensure thread safeness around internal
-       variables */
-    PMutex manager_access_mutex;
-
-    Ekiga::CodecList codecs;
-
-    /* used to get the STUNDetector results */
-    GAsyncQueue* queue;
-    unsigned int patience;
+    /* We use a callback instead of directly connecting the signal
+     * to the add_call method of the CallCore to prevent boost to
+     * keep a reference to the CallCore until the ECallManager is
+     * destroyed, which would be a crossed reference.
+     */
+    void on_created_call (Opal::Call *call);
+
+    Ekiga::SettingsPtr nat_settings;
+    Ekiga::SettingsPtr audio_codecs_settings;
+    Ekiga::SettingsPtr video_codecs_settings;
+    Ekiga::SettingsPtr video_devices_settings;
+    Ekiga::SettingsPtr protocols_settings;
+    Ekiga::SettingsPtr ports_settings;
+    Ekiga::SettingsPtr call_options_settings;
+    Ekiga::SettingsPtr call_forwarding_settings;
+    Ekiga::SettingsPtr personal_data_settings;
 
     std::string display_name;
-    std::string stun_server;
-    unsigned reject_delay;
-    bool forward_on_busy;
-    bool unconditional_forward;
-    bool forward_on_no_answer;
-    bool stun_enabled;
-    bool auto_answer;
 
-    boost::shared_ptr<Ekiga::Settings> nat_settings;
-    boost::shared_ptr<Ekiga::Settings> audio_codecs_settings;
-    boost::shared_ptr<Ekiga::Settings> video_codecs_settings;
-    boost::shared_ptr<Ekiga::Settings> video_devices_settings;
-    boost::shared_ptr<Ekiga::Settings> protocols_settings;
-    boost::shared_ptr<Ekiga::Settings> ports_settings;
-    boost::shared_ptr<Ekiga::Settings> call_options_settings;
-    boost::shared_ptr<Ekiga::Settings> call_forwarding_settings;
-    boost::shared_ptr<Ekiga::Settings> personal_data_settings;
-    boost::shared_ptr<Sip::EndPoint> sip_endpoint;
-#ifdef HAVE_H323
-    boost::shared_ptr<H323::EndPoint> h323_endpoint;
-#endif
+protected:
+    Ekiga::ServiceCore& core;
+    EndPoint& endpoint;
   };
 };
 #endif
diff --git a/lib/engine/components/opal/opal-call.cpp b/lib/engine/components/opal/opal-call.cpp
index fb1e407..9c991de 100644
--- a/lib/engine/components/opal/opal-call.cpp
+++ b/lib/engine/components/opal/opal-call.cpp
@@ -44,7 +44,7 @@
 
 #include "call.h"
 #include "opal-call.h"
-#include "opal-call-manager.h"
+#include "opal-endpoint.h"
 #include "notification-core.h"
 #include "call-core.h"
 #include "runtime.h"
@@ -95,10 +95,10 @@ private:
 };
 
 
-Opal::Call::Call (Opal::CallManager& _manager,
+Opal::Call::Call (Opal::EndPoint& _manager,
                  const std::string& uri)
   : OpalCall (_manager), Ekiga::Call (), remote_uri (uri),
-    call_setup(false), outgoing(false), auto_answer (_manager.get_auto_answer ())
+    call_setup(false), outgoing(false)
 {
   NoAnswerTimer.SetNotifier (PCREATE_NOTIFIER (OnNoAnswerTimeout));
 
@@ -651,8 +651,11 @@ Opal::Call::OnAnswerCall (OpalConnection & connection,
 
   parse_info (connection);
 
+  /*
   if (auto_answer)
     return OpalConnection::AnswerCallNow;
+*/
+  std::cout << "FIXME" << std::endl << std::flush;
 
   return OpalCall::OnAnswerCall (connection, caller);
 }
diff --git a/lib/engine/components/opal/opal-call.h b/lib/engine/components/opal/opal-call.h
index d057717..1e61ea0 100644
--- a/lib/engine/components/opal/opal-call.h
+++ b/lib/engine/components/opal/opal-call.h
@@ -55,7 +55,7 @@ class GMManager;
 
 namespace Opal {
 
-  class CallManager;
+  class EndPoint;
   class Call
     : public OpalCall,
       public Ekiga::Call
@@ -63,7 +63,7 @@ namespace Opal {
 
 public:
 
-    Call (Opal::CallManager& _manager,
+    Call (EndPoint& _manager,
           const std::string & uri);
     ~Call ();
 
diff --git a/lib/engine/components/opal/opal-main.cpp b/lib/engine/components/opal/opal-main.cpp
index bd05000..02f7263 100644
--- a/lib/engine/components/opal/opal-main.cpp
+++ b/lib/engine/components/opal/opal-main.cpp
@@ -37,7 +37,6 @@
 #include "config.h"
 
 #include "opal-main.h"
-#include "opal-process.h"
 
 #include "account-core.h"
 #include "chat-core.h"
@@ -49,18 +48,12 @@
 
 #include "opal-plugins-hook.h"
 
-#include "sip-endpoint.h"
+#include "sip-call-manager.h"
+
 #ifdef HAVE_H323
-#include "h323-endpoint.h"
+#include "h323-call-manager.h"
 #endif
 
-// opal manages its endpoints itself, so we must be wary
-struct null_deleter
-{
-    void operator()(void const *) const
-    { }
-};
-
 
 /* FIXME: add here an Ekiga::Service which will add&remove publishers,
  * and fetchers
@@ -94,7 +87,19 @@ struct OPALSpark: public Ekiga::Spark
        && !account_store) {
 
       hook_ekiga_plugins_to_opal (core);
-      GnomeMeeting::Process ()->Start ();
+
+      // We create our various CallManagers: SIP, H.323
+      boost::shared_ptr<Opal::Sip::CallManager> sip_call_manager (new Opal::Sip::CallManager (core, 
GnomeMeeting::Process ()->get_endpoint ()));
+      contact_core->push_back (Ekiga::URIActionProviderPtr (sip_call_manager));
+      presence_core->push_back (Ekiga::URIActionProviderPtr (sip_call_manager));
+      call_core->add_manager (sip_call_manager);
+
+#ifdef HAVE_H323
+      boost::shared_ptr<Opal::H323::CallManager> h323_call_manager (new Opal::H323::CallManager (core, 
GnomeMeeting::Process ()->get_endpoint ()));
+      contact_core->push_back (Ekiga::URIActionProviderPtr (h323_call_manager));
+      presence_core->push_back (Ekiga::URIActionProviderPtr (h323_call_manager));
+      call_core->add_manager (h323_call_manager);
+#endif
 
       result = true;
     }
@@ -111,13 +116,12 @@ struct OPALSpark: public Ekiga::Spark
   bool result;
 };
 
-void
-opal_init_pprocess (Ekiga::ServiceCore& core,
-                    int argc,
+GnomeMeeting &
+opal_init_pprocess (int argc,
                     char *argv [])
 {
   /* Ekiga PTLIB Process initialisation */
-  static GnomeMeeting instance (core);
+  static GnomeMeeting instance;
   instance.GetArguments ().SetArgs (argc, argv);
   PArgList & args = instance.GetArguments ();
   args.Parse ("d-debug:", false);
@@ -125,7 +129,7 @@ opal_init_pprocess (Ekiga::ServiceCore& core,
   if (args.IsParsed ()) {
     int debug_level = args.GetOptionAs ('d', 0);
     if (debug_level == 0)
-      return;
+      return instance;
 #ifndef WIN32
     char* text_label =  g_strdup_printf ("%d", debug_level);
     setenv ("PTLIB_TRACE_CODECS", text_label, TRUE);
@@ -159,6 +163,7 @@ opal_init_pprocess (Ekiga::ServiceCore& core,
 #endif
 #endif
   }
+  return instance;
 }
 
 void
diff --git a/lib/engine/components/opal/opal-main.h b/lib/engine/components/opal/opal-main.h
index 24bdd4b..1161c16 100644
--- a/lib/engine/components/opal/opal-main.h
+++ b/lib/engine/components/opal/opal-main.h
@@ -40,9 +40,10 @@
 #include "kickstart.h"
 #include "services.h"
 
-void opal_init_pprocess (Ekiga::ServiceCore& core,
-                         int argc,
-                         char *argv[]);
+#include "opal-process.h"
+
+GnomeMeeting &opal_init_pprocess (int argc,
+                                  char *argv[]);
 
 // Must be called after opal_init_pprocess.
 void opal_init (Ekiga::KickStart& kickstart);
diff --git a/lib/engine/components/opal/h323-endpoint.cpp 
b/lib/engine/components/opal/process/h323-endpoint.cpp
similarity index 78%
rename from lib/engine/components/opal/h323-endpoint.cpp
rename to lib/engine/components/opal/process/h323-endpoint.cpp
index fa2f391..cf47f17 100644
--- a/lib/engine/components/opal/h323-endpoint.cpp
+++ b/lib/engine/components/opal/process/h323-endpoint.cpp
@@ -138,24 +138,19 @@ namespace Opal {
 
 
 /* The class */
-Opal::H323::EndPoint::EndPoint (Opal::CallManager & _manager,
-                               const Ekiga::ServiceCore& _core): H323EndPoint (_manager),
-                                                                 manager (_manager),
-                                                                 core (_core)
+Opal::H323::EndPoint::EndPoint (Opal::EndPoint & _endpoint,
+                                const Ekiga::ServiceCore& _core): H323EndPoint (_endpoint),
+    endpoint (_endpoint),
+    core (_core)
 {
   protocol_name = "h323";
   uri_prefix = "h323:";
   /* Ready to take calls */
-  manager.AddRouteEntry("h323:.* = pc:*");
-  manager.AddRouteEntry("pc:.* = h323:<da>");
+  endpoint.AddRouteEntry("h323:.* = pc:*");
+  endpoint.AddRouteEntry("pc:.* = h323:<da>");
 
-  settings = boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (H323_SCHEMA));
-  settings->changed.connect (boost::bind (&EndPoint::setup, this, _1));
-
-  video_codecs_settings = boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (VIDEO_CODECS_SCHEMA));
-  video_codecs_settings->changed.connect (boost::bind (&EndPoint::setup, this, _1));
-
-  manager.ready.connect (boost::bind (&EndPoint::setup, this, ""));
+  std::cout << "FIXME" << std::endl;
+//  manager.ready.connect (boost::bind (&EndPoint::setup, this, ""));
 }
 
 Opal::H323::EndPoint::~EndPoint ()
@@ -170,7 +165,7 @@ Opal::H323::EndPoint::dial (const std::string&  uri)
     return false;
 
   PString token;
-  manager.SetUpCall("pc:*", uri, token, (void*) uri.c_str());
+  endpoint.SetUpCall("pc:*", uri, token, (void*) uri.c_str());
 
   return true;
 }
@@ -295,7 +290,7 @@ Opal::H323::EndPoint::set_listen_port (unsigned port)
 }
 
 
-const Ekiga::CallProtocolManager::InterfaceList &
+const Ekiga::CallManager::InterfaceList &
 Opal::H323::EndPoint::get_interfaces () const
 {
   return interfaces;
@@ -396,6 +391,9 @@ Opal::H323::EndPoint::OnIncomingConnection (OpalConnection & connection,
       busy = true;
   }
 
+  std::cout << "FIXME" << std::endl;
+
+  /*
   if (!forward_uri.empty () && manager.get_unconditional_forward ())
     connection.ForwardCall (forward_uri);
   else if (busy) {
@@ -419,58 +417,7 @@ Opal::H323::EndPoint::OnIncomingConnection (OpalConnection & connection,
 
     return H323EndPoint::OnIncomingConnection (connection, options, stroptions);
   }
+  */
 
   return false;
 }
-
-
-void
-Opal::H323::EndPoint::setup (const std::string setting)
-{
-  if (setting.empty () || setting == "listen-port") {
-
-    set_listen_port (settings->get_int ("listen-port"));
-  }
-  if (setting.empty () || setting == "maximum-video-tx-bitrate") {
-
-    int maximum_video_tx_bitrate = video_codecs_settings->get_int ("maximum-video-tx-bitrate");
-    // maximum_video_tx_bitrate is the max video bitrate specified by the user
-    // add to it 10% (approx.) accounting for audio,
-    // and multiply it by 10 as needed by SetInitialBandwidth
-    set_initial_bandwidth (maximum_video_tx_bitrate * 11);
-  }
-  if (setting.empty () || setting == "enable-h245-tunneling") {
-
-    DisableH245Tunneling (!settings->get_bool ("enable-h245-tunneling"));
-    PTRACE (4, "Opal::H323::EndPoint\tH.245 Tunneling: " << settings->get_bool ("enable-h245-tunneling"));
-  }
-  if (setting.empty () || setting == "enable-early-h245") {
-
-    DisableH245inSetup (!settings->get_bool ("enable-early-h245"));
-    PTRACE (4, "Opal::H323::EndPoint\tEarly H.245: " << settings->get_bool ("enable-early-h245"));
-  }
-  if (setting.empty () || setting == "enable-fast-connect") {
-
-    DisableFastStart (!settings->get_bool ("enable-fast-connect"));
-    PTRACE (4, "Opal::H323::EndPoint\tFast Connect: " << settings->get_bool ("enable-fast-connect"));
-  }
-  if (setting.empty () || setting == "dtmf-mode") {
-
-    set_dtmf_mode (settings->get_enum ("dtmf-mode"));
-  }
-  if (setting.empty () || setting == "forward-host") {
-
-    set_forward_uri (settings->get_string ("forward-host"));
-  }
-  if (setting.empty () || setting == "video-role") {
-
-    CallManager::VideoOptions options;
-    manager.get_video_options (options);
-    options.extended_video_roles = settings->get_enum ("video-role");
-    manager.set_video_options (options);
-  }
-  if (setting.empty () || setting == "enable-h239") {
-    SetDefaultH239Control(settings->get_bool ("enable-h239"));
-    PTRACE (4, "Opal::H323::EndPoint\tH.239 Control: " << settings->get_bool ("enable-h239"));
-  }
-}
diff --git a/lib/engine/components/opal/h323-endpoint.h b/lib/engine/components/opal/process/h323-endpoint.h
similarity index 85%
rename from lib/engine/components/opal/h323-endpoint.h
rename to lib/engine/components/opal/process/h323-endpoint.h
index 588102b..183b59f 100644
--- a/lib/engine/components/opal/h323-endpoint.h
+++ b/lib/engine/components/opal/process/h323-endpoint.h
@@ -16,7 +16,7 @@
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  *
- * Ekiga is licensed under the GPL license and as a special exc_managertion,
+ * 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
@@ -38,9 +38,10 @@
 #ifndef _H323_ENDPOINT_H_
 #define _H323_ENDPOINT_H_
 
-#include <opal/opal.h>
+#include <ptlib.h>
 
-#include "ekiga-settings.h"
+#include <opal/opal.h>
+#include <h323/h323.h>
 
 #include "call-core.h"
 #include "presence-core.h"
@@ -54,13 +55,12 @@ namespace Opal {
 
   namespace H323 {
 
-    class EndPoint : public H323EndPoint,
-                    public Ekiga::CallProtocolManager
+    class EndPoint : public H323EndPoint
     {
       PCLASSINFO(EndPoint, H323EndPoint);
 
   public:
-      EndPoint (CallManager & ep,
+      EndPoint (Opal::EndPoint & ep,
                const Ekiga::ServiceCore& core);
 
       ~EndPoint ();
@@ -81,7 +81,7 @@ namespace Opal {
 
       bool set_listen_port (unsigned port);
 
-      const Ekiga::CallProtocolManager::InterfaceList & get_interfaces () const;
+      const Ekiga::CallManager::InterfaceList & get_interfaces () const;
 
       void set_initial_bandwidth (unsigned max_tx_video_bitrate);
 
@@ -105,8 +105,6 @@ namespace Opal {
 
       bool IsRegisteredWithGatekeeper (const PString & address);
 
-      void setup (const std::string key = "");
-
   private:
       bool OnIncomingConnection (OpalConnection &connection,
                                  unsigned options,
@@ -114,20 +112,18 @@ namespace Opal {
 
       // this object is really managed by opal,
       // so the way it is handled here is correct
-      CallManager & manager;
+      Opal::EndPoint &endpoint;
 
       PMutex gk_name_mutex;
       PString gk_name;
 
-      Ekiga::CallProtocolManager::Interface listen_iface;
+      Ekiga::CallManager::Interface listen_iface;
 
       std::string protocol_name;
       std::string uri_prefix;
       std::string forward_uri;
 
-      boost::shared_ptr<Ekiga::Settings> settings;
-      boost::shared_ptr<Ekiga::Settings> video_codecs_settings;
-      Ekiga::CallProtocolManager::InterfaceList interfaces;
+      Ekiga::CallManager::InterfaceList interfaces;
 
       const Ekiga::ServiceCore & core;
     };
diff --git a/lib/engine/components/opal/process/opal-endpoint.cpp 
b/lib/engine/components/opal/process/opal-endpoint.cpp
new file mode 100644
index 0000000..651872b
--- /dev/null
+++ b/lib/engine/components/opal/process/opal-endpoint.cpp
@@ -0,0 +1,794 @@
+
+/* 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.
+ */
+
+
+/*
+ *                         opal-endpoint.cpp  -  description
+ *                         ---------------------------------
+ *   begin                : Sat Dec 23 2000
+ *   authors              : Damien Sandras
+ *   description          : This file contains our OpalManager.
+ *
+ */
+
+
+#include <algorithm>
+#include <glib/gi18n.h>
+
+#include "opal-call-manager.h"
+
+#include "pcss-endpoint.h"
+
+#include "call-core.h"
+#include "opal-codec-description.h"
+#include "videoinput-info.h"
+
+#include "call-manager.h"
+
+#include "sip-endpoint.h"
+#ifdef HAVE_H323
+#include "h323-endpoint.h"
+#endif
+
+#include <opal/transcoders.h>
+
+#include <stdlib.h>
+
+// opal manages its endpoints itself, so we must be wary
+struct null_deleter
+{
+  void operator()(void const *) const
+    { }
+};
+
+
+class StunDetector : public PThread
+{
+  PCLASSINFO(StunDetector, PThread);
+
+public:
+
+  StunDetector (const std::string & _server,
+                Opal::EndPoint& _manager,
+                GAsyncQueue* _queue)
+    : PThread (1000, AutoDeleteThread),
+    server (_server),
+    manager (_manager),
+    queue (_queue)
+  {
+    PTRACE (3, "Ekiga\tStarted STUN detector");
+    g_async_queue_ref (queue);
+    this->Resume ();
+  };
+
+  ~StunDetector ()
+    {
+      g_async_queue_unref (queue);
+      PTRACE (3, "Ekiga\tStopped STUN detector");
+    }
+
+  void Main ()
+    {
+      PSTUNClient::NatTypes result = manager.SetSTUNServer (server);
+
+      g_async_queue_push (queue, GUINT_TO_POINTER ((guint)result + 1));
+    };
+
+private:
+  const std::string server;
+  Opal::EndPoint & manager;
+  GAsyncQueue* queue;
+};
+
+
+/* The class */
+Opal::EndPoint::EndPoint (Ekiga::ServiceCore& core)
+{
+  call_core = core.get<Ekiga::CallCore> ("call-core");
+  notification_core = core.get<Ekiga::NotificationCore> ("notification-core");
+
+  stun_thread = 0;
+
+  /* Initialise the endpoint parameters */
+#if P_HAS_IPV6
+  char * ekiga_ipv6 = getenv("EKIGA_IPV6");
+  // use IPv6 instead of IPv4 if EKIGA_IPV6 env var is set
+  if (ekiga_ipv6 && PIPSocket::IsIpAddressFamilyV6Supported())
+    PIPSocket::SetDefaultIpAddressFamilyV6();
+  else
+    PIPSocket::SetDefaultIpAddressFamilyV4();
+#else
+  PIPSocket::SetDefaultIpAddressFamilyV4();
+#endif
+  PIPSocket::SetSuppressCanonicalName (true);  // avoid long delays
+  SetAutoStartTransmitVideo (true);
+  SetAutoStartReceiveVideo (true);
+  SetUDPPorts (5000, 5100);
+  SetTCPPorts (30000, 30100);
+  SetRtpIpPorts (5000, 5100);
+
+  pcssEP = NULL;
+
+  forward_on_no_answer = false;
+  forward_on_busy = false;
+  unconditional_forward = false;
+  stun_enabled = false;
+  auto_answer = false;
+
+  // Create video devices
+  PVideoDevice::OpenArgs video = GetVideoOutputDevice();
+  video.deviceName = "EKIGAOUT";
+  SetVideoOutputDevice (video);
+
+  video = GetVideoOutputDevice();
+  video.deviceName = "EKIGAIN";
+  SetVideoPreviewDevice (video);
+
+  video = GetVideoInputDevice();
+  video.deviceName = "EKIGA";
+  SetVideoInputDevice (video);
+
+  // Media formats
+  SetMediaFormatOrder (PStringArray ());
+  SetMediaFormatMask (PStringArray ());
+
+  // used to communicate with the StunDetector
+  queue = g_async_queue_new ();
+
+  PInterfaceMonitor::GetInstance().SetRefreshInterval (15000);
+
+  // Create endpoints / CallProtocolManagers
+  pcssEP = new GMPCSSEndpoint (*this, core);
+  pcssEP->SetSoundChannelPlayDevice("EKIGA");
+  pcssEP->SetSoundChannelRecordDevice("EKIGA");
+
+  sip_endpoint = boost::shared_ptr<Sip::EndPoint> (new Sip::EndPoint (*this, core), null_deleter ());
+
+#ifdef HAVE_H323
+  h323_endpoint= boost::shared_ptr<H323::EndPoint>(new H323::EndPoint (*this, core), null_deleter ());
+#endif
+}
+
+
+Opal::EndPoint::~EndPoint ()
+{
+  if (stun_thread)
+    stun_thread->WaitForTermination ();
+  ClearAllCalls (OpalConnection::EndedByLocalUser, true);
+
+  g_async_queue_unref (queue);
+}
+
+
+bool Opal::EndPoint::dial (const std::string & uri)
+{
+  if (sip_endpoint && sip_endpoint->is_supported_uri (uri))
+    return sip_endpoint->dial (uri);
+
+#ifdef HAVE_H323
+  if (h323_endpoint && h323_endpoint->is_supported_uri (uri))
+    return h323_endpoint->dial (uri);
+#endif
+
+  return false;
+}
+
+
+bool Opal::EndPoint::is_supported_uri (const std::string & uri)
+{
+  if (sip_endpoint && sip_endpoint->is_supported_uri (uri))
+    return true;
+
+#ifdef HAVE_H323
+  if (h323_endpoint && h323_endpoint->is_supported_uri (uri))
+    return true;
+#endif
+
+  return false;
+}
+
+
+void Opal::EndPoint::SetEchoCancellation (bool enabled)
+{
+  OpalEchoCanceler::Params ec;
+
+  // General settings
+  ec = GetEchoCancelParams ();
+  ec.m_enabled = enabled;
+  SetEchoCancelParams (ec);
+
+  // Adjust setting for all connections of all calls
+  for (PSafePtr<OpalCall> call = activeCalls;
+       call != NULL;
+       ++call) {
+
+    for (int i = 0;
+         i < 2;
+         i++) {
+
+      PSafePtr<OpalConnection> connection = call->GetConnection (i);
+      if (connection) {
+
+        OpalEchoCanceler *echo_canceler = connection->GetEchoCanceler ();
+
+        if (echo_canceler)
+          echo_canceler->SetParameters (ec);
+      }
+    }
+  }
+
+  PTRACE (4, "Opal::EndPoint\tEcho Cancellation: " << enabled);
+}
+
+
+bool Opal::EndPoint::GetEchoCancellation () const
+{
+  OpalEchoCanceler::Params ec = GetEchoCancelParams ();
+
+  return ec.m_enabled;
+}
+
+
+void Opal::EndPoint::SetMaximumJitter (unsigned max_val)
+{
+  unsigned val = std::min (std::max (max_val, (unsigned) 20), (unsigned) 1000);
+
+  SetAudioJitterDelay (20, val);
+
+  // Adjust setting for all sessions of all connections of all calls
+  for (PSafePtr<OpalCall> call = activeCalls;
+       call != NULL;
+       ++call) {
+
+    for (int i = 0;
+         i < 2;
+         i++) {
+
+      PSafePtr<OpalRTPConnection> connection = PSafePtrCast<OpalConnection, OpalRTPConnection> 
(call->GetConnection (i));
+      if (connection) {
+
+        OpalMediaStreamPtr stream = connection->GetMediaStream (OpalMediaType::Audio (), false);
+        if (stream != NULL) {
+
+          OpalRTPSession *session = (OpalRTPSession*)connection->GetMediaSession (stream->GetSessionID ());
+          if (session != NULL) {
+
+            unsigned units = session->GetJitterTimeUnits ();
+            OpalJitterBuffer::Init init;
+            init.m_minJitterDelay = 20 * units;
+            init.m_maxJitterDelay = val * units;
+            init.m_timeUnits = units;
+            session->SetJitterBufferSize (init);
+          }
+        }
+      }
+    }
+  }
+
+  PTRACE (4, "Opal::EndPoint\tSet Maximum Jitter to " << val);
+}
+
+
+unsigned Opal::EndPoint::GetMaximumJitter () const
+{
+  return GetMaxAudioJitterDelay ();
+}
+
+
+void Opal::EndPoint::SetSilenceDetection (bool enabled)
+{
+  OpalSilenceDetector::Params sd;
+
+  // General settings
+  sd = GetSilenceDetectParams ();
+  if (enabled)
+    sd.m_mode = OpalSilenceDetector::AdaptiveSilenceDetection;
+  else
+    sd.m_mode = OpalSilenceDetector::NoSilenceDetection;
+  SetSilenceDetectParams (sd);
+
+  // Adjust setting for all connections of all calls
+  for (PSafePtr<OpalCall> call = activeCalls;
+       call != NULL;
+       ++call) {
+
+    for (int i = 0;
+         i < 2;
+         i++) {
+
+      PSafePtr<OpalConnection> connection = call->GetConnection (i);
+      if (connection) {
+
+        OpalSilenceDetector *silence_detector = connection->GetSilenceDetector ();
+
+        if (silence_detector)
+          silence_detector->SetParameters (sd);
+      }
+    }
+  }
+
+  PTRACE (4, "Opal::EndPoint\tSilence Detection: " << enabled);
+}
+
+
+bool Opal::EndPoint::GetSilenceDetection () const
+{
+  OpalSilenceDetector::Params sd;
+
+  sd = GetSilenceDetectParams ();
+
+  return (sd.m_mode != OpalSilenceDetector::NoSilenceDetection);
+}
+
+
+void Opal::EndPoint::set_reject_delay (unsigned delay)
+{
+  reject_delay = std::max ((unsigned) 5, delay);
+}
+
+
+unsigned Opal::EndPoint::get_reject_delay () const
+{
+  return reject_delay;
+}
+
+
+void Opal::EndPoint::set_auto_answer (bool enabled)
+{
+  auto_answer = enabled;
+}
+
+
+bool Opal::EndPoint::get_auto_answer (void) const
+{
+  return auto_answer;
+}
+
+
+const Ekiga::CodecList & Opal::EndPoint::get_codecs () const
+{
+  return codecs;
+}
+
+
+void Opal::EndPoint::set_codecs (Ekiga::CodecList & _codecs)
+{
+  PStringArray mask, order;
+  OpalMediaFormatList formats;
+  OpalMediaFormat::GetAllRegisteredMediaFormats (formats);
+
+  codecs = _codecs;
+
+  for (Ekiga::CodecList::const_iterator iter = codecs.begin ();
+       iter != codecs.end ();
+       iter++)
+    if ((*iter).active)
+      order += (*iter).name;
+
+  formats.Remove (order);
+
+  for (int i = 0 ; i < formats.GetSize () ; i++)
+    mask += (const char *) formats[i];
+
+  SetMediaFormatOrder (order);
+  SetMediaFormatMask (mask);
+  PTRACE (4, "Ekiga\tSet codecs: " << setfill(';') << GetMediaFormatOrder ());
+  PTRACE (4, "Ekiga\tDisabled codecs: " << setfill(';') << GetMediaFormatMask ());
+}
+
+
+void Opal::EndPoint::set_forward_on_no_answer (bool enabled)
+{
+  forward_on_no_answer = enabled;
+}
+
+bool Opal::EndPoint::get_forward_on_no_answer ()
+{
+  return forward_on_no_answer;
+}
+
+void Opal::EndPoint::set_forward_on_busy (bool enabled)
+{
+  forward_on_busy = enabled;
+}
+
+bool Opal::EndPoint::get_forward_on_busy ()
+{
+  return forward_on_busy;
+}
+
+void Opal::EndPoint::set_unconditional_forward (bool enabled)
+{
+  unconditional_forward = enabled;
+}
+
+bool Opal::EndPoint::get_unconditional_forward ()
+{
+  return unconditional_forward;
+}
+
+
+void Opal::EndPoint::set_stun_server (const std::string & server)
+{
+  std::cout << "Set STUN SERVER TO " << server << std::endl << std::flush;
+  if (server.empty ())
+    stun_server = "stun.ekiga.net";
+
+  stun_server = server;
+  PTRACE (4, "Opal::EndPoint\tSet STUN Server to " << stun_server);
+}
+
+
+void Opal::EndPoint::set_stun_enabled (bool enabled)
+{
+  stun_enabled = enabled;
+  if (stun_enabled && !stun_thread) {
+
+    // Ready
+    stun_thread = new StunDetector (stun_server, *this, queue);
+    patience = 20;
+    Ekiga::Runtime::run_in_main (boost::bind (&Opal::EndPoint::HandleSTUNResult, this), 1);
+  }
+  else {
+    //ready ();
+  }
+
+  PTRACE (4, "Opal::EndPoint\tSTUN Detection: " << enabled);
+}
+
+
+boost::shared_ptr<Opal::Sip::EndPoint> Opal::EndPoint::get_sip_endpoint ()
+{
+  return sip_endpoint;
+}
+
+
+#ifdef HAVE_H323
+boost::shared_ptr<Opal::H323::EndPoint> Opal::EndPoint::get_h323_endpoint ()
+{
+  return h323_endpoint;
+}
+#endif
+
+
+void Opal::EndPoint::SetVideoOptions (const Opal::EndPoint::VideoOptions & options)
+{
+  OpalMediaFormatList media_formats_list;
+  OpalMediaFormat::GetAllRegisteredMediaFormats (media_formats_list);
+
+  int maximum_frame_rate = std::min (std::max ((signed) options.maximum_frame_rate, 1), 30);
+  int maximum_bitrate = (options.maximum_bitrate > 0 ? options.maximum_bitrate : 16384);
+  int maximum_transmitted_bitrate = (options.maximum_transmitted_bitrate > 0 ? 
options.maximum_transmitted_bitrate : 256);
+  int temporal_spatial_tradeoff = (options.temporal_spatial_tradeoff > 0 ? options.temporal_spatial_tradeoff 
: 12);
+  // Configure all mediaOptions of all Video MediaFormats
+  for (int i = 0 ; i < media_formats_list.GetSize () ; i++) {
+
+    OpalMediaFormat media_format = media_formats_list [i];
+    if (media_format.GetMediaType() == OpalMediaType::Video ()) {
+
+      media_format.SetOptionInteger (OpalVideoFormat::FrameWidthOption (), Ekiga::VideoSizes 
[options.size].width);
+      media_format.SetOptionInteger (OpalVideoFormat::FrameHeightOption (), Ekiga::VideoSizes 
[options.size].height);
+      media_format.SetOptionInteger (OpalVideoFormat::FrameTimeOption (), (int) (media_format.GetClockRate 
() / maximum_frame_rate));
+      media_format.SetOptionInteger (OpalVideoFormat::MaxBitRateOption (), maximum_bitrate * 1000);
+      media_format.SetOptionInteger (OpalVideoFormat::TargetBitRateOption (), maximum_transmitted_bitrate * 
1000);
+      media_format.SetOptionInteger (OpalVideoFormat::MinRxFrameWidthOption(), GM_QSIF_WIDTH);
+      media_format.SetOptionInteger (OpalVideoFormat::MinRxFrameHeightOption(), GM_QSIF_HEIGHT);
+      media_format.SetOptionInteger (OpalVideoFormat::MaxRxFrameWidthOption(), GM_1080P_WIDTH);
+      media_format.SetOptionInteger (OpalVideoFormat::MaxRxFrameHeightOption(), GM_1080P_HEIGHT);
+      media_format.AddOption(new OpalMediaOptionUnsigned (OpalVideoFormat::TemporalSpatialTradeOffOption (), 
true, OpalMediaOption::NoMerge, temporal_spatial_tradeoff));
+      media_format.SetOptionInteger (OpalVideoFormat::TemporalSpatialTradeOffOption(), 
temporal_spatial_tradeoff);
+
+      if (media_format.GetName() != "YUV420P" &&
+          media_format.GetName() != "RGB32" &&
+          media_format.GetName() != "RGB24")
+        media_format.SetOptionInteger (OpalVideoFormat::RateControlPeriodOption(), 300);
+
+      switch (options.extended_video_roles) {
+      case 0 :
+        media_format.SetOptionInteger(OpalVideoFormat::ContentRoleMaskOption(), 0);
+        break;
+
+      case 2 : // Force Presentation (slides)
+        media_format.SetOptionInteger(OpalVideoFormat::ContentRoleMaskOption(),
+                                      OpalVideoFormat::ContentRoleBit(OpalVideoFormat::ePresentation));
+        break;
+
+      case 3 : // Force Live (main)
+        media_format.SetOptionInteger(OpalVideoFormat::ContentRoleMaskOption(),
+                                      OpalVideoFormat::ContentRoleBit(OpalVideoFormat::eMainRole));
+        break;
+
+        default :
+          break;
+      }
+
+      OpalMediaFormat::SetRegisteredMediaFormat(media_format);
+    }
+  }
+
+  // Adjust setting for all sessions of all connections of all calls
+  for (PSafePtr<OpalCall> call = activeCalls;
+       call != NULL;
+       ++call) {
+
+    for (int i = 0;
+         i < 2;
+         i++) {
+
+      PSafePtr<OpalRTPConnection> connection = PSafePtrCast<OpalConnection, OpalRTPConnection> 
(call->GetConnection (i));
+      if (connection) {
+
+        OpalMediaStreamPtr stream = connection->GetMediaStream (OpalMediaType::Video (), false);
+        if (stream != NULL) {
+
+          OpalMediaFormat mediaFormat = stream->GetMediaFormat ();
+          mediaFormat.SetOptionInteger (OpalVideoFormat::TemporalSpatialTradeOffOption(),
+                                        temporal_spatial_tradeoff);
+          mediaFormat.SetOptionInteger (OpalVideoFormat::TargetBitRateOption (),
+                                        maximum_transmitted_bitrate * 1000);
+          mediaFormat.ToNormalisedOptions();
+          stream->UpdateMediaFormat (mediaFormat);
+        }
+      }
+    }
+  }
+
+  PTRACE (4, "Opal::EndPoint\tVideo Max Bitrate: " << maximum_bitrate);
+  PTRACE (4, "Opal::EndPoint\tVideo Max Tx Bitrate: " << maximum_transmitted_bitrate);
+  PTRACE (4, "Opal::EndPoint\tVideo Temporal Spatial Tradeoff: " << temporal_spatial_tradeoff);
+  PTRACE (4, "Opal::EndPoint\tVideo Size: " << options.size);
+  PTRACE (4, "Opal::EndPoint\tVideo Max Frame Rate: " << maximum_frame_rate);
+}
+
+
+void Opal::EndPoint::GetVideoOptions (Opal::EndPoint::VideoOptions & options) const
+{
+  OpalMediaFormatList media_formats_list;
+  OpalMediaFormat::GetAllRegisteredMediaFormats (media_formats_list);
+
+  for (int i = 0 ; i < media_formats_list.GetSize () ; i++) {
+
+    OpalMediaFormat media_format = media_formats_list [i];
+    if (media_format.GetMediaType () == OpalMediaType::Video ()) {
+
+      int j;
+      for (j = 0; j < NB_VIDEO_SIZES; j++) {
+
+        if (Ekiga::VideoSizes [j].width == media_format.GetOptionInteger (OpalVideoFormat::FrameWidthOption 
())
+            && Ekiga::VideoSizes [j].height == media_format.GetOptionInteger 
(OpalVideoFormat::FrameHeightOption ()))
+          break;
+      }
+      if (j >= NB_VIDEO_SIZES)
+        g_error ("Cannot find video size");
+      options.size = j;
+
+      options.maximum_frame_rate = (int) (media_format.GetClockRate () / media_format.GetFrameTime ());
+      options.maximum_bitrate = (int) (media_format.GetOptionInteger (OpalVideoFormat::MaxBitRateOption ()) 
/ 1000);
+      options.maximum_transmitted_bitrate = (int) (media_format.GetOptionInteger 
(OpalVideoFormat::TargetBitRateOption ()) / 1000);
+      options.temporal_spatial_tradeoff = media_format.GetOptionInteger 
(OpalVideoFormat::TemporalSpatialTradeOffOption ());
+
+      int evr = media_format.GetOptionInteger (OpalVideoFormat::OpalVideoFormat::ContentRoleMaskOption ());
+      switch (evr) {
+      case 0: // eNoRole
+        options.extended_video_roles = 0;
+        break;
+      case 1: // ePresentation
+        options.extended_video_roles = 2;
+        break;
+      case 2: // eMainRole
+        options.extended_video_roles = 3;
+        break;
+      default:
+        options.extended_video_roles = 1;
+        break;
+      }
+
+      break;
+    }
+  }
+}
+
+
+OpalCall *Opal::EndPoint::CreateCall (void *uri)
+{
+  Opal::Call* call = 0;
+
+  if (uri != 0)
+    call = new Opal::Call (*this, (const char *) uri);
+  else
+    call = new Opal::Call (*this, "");
+
+  Ekiga::Runtime::run_in_main (boost::bind (boost::ref (created_call), call));
+
+  return call;
+}
+
+void
+Opal::EndPoint::DestroyCall (OpalCall* call)
+{
+  delete call;
+}
+
+
+void
+Opal::EndPoint::OnClosedMediaStream (const OpalMediaStream & stream)
+{
+  OpalMediaFormatList list = pcssEP->GetMediaFormats ();
+  OpalManager::OnClosedMediaStream (stream);
+
+  if (list.FindFormat(stream.GetMediaFormat()) != list.end ())
+    dynamic_cast <Opal::Call &> (stream.GetConnection ().GetCall ()).OnClosedMediaStream ((OpalMediaStream 
&) stream);
+}
+
+
+bool
+Opal::EndPoint::OnOpenMediaStream (OpalConnection & connection,
+                               OpalMediaStream & stream)
+{
+  OpalMediaFormatList list = pcssEP->GetMediaFormats ();
+  if (!OpalManager::OnOpenMediaStream (connection, stream))
+    return FALSE;
+
+  if (list.FindFormat(stream.GetMediaFormat()) == list.end ())
+    dynamic_cast <Opal::Call &> (connection.GetCall ()).OnOpenMediaStream (stream);
+
+  return TRUE;
+}
+
+
+void Opal::EndPoint::GetAllowedFormats (OpalMediaFormatList & full_list)
+{
+  OpalMediaFormatList list = OpalTranscoder::GetPossibleFormats (pcssEP->GetMediaFormats ());
+  list.RemoveNonTransportable ();
+  std::list<std::string> black_list;
+
+  black_list.push_back ("GSM-AMR");
+  black_list.push_back ("Linear-16-Stereo-48kHz");
+  black_list.push_back ("LPC-10");
+  black_list.push_back ("SpeexIETFNarrow-11k");
+  black_list.push_back ("SpeexIETFNarrow-15k");
+  black_list.push_back ("SpeexIETFNarrow-18.2k");
+  black_list.push_back ("SpeexIETFNarrow-24.6k");
+  black_list.push_back ("SpeexIETFNarrow-5.95k");
+  black_list.push_back ("iLBC-13k3");
+  black_list.push_back ("iLBC-15k2");
+  black_list.push_back ("RFC4175_YCbCr-4:2:0");
+  black_list.push_back ("RFC4175_RGB");
+
+  // Disable T.140 chat for now
+  black_list.push_back ("T.140");
+
+  // Disable CISCO NSE
+  black_list.push_back ("NamedSignalEvent");
+
+  // Disable Far-End Camera Control for now.
+  black_list.push_back ("FECC-RTP");
+  black_list.push_back ("FECC-HDLC");
+
+
+  // Purge blacklisted codecs
+  for (PINDEX i = 0 ; i < list.GetSize () ; i++) {
+
+    std::list<std::string>::iterator it = find (black_list.begin (), black_list.end (), (const char *) list 
[i]);
+    if (it == black_list.end ()) {
+      if (list [i].GetMediaType () == OpalMediaType::Audio () || list [i].GetMediaType () == 
OpalMediaType::Video ())
+        full_list += list [i];
+    }
+  }
+
+  PTRACE(4, "Ekiga\tAll available formats: " << setfill (',') << full_list);
+}
+
+void
+Opal::EndPoint::HandleSTUNResult ()
+{
+  gboolean error = false;
+  gboolean got_answer = false;
+
+  if (g_async_queue_length (queue) > 0) {
+
+    PSTUNClient::NatTypes result
+      = (PSTUNClient::NatTypes)(GPOINTER_TO_UINT (g_async_queue_pop (queue))-1);
+    got_answer = true;
+    stun_thread = 0;
+
+    if (result == PSTUNClient::SymmetricNat
+       || result == PSTUNClient::BlockedNat
+       || result == PSTUNClient::PartiallyBlocked) {
+
+      error = true;
+    }
+    else {
+
+      //ready ();
+    }
+  }
+  else if (patience == 0) {
+
+    error = true;
+  }
+
+  if (error) {
+
+    ReportSTUNError (_("Ekiga did not manage to configure your network settings automatically. You can"
+                      " still use it, but you need to configure your network settings manually.\n\n"
+                      "Please see http://wiki.ekiga.org/index.php/Enable_port_forwarding_manually for"
+                      " instructions"));
+    //ready ();
+  }
+  else if (!got_answer) {
+
+    patience--;
+    Ekiga::Runtime::run_in_main (boost::bind (&Opal::EndPoint::HandleSTUNResult, this), 1);
+  }
+}
+
+void
+Opal::EndPoint::ReportSTUNError (const std::string error)
+{
+  boost::shared_ptr<Ekiga::CallCore> ccore = call_core.lock ();
+  if (!ccore)
+    return;
+
+  // notice we're in for an infinite loop if nobody ever reports to the user!
+  if ( !ccore->errors (error)) {
+
+    Ekiga::Runtime::run_in_main (boost::bind (&Opal::EndPoint::ReportSTUNError, this, error),
+                                10);
+  }
+}
+
+PBoolean
+Opal::EndPoint::CreateVideoOutputDevice(const OpalConnection & connection,
+                                     const OpalMediaFormat & media_fmt,
+                                     PBoolean preview,
+                                     PVideoOutputDevice * & device,
+                                     PBoolean & auto_delete)
+{
+  PVideoDevice::OpenArgs videoArgs;
+  PString title;
+
+  videoArgs = preview ?
+    GetVideoPreviewDevice() : GetVideoOutputDevice();
+
+  if (!preview) {
+    unsigned openChannelCount = 0;
+    OpalMediaStreamPtr mediaStream;
+
+    while ((mediaStream = connection.GetMediaStream(OpalMediaType::Video(),
+                                                    preview, mediaStream)) != NULL)
+      ++openChannelCount;
+
+    videoArgs.deviceName += psprintf(" ID=%u", openChannelCount);
+  }
+
+  media_fmt.AdjustVideoArgs(videoArgs);
+
+  auto_delete = true;
+  device = PVideoOutputDevice::CreateOpenedDevice(videoArgs, false);
+  return device != NULL;
+}
diff --git a/lib/engine/components/opal/process/opal-endpoint.h 
b/lib/engine/components/opal/process/opal-endpoint.h
new file mode 100644
index 0000000..94a8d78
--- /dev/null
+++ b/lib/engine/components/opal/process/opal-endpoint.h
@@ -0,0 +1,203 @@
+
+/* 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.
+ */
+
+
+/*
+ *                         opal-endpoint.h  -  description
+ *                         -------------------------------
+ *   begin                : Sat Dec 23 2000
+ *   authors              : Damien Sandras
+ *   description          : This file contains our OpalManager.
+ *
+ */
+
+
+#ifndef __OPAL_ENDPOINT_H_
+#define __OPAL_ENDPOINT_H_
+
+#include "config.h"
+
+#include <ptlib.h>
+
+#include <h323/h323.h>
+#include <sip/sip.h>
+
+#include "menu-builder.h"
+
+#include "opal-call.h"
+
+#include "call-manager.h"
+#include "contact-core.h"
+
+#include "actor.h"
+#include "opal-codec-description.h"
+
+class GMPCSSEndpoint;
+
+namespace Opal {
+
+  class Account;
+  class CallManager;
+  namespace Sip { class EndPoint; };
+  namespace H323 { class EndPoint; };
+
+  /* This is the OPAL endpoint. We do not want it to directly
+   * use the CallCore, CallManager's and other engine implementations.
+   * We want it to provide those services to the relevant engine objects
+   * and trigger signals when appropriate.
+   */
+  class EndPoint : public OpalManager
+  {
+    PCLASSINFO(EndPoint, OpalManager);
+
+public:
+
+    EndPoint (Ekiga::ServiceCore & _core);
+
+    ~EndPoint ();
+
+    /** Call Manager **/
+    bool dial (const std::string & uri);
+    void hang_up ();
+    bool is_supported_uri (const std::string & uri);
+
+    void SetEchoCancellation (bool enabled);
+    bool GetEchoCancellation () const;
+
+    void SetMaximumJitter (unsigned max_val);
+    unsigned GetMaximumJitter () const;
+
+    void SetSilenceDetection (bool enabled);
+    bool GetSilenceDetection () const;
+
+    void set_reject_delay (unsigned delay);
+    unsigned get_reject_delay () const;
+
+    void set_auto_answer (bool enabled);
+    bool get_auto_answer () const;
+
+    void set_codecs (Ekiga::CodecList & codecs);
+    const Ekiga::CodecList & get_codecs () const;
+
+
+    /* Extended stuff, OPAL EndPoint specific */
+
+    void set_forward_on_busy (bool enabled);
+    bool get_forward_on_busy ();
+
+    void set_forward_on_no_answer (bool enabled);
+    bool get_forward_on_no_answer ();
+
+    void set_unconditional_forward (bool enabled);
+    bool get_unconditional_forward ();
+
+    void set_stun_server (const std::string & server);
+    void set_stun_enabled (bool);
+
+    boost::shared_ptr<Sip::EndPoint> get_sip_endpoint ();
+#ifdef HAVE_H323
+    boost::shared_ptr<H323::EndPoint> get_h323_endpoint ();
+#endif
+
+
+    /**/
+    struct VideoOptions
+      {
+        VideoOptions ()
+          : size (0),
+          maximum_frame_rate (0),
+          temporal_spatial_tradeoff (0),
+          maximum_bitrate (0),
+          maximum_transmitted_bitrate (0),
+          extended_video_roles (0) {};
+
+        unsigned size;
+        unsigned maximum_frame_rate;
+        unsigned temporal_spatial_tradeoff;
+        unsigned maximum_bitrate;
+        unsigned maximum_transmitted_bitrate;
+        unsigned extended_video_roles;
+      };
+
+    void SetVideoOptions (const VideoOptions & options);
+    void GetVideoOptions (VideoOptions & options) const;
+
+    boost::signals2::signal<void(Opal::Call *)> created_call;
+
+private:
+    boost::weak_ptr<Ekiga::CallCore> call_core;
+    boost::shared_ptr<Ekiga::NotificationCore> notification_core;
+
+    OpalCall *CreateCall (void *uri);
+    virtual void DestroyCall (OpalCall *);
+
+    virtual bool OnOpenMediaStream (OpalConnection &,
+                                    OpalMediaStream &);
+
+    virtual void OnClosedMediaStream (const OpalMediaStream &);
+
+    void GetAllowedFormats (OpalMediaFormatList & full_list);
+
+    PThread* stun_thread;
+    void HandleSTUNResult ();
+
+    void ReportSTUNError (const std::string error);
+
+    virtual PBoolean CreateVideoOutputDevice(const OpalConnection & connection,
+                                             const OpalMediaFormat & media_fmt,
+                                             PBoolean preview,
+                                             PVideoOutputDevice * & device,
+                                             PBoolean & auto_delete);
+
+    /* The various related endpoints */
+    GMPCSSEndpoint *pcssEP;
+
+    /* Various mutexes to ensure thread safeness around internal
+       variables */
+    PMutex manager_access_mutex;
+
+    Ekiga::CodecList codecs;
+
+    /* used to get the STUNDetector results */
+    GAsyncQueue* queue;
+    unsigned int patience;
+
+    std::string stun_server;
+    unsigned reject_delay;
+    bool forward_on_busy;
+    bool unconditional_forward;
+    bool forward_on_no_answer;
+    bool stun_enabled;
+    bool auto_answer;
+
+    boost::shared_ptr<Sip::EndPoint> sip_endpoint;
+#ifdef HAVE_H323
+    boost::shared_ptr<H323::EndPoint> h323_endpoint;
+#endif
+  };
+};
+#endif
diff --git a/lib/engine/components/opal/opal-process.cpp b/lib/engine/components/opal/process/opal-process.cpp
similarity index 71%
rename from lib/engine/components/opal/opal-process.cpp
rename to lib/engine/components/opal/process/opal-process.cpp
index 7f672e6..ecf7de0 100644
--- a/lib/engine/components/opal/opal-process.cpp
+++ b/lib/engine/components/opal/process/opal-process.cpp
@@ -47,18 +47,17 @@
 GnomeMeeting *GnomeMeeting::GM = 0;
 
 /* The main GnomeMeeting Class  */
-GnomeMeeting::GnomeMeeting (Ekiga::ServiceCore& _core)
-  : PProcess("", "", MAJOR_VERSION, MINOR_VERSION, BUILD_TYPE, BUILD_NUMBER),
-    core(_core)
+GnomeMeeting::GnomeMeeting ()
+        : PProcess("", "", MAJOR_VERSION, MINOR_VERSION, BUILD_TYPE, BUILD_NUMBER)
 {
   GM = this;
+  endpoint = NULL;
 }
 
 GnomeMeeting::~GnomeMeeting ()
 {
   std::cout << "PPROCESS END Start" << std::endl << std::flush;
   std::cout << "bank use count" << bank.use_count () << std::endl << std::flush;
-  std::cout << "call manager use count" << call_manager.use_count () << std::endl << std::flush;
 
   boost::shared_ptr<Ekiga::AccountCore> acore = account_core.lock ();
   // First remove all Opal::Accounts from our Bank.
@@ -67,20 +66,20 @@ GnomeMeeting::~GnomeMeeting ()
   // reference to the endpoints. Indeed they try to unregister from
   // presence when killed, and that gives a crash if the call manager
   // is already gone!
-  bank->clear ();
-  acore->remove_bank (bank);
+  /*
+     bank->clear ();
+     acore->remove_bank (bank);
 
-  boost::shared_ptr<Ekiga::PresenceCore> pcore = presence_core.lock ();
-  pcore->remove_presence_publisher (bank);
-  pcore->remove_cluster (bank);
-
-  core.remove (bank);
+     boost::shared_ptr<Ekiga::PresenceCore> pcore = presence_core.lock ();
+     pcore->remove_presence_publisher (bank);
+     pcore->remove_cluster (bank);
 
-  boost::shared_ptr<Ekiga::CallCore> ccore = call_core.lock ();
-  ccore->remove_manager (call_manager);
+     core.remove (bank);
 
-  std::cout << "bank use count" << bank.use_count () << std::endl << std::flush;
-  std::cout << "call manager use count" << call_manager.use_count () << std::endl << std::flush;
+     std::cout << "bank use count" << bank.use_count () << std::endl << std::flush;
+   */
+  if (endpoint)
+    delete endpoint;
 
   std::cout << "PPROCESS END END" << std::endl << std::flush;
 }
@@ -97,21 +96,24 @@ void GnomeMeeting::Main ()
 }
 
 
-void GnomeMeeting::Start ()
+void GnomeMeeting::Start (Ekiga::ServiceCore& core)
 {
-  call_core = boost::weak_ptr<Ekiga::CallCore> (core.get<Ekiga::CallCore> ("call-core"));
-
-  boost::shared_ptr<Ekiga::CallCore> ccore = call_core.lock ();
-  call_manager = boost::shared_ptr<Opal::CallManager> (new Opal::CallManager (core));
-  ccore->add_manager (call_manager);
+  endpoint = new Opal::EndPoint (core);
 
-  call_manager->ready.connect (boost::bind (&GnomeMeeting::on_ready, this,
+  //call_manager->ready.connect (boost::bind (&GnomeMeeting::on_ready, this,
 #ifdef HAVE_H323
-                                            (Opal::H323::EndPoint*) call_manager->FindEndPoint ("h323"),
+    //                                        (Opal::H323::EndPoint*) call_manager->FindEndPoint ("h323"),
 #endif
-                                            (Opal::Sip::EndPoint*) call_manager->FindEndPoint ("sip")));
+      //                                      (Opal::Sip::EndPoint*) call_manager->FindEndPoint ("sip")));
 
-  call_manager->setup ();
+  //call_manager->setup ();
+}
+
+
+Opal::EndPoint&
+GnomeMeeting::get_endpoint ()
+{
+  return *endpoint;
 }
 
 
@@ -121,6 +123,7 @@ void GnomeMeeting::on_ready (
 #endif
                              Opal::Sip::EndPoint* sip_endpoint)
 {
+  /*
   presence_core = boost::weak_ptr<Ekiga::PresenceCore> (core.get<Ekiga::PresenceCore> ("presence-core"));
   account_core = boost::weak_ptr<Ekiga::AccountCore> (core.get<Ekiga::AccountCore> ("account-core"));
 
@@ -136,4 +139,5 @@ void GnomeMeeting::on_ready (
   pcore->add_cluster (bank);
   core.add (bank);
   pcore->add_presence_publisher (bank);
+  */
 }
diff --git a/lib/engine/components/opal/opal-process.h b/lib/engine/components/opal/process/opal-process.h
similarity index 94%
rename from lib/engine/components/opal/opal-process.h
rename to lib/engine/components/opal/process/opal-process.h
index 26aca80..b7040ae 100644
--- a/lib/engine/components/opal/opal-process.h
+++ b/lib/engine/components/opal/process/opal-process.h
@@ -64,16 +64,18 @@ class GnomeMeeting : public PProcess
 
  public:
 
-  GnomeMeeting (Ekiga::ServiceCore& core);
+  GnomeMeeting ();
 
   ~GnomeMeeting ();
 
   void Main();
 
-  void Start ();
+  void Start (Ekiga::ServiceCore& core);
 
   static GnomeMeeting *Process ();
 
+  Opal::EndPoint& get_endpoint ();
+
  private:
 
   void on_ready (
@@ -83,14 +85,12 @@ class GnomeMeeting : public PProcess
                  Opal::Sip::EndPoint* sip_endpoint);
 
   static GnomeMeeting *GM;
-  boost::shared_ptr<Opal::CallManager> call_manager;
+  Opal::EndPoint *endpoint;
   boost::shared_ptr<Opal::Bank> bank;
 
   boost::weak_ptr<Ekiga::CallCore> call_core;
   boost::weak_ptr<Ekiga::PresenceCore> presence_core;
   boost::weak_ptr<Ekiga::AccountCore> account_core;
-
-  Ekiga::ServiceCore& core;
 };
 
 #endif
diff --git a/lib/engine/components/opal/pcss-endpoint.cpp 
b/lib/engine/components/opal/process/pcss-endpoint.cpp
similarity index 90%
rename from lib/engine/components/opal/pcss-endpoint.cpp
rename to lib/engine/components/opal/process/pcss-endpoint.cpp
index f1621d1..2b87b7f 100644
--- a/lib/engine/components/opal/pcss-endpoint.cpp
+++ b/lib/engine/components/opal/process/pcss-endpoint.cpp
@@ -35,13 +35,13 @@
  */
 
 #include "pcss-endpoint.h"
-#include "opal-call-manager.h"
+#include "opal-endpoint.h"
 
 
-GMPCSSEndpoint::GMPCSSEndpoint (Opal::CallManager & ep,
-                                Ekiga::ServiceCore & _core) 
-:   OpalPCSSEndPoint (ep),
-    core (_core)
+GMPCSSEndpoint::GMPCSSEndpoint (Opal::EndPoint & ep,
+                                Ekiga::ServiceCore & _core)
+:   OpalPCSSEndPoint(ep),
+    core(_core)
 {
 #ifdef WIN32
   SetSoundChannelBufferDepth (20);
diff --git a/lib/engine/components/opal/pcss-endpoint.h b/lib/engine/components/opal/process/pcss-endpoint.h
similarity index 92%
rename from lib/engine/components/opal/pcss-endpoint.h
rename to lib/engine/components/opal/process/pcss-endpoint.h
index dac53a8..10f712f 100644
--- a/lib/engine/components/opal/pcss-endpoint.h
+++ b/lib/engine/components/opal/process/pcss-endpoint.h
@@ -44,7 +44,7 @@
 #include <ep/pcss.h>
 
 namespace Opal {
-  class CallManager;
+  class EndPoint;
 }
 
 class GMPCSSEndpoint : public OpalPCSSEndPoint
@@ -52,11 +52,11 @@ class GMPCSSEndpoint : public OpalPCSSEndPoint
   PCLASSINFO (GMPCSSEndpoint, OpalPCSSEndPoint);
 
 public:
-  GMPCSSEndpoint (Opal::CallManager &manager, Ekiga::ServiceCore & _core);
+  GMPCSSEndpoint (Opal::EndPoint &endpoint, Ekiga::ServiceCore & _core);
 
   bool OnShowIncoming (const OpalPCSSConnection &connection);
 
-  bool OnShowOutgoing (const OpalPCSSConnection &connection);  
+  bool OnShowOutgoing (const OpalPCSSConnection &connection);
 
 private:
   Ekiga::ServiceCore & core;
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/process/sip-endpoint.cpp
similarity index 91%
rename from lib/engine/components/opal/sip-endpoint.cpp
rename to lib/engine/components/opal/process/sip-endpoint.cpp
index b278af3..4c6ab3b 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/process/sip-endpoint.cpp
@@ -106,19 +106,18 @@ namespace Opal {
 
 
 /* The class */
-Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager,
-                               const Ekiga::ServiceCore& _core): SIPEndPoint (_manager),
-                                                                 manager (_manager),
+Opal::Sip::EndPoint::EndPoint (Opal::EndPoint & _endpoint,
+                               const Ekiga::ServiceCore& _core): SIPEndPoint (_endpoint),
+                                                                 endpoint (_endpoint),
                                                                  core (_core)
 {
   boost::shared_ptr<Ekiga::ChatCore> chat_core = core.get<Ekiga::ChatCore> ("chat-core");
   boost::shared_ptr<Ekiga::PresenceCore> presence_core = core.get<Ekiga::PresenceCore> ("presence-core");
 
-  protocol_name = "sip";
   uri_prefix = "sip:";
 
-  dialect = boost::shared_ptr<SIP::Dialect>(new SIP::Dialect (presence_core, boost::bind 
(&Opal::Sip::EndPoint::send_message, this, _1, _2)));
-  chat_core->add_dialect (dialect);
+ // dialect = boost::shared_ptr<SIP::Dialect>(new SIP::Dialect (presence_core, boost::bind 
(&Opal::Sip::EndPoint::send_message, this, _1, _2)));
+//  chat_core->add_dialect (dialect);
 
   /* Timeouts */
   SetAckTimeout (PTimeInterval (0, 32));
@@ -132,8 +131,8 @@ Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager,
   SetUserAgent ("Ekiga/" PACKAGE_VERSION);
 
   /* Ready to take calls */
-  manager.AddRouteEntry("sip:.* = pc:*");
-  manager.AddRouteEntry("pc:.* = sip:<da>");
+  endpoint.AddRouteEntry("sip:.* = pc:*");
+  endpoint.AddRouteEntry("pc:.* = sip:<da>");
 
   /* NAT Binding */
   PTimeInterval timeout;
@@ -141,10 +140,8 @@ Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager,
   GetKeepAlive (timeout, type);
   SetKeepAlive(timeout, KeepAliveByOPTION);
 
-  settings = boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (SIP_SCHEMA));
-  settings->changed.connect (boost::bind (&EndPoint::setup, this, _1));
-
-  manager.ready.connect (boost::bind (&EndPoint::setup, this, ""));
+  std::cout << "FIXME" << std::endl;
+  //manager.ready.connect (boost::bind (&EndPoint::setup, this, ""));
 }
 
 
@@ -152,26 +149,6 @@ Opal::Sip::EndPoint::~EndPoint ()
 {
 }
 
-void
-Opal::Sip::EndPoint::setup (std::string setting)
-{
-  if (setting.empty () || setting == "listen-port")  {
-    set_listen_port (settings->get_int ("listen-port"));
-  }
-  if (setting.empty () || setting == "binding-timeout")  {
-    set_nat_binding_delay (settings->get_int ("binding-timeout"));
-  }
-  if (setting.empty () || setting == "outbound-proxy-host")  {
-    set_outbound_proxy (settings->get_string ("outbound-proxy-host"));
-  }
-  if (setting.empty () || setting == "dtmf-mode")  {
-    set_dtmf_mode (settings->get_enum ("dtmf-mode"));
-  }
-  if (setting.empty () || setting == "forward-host")  {
-    set_forward_uri (settings->get_string ("forward-host"));
-  }
-}
-
 
 bool
 Opal::Sip::EndPoint::send_message (const std::string & _uri,
@@ -218,7 +195,7 @@ Opal::Sip::EndPoint::dial (const std::string & uri)
   }
 
   PString token;
-  manager.SetUpCall ("pc:*", ustr.str(), token, (void*) ustr.str().c_str());
+  endpoint.SetUpCall ("pc:*", ustr.str(), token, (void*) ustr.str().c_str());
 
   return true;
 }
@@ -231,13 +208,6 @@ Opal::Sip::EndPoint::is_supported_uri (const std::string & uri)
 }
 
 
-const std::string&
-Opal::Sip::EndPoint::get_protocol_name () const
-{
-  return protocol_name;
-}
-
-
 void
 Opal::Sip::EndPoint::set_dtmf_mode (unsigned mode)
 {
@@ -275,18 +245,16 @@ Opal::Sip::EndPoint::get_dtmf_mode () const
 bool
 Opal::Sip::EndPoint::set_listen_port (unsigned port)
 {
-  unsigned udp_min, udp_max;
-  unsigned tcp_min, tcp_max;
-
-  manager.get_udp_ports (udp_min, udp_max);
-  manager.get_tcp_ports (tcp_min, tcp_max);
+  unsigned udp_min = endpoint.GetUDPPortBase ();
+  unsigned udp_max = endpoint.GetUDPPortMax ();
+  unsigned tcp_min = endpoint.GetTCPPortBase ();
+  unsigned tcp_max = endpoint.GetTCPPortMax ();
 
   const std::string protocols[] = { "udp", "tcp", "" };
   const unsigned ports[][2] = { { udp_min, udp_max }, { tcp_min, tcp_max } };
 
   if (port > 0) {
 
-    interfaces.clear ();
     RemoveListener (NULL);
     for (int i = 0 ; !protocols[i].empty () ; i++) {
 
@@ -304,8 +272,6 @@ Opal::Sip::EndPoint::set_listen_port (unsigned port)
           if (StartListeners (PStringArray (str.str ()))) {
 
             PTRACE (4, "Opal::Sip::EndPoint\tSet listen port to " << port << " (" << protocols[i] << ")");
-            listen_iface.port = port;
-            interfaces.push_back (listen_iface);
             break;
           }
 
@@ -313,8 +279,6 @@ Opal::Sip::EndPoint::set_listen_port (unsigned port)
         }
       }
       else {
-        listen_iface.port = port;
-        interfaces.push_back (listen_iface);
         PTRACE (4, "Opal::Sip::EndPoint\tSet listen port to " << port << " (" << protocols[i] << ")");
       }
     }
@@ -324,13 +288,6 @@ Opal::Sip::EndPoint::set_listen_port (unsigned port)
 }
 
 
-const Ekiga::CallProtocolManager::InterfaceList &
-Opal::Sip::EndPoint::get_interfaces () const
-{
-  return interfaces;
-}
-
-
 void
 Opal::Sip::EndPoint::set_forward_uri (const std::string & uri)
 {
@@ -444,7 +401,7 @@ Opal::Sip::EndPoint::OnRegistrationStatus (const RegistrationStatus & status)
   if (status.m_reason == SIP_PDU::Successful_OK) {
     account->handle_registration_event (status.m_wasRegistering?Account::Registered:Account::Unregistered,
                                         std::string (),
-                                        manager.AddPresentity (PURL (status.m_addressofRecord)));
+                                        endpoint.AddPresentity (PURL (status.m_addressofRecord)));
   }
   /* Registration or unregistration failure */
   else {
@@ -737,6 +694,8 @@ Opal::Sip::EndPoint::OnIncomingConnection (OpalConnection &connection,
     if (conn->GetCall().GetToken() != connection.GetCall().GetToken() && !conn->IsReleased ())
       busy = true;
   }
+  std::cout << "FIXME" << std::endl << std::flush;
+  /*
 
   if (!forward_uri.empty () && manager.get_unconditional_forward ())
     connection.ForwardCall (forward_uri);
@@ -759,7 +718,7 @@ Opal::Sip::EndPoint::OnIncomingConnection (OpalConnection &connection,
         call->set_reject_delay (manager.get_reject_delay ());
     }
   }
-
+*/
   return true;
 }
 
diff --git a/lib/engine/components/opal/sip-endpoint.h b/lib/engine/components/opal/process/sip-endpoint.h
similarity index 87%
rename from lib/engine/components/opal/sip-endpoint.h
rename to lib/engine/components/opal/process/sip-endpoint.h
index 342c3c0..fb0e3d1 100644
--- a/lib/engine/components/opal/sip-endpoint.h
+++ b/lib/engine/components/opal/process/sip-endpoint.h
@@ -38,11 +38,13 @@
 #ifndef _SIP_ENDPOINT_H_
 #define _SIP_ENDPOINT_H_
 
+#include <ptlib.h>
+
 #include <opal/opal.h>
+#include <sip/sip.h>
 
 #include "presence-core.h"
 #include "call-manager.h"
-#include "call-protocol-manager.h"
 #include "opal-bank.h"
 #include "sip-dialect.h"
 #include "call-core.h"
@@ -50,14 +52,12 @@
 
 #include "opal-call-manager.h"
 
-#include "ekiga-settings.h"
 
 namespace Opal {
 
   namespace Sip {
 
-    class EndPoint : public SIPEndPoint,
-                    public Ekiga::CallProtocolManager
+    class EndPoint : public SIPEndPoint
     {
       PCLASSINFO(EndPoint, SIPEndPoint);
 
@@ -66,34 +66,26 @@ namespace Opal {
       typedef std::list<std::string> domain_list;
       typedef std::list<std::string>::iterator domain_list_iterator;
 
-      EndPoint (CallManager& ep,
+      EndPoint (Opal::EndPoint& ep,
                const Ekiga::ServiceCore& core);
 
       ~EndPoint ();
 
-      /* Set up endpoint: all options or a specific setting */
-      void setup (std::string setting = "");
-
-
       /* Chat subsystem */
       bool send_message (const std::string & uri,
                          const Ekiga::Message::payload_type payload);
 
-
       /* CallProtocolManager */
       bool dial (const std::string & uri);
 
       bool is_supported_uri (const std::string & uri);
 
-
-      const std::string & get_protocol_name () const;
-
       void set_dtmf_mode (unsigned mode);
       unsigned get_dtmf_mode () const;
 
       bool set_listen_port (unsigned port);
 
-      const Ekiga::CallProtocolManager::InterfaceList & get_interfaces () const;
+      const Ekiga::CallManager::InterfaceList & get_interfaces () const;
 
 
       /* SIP EndPoint */
@@ -146,22 +138,19 @@ namespace Opal {
 
       // this object is really managed by opal,
       // so the way it is handled here is correct
-      CallManager & manager;
+      Opal::EndPoint & endpoint;
 
       std::map<std::string, PString> publications;
 
-      Ekiga::CallProtocolManager::Interface listen_iface;
+      Ekiga::CallManager::Interface listen_iface;
 
-      std::string protocol_name;
       std::string uri_prefix;
       std::string forward_uri;
       std::string outbound_proxy;
 
       boost::shared_ptr<SIP::Dialect> dialect;
 
-      boost::shared_ptr<Ekiga::Settings> settings;
       const Ekiga::ServiceCore & core;
-      Ekiga::CallProtocolManager::InterfaceList interfaces;
     };
   };
 };
diff --git a/lib/engine/components/opal/sip-call-manager.cpp b/lib/engine/components/opal/sip-call-manager.cpp
new file mode 100644
index 0000000..e5dea7e
--- /dev/null
+++ b/lib/engine/components/opal/sip-call-manager.cpp
@@ -0,0 +1,136 @@
+
+/* 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.
+ */
+
+
+/*
+ *                         sip-call-manager.cpp  -  description
+ *                         ------------------------------------
+ *   begin                : Sun Mar 15 2014
+ *   authors              : Damien Sandras
+ *   description          : This file contains the engine SIP CallManager.
+ *
+ */
+
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include "sip-call-manager.h"
+#include "sip-endpoint.h"
+
+
+/* The engine class */
+Opal::Sip::CallManager::CallManager (Ekiga::ServiceCore& _core,
+                               Opal::EndPoint& _endpoint) : Opal::CallManager (_core, _endpoint), 
protocol_name ("sip")
+{
+  /* Setup things */
+  Ekiga::SettingsCallback setup_cb = boost::bind (&Opal::Sip::CallManager::setup, this, _1);
+  sip_settings = Ekiga::SettingsPtr (new Ekiga::Settings (SIP_SCHEMA, setup_cb));
+
+  setup ();
+  std::cout << "hey: Created Opal::Sip::CallManager" << std::endl;
+}
+
+
+Opal::Sip::CallManager::~CallManager ()
+{
+  std::cout << "hey: Destroyed Opal::Sip::CallManager" << std::endl;
+}
+
+
+/* URIActionProvider Methods */
+void Opal::Sip::CallManager::pull_actions (Ekiga::Actor & actor,
+                                     G_GNUC_UNUSED const std::string & name,
+                                     const std::string & uri)
+{
+  if (is_supported_uri (uri)) {
+    add_action (actor, Ekiga::ActionPtr (new Ekiga::Action ("call", _("Call"), boost::bind 
(&Opal::Sip::CallManager::dial, this, uri))));
+  }
+}
+
+
+const std::string & Opal::Sip::CallManager::get_protocol_name () const
+{
+  return protocol_name;
+}
+
+
+const Ekiga::CallManager::InterfaceList Opal::Sip::CallManager::get_interfaces () const
+{
+  Ekiga::CallManager::InterfaceList ilist;
+
+  boost::shared_ptr<Opal::Sip::EndPoint> sip_endpoint = endpoint.get_sip_endpoint ();
+  if (!sip_endpoint)
+    return ilist;
+
+  OpalListenerList listeners = sip_endpoint->GetListeners ();
+  for (int i = 0 ; i < listeners.GetSize () ; i++) {
+    Ekiga::CallManager::Interface iface;
+    PIPSocket::Address address;
+    WORD port;
+    PString proto_prefix = listeners[i].GetLocalAddress ().GetProtoPrefix ();
+    listeners[i].GetLocalAddress ().GetIpAndPort (address, port);
+
+    iface.voip_protocol = get_protocol_name ();
+    iface.id = "*";
+    iface.protocol = (const char*) proto_prefix.Left (proto_prefix.GetLength () - 1); // Strip final $ 
delimiter
+    iface.port = (unsigned int) port;
+
+    ilist.push_back (iface);
+  }
+
+  return ilist;
+}
+
+
+void Opal::Sip::CallManager::setup (const std::string & setting)
+{
+  std::cout << "In Opal::Sip::CallManager::setup " << std::endl;
+  boost::shared_ptr<Opal::Sip::EndPoint> sip_endpoint = endpoint.get_sip_endpoint ();
+  if (sip_endpoint) {
+    if (setting.empty () || setting == "listen-port")  {
+      sip_endpoint->set_listen_port (sip_settings->get_int ("listen-port"));
+    }
+    if (setting.empty () || setting == "binding-timeout")  {
+      sip_endpoint->set_nat_binding_delay (sip_settings->get_int ("binding-timeout"));
+    }
+    if (setting.empty () || setting == "outbound-proxy-host")  {
+      sip_endpoint->set_outbound_proxy (sip_settings->get_string ("outbound-proxy-host"));
+    }
+
+    if (setting.empty () || setting == "dtmf-mode")  {
+      sip_endpoint->set_dtmf_mode (sip_settings->get_enum ("dtmf-mode"));
+    }
+
+    if (setting.empty () || setting == "forward-host")  {
+      sip_endpoint->set_forward_uri (sip_settings->get_string ("forward-host"));
+    }
+  }
+
+  Opal::CallManager::setup (setting);
+}
diff --git a/lib/engine/components/opal/sip-call-manager.h b/lib/engine/components/opal/sip-call-manager.h
new file mode 100644
index 0000000..112a58b
--- /dev/null
+++ b/lib/engine/components/opal/sip-call-manager.h
@@ -0,0 +1,90 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2015 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.
+ */
+
+
+/*
+ *                         sip-call-manager.h  -  description
+ *                         ----------------------------------
+ *   begin                : Sun Mar 15 2014
+ *   authors              : Damien Sandras
+ *   description          : This file contains the engine SIP CallManager.
+ *
+ */
+
+
+#ifndef __SIP_CALL_MANAGER_H_
+#define __SIP_CALL_MANAGER_H_
+
+#include "opal-call-manager.h"
+#include "opal-endpoint.h"
+
+#include "ekiga-settings.h"
+
+namespace Opal {
+
+  namespace Sip {
+
+    /* This is the engine CallManager implementation.
+     * It uses the Opal::Manager object to implement the engine
+     * CallManager interface.
+     */
+    class CallManager :
+        public Opal::CallManager,
+        public Ekiga::URIActionProvider
+    {
+  public:
+      CallManager (Ekiga::ServiceCore& core,
+                   Opal::EndPoint& endpoint);
+      ~CallManager ();
+
+      /* URIActionProvider Methods */
+      void pull_actions (Ekiga::Actor & actor,
+                         const std::string & name,
+                         const std::string & uri);
+
+      /* CallManager methods we implement */
+      const std::string & get_protocol_name () const;
+
+      const Ekiga::CallManager::InterfaceList get_interfaces () const;
+
+      /*
+         void set_dtmf_mode (unsigned mode);
+         unsigned get_dtmf_mode ();
+         bool set_listen_port (unsigned port);
+         const InterfaceList & get_interfaces () const;
+       */
+
+      /* Set up endpoint: all options or a specific setting */
+      void setup (const std::string & setting = "");
+
+  private:
+      Ekiga::SettingsPtr sip_settings;
+      std::string protocol_name;
+    };
+  };
+};
+#endif
diff --git a/lib/engine/protocol/call-core.cpp b/lib/engine/protocol/call-core.cpp
index 28fc0fc..c89e3eb 100644
--- a/lib/engine/protocol/call-core.cpp
+++ b/lib/engine/protocol/call-core.cpp
@@ -49,11 +49,18 @@ CallCore::CallCore (boost::shared_ptr<Ekiga::FriendOrFoe> iff_): iff(iff_)
 }
 
 
-void CallCore::add_manager (boost::shared_ptr<CallManager> manager)
+CallCore::~CallCore ()
 {
-  manager_added (manager);
+#if DEBUG
+  std::cout << "Ekiga::CallCore: Destructor invoked" << std::endl << std::flush;
+#endif
+}
+
 
+void CallCore::add_manager (boost::shared_ptr<CallManager> manager)
+{
   add_object (manager);
+  manager_added (manager);
 }
 
 
diff --git a/lib/engine/protocol/call-core.h b/lib/engine/protocol/call-core.h
index 5239a28..9b6df8f 100644
--- a/lib/engine/protocol/call-core.h
+++ b/lib/engine/protocol/call-core.h
@@ -26,7 +26,7 @@
 /*
  *                         call-core.h  -  description
  *                         ------------------------------------------
- *   begin                : written in 2007 by Damien Sandras 
+ *   begin                : written in 2007 by Damien Sandras
  *   copyright            : (c) 2007 by Damien Sandras
  *   description          : declaration of the interface of a call core.
  *                          A call core manages CallManagers.
@@ -45,7 +45,6 @@
 #include "friend-or-foe/friend-or-foe.h"
 #include "call.h"
 #include "call-manager.h"
-#include "call-protocol-manager.h"
 #include "contact-core.h"
 
 #include <boost/smart_ptr.hpp>
@@ -65,6 +64,14 @@ namespace Ekiga
 
   class CallManager;
 
+  /* The CallCore is handling Calls from the various CallManagers it supports.
+   *
+   * This is the only objective of the CallCore.
+   *
+   * Settings must be handled by the CallManagers, not by the CallCore.
+   * This is true even in the case of settings which are common to several
+   * CallManagers.
+   */
   class CallCore:
     public Service,
     protected RefLister<CallManager>
@@ -77,6 +84,7 @@ namespace Ekiga
       /** The constructor
        */
       CallCore (boost::shared_ptr<Ekiga::FriendOrFoe> iff);
+      ~CallCore ();
 
 
       /*** Service Implementation ***/
diff --git a/lib/engine/protocol/call-manager.h b/lib/engine/protocol/call-manager.h
index 659e20b..35a7e2b 100644
--- a/lib/engine/protocol/call-manager.h
+++ b/lib/engine/protocol/call-manager.h
@@ -44,7 +44,7 @@
 
 #include <boost/smart_ptr.hpp>
 
-#include "call-protocol-manager.h"
+#include "live-object.h"
 #include "codec-description.h"
 
 namespace Ekiga
@@ -55,14 +55,20 @@ namespace Ekiga
  * @{
  */
 
-  class CallManager :
-    public Ekiga::LiveObject
+  class CallManager : public Ekiga::LiveObject
   {
-
     public:
+    class Interface
+    {
+        public:
+        std::string voip_protocol;
+        std::string protocol;
+        std::string id;
+        bool publish;
+        unsigned port;
+    };
+    typedef std::list<Interface> InterfaceList;
 
-    typedef std::set<boost::shared_ptr<CallProtocolManager> >::iterator iterator;
-    typedef std::set<boost::shared_ptr<CallProtocolManager> >::const_iterator const_iterator;
 
     /* The constructor
      */
@@ -72,44 +78,6 @@ namespace Ekiga
      */
     virtual ~CallManager () {}
 
-    /** Add a CallProtocolManager to the CallManager.
-     * @param The manager to be added.
-     */
-    void add_protocol_manager (boost::shared_ptr<CallProtocolManager> manager);
-
-    /** Remove a CallProtocolManager from the CallManager.
-     * @param The manager to be removed.
-     */
-    void remove_protocol_manager (boost::shared_ptr<CallProtocolManager> manager);
-
-    /** Return a pointer to a CallProtocolManager of the CallManager.
-     * @param protocol is the protcol name.
-     * @return a pointer to the CallProtocolManager or NULL if none.
-     */
-    boost::shared_ptr<CallProtocolManager> get_protocol_manager (const std::string &protocol) const;
-
-    /** Return iterator to beginning
-     * @return iterator to beginning
-     */
-    iterator begin ();
-    const_iterator begin () const;
-
-    /** Return iterator to end
-     * @return iterator to end
-     */
-    iterator end ();
-    const_iterator end () const;
-
-    /** This signal is emitted when a Ekiga::CallProtocolManager has been
-     * added to the CallManager.
-     */
-    boost::signals2::signal<void(boost::shared_ptr<CallProtocolManager>)> manager_added;
-
-    /** This signal is emitted when a Ekiga::CallProtocolManager has been
-     * removed from the CallManager.
-     */
-    boost::signals2::signal<void(boost::shared_ptr<CallProtocolManager>)> manager_removed;
-
 
     /*
      * CALL MANAGEMENT
@@ -137,16 +105,16 @@ namespace Ekiga
      * PROTOCOL INFORMATION
      */
 
-    /**
+    /** Return the protocol name
      * @return the protocol name
      */
-    const std::list<std::string> get_protocol_names () const;
+    virtual const std::string & get_protocol_name () const = 0;
 
     /**
-     * @return the interface on which we are accepting calls. Generally,
+     * @return the interfaces on which we are accepting calls. Generally,
      * under the form protocol:IP:port.
      */
-    const CallProtocolManager::InterfaceList get_interfaces () const;
+    virtual const InterfaceList get_interfaces () const = 0;
 
 
     /*
@@ -234,9 +202,6 @@ namespace Ekiga
      * MISC
      */
     boost::signals2::signal<void(void)> ready;
-
-    private:
-    std::set<boost::shared_ptr<CallProtocolManager> > managers;
   };
 
   /**
diff --git a/lib/settings/ekiga-settings.h b/lib/settings/ekiga-settings.h
index 82c327a..cce7598 100644
--- a/lib/settings/ekiga-settings.h
+++ b/lib/settings/ekiga-settings.h
@@ -211,6 +211,20 @@ public:
       g_array_free (array, TRUE);
     }
 
+    void get_int_tuple (const std::string & key, int & a, int & b)
+    {
+      std::string  s = get_string (key);
+      gchar **couple = NULL;
+      if (!s.empty ())
+        couple = g_strsplit (s.c_str (), ":", 2);
+      if (couple && couple [0])
+        a = atoi (couple [0]);
+      if (couple && couple [1])
+        b = atoi (couple [1]);
+
+      g_strfreev (couple);
+    }
+
     boost::signals2::signal<void(std::string)> changed;
 
 private:
diff --git a/plugins/avahi/avahi-publisher.cpp b/plugins/avahi/avahi-publisher.cpp
index 35cd4fc..3699452 100644
--- a/plugins/avahi/avahi-publisher.cpp
+++ b/plugins/avahi/avahi-publisher.cpp
@@ -91,7 +91,7 @@ Avahi::PresencePublisher::publish (G_GNUC_UNUSED const Ekiga::PersonalDetails& d
 {
   if (group != NULL) {
 
-    Ekiga::CallProtocolManager::InterfaceList interfaces;
+    Ekiga::CallManager::InterfaceList interfaces;
     AvahiStringList* txt_record = NULL;
 
     txt_record = prepare_txt_record ();
@@ -99,12 +99,12 @@ Avahi::PresencePublisher::publish (G_GNUC_UNUSED const Ekiga::PersonalDetails& d
         iter != call_core.end ();
         ++iter) {
 
-      Ekiga::CallProtocolManager::InterfaceList ints = (*iter)->get_interfaces ();
+      Ekiga::CallManager::InterfaceList ints = (*iter)->get_interfaces ();
       interfaces.insert (interfaces.begin (), ints.begin (), ints.end ());
 
     }
 
-    for (Ekiga::CallProtocolManager::InterfaceList::const_iterator iter = interfaces.begin ();
+    for (Ekiga::CallManager::InterfaceList::const_iterator iter = interfaces.begin ();
         iter != interfaces.end ();
         ++iter) {
 
@@ -236,21 +236,21 @@ Avahi::PresencePublisher::entry_group_callback (AvahiEntryGroup* group_,
 void
 Avahi::PresencePublisher::add_services ()
 {
-  Ekiga::CallProtocolManager::InterfaceList interfaces;
+  Ekiga::CallManager::InterfaceList interfaces;
   AvahiStringList* txt_record = NULL;
 
   for (Ekiga::CallCore::iterator iter = call_core.begin ();
        iter != call_core.end ();
        ++iter) {
 
-    Ekiga::CallProtocolManager::InterfaceList ints = (*iter)->get_interfaces ();
+    Ekiga::CallManager::InterfaceList ints = (*iter)->get_interfaces ();
     interfaces.insert (interfaces.begin (), ints.begin (), ints.end ());
 
   }
 
   txt_record = prepare_txt_record ();
 
-  for (Ekiga::CallProtocolManager::InterfaceList::const_iterator iter = interfaces.begin ();
+  for (Ekiga::CallManager::InterfaceList::const_iterator iter = interfaces.begin ();
        iter != interfaces.end ();
        ++iter) {
 



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