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_SettingClientEx.h
19 * @brief This is the header file for _SettingClientEx class.
22 #ifndef _FSYSTEM_INTERNAL_SETTING_CLIENT_EX_H_
23 #define _FSYSTEM_INTERNAL_SETTING_CLIENT_EX_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 SysTryReturnResult(NID_SYS, __count > 0, E_SYSTEM, "Listenr count[%d] is error.", __count);
88 virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
90 ISettingEventListener* pListener = dynamic_cast<ISettingEventListener*> (&listener);
91 const _SettingEventArg* pArg = dynamic_cast<const _SettingEventArg*>(&arg);
93 if(pListener == null || pArg == null)
95 SysLogException(NID_SYS, E_SYSTEM, "It is failed to get listner or arguemnt");
99 Tizen::Base::String value =pArg->KeyName;
100 pListener->OnSettingChanged(value);
104 class _SettingAsyncEventArg : public Tizen::Base::Runtime::IEventArg
107 Tizen::Base::String Key;
111 class _SettingAsyncEvent : public Tizen::Base::Runtime::Event
114 virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
116 ISettingInfoSetValueAsyncResultListener* pListener = dynamic_cast<ISettingInfoSetValueAsyncResultListener*> (&listener);
117 const _SettingAsyncEventArg* pArg = dynamic_cast<const _SettingAsyncEventArg*>(&arg);
119 if(pListener == null || pArg == null)
121 SysLogException(NID_SYS, E_SYSTEM, "It is failed to get listner or arguemnts [%x/%x].", pListener, pArg);
125 result r = pArg->errorCode;
126 pListener->OnResultReceivedForSetValueAsync(pArg->Key, r);
127 RemoveListener(listener);
131 class _SettingClientEx
132 : public Tizen::Base::Object
133 , public Tizen::Io::_IIpcClientEventListener
136 _SettingClientEx(void);
137 virtual ~_SettingClientEx(void);
140 result GetValue(const Tizen::Base::String& key, bool& value);
141 result GetValueForPrivilegedKey(const Tizen::Base::String& key, bool& value);
142 result GetValue(const Tizen::Base::String& key, double& value);
143 result GetValue(const Tizen::Base::String& key, int& value);
144 result GetValue(const Tizen::Base::String& key, long long& value);
145 result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value);
146 result GetValue(const Tizen::Base::String& key, Tizen::Base::UuId& value);
148 bool HasKey(const Tizen::Base::String& key);
150 result SetValue(const Tizen::Base::String& key, const bool& value);
151 result SetValueForPrivilegedKey(const Tizen::Base::String& key, bool value);
152 result SetValueAsync(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
153 result SetValueAsyncForPrivilegedKey(const Tizen::Base::String& key, bool value, ISettingInfoSetValueAsyncResultListener* listener);
154 result SetValue(const Tizen::Base::String& key, const int& value);
155 result SetValue(const Tizen::Base::String& key, const Tizen::Base::String& value);
156 result SetValueForPrivilegedKey(const Tizen::Base::String& key, Tizen::Base::String value);
158 result AddSettingEventListenerForInternal(ISettingEventListener& listener);
159 result RemoveSettingEventListenerForInternal(ISettingEventListener& listener);
160 result AddSettingEventListener(ISettingEventListener& listener);
161 result RemoveSettingEventListener(ISettingEventListener& listener);
163 result SetSettingEventListener(ISettingEventListener* pListener);
165 result ResetToFactoryDefault(void);
167 void OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message);
169 static _SettingClientEx* GetInstance(void);
172 void OnDataReceived(const Tizen::Base::Collection::ArrayList& data);
173 result ConvertCode(Tizen::Base::String code);
175 Tizen::Base::String ConvertKeyOspToTizen(Tizen::Base::String ospKey);
176 result ConvertKeyTizenToOsp(Tizen::Base::String tizenKey, Tizen::Base::String& ospKey);
178 result GetOnService(Tizen::Base::String commandId, Tizen::Base::String key, Tizen::Base::String& response);
179 result SetOnService(Tizen::Base::String commandId, Tizen::Base::String key, Tizen::Base::String value);
180 result SetVolume(const Tizen::Base::String& soundCategory, int level);
182 result SubscribeEvent(void);
184 static void InitSettingClient(void);
186 Tizen::Base::Collection::HashMap __asyncEventList;
187 Tizen::Io::_IpcClient __ipcClient;
190 bool __subscribedForInternal;
191 ISettingEventListener* __pListener;
193 _SettingEvent* __pSettingEvent;
194 _SettingEvent* __pSettingEventForInternal;
195 static _SettingClientEx* __pSettingClient;
200 #endif //_FSYSTEM_INTERNAL_SETTING_CLIENT_EX_H_