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 ff423a4..8b66127 100644
--- a/src/main.c
+++ b/src/main.c
@@ -201,10 +201,14 @@
 	else
 		main_opts.name_resolv = boolean;
 
-	main_opts.link_mode = HCI_LM_ACCEPT;
-
-	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);
+	}
 }
 
 /*
@@ -297,6 +301,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 b03e169..9174deb 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -50,3 +50,10 @@
 # Enable name resolving after inquiry. Set it to 'false' if you don't need
 # remote devices name and want shorter discovery cycle. Defaults to 'true'.
 NameResolving = true
+
+# 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