fbee6e97f3ea4b2962eb8e9dc7f7cc762350df55
[platform/framework/native/appfw.git] / src / system / FSys_SystemResource.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        FSys_SystemResource.cpp
19  * @brief       This is the implementation for the _SystemResource class.
20  */
21
22 #include <libintl.h>
23 #include <pthread.h>
24
25 #include <FBaseResult.h>
26 #include <FBaseString.h>
27
28 #include <FBaseSysLog.h>
29
30 #include "FSys_SystemResource.h"
31
32
33 using namespace Tizen::Base;
34
35 namespace Tizen { namespace System
36 {
37
38 _ResourceDomainId _RESOURCE_DOMAIN_ID_OSP = "osp";
39
40 _SystemResource* _SystemResource::__pSystemRsrc = null;
41
42 _SystemResource::_SystemResource(void)
43 {
44 }
45
46
47 _SystemResource::~_SystemResource(void)
48 {
49 }
50
51 void
52 _SystemResource::InitSystemResource(void)
53 {
54         static _SystemResource systemResource;
55         __pSystemRsrc = &systemResource;
56 }
57
58 _SystemResource*
59 _SystemResource::GetInstance(void)
60 {
61         static pthread_once_t once_block = PTHREAD_ONCE_INIT;
62         if(__pSystemRsrc == null)
63         {
64                 pthread_once(&once_block, InitSystemResource);
65         }
66         return __pSystemRsrc;
67 }
68
69
70 String
71 _SystemResource::GetString(_ResourceDomainId domainId, _ResourceId resourceId) const
72 {
73         return String(dgettext(domainId, resourceId));
74 }
75
76 #define _L(r)   # r
77
78 String
79 _SystemResource::GetString(_SystemStringId id) const
80 {
81         static const char* const systemStringTable[] =
82         {
83                 _L(IDS_COM_INVALID),
84                 _L(IDS_COM_SK_OK),
85                 _L(IDS_COM_SK_CANCEL),
86                 _L(IDS_COM_POP_SELECT_DEFAULT_APPLICATION),
87                 _L(IDS_COM_POP_DEFAULT_APPLICATION),
88                 _L(IDS_COM_POP_APPLICATION_TYPE),
89         };
90
91         return GetString(_RESOURCE_DOMAIN_ID_OSP, systemStringTable[id]);
92 }
93
94 #undef _L
95
96 } } // Tizen::System