Delay server ready timing until creating cache
[platform/core/appfw/pkgmgr-info.git] / src / common / system_locale.hh
1 // Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMMON_SYSTEM_LOCALE_HH_
6 #define COMMON_SYSTEM_LOCALE_HH_
7
8 #include <vconf.h>
9
10 #include <string>
11
12 namespace pkgmgr_common {
13
14 #ifndef EXPORT_API
15 #define EXPORT_API __attribute__((visibility("default")))
16 #endif
17
18 class EXPORT_API SystemLocale {
19  public:
20   class IEvent {
21    public:
22     virtual ~IEvent() = default;
23     virtual void OnChanged(const std::string& locale) = 0;
24   };
25
26   static SystemLocale& GetInst(bool is_online = true);
27   const std::string& Get() const;
28   void RegisterEvent(IEvent* listener);
29   void UnRegisterEvent();
30
31  private:
32   std::string lang_;
33   std::string locale_;
34   bool is_online_;
35   IEvent* listener_ = nullptr;
36
37   SystemLocale(bool is_online);
38   ~SystemLocale();
39   void SetLocale();
40   static void LanChangedCb(keynode_t* node, void* user_data);
41 };
42
43 }  // namespace pkgmgr_common
44
45 #endif  // COMMON_SYSTEM_LOCALE_HH_