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