• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROMEOS_NETWORK_DEVICE_STATE_H_
6 #define CHROMEOS_NETWORK_DEVICE_STATE_H_
7 
8 #include "base/values.h"
9 #include "chromeos/network/managed_state.h"
10 #include "chromeos/network/network_util.h"
11 
12 namespace chromeos {
13 
14 // Simple class to provide device state information. Similar to NetworkState;
15 // see network_state.h for usage guidelines.
16 class CHROMEOS_EXPORT DeviceState : public ManagedState {
17  public:
18   typedef std::vector<CellularScanResult> CellularScanResults;
19 
20   explicit DeviceState(const std::string& path);
21   virtual ~DeviceState();
22 
23   // ManagedState overrides
24   virtual bool PropertyChanged(const std::string& key,
25                                const base::Value& value) OVERRIDE;
26   virtual bool InitialPropertiesReceived(
27       const base::DictionaryValue& properties) OVERRIDE;
28 
29   // Accessors
mac_address()30   const std::string& mac_address() const { return mac_address_; }
31 
32   // Returns |mac_address_| in aa:bb format.
33   std::string GetFormattedMacAddress() const;
34 
35   // Cellular specific accessors
home_provider_id()36   const std::string& home_provider_id() const { return home_provider_id_; }
provider_requires_roaming()37   bool provider_requires_roaming() const { return provider_requires_roaming_; }
support_network_scan()38   bool support_network_scan() const { return support_network_scan_; }
scanning()39   bool scanning() const { return scanning_; }
technology_family()40   const std::string& technology_family() const { return technology_family_; }
carrier()41   const std::string& carrier() const { return carrier_; }
sim_lock_type()42   const std::string& sim_lock_type() const { return sim_lock_type_; }
sim_retries_left()43   uint32 sim_retries_left() const { return sim_retries_left_; }
sim_lock_enabled()44   bool sim_lock_enabled() const { return sim_lock_enabled_; }
meid()45   const std::string& meid() const { return meid_; }
imei()46   const std::string& imei() const { return imei_; }
iccid()47   const std::string& iccid() const { return iccid_; }
mdn()48   const std::string& mdn() const { return mdn_; }
scan_results()49   const CellularScanResults& scan_results() const { return scan_results_; }
properties()50   const DictionaryValue& properties() const { return properties_; }
51 
52   // Ethernet specific accessors
eap_authentication_completed()53   bool eap_authentication_completed() const {
54     return eap_authentication_completed_;
55   }
56 
57   // Returns true if the technology family is GSM and sim_present_ is false.
58   bool IsSimAbsent() const;
59 
60  private:
61   // Common Device Properties
62   std::string mac_address_;
63 
64   // Cellular specific properties
65   std::string home_provider_id_;
66   bool provider_requires_roaming_;
67   bool support_network_scan_;
68   bool scanning_;
69   std::string technology_family_;
70   std::string carrier_;
71   std::string sim_lock_type_;
72   uint32 sim_retries_left_;
73   bool sim_lock_enabled_;
74   bool sim_present_;
75   std::string meid_;
76   std::string imei_;
77   std::string iccid_;
78   std::string mdn_;
79   CellularScanResults scan_results_;
80 
81   // Ethernet specific properties
82   bool eap_authentication_completed_;
83 
84   // Keep all Device properties in a dictionary. Devices are limited and should
85   // change rarely if ever, so the overhead for this is small.
86   DictionaryValue properties_;
87 
88   DISALLOW_COPY_AND_ASSIGN(DeviceState);
89 };
90 
91 }  // namespace chromeos
92 
93 #endif  // CHROMEOS_NETWORK_DEVICE_STATE_H_
94