blob: 9c05be1c7a7d7d9175315fe9236892add0214907 [file] [log] [blame]
// Copyright 2014 The Chromium OS 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 LIBWEAVE_SRC_PRIVET_PRIVET_TYPES_H_
#define LIBWEAVE_SRC_PRIVET_PRIVET_TYPES_H_
#include <string>
#include <base/logging.h>
#include <weave/error.h>
#include <weave/settings.h>
namespace weave {
namespace privet {
enum class CryptoType {
kNone,
kSpake_p224,
};
enum class WifiType {
kWifi24,
kWifi50,
};
class UserInfo {
public:
explicit UserInfo(AuthScope scope = AuthScope::kNone, uint64_t user_id = 0)
: scope_{scope}, user_id_{scope == AuthScope::kNone ? 0 : user_id} {}
AuthScope scope() const { return scope_; }
uint64_t user_id() const { return user_id_; }
private:
AuthScope scope_;
uint64_t user_id_;
};
class ConnectionState final {
public:
enum Status {
kDisabled,
kUnconfigured,
kConnecting,
kOnline,
kOffline,
};
explicit ConnectionState(Status status) : status_(status) {}
explicit ConnectionState(ErrorPtr error)
: status_(kOffline), error_(std::move(error)) {}
Status status() const {
CHECK(!error_);
return status_;
}
bool IsStatusEqual(Status status) const {
if (error_)
return false;
return status_ == status;
}
const Error* error() const { return error_.get(); }
private:
Status status_;
ErrorPtr error_;
};
class SetupState final {
public:
enum Status {
kNone,
kInProgress,
kSuccess,
};
explicit SetupState(Status status) : status_(status) {}
explicit SetupState(ErrorPtr error)
: status_(kNone), error_(std::move(error)) {}
Status status() const {
CHECK(!error_);
return status_;
}
bool IsStatusEqual(Status status) const {
if (error_)
return false;
return status_ == status;
}
const Error* error() const { return error_.get(); }
private:
Status status_;
ErrorPtr error_;
};
} // namespace privet
} // namespace weave
#endif // LIBWEAVE_SRC_PRIVET_PRIVET_TYPES_H_