Make virtual table at runtime
[platform/core/security/vist.git] / doc / policy / bluetooth.md
1 # Bluetooth Policy Virtual Table
2
3 | Table  | Column | Type | Value |
4 |---|---|---|---|
5 | bluetooth | state | int | 0 = off , 1 = on |
6 |   | desktopConnectivity | int | 0 = off , 1 = on |
7 |   | tethering | int | 0 = off , 1 = on |
8 |   | pairing | int | 0 = off , 1 = on |
9
10 ## Get bluetooth policies
11 ```sql
12   SELECT * FROM bluetooth
13   SELECT state FROM bluetooth
14   SELECT desktopConnectivity FROM bluetooth
15   SELECT pairing FROM bluetooth
16   SELECT tethering FROM bluetooth
17 ```
18
19 ## Set bluetooth policies
20 ```sql
21   UPDATE bluetooth SET state = 1 # on
22   UPDATE bluetooth SET desktopConnectivity = 0 # off
23   UPDATE bluetooth SET pairing = 1 # on
24   UPDATE bluetooth SET tethering = 0 # off
25   UPDATE bluetooth SET state = 1, pairing = 0
26 ```
27
28 # Query Builder
29 ## Schema
30 ```cpp
31   struct Bluetooth {
32     int state;
33     int desktopConnectivity;
34     int pairing;
35     int tethering; 
36
37     DECLARE_COLUMN(State, "state", &Bluetooth::state);
38     DECLARE_COLUMN(DesktopConnectivity, "desktopConnectivity", &Bluetooth::DesktopConnectivity);
39     DECLARE_COLUMN(Pairing, "pairing", &Bluetooth::pairing);
40     DECLARE_COLUMN(Tethering, "tethering", &Bluetooth::tethering);
41   };
42   
43   DECLARE_TABLE(bluetoothTable, "bluetooth", Bluetooth::State,
44                                              Bluetooth::DesktopConnectivity,
45                                              Bluetooth::Pairing,
46                                              Bluetooth::Tethering);
47 ```
48
49 ## Generate type-safed query
50
51 ```cpp
52 // SELECT * FROM bluetooth
53   bluetoothTable.selectAll();
54   
55 // SELECT state FROM bluetooth
56   bluetoothTable.selectAll(Bluetooth::State);
57
58 // UPDATE bluetooth SET state = 1
59   bluetoothTable.update(Bluetooth::State = 1);
60
61 // UPDATE bluetooth SET state = 1, pairing = 0
62   bluetoothTable.update(Bluetooth::State = 1, Bluetooth::Pairing = 0);
63 ```