OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "printing/backend/cups_helper.h" | 5 #include "printing/backend/cups_helper.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
9 | 9 |
10 namespace printing { | 10 namespace printing { |
11 | 11 |
12 // Default port for IPP print servers. | 12 // Default port for IPP print servers. |
13 static const int kDefaultIPPServerPort = 631; | 13 static const int kDefaultIPPServerPort = 631; |
14 | 14 |
15 // Helper wrapper around http_t structure, with connection and cleanup | 15 // Helper wrapper around http_t structure, with connection and cleanup |
16 // functionality. | 16 // functionality. |
17 HttpConnectionCUPS::HttpConnectionCUPS(const GURL& print_server_url) | 17 HttpConnectionCUPS::HttpConnectionCUPS(const GURL& print_server_url, |
| 18 http_encryption_t encryption) |
18 : http_(NULL) { | 19 : http_(NULL) { |
19 // If we have an empty url, use default print server. | 20 // If we have an empty url, use default print server. |
20 if (print_server_url.is_empty()) | 21 if (print_server_url.is_empty()) |
21 return; | 22 return; |
22 | 23 |
23 int port = print_server_url.IntPort(); | 24 int port = print_server_url.IntPort(); |
24 if (port == url_parse::PORT_UNSPECIFIED) | 25 if (port == url_parse::PORT_UNSPECIFIED) |
25 port = kDefaultIPPServerPort; | 26 port = kDefaultIPPServerPort; |
26 | 27 |
27 http_ = httpConnectEncrypt(print_server_url.host().c_str(), port, | 28 http_ = httpConnectEncrypt(print_server_url.host().c_str(), port, |
28 HTTP_ENCRYPT_NEVER); | 29 encryption); |
29 if (http_ == NULL) { | 30 if (http_ == NULL) { |
30 LOG(ERROR) << "CP_CUPS: Failed connecting to print server: " << | 31 LOG(ERROR) << "CP_CUPS: Failed connecting to print server: " << |
31 print_server_url; | 32 print_server_url; |
32 } | 33 } |
33 } | 34 } |
34 | 35 |
35 HttpConnectionCUPS::~HttpConnectionCUPS() { | 36 HttpConnectionCUPS::~HttpConnectionCUPS() { |
36 if (http_ != NULL) | 37 if (http_ != NULL) |
37 httpClose(http_); | 38 httpClose(http_); |
38 } | 39 } |
39 | 40 |
40 void HttpConnectionCUPS::SetBlocking(bool blocking) { | 41 void HttpConnectionCUPS::SetBlocking(bool blocking) { |
41 httpBlocking(http_, blocking ? 1 : 0); | 42 httpBlocking(http_, blocking ? 1 : 0); |
42 } | 43 } |
43 | 44 |
44 http_t* HttpConnectionCUPS::http() { | 45 http_t* HttpConnectionCUPS::http() { |
45 return http_; | 46 return http_; |
46 } | 47 } |
47 | 48 |
48 } // namespace printing | 49 } // namespace printing |
OLD | NEW |