tizen 2.3.1 release
[framework/web/mobile/wrt-plugins-tizen.git] / src / Systeminfo / SystemInfoSIM.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_SIM_H__
19 #define __TIZEN_SYSTEMINFO_SYSTEMINFO_SIM_H__
20
21 #include <memory>
22 #include <string>
23 #include <atomic>
24 #include <ITapiSim.h>
25 #include "SystemInfoProperty.h"
26
27 namespace DeviceAPI {
28 namespace SystemInfo {
29
30 class SystemInfoSIM;
31 typedef std::shared_ptr<SystemInfoSIM> SystemInfoSIMPtr;
32
33 class SystemInfoSIM : public SystemInfoProperty {
34 public:
35     SystemInfoSIM(TapiHandle *tapi_handle);
36     virtual ~SystemInfoSIM();
37     virtual bool isReady() const;
38
39     std::string getState() const;
40     std::string getOperatorName() const;
41     std::string getMsisdn() const;
42     std::string getIccid() const;
43     unsigned short getMcc() const;
44     unsigned short getMnc() const;
45     std::string getMsin() const;
46     std::string getSpn() const;
47 private:
48     std::atomic_bool m_ready;
49     std::atomic<unsigned short> m_properties_to_process;
50     unsigned short m_mcc;
51     unsigned short m_mnc;
52     std::string m_operator_name;
53     std::string m_msin;
54     std::string m_state;
55     std::string m_msisdn;
56     std::string m_iccid;
57     std::string m_spn;
58
59     /**
60      * Decrement m_properties_to_process and if all properties are set,
61      * notify Systeminfo (in order to call js callback)
62      */
63     void checkIfReady();
64
65     static void cphsValueCallback(TapiHandle *handle, int result, void *data, void *user_data);
66     static void msisdnValueCallback(TapiHandle *handle, int result, void *data, void *user_data);
67     static void iccidValueCallback(TapiHandle *handle, int result, void *data, void *user_data);
68     static void spnValueCallback(TapiHandle *handle, int result, void *data, void *user_data);
69 };
70
71 } // SystemInfo
72 } // DeviceAPI
73
74 #endif //__TIZEN_SYSTEMINFO_SYSTEMINFO_SIM_H__