| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef GCP20_PROTOTYPE_PRINTER_H_ | 5 #ifndef GCP20_PROTOTYPE_PRINTER_H_ |
| 6 #define GCP20_PROTOTYPE_PRINTER_H_ | 6 #define GCP20_PROTOTYPE_PRINTER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 // Returns true if printer was started. | 31 // Returns true if printer was started. |
| 32 bool IsOnline() const; | 32 bool IsOnline() const; |
| 33 | 33 |
| 34 // Stops all servers. | 34 // Stops all servers. |
| 35 void Stop(); | 35 void Stop(); |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 struct RegistrationInfo { | 38 struct RegistrationInfo { |
| 39 enum RegistrationState { | 39 enum RegistrationState { |
| 40 DEV_REG_UNREGISTERED = 0, | 40 DEV_REG_UNREGISTERED, |
| 41 DEV_REG_REGISTRATION_STARTED, | 41 DEV_REG_REGISTRATION_STARTED, |
| 42 DEV_REG_REGISTRATION_CLAIM_TOKEN_READY, | 42 DEV_REG_REGISTRATION_CLAIM_TOKEN_READY, |
| 43 DEV_REG_REGISTRATION_COMPLETING, | 43 DEV_REG_REGISTRATION_COMPLETING, |
| 44 DEV_REG_REGISTRATION_ERROR, | 44 DEV_REG_REGISTRATION_ERROR, |
| 45 DEV_REG_REGISTERED, | 45 DEV_REG_REGISTERED, |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 enum ConfirmationState { |
| 49 CONFIRMATION_PENDING, |
| 50 CONFIRMATION_CONFIRMED, |
| 51 CONFIRMATION_DISCARTED, |
| 52 CONFIRMATION_TIMEOUT, |
| 53 }; |
| 54 |
| 48 RegistrationInfo(); | 55 RegistrationInfo(); |
| 49 ~RegistrationInfo(); | 56 ~RegistrationInfo(); |
| 50 | 57 |
| 51 std::string user; | 58 std::string user; |
| 52 std::string refresh_token; | 59 std::string refresh_token; |
| 53 std::string device_id; | 60 std::string device_id; |
| 54 RegistrationState state; | 61 RegistrationState state; |
| 62 ConfirmationState confirmation_state; |
| 55 | 63 |
| 56 std::string registration_token; | 64 std::string registration_token; |
| 57 std::string complete_invite_url; | 65 std::string complete_invite_url; |
| 58 | 66 |
| 59 // Contains error response if |DEV_REG_REGISTRATION_ERROR| is set. | 67 // Contains error response if |DEV_REG_REGISTRATION_ERROR| is set. |
| 60 std::string error_description; | 68 std::string error_description; |
| 61 }; | 69 }; |
| 62 | 70 |
| 63 enum RegistrationAction { | 71 enum RegistrationAction { |
| 64 REG_ACTION_START, | 72 REG_ACTION_START, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 95 | 103 |
| 96 // Checks if register call is called correctly (|user| is correct, | 104 // Checks if register call is called correctly (|user| is correct, |
| 97 // error is no set etc). Returns |false| if error status is put into |status|. | 105 // error is no set etc). Returns |false| if error status is put into |status|. |
| 98 // Otherwise no error was occurred. | 106 // Otherwise no error was occurred. |
| 99 PrivetHttpServer::RegistrationErrorStatus CheckCommonRegErrors( | 107 PrivetHttpServer::RegistrationErrorStatus CheckCommonRegErrors( |
| 100 const std::string& user) const; | 108 const std::string& user) const; |
| 101 | 109 |
| 102 // Generates ProxyId for this device. | 110 // Generates ProxyId for this device. |
| 103 std::string GenerateProxyId() const; | 111 std::string GenerateProxyId() const; |
| 104 | 112 |
| 113 // Checks if confirmation was received. |
| 114 void WaitUserConfirmation(base::Time valid_until); |
| 115 |
| 105 // Creates data for DNS TXT respond. | 116 // Creates data for DNS TXT respond. |
| 106 std::vector<std::string> CreateTxt() const; | 117 std::vector<std::string> CreateTxt() const; |
| 107 | 118 |
| 108 RegistrationInfo reg_info_; | |
| 109 | |
| 110 // Saving and loading registration info from file. | 119 // Saving and loading registration info from file. |
| 111 void SaveToFile(const std::string& filename) const; | 120 void SaveToFile(const std::string& filename) const; |
| 112 bool LoadFromFile(const std::string& filename); | 121 bool LoadFromFile(const std::string& filename); |
| 113 | 122 |
| 123 // Converts errors. |
| 124 PrivetHttpServer::RegistrationErrorStatus ConfirmationToRegistrationError( |
| 125 RegistrationInfo::ConfirmationState state); |
| 126 |
| 127 RegistrationInfo reg_info_; |
| 128 |
| 114 // Contains DNS-SD server. | 129 // Contains DNS-SD server. |
| 115 DnsSdServer dns_server_; | 130 DnsSdServer dns_server_; |
| 116 | 131 |
| 117 // Contains Privet HTTP server. | 132 // Contains Privet HTTP server. |
| 118 PrivetHttpServer http_server_; | 133 PrivetHttpServer http_server_; |
| 119 | 134 |
| 120 // Contains Cloud Print client. | 135 // Contains Cloud Print client. |
| 121 scoped_ptr<CloudPrintRequester> requester_; | 136 scoped_ptr<CloudPrintRequester> requester_; |
| 122 | 137 |
| 123 XPrivetToken xtoken_; | 138 XPrivetToken xtoken_; |
| 124 | 139 |
| 125 // Uses for calculating uptime. | 140 // Uses for calculating uptime. |
| 126 base::Time starttime_; | 141 base::Time starttime_; |
| 127 | 142 |
| 128 DISALLOW_COPY_AND_ASSIGN(Printer); | 143 DISALLOW_COPY_AND_ASSIGN(Printer); |
| 129 }; | 144 }; |
| 130 | 145 |
| 131 #endif // GCP20_PROTOTYPE_PRINTER_H_ | 146 #endif // GCP20_PROTOTYPE_PRINTER_H_ |
| 132 | 147 |
| OLD | NEW |