fa3097dd94e01946dbfa2765107f8c5118703562
[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 <system_info.h>
31 #include <gio/gio.h>
32
33 typedef enum {
34         _PROFILE_UNKNOWN = 0,
35         _PROFILE_MOBILE = 0x1,
36         _PROFILE_WEARABLE = 0x2,
37         _PROFILE_TV = 0x4,
38         _PROFILE_IVI = 0x8,
39         _PROFILE_COMMON = 0x10,
40 } tizen_profile_t;
41
42 /* For optimization, make this extern and define in a shared C file */
43 extern tizen_profile_t profile;
44
45 /* Accessing system info */
46 int system_info_get_platform_string(const char *key, char **value);
47
48 static inline tizen_profile_t get_tizen_profile()
49 {
50         char *profileName = NULL;
51
52         if (__builtin_expect(profile != _PROFILE_UNKNOWN, 1))
53                 return profile;
54
55         system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
56
57         /* To pass the checking of g_ir */
58         if (!profileName)
59                 return _PROFILE_UNKNOWN;
60
61         switch (*profileName) {
62         case 'm':
63         case 'M':
64                 profile = _PROFILE_MOBILE;
65                 break;
66         case 'w':
67         case 'W':
68                 profile = _PROFILE_WEARABLE;
69                 break;
70         case 't':
71         case 'T':
72                 profile = _PROFILE_TV;
73                 break;
74         case 'i':
75         case 'I':
76                 profile = _PROFILE_IVI;
77                 break;
78         default: // common or unknown ==> ALL ARE COMMON.
79                 profile = _PROFILE_COMMON;
80         }
81         free(profileName);
82
83         return profile;
84 }
85
86 typedef enum {
87         _MODEL_UNKNOWN = 0,
88         _MODEL_TM1 = 0x1,
89         _MODEL_TM2 = 0x2,
90         _MODEL_TW1 = 0x4,
91         _MODEL_TW2 = 0x8,
92 } tizen_model_name_t;
93
94 extern tizen_model_name_t model_name;
95
96 static inline tizen_model_name_t get_tizen_model_name()
97 {
98         char *modelName = NULL;
99
100         if (__builtin_expect(model_name != _MODEL_UNKNOWN, 1))
101                 return profile;
102
103         system_info_get_platform_string("http://tizen.org/system/model_name", &modelName);
104
105         /* To pass the checking of g_ir */
106         if (!modelName)
107                 return _MODEL_UNKNOWN;
108
109         if (g_strcmp0(modelName, "TM1") == 0)
110                 model_name = _MODEL_TM1;
111         else if (g_strcmp0(modelName, "TM2") == 0)
112                 model_name = _MODEL_TM2;
113         else if (g_strcmp0(modelName, "TW1") == 0)
114                 model_name = _MODEL_TW1;
115         else if (g_strcmp0(modelName, "TW2") == 0)
116                 model_name = _MODEL_TW2;
117         else
118                 model_name = _MODEL_UNKNOWN;
119
120         free(modelName);
121
122         return model_name;
123 }
124
125 #define TIZEN_PROFILE_WEARABLE (get_tizen_profile() == _PROFILE_WEARABLE)
126 #define TIZEN_PROFILE_IVI (get_tizen_profile() == _PROFILE_IVI)
127 #define TIZEN_PROFILE_TV (get_tizen_profile() == _PROFILE_TV)
128 #define TIZEN_PROFILE_MOBILE (get_tizen_profile() == _PROFILE_MOBILE)
129
130 #define TIZEN_MODEL_NAME_TM1 (get_tizen_model_name() == _MODEL_TM1)
131 #define TIZEN_MODEL_NAME_TM2 (get_tizen_model_name() == _MODEL_TM2)
132 #define TIZEN_MODEL_NAME_TW1 (get_tizen_model_name() == _MODEL_TW1)
133 #define TIZEN_MODEL_NAME_TW2 (get_tizen_model_name() == _MODEL_TW2)
134
135 #endif /* __DEF_BT_AGENT_PROFILE_H_ */