| 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 12 matching lines...) Expand all Loading... |
| 23 // This class maintains work of DNS-SD server, HTTP server and others. | 23 // This class maintains work of DNS-SD server, HTTP server and others. |
| 24 class Printer : public base::SupportsWeakPtr<Printer>, | 24 class Printer : public base::SupportsWeakPtr<Printer>, |
| 25 public PrivetHttpServer::Delegate, | 25 public PrivetHttpServer::Delegate, |
| 26 public CloudPrintRequester::Delegate, | 26 public CloudPrintRequester::Delegate, |
| 27 public CloudPrintXmppListener::Delegate { | 27 public CloudPrintXmppListener::Delegate { |
| 28 public: | 28 public: |
| 29 // Constructs uninitialized object. | 29 // Constructs uninitialized object. |
| 30 Printer(); | 30 Printer(); |
| 31 | 31 |
| 32 // Destroys the object. | 32 // Destroys the object. |
| 33 virtual ~Printer(); | 33 ~Printer() override; |
| 34 | 34 |
| 35 // Starts all servers. | 35 // Starts all servers. |
| 36 bool Start(); | 36 bool Start(); |
| 37 | 37 |
| 38 // Returns true if printer was started. | 38 // Returns true if printer was started. |
| 39 bool IsRunning() const; | 39 bool IsRunning() const; |
| 40 | 40 |
| 41 // Stops all servers. | 41 // Stops all servers. |
| 42 void Stop(); | 42 void Stop(); |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 FRIEND_TEST_ALL_PREFIXES(Printer, ValidateCapabilities); | 45 FRIEND_TEST_ALL_PREFIXES(Printer, ValidateCapabilities); |
| 46 | 46 |
| 47 enum ConnectionState { | 47 enum ConnectionState { |
| 48 NOT_CONFIGURED, | 48 NOT_CONFIGURED, |
| 49 OFFLINE, | 49 OFFLINE, |
| 50 ONLINE, | 50 ONLINE, |
| 51 CONNECTING | 51 CONNECTING |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 std::string GetRawCdd(); | 54 std::string GetRawCdd(); |
| 55 | 55 |
| 56 // PrivetHttpServer::Delegate methods: | 56 // PrivetHttpServer::Delegate methods: |
| 57 virtual PrivetHttpServer::RegistrationErrorStatus RegistrationStart( | 57 PrivetHttpServer::RegistrationErrorStatus RegistrationStart( |
| 58 const std::string& user) override; | 58 const std::string& user) override; |
| 59 virtual PrivetHttpServer::RegistrationErrorStatus RegistrationGetClaimToken( | 59 PrivetHttpServer::RegistrationErrorStatus RegistrationGetClaimToken( |
| 60 const std::string& user, | 60 const std::string& user, |
| 61 std::string* token, | 61 std::string* token, |
| 62 std::string* claim_url) override; | 62 std::string* claim_url) override; |
| 63 virtual PrivetHttpServer::RegistrationErrorStatus RegistrationComplete( | 63 PrivetHttpServer::RegistrationErrorStatus RegistrationComplete( |
| 64 const std::string& user, | 64 const std::string& user, |
| 65 std::string* device_id) override; | 65 std::string* device_id) override; |
| 66 virtual PrivetHttpServer::RegistrationErrorStatus RegistrationCancel( | 66 PrivetHttpServer::RegistrationErrorStatus RegistrationCancel( |
| 67 const std::string& user) override; | 67 const std::string& user) override; |
| 68 virtual void GetRegistrationServerError(std::string* description) override; | 68 void GetRegistrationServerError(std::string* description) override; |
| 69 virtual void CreateInfo(PrivetHttpServer::DeviceInfo* info) override; | 69 void CreateInfo(PrivetHttpServer::DeviceInfo* info) override; |
| 70 virtual bool IsRegistered() const override; | 70 bool IsRegistered() const override; |
| 71 virtual bool IsLocalPrintingAllowed() const override; | 71 bool IsLocalPrintingAllowed() const override; |
| 72 virtual bool CheckXPrivetTokenHeader(const std::string& token) const override; | 72 bool CheckXPrivetTokenHeader(const std::string& token) const override; |
| 73 virtual const base::DictionaryValue& GetCapabilities() override; | 73 const base::DictionaryValue& GetCapabilities() override; |
| 74 virtual LocalPrintJob::CreateResult CreateJob( | 74 LocalPrintJob::CreateResult CreateJob( |
| 75 const std::string& ticket, | 75 const std::string& ticket, |
| 76 std::string* job_id, | 76 std::string* job_id, |
| 77 int* expires_in, | 77 int* expires_in, |
| 78 int* error_timeout, | 78 int* error_timeout, |
| 79 std::string* error_description) override; | 79 std::string* error_description) override; |
| 80 virtual LocalPrintJob::SaveResult SubmitDoc( | 80 LocalPrintJob::SaveResult SubmitDoc( |
| 81 const LocalPrintJob& job, | 81 const LocalPrintJob& job, |
| 82 std::string* job_id, | 82 std::string* job_id, |
| 83 int* expires_in, | 83 int* expires_in, |
| 84 std::string* error_description, | 84 std::string* error_description, |
| 85 int* timeout) override; | 85 int* timeout) override; |
| 86 virtual LocalPrintJob::SaveResult SubmitDocWithId( | 86 LocalPrintJob::SaveResult SubmitDocWithId( |
| 87 const LocalPrintJob& job, | 87 const LocalPrintJob& job, |
| 88 const std::string& job_id, | 88 const std::string& job_id, |
| 89 int* expires_in, | 89 int* expires_in, |
| 90 std::string* error_description, | 90 std::string* error_description, |
| 91 int* timeout) override; | 91 int* timeout) override; |
| 92 virtual bool GetJobState(const std::string& id, | 92 bool GetJobState(const std::string& id, LocalPrintJob::Info* info) override; |
| 93 LocalPrintJob::Info* info) override; | |
| 94 | 93 |
| 95 // CloudRequester::Delegate methods: | 94 // CloudRequester::Delegate methods: |
| 96 virtual void OnRegistrationStartResponseParsed( | 95 void OnRegistrationStartResponseParsed( |
| 97 const std::string& registration_token, | 96 const std::string& registration_token, |
| 98 const std::string& complete_invite_url, | 97 const std::string& complete_invite_url, |
| 99 const std::string& device_id) override; | 98 const std::string& device_id) override; |
| 100 virtual void OnRegistrationFinished( | 99 void OnRegistrationFinished( |
| 101 const std::string& refresh_token, | 100 const std::string& refresh_token, |
| 102 const std::string& access_token, | 101 const std::string& access_token, |
| 103 int access_token_expires_in_seconds) override; | 102 int access_token_expires_in_seconds) override; |
| 104 virtual void OnXmppJidReceived(const std::string& xmpp_jid) override; | 103 void OnXmppJidReceived(const std::string& xmpp_jid) override; |
| 105 virtual void OnAccesstokenReceviced(const std::string& access_token, | 104 void OnAccesstokenReceviced(const std::string& access_token, |
| 106 int expires_in_seconds) override; | 105 int expires_in_seconds) override; |
| 107 virtual void OnRegistrationError(const std::string& description) override; | 106 void OnRegistrationError(const std::string& description) override; |
| 108 virtual void OnNetworkError() override; | 107 void OnNetworkError() override; |
| 109 virtual void OnServerError(const std::string& description) override; | 108 void OnServerError(const std::string& description) override; |
| 110 virtual void OnAuthError() override; | 109 void OnAuthError() override; |
| 111 virtual std::string GetAccessToken() override; | 110 std::string GetAccessToken() override; |
| 112 virtual void OnPrintJobsAvailable( | 111 void OnPrintJobsAvailable( |
| 113 const std::vector<cloud_print_response_parser::Job>& jobs) override; | 112 const std::vector<cloud_print_response_parser::Job>& jobs) override; |
| 114 virtual void OnPrintJobDownloaded( | 113 void OnPrintJobDownloaded( |
| 115 const cloud_print_response_parser::Job& job) override; | 114 const cloud_print_response_parser::Job& job) override; |
| 116 virtual void OnPrintJobDone() override; | 115 void OnPrintJobDone() override; |
| 117 virtual void OnLocalSettingsReceived( | 116 void OnLocalSettingsReceived( |
| 118 LocalSettings::State state, | 117 LocalSettings::State state, |
| 119 const LocalSettings& settings) override; | 118 const LocalSettings& settings) override; |
| 120 virtual void OnLocalSettingsUpdated() override; | 119 void OnLocalSettingsUpdated() override; |
| 121 | 120 |
| 122 // CloudPrintXmppListener::Delegate methods: | 121 // CloudPrintXmppListener::Delegate methods: |
| 123 virtual void OnXmppConnected() override; | 122 void OnXmppConnected() override; |
| 124 virtual void OnXmppAuthError() override; | 123 void OnXmppAuthError() override; |
| 125 virtual void OnXmppNetworkError() override; | 124 void OnXmppNetworkError() override; |
| 126 virtual void OnXmppNewPrintJob(const std::string& device_id) override; | 125 void OnXmppNewPrintJob(const std::string& device_id) override; |
| 127 virtual void OnXmppNewLocalSettings(const std::string& device_id) override; | 126 void OnXmppNewLocalSettings(const std::string& device_id) override; |
| 128 virtual void OnXmppDeleteNotification(const std::string& device_id) override; | 127 void OnXmppDeleteNotification(const std::string& device_id) override; |
| 129 | 128 |
| 130 // Method for trying to reconnecting to server on start or after network fail. | 129 // Method for trying to reconnecting to server on start or after network fail. |
| 131 void TryConnect(); | 130 void TryConnect(); |
| 132 | 131 |
| 133 // Connects XMPP. | 132 // Connects XMPP. |
| 134 void ConnectXmpp(); | 133 void ConnectXmpp(); |
| 135 | 134 |
| 136 // Method to handle pending events. | 135 // Method to handle pending events. |
| 137 // Do *NOT* call this method instantly. Only with |PostOnIdle|. | 136 // Do *NOT* call this method instantly. Only with |PostOnIdle|. |
| 138 void OnIdle(); | 137 void OnIdle(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 bool pending_print_jobs_check_; | 247 bool pending_print_jobs_check_; |
| 249 | 248 |
| 250 // Contains |true| if Printer has to be deleted. | 249 // Contains |true| if Printer has to be deleted. |
| 251 bool pending_deletion_; | 250 bool pending_deletion_; |
| 252 | 251 |
| 253 DISALLOW_COPY_AND_ASSIGN(Printer); | 252 DISALLOW_COPY_AND_ASSIGN(Printer); |
| 254 }; | 253 }; |
| 255 | 254 |
| 256 #endif // GCP20_PROTOTYPE_PRINTER_H_ | 255 #endif // GCP20_PROTOTYPE_PRINTER_H_ |
| 257 | 256 |
| OLD | NEW |