ekiga r5991 - in trunk: . lib/engine lib/engine/hal lib/engine/hal/dbus lib/engine/hal/skel



Author: mschneid
Date: Sat Feb 23 20:46:39 2008
New Revision: 5991
URL: http://svn.gnome.org/viewvc/ekiga?rev=5991&view=rev

Log:
Add an initial implementation of a hal-core, and an
implementation of a HalManager listening on dbus for
added/removed devices and network interfaces going up
and down. Deactivated for now, some more work is needed,



Added:
   trunk/lib/engine/hal/
   trunk/lib/engine/hal/Makefile.am
   trunk/lib/engine/hal/dbus/
   trunk/lib/engine/hal/dbus/Makefile.am
   trunk/lib/engine/hal/dbus/hal-main-dbus.cpp
   trunk/lib/engine/hal/dbus/hal-main-dbus.h
   trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp
   trunk/lib/engine/hal/dbus/hal-manager-dbus.h
   trunk/lib/engine/hal/dbus/hal-marshal.list
   trunk/lib/engine/hal/skel/
   trunk/lib/engine/hal/skel/Makefile.am
   trunk/lib/engine/hal/skel/hal-core.cpp
   trunk/lib/engine/hal/skel/hal-core.h
   trunk/lib/engine/hal/skel/hal-manager.h
Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/lib/engine/Makefile.am
   trunk/lib/engine/engine.cpp

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Sat Feb 23 20:46:39 2008
@@ -692,6 +692,9 @@
 lib/engine/vidinput/skel/Makefile
 lib/engine/vidinput/mlogo/Makefile
 lib/engine/vidinput/ptlib/Makefile
+lib/engine/hal/Makefile
+lib/engine/hal/skel/Makefile
+lib/engine/hal/dbus/Makefile
 lib/engine/gui/Makefile
 lib/engine/gui/gtk-core/Makefile
 lib/engine/gui/gtk-frontend/Makefile

Modified: trunk/lib/engine/Makefile.am
==============================================================================
--- trunk/lib/engine/Makefile.am	(original)
+++ trunk/lib/engine/Makefile.am	Sat Feb 23 20:46:39 2008
@@ -1,4 +1,4 @@
-SUBDIRS = framework addressbook presence gui protocol display vidinput components
+SUBDIRS = framework addressbook presence gui protocol display vidinput hal components
 
 noinst_LTLIBRARIES = libekiga_engine.la
 
@@ -18,6 +18,7 @@
 	-I$(top_srcdir)/lib/engine/presence/local-roster		\
 	-I$(top_srcdir)/lib/engine/display/skel				\
 	-I$(top_srcdir)/lib/engine/vidinput/skel			\
+	-I$(top_srcdir)/lib/engine/hal/skel				\
 	-I$(top_srcdir)/lib/engine/components/gmconf-personal-details
 
 # XVideo/X
@@ -42,6 +43,11 @@
 INCLUDES +=                                             \
 	-I$(top_srcdir)/lib/engine/vidinput/ptlib
 
+# DBus / HALd
+if HAVE_DBUS
+INCLUDES +=                                             \
+	-I$(top_srcdir)/lib/engine/hal/dbus
+endif
 
 libekiga_engine_la_SOURCES = engine.h engine.cpp
 
@@ -60,6 +66,7 @@
 	$(top_builddir)/lib/engine/presence/local-roster/liblocal-roster.la 				\
 	$(top_builddir)/lib/engine/display/skel/libgmdisplay.la						\
 	$(top_builddir)/lib/engine/vidinput/skel/libgmvidinput.la					\
+	$(top_builddir)/lib/engine/hal/skel/libgmhal.la					\
 	$(top_builddir)/lib/engine/components/gmconf-personal-details/libgmconfpersonaldetails.la	\
 	$(AM_LIBS)
 
@@ -71,6 +78,12 @@
 libekiga_engine_la_LIBADD += \
 	$(top_builddir)/lib/engine/vidinput/ptlib/libgmvidinput-ptlib.la
 
+# DBus/HALd
+if HAVE_DBUS
+libekiga_engine_la_LIBADD += \
+	$(top_builddir)/lib/engine/hal/dbus/libgmhal-dbus.la
+endif
+
 # XVideo/X
 if !WIN32
 libekiga_engine_la_LIBADD += \

Modified: trunk/lib/engine/engine.cpp
==============================================================================
--- trunk/lib/engine/engine.cpp	(original)
+++ trunk/lib/engine/engine.cpp	Sat Feb 23 20:46:39 2008
@@ -46,6 +46,7 @@
 #include "call-core.h"
 #include "display-core.h"
 #include "vidinput-core.h"
+#include "hal-core.h"
 #include "history-main.h"
 #include "local-roster-main.h"
 #include "local-roster-bridge.h"
@@ -65,6 +66,10 @@
 
 #include "vidinput-main-ptlib.h"
 
+#ifdef HAVE_DBUS
+#include "hal-main-dbus.h"
+#endif
+
 #include "opal-main.h"
 
 #ifdef HAVE_AVAHI
@@ -92,12 +97,14 @@
   Ekiga::CallCore *call_core = new Ekiga::CallCore;
   Ekiga::DisplayCore *display_core = new Ekiga::DisplayCore;
   Ekiga::VidInputCore *vidinput_core = new Ekiga::VidInputCore(*display_core);
+  Ekiga::HalCore *hal_core = new Ekiga::HalCore;
 
   core->add (*contact_core);
   core->add (*presence_core);
   core->add (*call_core);
   core->add (*display_core);
   core->add (*vidinput_core);
+  core->add (*hal_core);
   core->add (*runtime);
 
   if (!gmconf_personal_details_init (*core, &argc, &argv)) {
@@ -129,6 +136,14 @@
     return;
   }
 
+#ifdef HAVE_DBUS
+// Do not use the dbus HAL for now until the main loop is moved
+//  if (!hal_dbus_init (*core, &argc, &argv)) {
+//    delete core;
+//    return;
+//  }
+#endif
+
   if (!opal_init (*core, &argc, &argv)) {
     delete core;
     return;

Added: trunk/lib/engine/hal/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/lib/engine/hal/Makefile.am	Sat Feb 23 20:46:39 2008
@@ -0,0 +1,5 @@
+SUBDIRS = skel 
+
+if HAVE_DBUS
+SUBDIRS += dbus
+endif

Added: trunk/lib/engine/hal/dbus/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/lib/engine/hal/dbus/Makefile.am	Sat Feb 23 20:46:39 2008
@@ -0,0 +1,32 @@
+noinst_LTLIBRARIES = libgmhal-dbus.la
+
+hal_dir = $(top_srcdir)/lib/engine/hal/dbus
+
+AM_CXXFLAGS = $(SIGC_CFLAGS) $(GLIB_CFLAGS) $(DBUS_CFLAGS)
+
+AM_CFLAGS = $(GLIB_CFLAGS) $(DBUS_CFLAGS)
+
+INCLUDES = \
+	-I$(top_srcdir)/lib/engine/include \
+	-I$(top_srcdir)/lib/engine/framework \
+	-I$(top_srcdir)/lib/engine/hal/skel \
+	-I$(top_srcdir)/lib/engine/hal/dbus
+
+libgmhal_dbus_la_SOURCES = \
+	$(hal_dir)/hal-manager-dbus.h \
+	$(hal_dir)/hal-manager-dbus.cpp \
+	$(hal_dir)/hal-main-dbus.h \
+	$(hal_dir)/hal-main-dbus.cpp \
+	$(hal_dir)/hal-marshal.h \
+	$(hal_dir)/hal-marshal.c
+
+# forces the HAVE :
+BUILT_SOURCES = hal-marshal.h hal-marshal.c
+
+libgmhal_dbus_la_LDFLAGS = -export-dynamic -no-undefined $(SIGC_LIBS) $(GLIB_LIBS) $(DBUS_LIBS)
+
+hal-marshal.h: hal-marshal.list
+	$(LIBTOOL) --mode=execute glib-genmarshal --prefix=gm_hal_dbus_marshal $^ --header > $  tmp && mv $  tmp $@
+    
+hal-marshal.c: hal-marshal.list
+	$(LIBTOOL) --mode=execute glib-genmarshal --prefix=gm_hal_dbus_marshal $^ --body > $  tmp && mv $  tmp $@

Added: trunk/lib/engine/hal/dbus/hal-main-dbus.cpp
==============================================================================
--- (empty file)
+++ trunk/lib/engine/hal/dbus/hal-main-dbus.cpp	Sat Feb 23 20:46:39 2008
@@ -0,0 +1,63 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+ *
+ * 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.
+ */
+
+
+/*
+ *                         vidinput-main-mlogo.cpp  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Matthias Schneider
+ *   copyright            : (c) 2008 by Matthias Schneider
+ *   description          : code to hook the Moving Logo vidinput manager 
+ *                          into the main program
+ *
+ */
+
+#include "hal-main-dbus.h"
+#include "hal-core.h"
+#include "hal-manager-dbus.h"
+
+bool
+hal_dbus_init (Ekiga::ServiceCore &core,
+	    int */*argc*/,
+	    char **/*argv*/[])
+{
+  bool result = false;
+  Ekiga::HalCore *hal_core = NULL;
+
+  hal_core
+    = dynamic_cast<Ekiga::HalCore*>(core.get ("hal-core"));
+
+  if (hal_core != NULL) {
+
+    HalManager_dbus *hal_manager = new HalManager_dbus(core);
+
+    hal_core->add_manager (*hal_manager);
+    result = true;
+  }
+
+  return result;
+}

Added: trunk/lib/engine/hal/dbus/hal-main-dbus.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/hal/dbus/hal-main-dbus.h	Sat Feb 23 20:46:39 2008
@@ -0,0 +1,48 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+ *
+ * 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.
+ */
+
+
+/*
+ *                         vidinput-main-mlogo.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Matthias Schneider
+ *   copyright            : (c) 2008 by Matthias Schneider
+ *   description          : code to hook the Moving Logo vidinput manager 
+ *                          into the main program
+ *
+ */
+
+#ifndef __HAL_MAIN_DBUS_H__
+#define __HAL_MAIN_DBUS_H__
+
+#include "services.h"
+
+bool hal_dbus_init (Ekiga::ServiceCore &core,
+  		     int *argc,
+		     char **argv[]);
+
+#endif

Added: trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp
==============================================================================
--- (empty file)
+++ trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp	Sat Feb 23 20:46:39 2008
@@ -0,0 +1,228 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+
+ * 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.
+ */
+
+
+/*
+ *                         hal-manager-dbus.cpp  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Matthias Schneider
+ *   copyright            : (c) 2008 by Matthias Schneider
+ *   description          : Declaration of the interface of a hal core.
+ *                          A hal core manages HalManagers.
+ *
+ */
+
+#include "hal-manager-dbus.h"
+#include "hal-marshal.h"
+
+//FIXME: for tracing
+#include "ptbuildopts.h"
+#include "ptlib.h"
+
+HalManager_dbus::HalManager_dbus (Ekiga::ServiceCore & _core)
+:    core (_core), runtime (*(dynamic_cast<Ekiga::Runtime *> (_core.get ("runtime"))))
+{
+  PTRACE(4, "HalManager_dbus\tInitialising HAL Manager");
+  GError *error = NULL;
+  bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+  if (error != NULL) {
+    PTRACE (1, "HalManager_dbus\tConnecting to system bus failed: " << error->message);
+    g_error_free(error);
+    return;
+  }
+
+  hal_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.Hal",
+                                              "/org/freedesktop/Hal/Manager",
+                                              "org.freedesktop.Hal.Manager");
+
+  //FIXME: Is this necessary?
+//   dbus_g_object_register_marshaller(gm_hal_dbus_marshal_VOID__STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID);
+
+  dbus_g_proxy_add_signal(hal_proxy, "DeviceRemoved", G_TYPE_STRING, G_TYPE_INVALID);
+  dbus_g_proxy_connect_signal(hal_proxy, "DeviceRemoved", G_CALLBACK(&device_removed_cb_proxy), this, NULL);
+
+  dbus_g_proxy_add_signal(hal_proxy, "DeviceAdded", G_TYPE_STRING, G_TYPE_INVALID);
+  dbus_g_proxy_connect_signal(hal_proxy, "DeviceAdded", G_CALLBACK(&device_added_cb_proxy), this, NULL);
+
+  populate_devices_list();
+
+  nm_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.NetworkManager",
+                                              "/org/freedesktop/NetworkManager",
+                                              "org.freedesktop.NetworkManager");
+
+  dbus_g_proxy_add_signal(nm_proxy, "DeviceNoLongerActive", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+  dbus_g_proxy_connect_signal(nm_proxy, "DeviceNoLongerActive", G_CALLBACK(&device_no_longer_active_cb_proxy), this, NULL);
+
+  dbus_g_proxy_add_signal(nm_proxy, "DeviceNowActive", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+  dbus_g_proxy_connect_signal(nm_proxy, "DeviceNowActive", G_CALLBACK(&device_now_active_cb_proxy), this, NULL);
+
+// The Main loop should be used from Ekiga itself
+       static GMainLoop *loop = g_main_loop_new (NULL, FALSE);
+
+       GMainContext *ctx = g_main_loop_get_context (loop);
+       while (g_main_context_pending (ctx))
+         g_main_context_iteration (ctx, FALSE);
+
+        dbus_g_connection_flush (bus);
+        g_main_loop_run (loop);
+// The Main loop should be used from Ekiga itself
+}
+
+HalManager_dbus::~HalManager_dbus ()
+{
+  g_object_unref(hal_proxy);
+  g_object_unref(nm_proxy);
+  dbus_g_connection_unref(bus);
+}
+
+void HalManager_dbus::device_added_cb_proxy (DBusGProxy */*object*/, const char *device, gpointer user_data)
+{
+  HalManager_dbus* hal_manager_dbus = reinterpret_cast<HalManager_dbus *> (user_data);
+  hal_manager_dbus->device_added_cb(device);
+}
+
+void HalManager_dbus::device_removed_cb_proxy (DBusGProxy */*object*/, const char *device, gpointer user_data)
+{
+  HalManager_dbus* hal_manager_dbus = reinterpret_cast<HalManager_dbus *> (user_data);
+  hal_manager_dbus->device_removed_cb(device);
+}
+
+void HalManager_dbus::device_now_active_cb_proxy (DBusGProxy */*object*/, const char *device, gpointer user_data)
+{
+  HalManager_dbus* hal_manager_dbus = reinterpret_cast<HalManager_dbus *> (user_data);
+  hal_manager_dbus->device_now_active_cb(device);
+}
+
+void HalManager_dbus::device_no_longer_active_cb_proxy (DBusGProxy */*object*/, const char *device, gpointer user_data)
+{
+  HalManager_dbus* hal_manager_dbus = reinterpret_cast<HalManager_dbus *> (user_data);
+  hal_manager_dbus->device_no_longer_active_cb(device);
+}
+
+void HalManager_dbus::device_added_cb (const char *device)
+{
+  std::string type, name;
+  HalDevice hal_device;
+  hal_device.key = device;
+  get_device_type_name(device, hal_device.category, hal_device.product, hal_device.parent_product);
+  hal_devices.push_back(hal_device);
+  PTRACE(4, "HalManager_dbus\tAdded device " << hal_device.category << "," << hal_device.product << " - " << hal_device.parent_product);
+}
+
+void HalManager_dbus::device_removed_cb (const char *device)
+{
+  bool found = false;
+  std::vector<HalDevice>::iterator iter;
+
+  for (iter = hal_devices.begin ();
+       iter != hal_devices.end () ;
+       iter++)
+      if (iter->key == device) { 
+        found = true;
+        break;
+      }
+
+  if (found) {
+    PTRACE(4, "HalManager_dbus\tRemoved device " << iter->category << "," << iter->product << " - " << iter->parent_product);
+    hal_devices.erase(iter);
+  }
+}
+
+void HalManager_dbus::device_now_active_cb (const char *device)
+{
+  PTRACE(4, "HalManager_dbus\tActivated network device " << device);
+}
+
+void HalManager_dbus::device_no_longer_active_cb (const char *device)
+{
+  PTRACE(4, "HalManager_dbus\tDeactivated network device " << device);
+}
+
+void HalManager_dbus::get_string_property(DBusGProxy *proxy, const char * property, std::string & value)
+{
+  char* c_value = NULL;
+  GError *error = NULL;
+
+  dbus_g_proxy_call (proxy, "GetPropertyString", &error, G_TYPE_STRING, property, G_TYPE_INVALID, G_TYPE_STRING, &c_value, G_TYPE_INVALID);
+
+  if (error != NULL)
+    g_error_free(error);
+   else
+     if (c_value) 
+       value = c_value;
+
+  g_free (c_value);
+}
+
+void HalManager_dbus::get_device_type_name (const char * device, std::string & category, std::string & product, std::string & parent_product)
+{
+  DBusGProxy * device_proxy = NULL;
+  DBusGProxy * parent_proxy = NULL;
+  device_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.Hal",
+                                                 device,
+                                                 "org.freedesktop.Hal.Device");
+  std::string parent;
+  get_string_property(device_proxy, "info.category", category);
+  get_string_property(device_proxy, "info.product", product);
+  get_string_property(device_proxy, "info.parent", parent);
+
+  parent_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.Hal",
+                                                 parent.c_str(),
+                                                 "org.freedesktop.Hal.Device");
+
+  get_string_property(parent_proxy, "info.product", parent_product);
+
+  g_object_unref(device_proxy);
+  g_object_unref(parent_proxy);
+}
+
+void HalManager_dbus::populate_devices_list ()
+{
+  GError *error = NULL;
+
+  PTRACE(4, "HalManager_dbus\tPopulating device list");
+  char **device_list;
+  char **device_list_ptr;
+  HalDevice hal_device;
+
+  dbus_g_proxy_call (hal_proxy, "GetAllDevices", &error, G_TYPE_INVALID, G_TYPE_STRV, &device_list, G_TYPE_INVALID);
+  if (error != NULL) {
+    PTRACE(1, "HalManager_dbus\tPopulating full device list failed - " << error->message);
+    g_error_free(error);
+    return;
+  }
+
+  for (device_list_ptr = device_list; *device_list_ptr; device_list_ptr++) {
+    hal_device.key = *device_list_ptr;
+
+    if (hal_device.key != "/org/freedesktop/Hal/devices/computer") {
+      get_device_type_name(*device_list_ptr, hal_device.category, hal_device.product, hal_device.parent_product);
+      hal_devices.push_back(hal_device);
+    }
+  }
+
+  g_strfreev(device_list);
+  PTRACE(4, "HalManager_dbus\tPopulated device list with " << hal_devices.size() << " devices");
+}
\ No newline at end of file

Added: trunk/lib/engine/hal/dbus/hal-manager-dbus.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/hal/dbus/hal-manager-dbus.h	Sat Feb 23 20:46:39 2008
@@ -0,0 +1,116 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+
+ * 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.
+ */
+
+
+/*
+ *                         hal-manager-mlogo.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Matthias Schneider
+ *   copyright            : (c) 2008 by Matthias Schneider
+ *   description          : Declaration of the interface of a hal core.
+ *                          A hal core manages VidInputManagers.
+ *
+ */
+
+
+#ifndef __HAL_MANAGER_DBUS_H__
+#define __HAL_MANAGER_DBUS_H__
+
+#include "hal-core.h"
+#include "hal-manager.h"
+#include "runtime.h"
+
+extern "C" {
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#include <glib-object.h>
+}
+
+#include <vector>
+
+/**
+ * @addtogroup hal
+ * @{
+ */
+  typedef struct HalDevice {
+    std::string key;
+    std::string category;
+    std::string product;
+    std::string parent_product;
+  };
+
+  class HalManager_dbus
+   : public Ekiga::HalManager
+    {
+  public:
+
+      /* The constructor
+       */
+      HalManager_dbus (Ekiga::ServiceCore & core);
+      /* The destructor
+       */
+      ~HalManager_dbus ();
+
+
+      /*                 
+       * DISPLAY MANAGEMENT 
+       */               
+
+      /** Create a call based on the remote uri given as parameter
+       * @param uri  an uri
+       * @return     true if a Ekiga::Call could be created
+       */
+      static void device_added_cb_proxy (DBusGProxy *object, const char *device, gpointer user_data);
+      static void device_removed_cb_proxy (DBusGProxy *object, const char *device, gpointer user_data);
+
+      static void device_no_longer_active_cb_proxy (DBusGProxy *object, const char *device, gpointer user_data);
+      static void device_now_active_cb_proxy (DBusGProxy *object, const char *device, gpointer user_data);
+
+      void device_added_cb (const char *device);
+      void device_removed_cb (const char *device);
+
+      void device_now_active_cb (const char *device);
+      void device_no_longer_active_cb (const char *device);
+
+  protected:  
+      void populate_devices_list();
+      void get_device_type_name (const char * device, std::string & category, std::string & product, std::string & parent_product);
+      void get_string_property (DBusGProxy *proxy, const char * property, std::string & value);
+      Ekiga::ServiceCore & core;
+      Ekiga::Runtime & runtime;
+
+      DBusGConnection * bus;
+      DBusGProxy * hal_proxy;
+      DBusGProxy * nm_proxy;
+
+      std::vector <HalDevice> hal_devices;
+
+  };
+/**
+ * @}
+ */
+
+
+#endif

Added: trunk/lib/engine/hal/dbus/hal-marshal.list
==============================================================================
--- (empty file)
+++ trunk/lib/engine/hal/dbus/hal-marshal.list	Sat Feb 23 20:46:39 2008
@@ -0,0 +1 @@
+VOID:STRING

Added: trunk/lib/engine/hal/skel/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/lib/engine/hal/skel/Makefile.am	Sat Feb 23 20:46:39 2008
@@ -0,0 +1,18 @@
+noinst_LTLIBRARIES = libgmhal.la
+
+hal_dir = $(top_srcdir)/lib/engine/hal/skel
+
+AM_CXXFLAGS = $(SIGC_CFLAGS)
+
+INCLUDES = \
+	-I$(top_srcdir)/lib/engine/include \
+	-I$(top_srcdir)/lib/engine/framework \
+	-I$(top_srcdir)/lib/engine/hal/skel
+
+libgmhal_la_SOURCES = \
+	$(hal_dir)/hal-manager.h	\
+	$(hal_dir)/hal-info.h		\
+	$(hal_dir)/hal-core.h		\
+	$(hal_dir)/hal-core.cpp
+
+libgmhal_la_LDFLAGS = -export-dynamic -no-undefined $(SIGC_LIBS)

Added: trunk/lib/engine/hal/skel/hal-core.cpp
==============================================================================
--- (empty file)
+++ trunk/lib/engine/hal/skel/hal-core.cpp	Sat Feb 23 20:46:39 2008
@@ -0,0 +1,116 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+
+ * 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.
+ */
+
+
+/*
+ *                         hal-core.cpp  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Matthias Schneider
+ *   copyright            : (c) 2008 by Matthias Schneider
+ *   description          : declaration of the interface of a hal core.
+ *                          A hal core manages a HalManager.
+ *
+ */
+
+#include <iostream>
+#include <sstream>
+
+#include "config.h"
+
+#include "hal-core.h"
+#include "hal-manager.h"
+
+
+using namespace Ekiga;
+
+HalCore::HalCore ()
+{
+}
+
+HalCore::~HalCore ()
+{
+}
+
+
+void HalCore::add_manager (HalManager &manager)
+{
+  managers.insert (&manager);
+  manager_added.emit (manager);
+
+  manager.video_input_device_added.connect (sigc::mem_fun (this, &HalCore::on_video_input_device_added));
+  manager.video_input_device_removed.connect (sigc::mem_fun (this, &HalCore::on_video_input_device_removed));
+
+  manager.audio_input_device_added.connect (sigc::mem_fun (this, &HalCore::on_audio_input_device_added));
+  manager.audio_input_device_removed.connect (sigc::mem_fun (this, &HalCore::on_audio_input_device_removed));
+
+  manager.audio_output_device_added.connect (sigc::mem_fun (this, &HalCore::on_audio_output_device_added));
+  manager.audio_output_device_removed.connect (sigc::mem_fun (this, &HalCore::on_audio_output_device_removed));
+
+  manager.network_interface_up.connect (sigc::mem_fun (this, &HalCore::on_network_interface_up));
+  manager.network_interface_down.connect (sigc::mem_fun (this, &HalCore::on_network_interface_down));
+}
+
+
+void HalCore::visit_managers (sigc::slot<bool, HalManager &> visitor)
+{
+  bool go_on = true;
+
+  for (std::set<HalManager *>::iterator iter = managers.begin ();
+       iter != managers.end () && go_on;
+       iter++)
+      go_on = visitor (*(*iter));
+}
+
+void HalCore::on_video_input_device_added (HalVideoInputDevice & video_input_device) {
+  video_input_device_added.emit (video_input_device);
+}
+
+void HalCore::on_video_input_device_removed (HalVideoInputDevice & video_input_device) {
+  video_input_device_removed.emit (video_input_device);
+}
+
+void HalCore::on_audio_input_device_added (HalAudioInputDevice & audio_input_device) {
+  audio_input_device_added.emit (audio_input_device);
+}
+
+void HalCore::on_audio_input_device_removed (HalAudioInputDevice & audio_input_device) {
+  audio_input_device_removed.emit (audio_input_device);
+}
+
+void HalCore::on_audio_output_device_added (HalAudioOutputDevice & audio_output_device) {
+  audio_output_device_added.emit (audio_output_device);
+}
+
+void HalCore::on_audio_output_device_removed (HalAudioOutputDevice & audio_output_device) {
+  audio_output_device_removed.emit (audio_output_device);
+}
+
+void HalCore::on_network_interface_up (HalNetworkInterface & network_interface) {
+  network_interface_up.emit (network_interface);
+}
+
+void HalCore::on_network_interface_down (HalNetworkInterface & network_interface) {
+  network_interface_down.emit (network_interface);
+}

Added: trunk/lib/engine/hal/skel/hal-core.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/hal/skel/hal-core.h	Sat Feb 23 20:46:39 2008
@@ -0,0 +1,158 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+
+ * 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.
+ */
+
+
+/*
+ *                         hal-core.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Matthias Schneider
+ *   copyright            : (c) 2008 by Matthias Schneider
+ *   description          : Declaration of the interface of a hal core.
+ *                          A hal core manages HalManagers.
+ *
+ */
+
+#ifndef __HAL_CORE_H__
+#define __HAL_CORE_H__
+
+#include "services.h"
+
+#include <sigc++/sigc++.h>
+
+#include <set>
+#include <map>
+
+namespace Ekiga
+{
+/**
+ * @defgroup hal
+ * @{
+ */
+
+  class HalManager;
+
+  typedef struct HalVideoInputDevice {
+    std::string source;
+    std::string device;
+  };
+
+  typedef struct HalAudioInputDevice {
+    std::string source;
+    std::string device;
+  };
+
+  typedef struct HalAudioOutputDevice {
+    std::string source;
+    std::string device;
+  };
+
+  typedef struct HalNetworkInterface {
+    std::string name;
+  };
+
+  /** Core object for hal support
+   */
+  class HalCore
+    : public Service
+    {
+
+  public:
+
+      /* The constructor
+      */
+      HalCore ();
+
+      /* The destructor
+      */
+      ~HalCore ();
+
+      /*** Service Implementation ***/
+
+      /** Returns the name of the service.
+       * @return The service name.
+       */
+      const std::string get_name () const
+        { return "hal-core"; }
+
+
+      /** Returns the description of the service.
+       * @return The service description.
+       */
+      const std::string get_description () const
+        { return "\tHal Core managing Hal Manager objects"; }
+
+
+      /** Adds a HalManager to the HalCore service.
+       * @param The manager to be added.
+       */
+       void add_manager (HalManager &manager);
+
+      /** Triggers a callback for all Ekiga::HalManager sources of the
+       * HalCore service.
+       */
+       void visit_managers (sigc::slot<bool, HalManager &> visitor);
+
+      /** This signal is emitted when a Ekiga::HalManager has been
+       * added to the HalCore Service.
+       */
+       sigc::signal<void, HalManager &> manager_added;
+
+      /** See hal-manager.h for the API
+       */
+      sigc::signal<void, HalVideoInputDevice &> video_input_device_added;
+      sigc::signal<void, HalVideoInputDevice &> video_input_device_removed;
+
+      sigc::signal<void, HalAudioInputDevice &> audio_input_device_added;
+      sigc::signal<void, HalAudioInputDevice &> audio_input_device_removed;
+
+      sigc::signal<void, HalAudioOutputDevice &> audio_output_device_added;
+      sigc::signal<void, HalAudioOutputDevice &> audio_output_device_removed;
+
+      sigc::signal<void, HalNetworkInterface &> network_interface_up;
+      sigc::signal<void, HalNetworkInterface &> network_interface_down;
+
+  private:
+
+      void on_video_input_device_added (HalVideoInputDevice & video_input_device);
+      void on_video_input_device_removed (HalVideoInputDevice & video_input_device);
+
+      void on_audio_input_device_added (HalAudioInputDevice & audio_input_device);
+      void on_audio_input_device_removed (HalAudioInputDevice & audio_input_device);
+
+      void on_audio_output_device_added (HalAudioOutputDevice & audio_output_device);
+      void on_audio_output_device_removed (HalAudioOutputDevice & audio_output_device);
+
+      void on_network_interface_up (HalNetworkInterface & network_interface);
+      void on_network_interface_down (HalNetworkInterface & network_interface);
+
+      std::set<HalManager *> managers;
+
+    };
+/**
+ * @}
+ */
+};
+
+#endif

Added: trunk/lib/engine/hal/skel/hal-manager.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/hal/skel/hal-manager.h	Sat Feb 23 20:46:39 2008
@@ -0,0 +1,95 @@
+
+/*
+ * Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2008 Damien Sandras
+
+ * 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.
+ */
+
+
+/*
+ *                         hal-manager.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2008 by Matthias Schneider
+ *   copyright            : (c) 2008 by Matthias Schneider
+ *   description          : Declaration of the interface of a hal manager
+ *                          implementation backend.
+ *
+ */
+
+
+#ifndef __HAL_MANAGER_H__
+#define __HAL_MANAGER_H__
+
+#include "hal-core.h"
+
+namespace Ekiga
+{
+
+/**
+ * @addtogroup hal
+ * @{
+ */
+
+  class HalManager
+    {
+
+  public:
+
+      /* The constructor
+       */
+      HalManager () {}
+
+      /* The destructor
+       */
+      ~HalManager () {}
+
+
+      /*                 
+       * VIDINOUT MANAGEMENT 
+       */               
+
+      /** Create a call based on the remote uri given as parameter
+       * @param uri  an uri
+       * @return     true if a Ekiga::Call could be created
+       */
+
+      sigc::signal<void, HalVideoInputDevice &> video_input_device_added;
+      sigc::signal<void, HalVideoInputDevice &> video_input_device_removed;
+
+      sigc::signal<void, HalAudioInputDevice &> audio_input_device_added;
+      sigc::signal<void, HalAudioInputDevice &> audio_input_device_removed;
+
+      sigc::signal<void, HalAudioOutputDevice &> audio_output_device_added;
+      sigc::signal<void, HalAudioOutputDevice &> audio_output_device_removed;
+
+      sigc::signal<void, HalNetworkInterface &> network_interface_up;
+      sigc::signal<void, HalNetworkInterface &> network_interface_down;
+
+  protected:  
+
+  };
+/**
+ * @}
+ */
+
+};
+
+#endif



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