2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FSys_SettingClient.h
19 * @brief This is the header file for _SettingClient class.
22 #ifndef _FSYSTEM_INTERNAL_SETTING_CLIENT_H_
23 #define _FSYSTEM_INTERNAL_SETTING_CLIENT_H_
25 #include <FBaseColArrayList.h>
26 #include <FBaseColHashMap.h>
27 #include <FBaseObject.h>
28 #include <FBaseRtEvent.h>
29 #include <FBaseRtIEventArg.h>
30 #include <FBaseRtIEventListener.h>
31 #include <FBaseString.h>
32 #include <FBaseInteger.h>
33 #include <FBaseUuId.h>
34 #include <FSysISettingEventListener.h>
35 #include <FSysISettingInfoSetValueAsyncResultListener.h>
37 #include <FIo_IIpcClientEventListener.h>
38 #include <FIo_IpcClient.h>
40 namespace Tizen { namespace System
43 class _SettingEventArg : public Tizen::Base::Runtime::IEventArg
46 Tizen::Base::String KeyName;
49 class _SettingEvent : public Tizen::Base::Runtime::Event
57 result AddSettingEventListener(ISettingEventListener& listener)
59 result r = AddListener(listener);
60 SysTryReturnResult(NID_SYS, __count >= 0, E_SYSTEM, "Listenr count[%d] is error.", __count);
69 result RemoveSettingEventListener(ISettingEventListener& listener)
71 result r = RemoveListener(listener);
72 if(r == E_OBJ_NOT_FOUND)
74 return E_OBJ_NOT_FOUND;
76 SysTryReturnResult(NID_SYS, __count > 0, E_SYSTEM, "Listenr count[%d] is error.", __count);
92 virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
94 ISettingEventListener* pListener = dynamic_cast<ISettingEventListener*> (&listener);
95 const _SettingEventArg* pArg = dynamic_cast<const _SettingEventArg*>(&arg);
97 if(pListener == null || pArg == null)
99 SysLogException(NID_SYS, E_SYSTEM, "It is failed to get listner or arguemnt");
103 Tizen::Base::String value =pArg->KeyName;
104 pListener->OnSettingChanged(value);
108 class _SettingAsyncEventArg : public Tizen::Base::Runtime::IEventArg
111 Tizen::Base::String Key;
115 class _SettingAsyncEvent : public Tizen::Base::Runtime::Event
118 virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
120 ISettingInfoSetValueAsyncResultListener* pListener = dynamic_cast<ISettingInfoSetValueAsyncResultListener*> (&listener);
121 const _SettingAsyncEventArg* pArg = dynamic_cast<const _SettingAsyncEventArg*>(&arg);
123 if(pListener == null || pArg == null)
125 SysLogException(NID_SYS, E_SYSTEM, "It is failed to get listner or arguemnts [%x/%x].", pListener, pArg);
129 result r = pArg->errorCode;
130 pListener->OnResultReceivedForSetValueAsync(pArg->Key, r);
131 RemoveListener(listener);
136 : public Tizen::Base::Object
137 , public Tizen::Io::_IIpcClientEventListener
140 _SettingClient(void);
141 virtual ~_SettingClient(void);
143 result Construct(void);
144 result GetValue(const Tizen::Base::String& key, bool& value);
145 result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
146 result GetValue(const Tizen::Base::String& key, double& value);
147 result GetValue(const Tizen::Base::String& key, int& value);
148 result GetValue(const Tizen::Base::String& key, long long& value);
149 result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
150 result GetValue(const Tizen::Base::String& key, Tizen::Base::UuId& value);
152 bool HasKey(const Tizen::Base::String& key);
154 result SetValue(const Tizen::Base::String& key, const bool& value);
155 result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
156 result SetValueAsync(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
157 result SetValueAsyncForPrivilegedKey(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
158 result SetValue(const Tizen::Base::String& key, const int& value);
159 result SetValue(const Tizen::Base::String& key, const Tizen::Base::String& value);
160 result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String value);
162 result AddSettingEventListenerForInternal(ISettingEventListener& listener);
163 result RemoveSettingEventListenerForInternal(ISettingEventListener& listener);
164 result AddSettingEventListener(ISettingEventListener& listener);
165 result RemoveSettingEventListener(ISettingEventListener& listener);
167 result SetSettingEventListener(ISettingEventListener* pListener);
169 result ResetToFactoryDefault(void);
171 void OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message);
172 void OnIpcServerDisconnected(Tizen::Io::_IpcClient& client);
174 static _SettingClient* GetInstance(void);
177 void OnDataReceived(const Tizen::Base::Collection::ArrayList& data);
178 result ConvertCode(Tizen::Base::String code);
180 Tizen::Base::String ConvertKeyOspToTizen(Tizen::Base::String ospKey);
181 result ConvertKeyTizenToOsp(Tizen::Base::String tizenKey, Tizen::Base::String& ospKey);
183 result GetOnService(Tizen::Base::String commandId, Tizen::Base::String key, Tizen::Base::String& response);
184 result SetOnService(Tizen::Base::String commandId, Tizen::Base::String key, Tizen::Base::String value);
185 result SetVolume(const Tizen::Base::String& soundCategory, int level);
187 result SubscribeEvent(void);
189 static void InitSettingClient(void);
190 static void DestroySettingClient(void);
192 Tizen::Base::Collection::HashMap __asyncEventList;
193 Tizen::Io::_IpcClient* __pIpcClient;
196 bool __subscribedForInternal;
197 ISettingEventListener* __pListener;
199 _SettingEvent* __pSettingEvent;
200 _SettingEvent* __pSettingEventForInternal;
201 static _SettingClient* __pSettingClient;
206 #endif //_FSYSTEM_INTERNAL_SETTING_CLIENT_H_