forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhost_pairing_controller.h
141 lines (109 loc) · 4.09 KB
/
host_pairing_controller.h
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
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_
#define COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_
#include <string>
#include "base/macros.h"
namespace pairing_chromeos {
class HostPairingController {
public:
enum Stage {
STAGE_NONE,
STAGE_INITIALIZATION_ERROR,
STAGE_WAITING_FOR_CONTROLLER,
STAGE_WAITING_FOR_CODE_CONFIRMATION,
STAGE_CONTROLLER_CONNECTION_ERROR,
STAGE_SETUP_BASIC_CONFIGURATION,
STAGE_SETUP_NETWORK_ERROR,
STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE,
STAGE_WAITING_FOR_CREDENTIALS,
STAGE_ENROLLING,
STAGE_ENROLLMENT_ERROR,
STAGE_ENROLLMENT_SUCCESS,
STAGE_FINISHED
};
enum Connectivity {
CONNECTIVITY_UNTESTED,
CONNECTIVITY_NONE,
CONNECTIVITY_LIMITED,
CONNECTIVITY_CONNECTING,
CONNECTIVITY_CONNECTED,
};
enum UpdateStatus {
UPDATE_STATUS_UNKNOWN,
UPDATE_STATUS_UPDATING,
UPDATE_STATUS_REBOOTING,
UPDATE_STATUS_UPDATED,
};
enum EnrollmentStatus {
ENROLLMENT_STATUS_UNKNOWN,
ENROLLMENT_STATUS_ENROLLING,
ENROLLMENT_STATUS_FAILURE,
ENROLLMENT_STATUS_SUCCESS,
};
enum class ErrorCode : int {
ERROR_NONE = 0,
NETWORK_ERROR,
AUTH_ERROR,
ENROLL_ERROR,
OTHER_ERROR,
};
class Observer {
public:
Observer();
virtual ~Observer();
// Called when pairing has moved on from one stage to another.
virtual void PairingStageChanged(Stage new_stage) = 0;
// Called when the controller has sent a configuration to apply.
virtual void ConfigureHostRequested(bool accepted_eula,
const std::string& lang,
const std::string& timezone,
bool send_reports,
const std::string& keyboard_layout) {}
// Called when the controller has sent a network to add.
virtual void AddNetworkRequested(const std::string& onc_spec) {}
// Called when the controller has provided an |auth_token| for enrollment.
virtual void EnrollHostRequested(const std::string& auth_token) {}
// Called when the controller has sent a reboot request. This will happen
// when the host enrollment fails.
virtual void RebootHostRequested() {}
private:
DISALLOW_COPY_AND_ASSIGN(Observer);
};
HostPairingController();
virtual ~HostPairingController();
// Returns current stage of pairing process.
virtual Stage GetCurrentStage() = 0;
// Starts pairing process. Can be called only on |STAGE_NONE| stage.
virtual void StartPairing() = 0;
// Returns device name.
virtual std::string GetDeviceName() = 0;
// Returns 6-digit confirmation code. Can be called only on
// |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage.
virtual std::string GetConfirmationCode() = 0;
// Returns an enrollment domain name. Can be called on stage
// |STAGE_ENROLLMENT| and later.
virtual std::string GetEnrollmentDomain() = 0;
// Notify that the network connectivity status has changed.
virtual void OnNetworkConnectivityChanged(
Connectivity connectivity_status) = 0;
// Notify that the update status has changed.
virtual void OnUpdateStatusChanged(UpdateStatus update_status) = 0;
// Notify that enrollment status has changed.
// Can be called on stage |STAGE_WAITING_FOR_CREDENTIALS|.
virtual void OnEnrollmentStatusChanged(
EnrollmentStatus enrollment_status) = 0;
// Set the permanent id assigned during enrollment.
virtual void SetPermanentId(const std::string& permanent_id) = 0;
virtual void SetErrorCodeAndMessage(int error_code,
const std::string& error_message) = 0;
// Reset the controller.
virtual void Reset() = 0;
virtual void AddObserver(Observer* observer) = 0;
virtual void RemoveObserver(Observer* observer) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(HostPairingController);
};
} // namespace pairing_chromeos
#endif // COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_