Add new DA model name
[platform/core/connectivity/bluetooth-agent.git] / include / bluetooth-agent-profile.h
1 /*
2  * Bluetooth-agent-common
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:     Hocheol Seo <hocheol.seo@samsung.com>
7  *              Girishashok Joshi <girish.joshi@samsung.com>
8  *              Chanyeol Park <chanyeol.park@samsung.com>
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *              http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */
23
24 #ifndef __DEF_BT_AGENT_PROFILE_H_
25 #define __DEF_BT_AGENT_PROFILE_H_
26
27 #include <sys/types.h>
28 #include <libintl.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <system_info.h>
32 #include <gio/gio.h>
33
34 typedef enum {
35         _PROFILE_UNKNOWN = 0,
36         _PROFILE_MOBILE = 0x1,
37         _PROFILE_WEARABLE = 0x2,
38         _PROFILE_TV = 0x4,
39         _PROFILE_IVI = 0x8,
40         _PROFILE_IOT = 0x10,
41         _PROFILE_COMMON = 0x20,
42 } tizen_profile_t;
43
44 /* For optimization, make this extern and define in a shared C file */
45 extern tizen_profile_t profile;
46
47 /* Accessing system info */
48 int system_info_get_platform_string(const char *key, char **value);
49
50 static inline tizen_profile_t get_tizen_profile()
51 {
52         char *profileName = NULL;
53
54         if (__builtin_expect(profile != _PROFILE_UNKNOWN, 1))
55                 return profile;
56
57         system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
58
59         /* To pass the checking of g_ir */
60         if (!profileName)
61                 return _PROFILE_UNKNOWN;
62
63         switch (*profileName) {
64         case 'm':
65         case 'M':
66                 profile = _PROFILE_MOBILE;
67                 break;
68         case 'w':
69         case 'W':
70                 profile = _PROFILE_WEARABLE;
71                 break;
72         case 't':
73         case 'T':
74                 profile = _PROFILE_TV;
75                 break;
76         case 'i':
77         case 'I':
78                 if (!strncasecmp(profileName, "ivi", 3))
79                         profile = _PROFILE_IVI;
80                 else if (!strncasecmp(profileName, "iot", 3))
81                         profile = _PROFILE_IOT;
82                 else
83                         profile = _PROFILE_COMMON;
84                 break;
85         default: // common or unknown ==> ALL ARE COMMON.
86                 profile = _PROFILE_COMMON;
87         }
88         free(profileName);
89
90         return profile;
91 }
92
93 typedef enum {
94         _MODEL_UNKNOWN = 0,
95         _MODEL_TM1 = 0x1,
96         _MODEL_TM2 = 0x2,
97         _MODEL_TW1 = 0x4,
98         _MODEL_TW2 = 0x8,
99         _MODEL_FHUB = 0x10,
100         _MODEL_DA = 0x20,
101 } tizen_model_name_t;
102
103 extern tizen_model_name_t model_name;
104
105 /* LCOV_EXCL_START */
106 static inline tizen_model_name_t get_tizen_model_name()
107 {
108         char *modelName = NULL;
109
110         if (__builtin_expect(model_name != _MODEL_UNKNOWN, 1))
111                 return model_name;
112
113         system_info_get_platform_string("http://tizen.org/system/model_name", &modelName);
114
115         /* To pass the checking of g_ir */
116         if (!modelName)
117                 return _MODEL_UNKNOWN;
118
119         if (g_strcmp0(modelName, "TM1") == 0)
120                 model_name = _MODEL_TM1;
121         else if (g_strcmp0(modelName, "TM2") == 0)
122                 model_name = _MODEL_TM2;
123         else if (g_strcmp0(modelName, "TW1") == 0)
124                 model_name = _MODEL_TW1;
125         else if (g_strcmp0(modelName, "TW2") == 0)
126                 model_name = _MODEL_TW2;
127         else if (!strncasecmp(modelName, "Family Hub", 10))
128                 model_name = _MODEL_FHUB;
129         else if (!strcasecmp(modelName, "Robot Vacuum Cleaner") ||
130                         !strcasecmp(modelName, "Smart Dryer") ||
131                         !strcasecmp(modelName, "Smart Washer") ||
132                         !strcasecmp(modelName, "DDMS") ||
133                         !strcasecmp(modelName, "Smart Cooktop") ||
134                         !strcasecmp(modelName, "Smart Range") ||
135                         !strcasecmp(modelName, "Refrigerator") ||
136                         !strcasecmp(modelName, "Echo Heating System Controller") ||
137                         !strcasecmp(modelName, "Bespoke Washer") ||
138                         !strcasecmp(modelName, "Bespoke Dryer") ||
139                         !strcasecmp(modelName, "Appliance Emulator") ||
140                         !strcasecmp(modelName, "AI Hub Smart EHS"))
141                 model_name = _MODEL_DA;
142         else
143                 model_name = _MODEL_UNKNOWN;
144
145         free(modelName);
146
147         return model_name;
148 }
149 /* LCOV_EXCL_STOP */
150
151 #define TIZEN_PROFILE_WEARABLE (get_tizen_profile() == _PROFILE_WEARABLE)
152 #define TIZEN_PROFILE_IVI (get_tizen_profile() == _PROFILE_IVI)
153 #define TIZEN_PROFILE_TV (get_tizen_profile() == _PROFILE_TV)
154 #define TIZEN_PROFILE_MOBILE (get_tizen_profile() == _PROFILE_MOBILE)
155
156 #define TIZEN_MODEL_NAME_TM1 (get_tizen_model_name() == _MODEL_TM1)
157 #define TIZEN_MODEL_NAME_TM2 (get_tizen_model_name() == _MODEL_TM2)
158 #define TIZEN_MODEL_NAME_TW1 (get_tizen_model_name() == _MODEL_TW1)
159 #define TIZEN_MODEL_NAME_TW2 (get_tizen_model_name() == _MODEL_TW2)
160 #define TIZEN_MODEL_NAME_FHUB (get_tizen_model_name() == _MODEL_FHUB)
161 #define TIZEN_MODEL_NAME_DA (get_tizen_model_name() & (_MODEL_FHUB | _MODEL_DA))
162
163 #endif /* __DEF_BT_AGENT_PROFILE_H_ */