[ekiga] Fixed bug #576480 -- Some files inexplicably #include "engine.h"



commit 56f30cdb25b3933bcaef4d14c3c77ac0a1e615ba
Author: Julien Puydt <jpuydt gnome org>
Date:   Sun Sep 26 11:32:20 2010 +0200

    Fixed bug #576480 -- Some files inexplicably #include "engine.h"
    
    The idea is that we now push our plugins to opal explicitly,
    instead of relying on magic initializations and linker hacks.

 lib/Makefile.am                                   |    4 +-
 lib/engine/components/opal/opal-audio.cpp         |   36 ------
 lib/engine/components/opal/opal-main.cpp          |    5 +-
 lib/engine/components/opal/opal-plugins-hacks.cpp |  138 +++++++++++++++++++++
 lib/engine/components/opal/opal-plugins-hacks.h   |   40 ++++++
 lib/engine/components/opal/opal-videoinput.cpp    |   37 ------
 lib/engine/components/opal/opal-videoinput.h      |    5 +-
 lib/engine/components/opal/opal-videooutput.cpp   |   32 -----
 8 files changed, 187 insertions(+), 110 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 2d5ada8..b0ed30d 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -512,7 +512,9 @@ libekiga_la_SOURCES += \
 	$(components_dir)/opal/opal-videoinput.h \
 	$(components_dir)/opal/opal-videoinput.cpp \
 	$(components_dir)/opal/opal-videooutput.h \
-	$(components_dir)/opal/opal-videooutput.cpp
+	$(components_dir)/opal/opal-videooutput.cpp \
+	$(components_dir)/opal/opal-plugins-hacks.h \
+	$(components_dir)/opal/opal-plugins-hacks.cpp
 
 if HAVE_H323
 libekiga_la_SOURCES += \
diff --git a/lib/engine/components/opal/opal-audio.cpp b/lib/engine/components/opal/opal-audio.cpp
index d1e8d47..d4badc9 100644
--- a/lib/engine/components/opal/opal-audio.cpp
+++ b/lib/engine/components/opal/opal-audio.cpp
@@ -36,45 +36,9 @@
  *
  */
 
-
-#define P_FORCE_STATIC_PLUGIN
-
 #pragma implementation "opal-audio.h"
 
 #include "opal-audio.h"
-#include "engine.h"
-
-namespace OpalLinkerHacks {
-  int loadOpalAudio;
-}
-
-/* Plugin definition */
-class PSoundChannel_EKIGA_PluginServiceDescriptor 
-: public PDevicePluginServiceDescriptor
-{
-  public:
-    virtual PObject *CreateInstance (int) const 
-      {
-	return new PSoundChannel_EKIGA (*(engine_get_service_core ())); 
-      }
-    
-    
-    virtual PStringArray GetDeviceNames(int) const 
-      { 
-	return PStringList("EKIGA"); 
-      }
-    
-    virtual bool ValidateDeviceName (const PString & deviceName, 
-				     int) const 
-      { 
-	return deviceName.Find("EKIGA") == 0; 
-      }
-} PSoundChannel_EKIGA_descriptor;
-
-PCREATE_PLUGIN(EKIGA, PSoundChannel, &PSoundChannel_EKIGA_descriptor);
-
-
-///////////////////////////////////////////////////////////////////////////////
 
 PSoundChannel_EKIGA::PSoundChannel_EKIGA (Ekiga::ServiceCore & _core):
   core (_core),
diff --git a/lib/engine/components/opal/opal-main.cpp b/lib/engine/components/opal/opal-main.cpp
index d28b7ba..2a2bedf 100644
--- a/lib/engine/components/opal/opal-main.cpp
+++ b/lib/engine/components/opal/opal-main.cpp
@@ -54,6 +54,7 @@
 #include "opal-account.h"
 #include "opal-bank.h"
 #include "opal-call-manager.h"
+#include "opal-plugins-hacks.h"
 
 #include "sip-endpoint.h"
 #define SIP_KEY "/apps/" PACKAGE_NAME "/protocols/sip/"
@@ -151,9 +152,7 @@ struct OPALSpark: public Ekiga::Spark
 
       presence_core->add_supported_uri (&is_supported_address); //FIXME
 
-      OpalLinkerHacks::loadOpalVideoInput = 1;
-      OpalLinkerHacks::loadOpalVideoOutput = 1;
-      OpalLinkerHacks::loadOpalAudio = 1;
+      hook_ekiga_plugins_to_opal (core);
 
       result = true;
     }
diff --git a/lib/engine/components/opal/opal-plugins-hacks.cpp b/lib/engine/components/opal/opal-plugins-hacks.cpp
new file mode 100644
index 0000000..2c83994
--- /dev/null
+++ b/lib/engine/components/opal/opal-plugins-hacks.cpp
@@ -0,0 +1,138 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2010 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-plugins-hacks.cpp  -  description
+ *                         --------------------------------
+ *   begin                : Sun Sept 26 2010
+ *   copyright            : (C) 2010 by Julien Puydt
+ *   description          : Code to connect the various ekiga plugins to opal
+ *
+ */
+
+/*
+ * Notice that we use engine_get_service_core, which is an awful hack to get
+ * a static object -- it should be possible to register those plugins at
+ * runtime through a function, getting the necessary service core directly.
+ */
+
+#include "opal-audio.h"
+#include "opal-videoinput.h"
+#include "opal-videooutput.h"
+
+// we first declare the three plugin service descriptor classes
+
+class PSoundChannel_EKIGA_PluginServiceDescriptor : public PDevicePluginServiceDescriptor
+{
+public:
+
+  PSoundChannel_EKIGA_PluginServiceDescriptor (Ekiga::ServiceCore& core_): core(core_)
+  { }
+
+  virtual PObject* CreateInstance (int) const
+  { return new PSoundChannel_EKIGA (core); }
+
+
+  virtual PStringArray GetDeviceNames(int) const
+  { return PStringList ("EKIGA"); }
+
+  virtual bool ValidateDeviceName (const PString & deviceName,
+				   int) const
+  { return deviceName.Find ("EKIGA") == 0; }
+
+private:
+
+  Ekiga::ServiceCore& core;
+
+};
+
+class PVideoInputDevice_EKIGA_PluginServiceDescriptor : public PDevicePluginServiceDescriptor
+{
+public:
+
+  PVideoInputDevice_EKIGA_PluginServiceDescriptor (Ekiga::ServiceCore &core_): core(core_)
+  {}
+
+  virtual PObject* CreateInstance (int) const
+  { return new PVideoInputDevice_EKIGA (core); }
+
+
+  virtual PStringArray GetDeviceNames (int) const
+  { return PStringList ("EKIGA"); }
+
+  virtual bool ValidateDeviceName (const PString & deviceName,
+				   int) const
+  { return deviceName.Find ("EKIGA") == 0; }
+
+private:
+
+  Ekiga::ServiceCore& core;
+};
+
+class PVideoOutputDevice_EKIGA_PluginServiceDescriptor : public PDevicePluginServiceDescriptor
+{
+public:
+
+  PVideoOutputDevice_EKIGA_PluginServiceDescriptor (Ekiga::ServiceCore& core_): core(core_)
+  {}
+
+  virtual PObject *CreateInstance (int) const
+  { return new PVideoOutputDevice_EKIGA (core); }
+
+  virtual PStringArray GetDeviceNames (int) const
+  { return PStringList("EKIGA"); }
+
+  virtual bool ValidateDeviceName (const PString & deviceName,
+				   int) const
+  { return deviceName.Find ("EKIGA") == 0; }
+
+private:
+
+  Ekiga::ServiceCore& core;
+};
+
+// now, let's rock :
+
+boost::shared_ptr<PSoundChannel_EKIGA_PluginServiceDescriptor> audio;
+boost::shared_ptr<PVideoInputDevice_EKIGA_PluginServiceDescriptor> videoinput;
+boost::shared_ptr<PVideoOutputDevice_EKIGA_PluginServiceDescriptor> videooutput;
+
+void
+hook_ekiga_plugins_to_opal (Ekiga::ServiceCore& core)
+{
+  audio = boost::shared_ptr<PSoundChannel_EKIGA_PluginServiceDescriptor> (new PSoundChannel_EKIGA_PluginServiceDescriptor (core));
+  videoinput = boost::shared_ptr<PVideoInputDevice_EKIGA_PluginServiceDescriptor> (new PVideoInputDevice_EKIGA_PluginServiceDescriptor (core));
+  videooutput = boost::shared_ptr<PVideoOutputDevice_EKIGA_PluginServiceDescriptor> (new PVideoOutputDevice_EKIGA_PluginServiceDescriptor (core));
+
+  PPluginManager::GetPluginManager().RegisterService ("EKIGA", "PSoundChannel",
+						      audio.get ());
+  PPluginManager::GetPluginManager().RegisterService ("EKIGA", "PVideoInputDevice",
+						      videoinput.get ());
+  PPluginManager::GetPluginManager().RegisterService ("EKIGA", "PVideoOutputDevice",
+						      videooutput.get ());
+}
diff --git a/lib/engine/components/opal/opal-plugins-hacks.h b/lib/engine/components/opal/opal-plugins-hacks.h
new file mode 100644
index 0000000..109a875
--- /dev/null
+++ b/lib/engine/components/opal/opal-plugins-hacks.h
@@ -0,0 +1,40 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2010 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-plugins-hacks.h  -  description
+ *                         --------------------------------
+ *   begin                : Sun Sept 26 2010
+ *   copyright            : (C) 2010 by Julien Puydt
+ *   description          : Code to connect the various ekiga plugins to opal
+ *
+ */
+
+#include "services.h"
+
+void hook_ekiga_plugins_to_opal (Ekiga::ServiceCore& core);
diff --git a/lib/engine/components/opal/opal-videoinput.cpp b/lib/engine/components/opal/opal-videoinput.cpp
index 4a168b7..ea81867 100644
--- a/lib/engine/components/opal/opal-videoinput.cpp
+++ b/lib/engine/components/opal/opal-videoinput.cpp
@@ -36,44 +36,7 @@
  *
  */
 
-#define P_FORCE_STATIC_PLUGIN
-
-#include <ptbuildopts.h>
-#include <ptlib.h>
-#include <opal/manager.h>
-
 #include "opal-videoinput.h"
-#include "engine.h"
-
-
-namespace OpalLinkerHacks {
-  int loadOpalVideoInput;
-}
-
-/* Plugin definition */
-class PVideoInputDevice_EKIGA_PluginServiceDescriptor 
-: public PDevicePluginServiceDescriptor
-{
-  public:
-    virtual PObject *CreateInstance (int) const 
-      {
-	return new PVideoInputDevice_EKIGA (*(engine_get_service_core ())); 
-      }
-    
-    
-    virtual PStringArray GetDeviceNames(int) const 
-      { 
-	return PStringList("EKIGA"); 
-      }
-    
-    virtual bool ValidateDeviceName (const PString & deviceName, 
-				     int) const 
-      { 
-	return deviceName.Find("EKIGA") == 0; 
-      }
-} PVideoInputDevice_EKIGA_descriptor;
-
-PCREATE_PLUGIN(EKIGA, PVideoInputDevice, &PVideoInputDevice_EKIGA_descriptor);
 
 int PVideoInputDevice_EKIGA::devices_nbr = 0;
 
diff --git a/lib/engine/components/opal/opal-videoinput.h b/lib/engine/components/opal/opal-videoinput.h
index b9192e5..4d801c0 100644
--- a/lib/engine/components/opal/opal-videoinput.h
+++ b/lib/engine/components/opal/opal-videoinput.h
@@ -40,8 +40,11 @@
 #ifndef _EKIGA_VIDEO_INPUT_H_
 #define _EKIGA_VIDEO_INPUT_H_
 
-#include "videoinput-core.h"
+#include <ptbuildopts.h>
+#include <ptlib.h>
+#include <opal/manager.h>
 
+#include "videoinput-core.h"
 
 class PVideoInputDevice_EKIGA : public PVideoInputDevice 
 {
diff --git a/lib/engine/components/opal/opal-videooutput.cpp b/lib/engine/components/opal/opal-videooutput.cpp
index 41dadf6..a3254d8 100644
--- a/lib/engine/components/opal/opal-videooutput.cpp
+++ b/lib/engine/components/opal/opal-videooutput.cpp
@@ -35,47 +35,15 @@
  *
  */
 
-#define P_FORCE_STATIC_PLUGIN 
-
 #include <ptbuildopts.h>
 #include <ptlib.h>
 #include <opal/manager.h>
 
 #include "opal-videooutput.h"
-#include "engine.h"
-
-namespace OpalLinkerHacks {
-  int loadOpalVideoOutput;
-}
 
 int PVideoOutputDevice_EKIGA::devices_nbr = 0;
 
 PMutex PVideoOutputDevice_EKIGA::videoDisplay_mutex;
-/* Plugin definition */
-class PVideoOutputDevice_EKIGA_PluginServiceDescriptor 
-: public PDevicePluginServiceDescriptor
-{
-  public:
-    virtual PObject *CreateInstance (int) const 
-      {
-	return new PVideoOutputDevice_EKIGA (*(engine_get_service_core ())); 
-      }
-    
-    
-    virtual PStringArray GetDeviceNames(int) const 
-      { 
-	return PStringList("EKIGA"); 
-      }
-    
-    virtual bool ValidateDeviceName (const PString & deviceName, 
-				     int) const 
-      { 
-	return deviceName.Find("EKIGA") == 0; 
-      }
-} PVideoOutputDevice_EKIGA_descriptor;
-
-PCREATE_PLUGIN(EKIGA, PVideoOutputDevice, &PVideoOutputDevice_EKIGA_descriptor);
-
 
 /* The Methods */
 PVideoOutputDevice_EKIGA::PVideoOutputDevice_EKIGA (Ekiga::ServiceCore & _core)



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