rendered paste bodydiff --git a/audio/Makefile.am b/audio/Makefile.am
index e36c2c2..5a0d858 100644
--- a/audio/Makefile.am
+++ b/audio/Makefile.am
@@ -54,11 +54,10 @@ libgstbluetooth_la_CFLAGS = @GSTREAMER_CFLAGS@ @SBC_CFLAGS@
endif
endif
-AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@
+AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@ -ldl
INCLUDES = -I$(top_srcdir)/common
EXTRA_DIST = audio.service audio.conf audio-api.txt test-audio asound.conf
MAINTAINERCLEANFILES = Makefile.in
-
diff --git a/audio/audio.conf b/audio/audio.conf
index 0d73310..61ab6d5 100644
--- a/audio/audio.conf
+++ b/audio/audio.conf
@@ -32,6 +32,12 @@ EnhancedCallStatus=false
EnhancedCallControl=false
ExtendedErrorResultCodes=false
+#Telephony Plugin option.
+#Select the one you phone supports.
+#default is a dummy plugin.
+#values can be openmoko, telepathy.
+Plugin=default
+
# Just an example of potential config options for the other interfaces
#[A2DP]
#SBCSources=1
diff --git a/audio/headset.c b/audio/headset.c
index 6972daf..670b1a0 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -1694,7 +1694,7 @@ register_iface:
return hs;
}
-uint32_t headset_config_init(GKeyFile *config)
+uint32_t headset_config_init(GKeyFile *config, void *handle)
{
GError *err = NULL;
gboolean value;
diff --git a/audio/headset.h b/audio/headset.h
index 67155f7..b05d2e6 100644
--- a/audio/headset.h
+++ b/audio/headset.h
@@ -47,7 +47,7 @@ struct headset *headset_init(struct device *dev, sdp_record_t *record,
void headset_free(struct device *dev);
-uint32_t headset_config_init(GKeyFile *config);
+uint32_t headset_config_init(GKeyFile *config, void *handle);
void headset_update(struct device *dev, sdp_record_t *record, uint16_t svc);
diff --git a/audio/manager.c b/audio/manager.c
index 1c8970d..99fda87 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -36,6 +36,7 @@
#include <dirent.h>
#include <ctype.h>
#include <signal.h>
+#include <dlfcn.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
@@ -107,6 +108,8 @@ static uint32_t hf_record_id = 0;
static GIOChannel *hs_server = NULL;
static GIOChannel *hf_server = NULL;
+void *handle;/*holds the handle for the dyn lib*/
+
static struct enabled_interfaces enabled = {
.headset = TRUE,
.gateway = FALSE,
@@ -1536,6 +1539,46 @@ static GIOChannel *server_socket(uint8_t *channel)
return io;
}
+void *load_hfp_plugin(GKeyFile *config)
+{
+ char *str;
+ GError *err = NULL;
+ char filename[50] = "/usr/local/lib/bluetooth/";
+
+ if (config == NULL) {
+ strcat(filename,"dummy");
+ goto load;
+ }
+
+ str = g_key_file_get_string(config, "Headset", "Plugin", &err);
+
+ if (err) {
+ debug("audio.conf: %s", err->message);
+ g_error_free(err);
+ err = NULL;
+ } else {
+ if (strstr(str, "default"))
+ strcat(filename,"dummy");
+ if (strstr(str, "openmoko"))
+ strcat(filename,"openmoko");
+ if (strstr(str, "telepathy"))
+ strcat(filename,"telepathy");
+ }
+load:
+ strcat(filename,".so");
+ debug("filename is %s",filename);
+
+ /*Loads the library*/
+ handle = dlopen(filename, RTLD_LAZY);
+
+ if (!handle) {
+ debug("cant load the plugin library.\n");
+ return NULL;
+ }
+ dlerror(); /*Clear any existing error*/
+ return handle;
+}
+
static int headset_server_init(DBusConnection *conn, GKeyFile *config)
{
uint8_t chan = DEFAULT_HS_AG_CHANNEL;
@@ -1587,7 +1630,11 @@ static int headset_server_init(DBusConnection *conn, GKeyFile *config)
if (!hf_server)
return -1;
- features = headset_config_init(config);
+ handle = load_hfp_plugin(config);
+ if (handle == NULL)
+ return -1;
+
+ features = headset_config_init(config, handle);
if (hfp_ag_record(&buf, chan, features) < 0) {
error("Unable to allocate new service record");
@@ -1723,6 +1770,9 @@ void audio_exit(void)
{
server_exit();
+ if (handle == NULL)
+ dlclose(handle);
+
dbus_connection_destroy_object_path(connection, AUDIO_MANAGER_PATH);
dbus_connection_unref(connection);