Add new DA model names
[platform/core/connectivity/bluetooth-agent.git] / include / bluetooth-agent-profile.h
index d25af2f..ba0204b 100644 (file)
@@ -27,7 +27,9 @@
 #include <sys/types.h>
 #include <libintl.h>
 #include <stdlib.h>
+#include <string.h>
 #include <system_info.h>
+#include <gio/gio.h>
 
 typedef enum {
        _PROFILE_UNKNOWN = 0,
@@ -35,7 +37,8 @@ typedef enum {
        _PROFILE_WEARABLE = 0x2,
        _PROFILE_TV = 0x4,
        _PROFILE_IVI = 0x8,
-       _PROFILE_COMMON = 0x10,
+       _PROFILE_IOT = 0x10,
+       _PROFILE_COMMON = 0x20,
 } tizen_profile_t;
 
 /* For optimization, make this extern and define in a shared C file */
@@ -46,45 +49,111 @@ int system_info_get_platform_string(const char *key, char **value);
 
 static inline tizen_profile_t get_tizen_profile()
 {
-        char *profileName = NULL;
-
-        if (__builtin_expect(profile != _PROFILE_UNKNOWN, 1))
-                return profile;
-
-        system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
-
-        /* To pass the checking of g_ir */
-        if (!profileName)
-                return _PROFILE_UNKNOWN;
-
-        switch (*profileName) {
-        case 'm':
-        case 'M':
-                profile = _PROFILE_MOBILE;
-                break;
-        case 'w':
-        case 'W':
-                profile = _PROFILE_WEARABLE;
-                break;
-        case 't':
-        case 'T':
-                profile = _PROFILE_TV;
-                break;
-        case 'i':
-        case 'I':
-                profile = _PROFILE_IVI;
-                break;
-        default: // common or unknown ==> ALL ARE COMMON.
-                profile = _PROFILE_COMMON;
-        }
-        free(profileName);
-
-        return profile;
+       char *profileName = NULL;
+
+       if (__builtin_expect(profile != _PROFILE_UNKNOWN, 1))
+               return profile;
+
+       system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+
+       /* To pass the checking of g_ir */
+       if (!profileName)
+               return _PROFILE_UNKNOWN;
+
+       switch (*profileName) {
+       case 'm':
+       case 'M':
+               profile = _PROFILE_MOBILE;
+               break;
+       case 'w':
+       case 'W':
+               profile = _PROFILE_WEARABLE;
+               break;
+       case 't':
+       case 'T':
+               profile = _PROFILE_TV;
+               break;
+       case 'i':
+       case 'I':
+               if (!strncasecmp(profileName, "ivi", 3))
+                       profile = _PROFILE_IVI;
+               else if (!strncasecmp(profileName, "iot", 3))
+                       profile = _PROFILE_IOT;
+               else
+                       profile = _PROFILE_COMMON;
+               break;
+       default: // common or unknown ==> ALL ARE COMMON.
+               profile = _PROFILE_COMMON;
+       }
+       free(profileName);
+
+       return profile;
+}
+
+typedef enum {
+       _MODEL_UNKNOWN = 0,
+       _MODEL_TM1 = 0x1,
+       _MODEL_TM2 = 0x2,
+       _MODEL_TW1 = 0x4,
+       _MODEL_TW2 = 0x8,
+       _MODEL_FHUB = 0x10,
+       _MODEL_DA = 0x20,
+} tizen_model_name_t;
+
+extern tizen_model_name_t model_name;
+
+/* LCOV_EXCL_START */
+static inline tizen_model_name_t get_tizen_model_name()
+{
+       char *modelName = NULL;
+
+       if (__builtin_expect(model_name != _MODEL_UNKNOWN, 1))
+               return model_name;
+
+       system_info_get_platform_string("http://tizen.org/system/model_name", &modelName);
+
+       /* To pass the checking of g_ir */
+       if (!modelName)
+               return _MODEL_UNKNOWN;
+
+       if (g_strcmp0(modelName, "TM1") == 0)
+               model_name = _MODEL_TM1;
+       else if (g_strcmp0(modelName, "TM2") == 0)
+               model_name = _MODEL_TM2;
+       else if (g_strcmp0(modelName, "TW1") == 0)
+               model_name = _MODEL_TW1;
+       else if (g_strcmp0(modelName, "TW2") == 0)
+               model_name = _MODEL_TW2;
+       else if (!strncasecmp(modelName, "Family Hub", 10))
+               model_name = _MODEL_FHUB;
+       else if (!strcasecmp(modelName, "Robot Vacuum Cleaner") ||
+                       !strcasecmp(modelName, "Smart Dryer") ||
+                       !strcasecmp(modelName, "Smart Washer") ||
+                       !strcasecmp(modelName, "DDMS") ||
+                       !strcasecmp(modelName, "Smart Cooktop") ||
+                       !strcasecmp(modelName, "Smart Range") ||
+                       !strcasecmp(modelName, "Refrigerator") ||
+                       !strcasecmp(modelName, "Echo Heating System Controller"))
+               model_name = _MODEL_DA;
+       else
+               model_name = _MODEL_UNKNOWN;
+
+       free(modelName);
+
+       return model_name;
 }
+/* LCOV_EXCL_STOP */
 
 #define TIZEN_PROFILE_WEARABLE (get_tizen_profile() == _PROFILE_WEARABLE)
 #define TIZEN_PROFILE_IVI (get_tizen_profile() == _PROFILE_IVI)
 #define TIZEN_PROFILE_TV (get_tizen_profile() == _PROFILE_TV)
 #define TIZEN_PROFILE_MOBILE (get_tizen_profile() == _PROFILE_MOBILE)
 
+#define TIZEN_MODEL_NAME_TM1 (get_tizen_model_name() == _MODEL_TM1)
+#define TIZEN_MODEL_NAME_TM2 (get_tizen_model_name() == _MODEL_TM2)
+#define TIZEN_MODEL_NAME_TW1 (get_tizen_model_name() == _MODEL_TW1)
+#define TIZEN_MODEL_NAME_TW2 (get_tizen_model_name() == _MODEL_TW2)
+#define TIZEN_MODEL_NAME_FHUB (get_tizen_model_name() == _MODEL_FHUB)
+#define TIZEN_MODEL_NAME_DA (get_tizen_model_name() & (_MODEL_FHUB | _MODEL_DA))
+
 #endif /* __DEF_BT_AGENT_PROFILE_H_ */