Bug fix: TIVI-1996.
[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
19 #include <ico_log.h>
20 #include "CicoResourceConfig.h"
21
22 /*============================================================================*/
23 /* functions                                                                  */
24 /*============================================================================*/
25 /*--------------------------------------------------------------------------*/
26 /**
27  * @brief   CicoResourceConfig::GetImagePath
28  *          set the directory path of the image files.
29  *
30  * @param[out]  buff                buffer that the pass set
31  * @param[in]   len                 buffer length
32  * @return      none
33  */
34 /*--------------------------------------------------------------------------*/
35 void
36 CicoResourceConfig::GetImagePath(char *buff, int len)
37 {
38     char *pkg;
39
40     memset(buff, 0, len);
41     pkg = getenv("PKG_NAME");
42     if (pkg) {
43         snprintf(buff, len, ICO_IMAGE_PATH, pkg);
44     }
45     else {
46         pkg = getenv(ICO_HS_CONFIG_TOP_ENV);
47         snprintf(buff, len, ICO_LOCAL_IMAGE_PATH,
48                  pkg ? pkg : ICO_LOCAL_TOP_PATH);
49     }
50     ICO_DBG("buff=\"%s\"", buff);
51 }
52
53 /*--------------------------------------------------------------------------*/
54 /**
55  * @brief   CicoResourceConfig::GetSoundPath
56  *          set the directory path of the sounds files.
57  *
58  * @param[out]  buff                buffer that the pass set
59  * @param[in]   len                 buffer length
60  * @return      none
61  */
62 /*--------------------------------------------------------------------------*/
63 void
64 CicoResourceConfig::GetSoundPath(char *buff, int len)
65 {
66     char *pkg;
67
68     memset(buff, 0, len);
69     pkg = getenv("PKG_NAME");
70     if (pkg) {
71         snprintf(buff, len, ICO_SOUND_PATH, pkg);
72     }
73     else {
74         pkg = getenv(ICO_HS_CONFIG_TOP_ENV);
75         snprintf(buff, len, ICO_LOCAL_SOUND_PATH,
76                  pkg ? pkg : ICO_LOCAL_TOP_PATH);
77     }
78 }
79
80 /*--------------------------------------------------------------------------*/
81 /**
82  * @brief   CicoResourceConfig::GetEdjPath
83  *          set the directory path of efj files.
84  *
85  * @param[out]  buff                buffer that the pass set
86  * @param[in]   len                 buffer length
87  * @return      none
88  */
89 /*--------------------------------------------------------------------------*/
90 void
91 CicoResourceConfig::GetEdjPath(char *buff, int len)
92 {
93     char *pkg;
94
95     memset(buff, 0, len);
96     pkg = getenv("PKG_NAME");
97     if (pkg) {
98         snprintf(buff, len, ICO_EDJ_PATH, pkg);
99     }
100     else {
101         pkg = getenv(ICO_HS_CONFIG_TOP_ENV);
102         snprintf(buff, len, ICO_LOCAL_EDJ_PATH,
103                  pkg ? pkg : ICO_LOCAL_TOP_PATH);
104     }
105 }
106
107 /*--------------------------------------------------------------------------*/
108 /**
109  * @brief   CicoResourceConfig::GetConfPath
110  *          set the directory path of edj files for onscreen.
111  *
112  * @param[out]  buff                buffer that the pass set
113  * @param[in]   len                 buffer length
114  * @return      none
115  */
116 /*--------------------------------------------------------------------------*/
117 void
118 CicoResourceConfig::GetConfPath(char *buff, int len)
119 {
120     char *pkg;
121
122     memset(buff, 0, len);
123     pkg = getenv("PKG_NAME");
124     if (pkg) {
125         snprintf(buff, len, ICO_MANIFEST_PATH, pkg);
126     }
127     else {
128         pkg = getenv(ICO_HS_CONFIG_TOP_ENV);
129         snprintf(buff, len, ICO_LOCAL_MANIFEST_PATH,
130                  pkg ? pkg : ICO_LOCAL_TOP_PATH);
131     }
132 }
133 // vim: set expandtab ts=4 sw=4: