diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2008-08-20 00:21:51 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2008-08-20 00:21:51 +0000 |
commit | 1ff0402e472496cf5165dbd796df1bdc131a360b (patch) | |
tree | d363346777c732dd016aeb78e4a4e1a5b330c826 /cups/adminutil.c | |
parent | 9f5eb9be66a1755edd2c93bd7809883519c2e8eb (diff) |
Merge changes from CUPS 1.4svn-r7851.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@913 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'cups/adminutil.c')
-rw-r--r-- | cups/adminutil.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/cups/adminutil.c b/cups/adminutil.c index 3ea7e81af..96354a112 100644 --- a/cups/adminutil.c +++ b/cups/adminutil.c @@ -894,7 +894,58 @@ _cupsAdminGetServerSettings( */ if (!http) - http = _cupsConnect(); + { + /* + * See if we are connected to the same server... + */ + + if (cg->http) + { + /* + * Compare the connection hostname, port, and encryption settings to + * the cached defaults; these were initialized the first time we + * connected... + */ + + if (strcmp(cg->http->hostname, cg->server) || + cg->ipp_port != _httpAddrPort(cg->http->hostaddr) || + (cg->http->encryption != cg->encryption && + cg->http->encryption == HTTP_ENCRYPT_NEVER)) + { + /* + * Need to close the current connection because something has changed... + */ + + httpClose(cg->http); + cg->http = NULL; + } + } + + /* + * (Re)connect as needed... + */ + + if (!cg->http) + { + if ((cg->http = _httpCreate(cupsServer(), ippPort(), + cupsEncryption())) == NULL) + { + if (errno) + _cupsSetError(IPP_SERVICE_UNAVAILABLE, NULL, 0); + else + _cupsSetError(IPP_SERVICE_UNAVAILABLE, + _("Unable to connect to host."), 1); + + if (num_settings) + *num_settings = 0; + + if (settings) + *settings = NULL; + + return (0); + } + } + } if (!http || !num_settings || !settings) { |