summaryrefslogtreecommitdiff
path: root/protocols/Telegram/tdlib/td/td/telegram/net/AuthKeyState.h
blob: 6c6cb12fe65bbc05fb62506846e8691a71d96be2 (plain)
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
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once

#include "td/mtproto/AuthKey.h"

#include "td/utils/common.h"
#include "td/utils/StringBuilder.h"

namespace td {

enum class AuthKeyState : int32 { Empty, NoAuth, OK };

inline AuthKeyState get_auth_key_state(const mtproto::AuthKey &auth_key) {
  if (auth_key.empty()) {
    return AuthKeyState::Empty;
  } else if (auth_key.auth_flag()) {
    return AuthKeyState::OK;
  } else {
    return AuthKeyState::NoAuth;
  }
}

inline StringBuilder &operator<<(StringBuilder &sb, AuthKeyState state) {
  switch (state) {
    case AuthKeyState::Empty:
      return sb << "Empty";
    case AuthKeyState::NoAuth:
      return sb << "NoAuth";
    case AuthKeyState::OK:
      return sb << "OK";
    default:
      return sb << "Unknown AuthKeyState";
  }
}

}  // namespace td