File: hermes_profile_client.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (151 lines) | stat: -rw-r--r-- 5,256 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_ASH_COMPONENTS_DBUS_HERMES_HERMES_PROFILE_CLIENT_H_
#define CHROMEOS_ASH_COMPONENTS_DBUS_HERMES_HERMES_PROFILE_CLIENT_H_

#include <string>

#include "base/component_export.h"
#include "base/observer_list.h"
#include "chromeos/ash/components/dbus/hermes/hermes_response_status.h"
#include "dbus/property.h"
#include "third_party/cros_system_api/dbus/hermes/dbus-constants.h"

namespace dbus {
class Bus;
class ObjectPath;
class ObjectProxy;
}  // namespace dbus

namespace ash {

// HermesProfileClient is used to talk to Hermes profile objects.
class COMPONENT_EXPORT(HERMES_CLIENT) HermesProfileClient {
 public:
  class TestInterface {
   public:
    enum class EnableProfileBehavior {
      kNotConnectable,
      kConnectableButNotConnected,
      kConnectableAndConnected
    };

    // Clears the Profile properties for the given path.
    virtual void ClearProfile(const dbus::ObjectPath& carrier_profile_path) = 0;
    // Sets service state to connected after eSIM profiles are enabled.
    virtual void SetEnableProfileBehavior(
        EnableProfileBehavior enable_profile_behavior) = 0;

    // Sets the return for the next call to
    // HermesEuiccClient::EnableCarrierProfile(). The implementation of this
    // method should only accept error statuses since clients expect additional
    // steps to have been taken when successful.
    virtual void SetNextEnableCarrierProfileResult(
        HermesResponseStatus status) = 0;
  };

  // Hermes profile properties.
  class Properties : public dbus::PropertySet {
   public:
    Properties(dbus::ObjectProxy* object_proxy,
               const PropertyChangedCallback& callback);
    ~Properties() override;

    dbus::Property<std::string>& iccid() { return iccid_; }
    dbus::Property<std::string>& service_provider() {
      return service_provider_;
    }
    dbus::Property<std::string>& mcc_mnc() { return mcc_mnc_; }
    dbus::Property<std::string>& activation_code() { return activation_code_; }
    dbus::Property<std::string>& name() { return name_; }
    dbus::Property<std::string>& nick_name() { return nick_name_; }
    dbus::Property<hermes::profile::State>& state() { return state_; }
    dbus::Property<hermes::profile::ProfileClass>& profile_class() {
      return profile_class_;
    }

   private:
    dbus::Property<std::string> iccid_;
    dbus::Property<std::string> service_provider_;
    dbus::Property<std::string> mcc_mnc_;
    dbus::Property<std::string> activation_code_;
    dbus::Property<std::string> name_;
    dbus::Property<std::string> nick_name_;
    dbus::Property<hermes::profile::State> state_;
    dbus::Property<hermes::profile::ProfileClass> profile_class_;
  };

  // Interface for observing changes to profile objects.
  class Observer {
   public:
    virtual ~Observer() = default;

    // Called when a carrier profile property changes.
    virtual void OnCarrierProfilePropertyChanged(
        const dbus::ObjectPath& object_path,
        const std::string& property_name) = 0;
  };

  // Adds an observer for changes to Hermes profile objects.
  virtual void AddObserver(Observer* observer);

  // Removes an observer for Hermes profile objects.
  virtual void RemoveObserver(Observer* observer);

  // Enables eSIM carrier profile with given |carrier_profile_path|. |callback|
  // will receive status code indicating response status.
  virtual void EnableCarrierProfile(
      const dbus::ObjectPath& carrier_profile_path,
      HermesResponseCallback callback) = 0;

  // Disables eSIM carrier profile with given |carrier_profile_path|. |callback|
  // will receive status code indicating response status.
  virtual void DisableCarrierProfile(
      const dbus::ObjectPath& carrier_profile_path,
      HermesResponseCallback callback) = 0;

  // Rename the profile's nick name to |new_name| with given
  // |carrier_profile_path|. |callback| will receive status code indicating
  // response status.
  virtual void RenameProfile(const dbus::ObjectPath& carrier_profile_path,
                             const std::string& new_name,
                             HermesResponseCallback callback) = 0;

  // Returns properties for eSIM carrier profile with given
  // |carrier_profile_path|.
  virtual Properties* GetProperties(
      const dbus::ObjectPath& carrier_profile_path) = 0;

  // Returns an instance of Hermes Profile Test interface.
  virtual TestInterface* GetTestInterface() = 0;

  // Creates and initializes the global instance.
  static void Initialize(dbus::Bus* bus);

  // Creates and initializes a global fake instance.
  static void InitializeFake();

  // Destroys the global instance.
  static void Shutdown();

  // Returns the global instance.
  static HermesProfileClient* Get();

 protected:
  HermesProfileClient();
  virtual ~HermesProfileClient();

  const base::ObserverList<HermesProfileClient::Observer>::Unchecked&
  observers() {
    return observers_;
  }

 private:
  base::ObserverList<HermesProfileClient::Observer>::Unchecked observers_;
};

}  // namespace ash

#endif  // CHROMEOS_ASH_COMPONENTS_DBUS_HERMES_HERMES_PROFILE_CLIENT_H_