tizen 2.3.1 release
[framework/web/wearable/wrt-plugins-tizen.git] / src / Systeminfo / SystemInfoPropertySuccessCallbackData.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2013 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 #ifndef __TIZEN_SYSTEMINFO_SYSTEMINFO_PROPERTY_SUCCESSCALLBACK_H__
19 #define __TIZEN_SYSTEMINFO_SYSTEMINFO_PROPERTY_SUCCESSCALLBACK_H__
20
21 #include <CallbackUserData.h>
22 #include <memory>
23 #include <string>
24 #include <vector>
25
26 #include "SystemInfoProperty.h"
27
28 namespace DeviceAPI {
29 namespace SystemInfo {
30
31 class SystemInfoPropertySuccessCallbackData;
32 typedef SystemInfoPropertySuccessCallbackData PropertyCallbackData;
33 typedef std::shared_ptr<PropertyCallbackData> PropertyCallbackDataPtr;
34
35 struct PropertyCallbackDataHolder {
36     PropertyCallbackDataPtr ptr;
37 };
38
39 class SystemInfoPropertySuccessCallbackData: public Common::CallbackUserData {
40 public:
41     SystemInfoPropertySuccessCallbackData(JSContextRef globalCtx);
42     virtual ~SystemInfoPropertySuccessCallbackData();
43
44     void setError(const std::string &err_name, const std::string &err_message);
45     bool isError() const;
46     std::string getErrorName() const;
47     std::string getErrorMessage() const;
48
49     void setPropertyId(SystemInfoPropertyId property_id);
50     SystemInfoPropertyId getPropertyId() const;
51
52     void setNativeProperty(SystemInfoPropertyPtr property);
53     SystemInfoPropertyPtr getNativeProperty() const;
54     bool isPropertyReady() const;
55
56     void setOptions(SystemInfoOptions& options);
57     SystemInfoOptions getOptions() const;
58
59     void setListenerId(unsigned long id);
60     unsigned long getListenerId();
61
62     void setArrayCallback(bool isArray);
63     bool isArrayCallback();
64
65     void addNativeProperty(SystemInfoPropertyHolder* property);
66     std::vector<SystemInfoPropertyHolder*> getPropertyArray();
67
68     void clearArray();
69     bool isArrayEmpty();
70
71 private:
72     bool m_is_error;
73     bool m_is_array_callback;
74     std::string m_err_name;
75     std::string m_err_message;
76     unsigned long m_listener_id;
77
78     SystemInfoPropertyId m_property_id;
79     SystemInfoPropertyPtr m_native_property;
80     std::vector<SystemInfoPropertyHolder*> m_native_property_array;
81     SystemInfoOptions m_options;
82 };
83
84 } // SystemInfo
85 } // DeviceAPI
86 #endif //__TIZEN_SYSTEMINFO_SYSTEMINFO_PROPERTY_SUCCESSCALLBACK_H__