Allow configure default link policy in main.conf

Currently BlueZ is hard-coding the default link policy to include
role switch, hold mode, sniff mode and park state. However, some
device will have problem to maintain the connection or setup SCO
if they are in park state. Making these operation modes configurable
in main.conf improves flexibility so any of these four modes can be
disabled if necessary.

Signed-off-by: Bao Liang <tim.bao@motorola.com>
diff --git a/src/main.c b/src/main.c
index 403ffa3..c3471b0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -216,6 +216,14 @@
 
 	main_opts.link_policy = HCI_LP_RSWITCH | HCI_LP_SNIFF |
 						HCI_LP_HOLD | HCI_LP_PARK;
+	str = g_key_file_get_string(config, "General",
+						"DefaultLinkPolicy", &err);
+	if (err)
+		g_clear_error(&err);
+	else {
+		debug("default_link_policy=%s", str);
+		main_opts.link_policy &= strtol(str, NULL, 16);
+	}
 }
 
 /*
@@ -308,6 +316,9 @@
 	main_opts.remember_powered = TRUE;
 	main_opts.reverse_sdp = TRUE;
 	main_opts.name_resolv = TRUE;
+	main_opts.link_mode = HCI_LM_ACCEPT;
+	main_opts.link_policy = HCI_LP_RSWITCH | HCI_LP_SNIFF |
+						HCI_LP_HOLD | HCI_LP_PARK;
 
 	if (gethostname(main_opts.host_name, sizeof(main_opts.host_name) - 1) < 0)
 		strcpy(main_opts.host_name, "noname");
diff --git a/src/main.conf b/src/main.conf
index d1ae90a..bb401fe 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -55,3 +55,10 @@
 # makes debug link keys valid only for the duration of the connection
 # that they were created for.
 DebugKeys = false
+
+# The link policy for connections. By default it's set to 0x000f which is 
+# a bitwise OR of role switch(0x0001), hold mode(0x0002), sniff mode(0x0004)
+# and park state(0x0008) are all enabled. However, some devices have
+# connection stability issue or fail to setup SCO when the link is in park
+# state, which requires park state bit cleared.
+DefaultLinkPolicy = 0x000f