bug fix: TC-1152
[profile/ivi/ico-uxf-homescreen.git] / lib / common / CicoResourceConfig.cpp
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9 /**
10  * @brief   configuration of resource path
11  *
12  * @date    Feb-15-2013
13  */
14
15 #include <cstdio>
16 #include <cstdlib>
17 #include <cstring>
18 #include <tzplatform_config.h>
19
20 #include <ico_log.h>
21 #include "CicoResourceConfig.h"
22
23 /*============================================================================*/
24 /* functions                                                                  */
25 /*============================================================================*/
26 /*--------------------------------------------------------------------------*/
27 /**
28  * @brief   CicoResourceConfig::GetImagePath
29  *          set the directory path of the image files.
30  *
31  * @param[out]  buff                buffer that the pass set
32  * @param[in]   len                 buffer length
33  * @return      none
34  */
35 /*--------------------------------------------------------------------------*/
36 void
37 CicoResourceConfig::GetImagePath(char *buff, int len)
38 {
39     char *pkg;
40
41     memset(buff, 0, len);
42     pkg = getenv("PKG_NAME");
43     if (pkg) {
44         snprintf(buff, len, ICO_IMAGE_PATH, tzplatform_getenv(TZ_SYS_RO_APP), pkg);
45     }
46     else {
47         pkg = getenv(ICO_HS_CONFIG_TOP_ENV);
48         snprintf(buff, len, ICO_LOCAL_IMAGE_PATH,
49                  pkg ? pkg : ICO_LOCAL_TOP_PATH);
50     }
51     ICO_DBG("buff=\"%s\"", buff);
52 }
53
54 /*--------------------------------------------------------------------------*/
55 /**
56  * @brief   CicoResourceConfig::GetSoundPath
57  *          set the directory path of the sounds files.
58  *
59  * @param[out]  buff                buffer that the pass set
60  * @param[in]   len                 buffer length
61  * @return      none
62  */
63 /*--------------------------------------------------------------------------*/
64 void
65 CicoResourceConfig::GetSoundPath(char *buff, int len)
66 {
67     char *pkg;
68
69     memset(buff, 0, len);
70     pkg = getenv("PKG_NAME");
71     if (pkg) {
72         snprintf(buff, len, ICO_SOUND_PATH, tzplatform_getenv(TZ_SYS_RO_APP), pkg);
73     }
74     else {
75         pkg = getenv(ICO_HS_CONFIG_TOP_ENV);
76         snprintf(buff, len, ICO_LOCAL_SOUND_PATH,
77                  pkg ? pkg : ICO_LOCAL_TOP_PATH);
78     }
79 }
80
81 /*--------------------------------------------------------------------------*/
82 /**
83  * @brief   CicoResourceConfig::GetEdjPath
84  *          set the directory path of efj files.
85  *
86  * @param[out]  buff                buffer that the pass set
87  * @param[in]   len                 buffer length
88  * @return      none
89  */
90 /*--------------------------------------------------------------------------*/
91 void
92 CicoResourceConfig::GetEdjPath(char *buff, int len)
93 {
94     char *pkg;
95
96     memset(buff, 0, len);
97     pkg = getenv("PKG_NAME");
98     if (pkg) {
99         snprintf(buff, len, ICO_EDJ_PATH, tzplatform_getenv(TZ_SYS_RO_APP), pkg);
100     }
101     else {
102         pkg = getenv(ICO_HS_CONFIG_TOP_ENV);
103         snprintf(buff, len, ICO_LOCAL_EDJ_PATH,
104                  pkg ? pkg : ICO_LOCAL_TOP_PATH);
105     }
106 }
107
108 /*--------------------------------------------------------------------------*/
109 /**
110  * @brief   CicoResourceConfig::GetConfPath
111  *          set the directory path of edj files for onscreen.
112  *
113  * @param[out]  buff                buffer that the pass set
114  * @param[in]   len                 buffer length
115  * @return      none
116  */
117 /*--------------------------------------------------------------------------*/
118 void
119 CicoResourceConfig::GetConfPath(char *buff, int len)
120 {
121     char *pkg;
122
123     memset(buff, 0, len);
124     pkg = getenv("PKG_NAME");
125     if (pkg) {
126         snprintf(buff, len, ICO_MANIFEST_PATH,
127                  tzplatform_getenv(TZ_SYS_RO_APP), pkg);
128     }
129     else {
130         pkg = getenv(ICO_HS_CONFIG_TOP_ENV);
131         snprintf(buff, len, ICO_LOCAL_MANIFEST_PATH,
132                  pkg ? pkg : ICO_LOCAL_TOP_PATH);
133     }
134 }
135 // vim: set expandtab ts=4 sw=4: