Move GATT example server to a standalone plugin

The GATT example server was in the same plugin as the GATT client.
Moving it to a separate plugin will allow to easily disable it.
diff --git a/Makefile.am b/Makefile.am
index 77b9b7d..9b74970 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -204,8 +204,12 @@
 
 builtin_modules += attrib
 builtin_sources += attrib/main.c \
-		attrib/manager.h attrib/manager.c \
-		attrib/example.h attrib/example.c
+		attrib/manager.h attrib/manager.c
+endif
+
+if GATT_EXAMPLE_PLUGIN
+builtin_modules += gatt_example
+builtin_sources += plugins/gatt-example.c
 endif
 
 if HEALTHPLUGIN
diff --git a/acinclude.m4 b/acinclude.m4
index 69e0740..81b366e 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -190,6 +190,7 @@
 	health_enable=no
 	pnat_enable=no
 	attrib_enable=no
+	gatt_example_enable=no
 	tracer_enable=no
 	tools_enable=yes
 	hidd_enable=no
@@ -261,6 +262,10 @@
 		attrib_enable=${enableval}
 	])
 
+	AC_ARG_ENABLE(gatt-example, AC_HELP_STRING([--enable-gatt-example], [enable GATT example plugin]), [
+		gatt_example_enable=${enableval}
+	])
+
 	AC_ARG_ENABLE(gstreamer, AC_HELP_STRING([--enable-gstreamer], [enable GStreamer support]), [
 		gstreamer_enable=${enableval}
 	])
@@ -385,6 +390,7 @@
 	AM_CONDITIONAL(HAL, test "${hal_enable}" = "yes")
 	AM_CONDITIONAL(READLINE, test "${readline_found}" = "yes")
 	AM_CONDITIONAL(ATTRIBPLUGIN, test "${attrib_enable}" = "yes")
+	AM_CONDITIONAL(GATT_EXAMPLE_PLUGIN, test "${gatt_example_enable}" = "yes")
 	AM_CONDITIONAL(ECHOPLUGIN, test "no" = "yes")
 	AM_CONDITIONAL(PNATPLUGIN, test "${pnat_enable}" = "yes")
 	AM_CONDITIONAL(TRACER, test "${tracer_enable}" = "yes")
diff --git a/attrib/example.h b/attrib/example.h
deleted file mode 100644
index a2b07fe..0000000
--- a/attrib/example.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *
- *  BlueZ - Bluetooth protocol stack for Linux
- *
- *  Copyright (C) 2010  Nokia Corporation
- *  Copyright (C) 2010  Marcel Holtmann <marcel@holtmann.org>
- *
- *
- *  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
- *
- */
-
-int server_example_init(void);
-void server_example_exit(void);
diff --git a/attrib/manager.c b/attrib/manager.c
index 7c05720..6a2b80a 100644
--- a/attrib/manager.c
+++ b/attrib/manager.c
@@ -32,18 +32,12 @@
 #include "hcid.h"
 
 #include "manager.h"
-#include "example.h"
 
 int attrib_manager_init(void)
 {
-	if (main_opts.attrib_server)
-		return server_example_init();
-
 	return 0;
 }
 
 void attrib_manager_exit(void)
 {
-	if (main_opts.attrib_server)
-		server_example_exit();
 }
diff --git a/bootstrap-configure b/bootstrap-configure
index 69a102f..364998f 100755
--- a/bootstrap-configure
+++ b/bootstrap-configure
@@ -18,6 +18,7 @@
 		--libexecdir=/lib \
 		--enable-capng \
 		--enable-attrib \
+		--enable-gatt-example \
 		--enable-health \
 		--enable-tracer \
 		--enable-tools \
diff --git a/attrib/example.c b/plugins/gatt-example.c
similarity index 96%
rename from attrib/example.c
rename to plugins/gatt-example.c
index fae288c..f1dfd5b 100644
--- a/attrib/example.c
+++ b/plugins/gatt-example.c
@@ -22,22 +22,18 @@
  *
  */
 
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
-#include <arpa/inet.h>
-
+#include <glib.h>
 #include <bluetooth/uuid.h>
 
-#include <glib.h>
-
+#include "plugin.h"
+#include "hcid.h"
 #include "log.h"
 #include "attrib-server.h"
-
 #include "att.h"
-#include "example.h"
 
 /* FIXME: Not defined by SIG? UUID128? */
 #define OPCODES_SUPPORTED_UUID          0xA001
@@ -325,13 +321,21 @@
 	return 0;
 }
 
-int server_example_init(void)
+static int gatt_example_init(void)
 {
+	if (!main_opts.attrib_server) {
+		DBG("Attribute server is disabled");
+		return -1;
+	}
+
 	return register_attributes();
 }
 
-void server_example_exit(void)
+static void gatt_example_exit(void)
 {
+	if (!main_opts.attrib_server)
+		return;
+
 	while (sdp_handles) {
 		uint32_t handle = GPOINTER_TO_UINT(sdp_handles->data);
 
@@ -339,3 +343,6 @@
 		sdp_handles = g_slist_remove(sdp_handles, sdp_handles->data);
 	}
 }
+
+BLUETOOTH_PLUGIN_DEFINE(gatt_example, VERSION, BLUETOOTH_PLUGIN_PRIORITY_LOW,
+					gatt_example_init, gatt_example_exit)