X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=cups-avahi-5-services.patch;h=820b3c32b9d52270ed1a5dcb6358b9c5dd7f9037;hb=refs%2Fheads%2FDEVEL;hp=00328805100fa814c103378f276b6fc4c6c045ad;hpb=1b240119b4d57859a57428ea449b9fde4e9771c0;p=packages%2Fcups.git diff --git a/cups-avahi-5-services.patch b/cups-avahi-5-services.patch index 0032880..820b3c3 100644 --- a/cups-avahi-5-services.patch +++ b/cups-avahi-5-services.patch @@ -1,8 +1,105 @@ -diff --git a/scheduler/client.c b/scheduler/client.c -index e4c9b01..984dcc5 100644 ---- a/scheduler/client.c -+++ b/scheduler/client.c -@@ -4987,7 +4987,7 @@ valid_host(cupsd_client_t *con) /* I - Client connection */ +diff -up cups-1.5.2/cgi-bin/admin.c.avahi-5-services cups-1.5.2/cgi-bin/admin.c +--- cups-1.5.2/cgi-bin/admin.c.avahi-5-services 2011-08-17 22:01:53.000000000 +0100 ++++ cups-1.5.2/cgi-bin/admin.c 2012-03-14 15:08:25.701611799 +0000 +@@ -1643,7 +1643,7 @@ do_config_server(http_t *http) /* I - H + else + local_protocols[0] = '\0'; + +-#ifdef HAVE_DNSSD ++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) + if (cgiGetVariable("BROWSE_LOCAL_DNSSD")) + { + if (local_protocols[0]) +@@ -1651,7 +1651,7 @@ do_config_server(http_t *http) /* I - H + else + strcat(local_protocols, "dnssd"); + } +-#endif /* HAVE_DNSSD */ ++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */ + + #ifdef HAVE_LDAP + if (cgiGetVariable("BROWSE_LOCAL_LDAP")) +@@ -2718,9 +2718,9 @@ do_menu(http_t *http) /* I - HTTP conn + #endif /* HAVE_GSSAPI */ + cgiSetVariable("KERBEROS", ""); + +-#ifdef HAVE_DNSSD ++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) + cgiSetVariable("HAVE_DNSSD", "1"); +-#endif /* HAVE_DNSSD */ ++#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */ + + #ifdef HAVE_LDAP + cgiSetVariable("HAVE_LDAP", "1"); +diff -up cups-1.5.2/scheduler/avahi.h.avahi-5-services cups-1.5.2/scheduler/avahi.h +--- cups-1.5.2/scheduler/avahi.h.avahi-5-services 2012-03-14 15:07:29.477542381 +0000 ++++ cups-1.5.2/scheduler/avahi.h 2012-03-14 15:08:25.701611799 +0000 +@@ -3,7 +3,7 @@ + * + * Avahi poll implementation for the CUPS scheduler. + * +- * Copyright (C) 2010, 2011 Red Hat, Inc. ++ * Copyright (C) 2010, 2011, 2012 Red Hat, Inc. + * Authors: + * Tim Waugh + * +@@ -32,37 +32,40 @@ + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +-#include ++#ifndef _CUPS_AVAHI_H_ ++# define _CUPS_AVAHI_H_ + +-#ifdef HAVE_AVAHI +-# include +-# include +-#endif /* HAVE_AVAHI */ ++/* ++ * Include necessary headers... ++ */ + +-#ifdef HAVE_AUTHORIZATION_H +-# include +-#endif /* HAVE_AUTHORIZATION_H */ ++# include + ++# ifdef HAVE_AVAHI ++# include ++# include ++# endif /* HAVE_AVAHI */ + +-#ifdef HAVE_AVAHI ++# ifdef HAVE_AVAHI + typedef struct + { + AvahiPoll api; + cups_array_t *watched_fds; + cups_array_t *timeouts; + } AvahiCupsPoll; +-#endif /* HAVE_AVAHI */ ++# endif /* HAVE_AVAHI */ + + /* + * Prototypes... + */ + +-#ifdef HAVE_AVAHI ++# ifdef HAVE_AVAHI + extern AvahiCupsPoll * avahi_cups_poll_new(void); + extern void avahi_cups_poll_free(AvahiCupsPoll *cups_poll); + extern const AvahiPoll *avahi_cups_poll_get(AvahiCupsPoll *cups_poll); +-#endif /* HAVE_AVAHI */ ++# endif /* HAVE_AVAHI */ + ++#endif /* !_CUPS_AVAHI_H_ */ + + /* + * End of "$Id$". +diff -up cups-1.5.2/scheduler/client.c.avahi-5-services cups-1.5.2/scheduler/client.c +--- cups-1.5.2/scheduler/client.c.avahi-5-services 2012-01-13 23:00:22.000000000 +0000 ++++ cups-1.5.2/scheduler/client.c 2012-03-14 15:08:25.703611797 +0000 +@@ -4989,7 +4989,7 @@ valid_host(cupsd_client_t *con) /* I - !strncmp(host, "[::1]:", 6)); } @@ -11,7 +108,7 @@ index e4c9b01..984dcc5 100644 /* * Check if the hostname is something.local (Bonjour); if so, allow it. */ -@@ -4996,7 +4996,7 @@ valid_host(cupsd_client_t *con) /* I - Client connection */ +@@ -4998,7 +4998,7 @@ valid_host(cupsd_client_t *con) /* I - (!_cups_strcasecmp(end, ".local") || !_cups_strncasecmp(end, ".local:", 7) || !_cups_strcasecmp(end, ".local.") || !_cups_strncasecmp(end, ".local.:", 8))) return (1); @@ -20,11 +117,10 @@ index e4c9b01..984dcc5 100644 /* * Check if the hostname is an IP address... -diff --git a/scheduler/conf.c b/scheduler/conf.c -index badc630..c1edd39 100644 ---- a/scheduler/conf.c -+++ b/scheduler/conf.c -@@ -648,7 +648,7 @@ cupsdReadConfiguration(void) +diff -up cups-1.5.2/scheduler/conf.c.avahi-5-services cups-1.5.2/scheduler/conf.c +--- cups-1.5.2/scheduler/conf.c.avahi-5-services 2012-03-14 15:04:17.636305526 +0000 ++++ cups-1.5.2/scheduler/conf.c 2012-03-14 15:08:25.706611803 +0000 +@@ -652,7 +652,7 @@ cupsdReadConfiguration(void) Browsing = CUPS_DEFAULT_BROWSING; DefaultShared = CUPS_DEFAULT_DEFAULT_SHARED; @@ -33,28 +129,32 @@ index badc630..c1edd39 100644 cupsdSetString(&DNSSDRegType, "_ipp._tcp,_cups"); #endif /* HAVE_DNSSD */ -diff --git a/scheduler/dirsvc.c b/scheduler/dirsvc.c -index eb3c862..48dcef9 100644 ---- a/scheduler/dirsvc.c -+++ b/scheduler/dirsvc.c +diff -up cups-1.5.2/scheduler/dirsvc.c.avahi-5-services cups-1.5.2/scheduler/dirsvc.c +--- cups-1.5.2/scheduler/dirsvc.c.avahi-5-services 2012-03-14 15:04:17.674305572 +0000 ++++ cups-1.5.2/scheduler/dirsvc.c 2012-03-14 15:08:25.709611806 +0000 @@ -27,6 +27,7 @@ - * remote printers. - * cupsdRegisterPrinter() - Start sending broadcast information for a - * printer or update the broadcast contents. + * ldap_connect() - Start new LDAP connection + * ldap_reconnect() - Reconnect to LDAP Server + * ldap_disconnect() - Disconnect from LDAP Server + * cupsdStartAvahiClient() - Start an Avahi client if needed - * cupsdStartBrowsing() - Start sending and receiving broadcast - * information. - * cupsdStopBrowsing() - Stop sending and receiving broadcast -@@ -45,6 +46,8 @@ - * printer. - * dnssdPackTxtRecord() - Pack an array of key/value pairs into the TXT - * record format. + * cupsdStartBrowsing() - Start sending and receiving broadcast + * information. + * cupsdStartPolling() - Start polling servers as needed. +@@ -40,11 +41,12 @@ + * dequote() - Remote quotes from a string. + * dnssdAddAlias() - Add a DNS-SD alias name. + * dnssdBuildTxtRecord() - Build a TXT record from printer info. +- * dnssdComparePrinters() - Compare the registered names of two printers. + * dnssdDeregisterPrinter() - Stop sending broadcast information for a + * printer. + * dnssdPackTxtRecord() - Pack an array of key/value pairs into the TXT + * record format. + * avahiPackTxtRecord() - Pack an array of key/value pairs into an + * AvahiStringList. - * dnssdRegisterCallback() - DNSServiceRegister callback. - * dnssdRegisterPrinter() - Start sending broadcast information for a - * printer or update the broadcast contents. -@@ -83,6 +86,7 @@ + * dnssdRegisterCallback() - DNSServiceRegister callback. + * dnssdRegisterPrinter() - Start sending broadcast information for a + * printer or update the broadcast contents. +@@ -83,6 +85,7 @@ */ #include "cupsd.h" @@ -62,7 +162,7 @@ index eb3c862..48dcef9 100644 #include #ifdef HAVE_DNSSD -@@ -97,6 +101,17 @@ +@@ -97,6 +100,17 @@ # endif /* HAVE_SYSTEMCONFIGURATION */ # endif /* __APPLE__ */ #endif /* HAVE_DNSSD */ @@ -80,14 +180,13 @@ index eb3c862..48dcef9 100644 /* -@@ -159,26 +174,39 @@ static void update_polling(void); +@@ -159,27 +173,38 @@ static void update_polling(void); static void update_smb(int onoff); +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) +static cupsd_txt_record_t dnssdBuildTxtRecord(int *txt_len, cupsd_printer_t *p, + int for_lpd); -+static int dnssdComparePrinters(cupsd_printer_t *a, cupsd_printer_t *b); +static void dnssdDeregisterPrinter(cupsd_printer_t *p); +static void dnssdRegisterPrinter(cupsd_printer_t *p); +static void dnssdStop(void); @@ -100,6 +199,7 @@ index eb3c862..48dcef9 100644 # endif /* HAVE_COREFOUNDATION */ -static char *dnssdBuildTxtRecord(int *txt_len, cupsd_printer_t *p, - int for_lpd); +-static int dnssdComparePrinters(cupsd_printer_t *a, cupsd_printer_t *b); -static void dnssdDeregisterPrinter(cupsd_printer_t *p); -static char *dnssdPackTxtRecord(int *txt_len, char *keyvalue[][2], - int count); @@ -124,10 +224,10 @@ index eb3c862..48dcef9 100644 + void *userdata); +#endif /* HAVE_AVAHI */ + - - /* - * 'cupsdDeregisterPrinter()' - Stop sending broadcast information for a -@@ -283,10 +310,10 @@ cupsdDeregisterPrinter( + #ifdef HAVE_LDAP + static const char * const ldap_attrs[] =/* CUPS LDAP attributes */ + { +@@ -283,10 +308,10 @@ cupsdDeregisterPrinter( ldap_dereg_printer(p); #endif /* HAVE_LDAP */ @@ -141,7 +241,7 @@ index eb3c862..48dcef9 100644 } -@@ -702,10 +729,10 @@ cupsdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */ +@@ -702,10 +727,10 @@ cupsdRegisterPrinter(cupsd_printer_t *p) slpRegisterPrinter(p); */ #endif /* HAVE_LIBSLP */ @@ -155,7 +255,7 @@ index eb3c862..48dcef9 100644 } -@@ -1419,6 +1446,27 @@ ldap_disconnect(LDAP *ld) /* I - LDAP handle */ +@@ -1419,6 +1444,36 @@ ldap_disconnect(LDAP *ld) /* I - LDAP h #endif /* HAVE_LDAP */ @@ -167,14 +267,23 @@ index eb3c862..48dcef9 100644 +void +cupsdStartAvahiClient(void) +{ ++ int error = 0; ++ + if (!AvahiCupsClient && !AvahiCupsClientConnecting) + { + if (!AvahiCupsPollHandle) + AvahiCupsPollHandle = avahi_cups_poll_new (); + + if (AvahiCupsPollHandle) -+ avahi_client_new (avahi_cups_poll_get (AvahiCupsPollHandle), -+ AVAHI_CLIENT_NO_FAIL, avahi_client_cb, NULL, NULL); ++ { ++ if (avahi_client_new (avahi_cups_poll_get (AvahiCupsPollHandle), ++ AVAHI_CLIENT_NO_FAIL, ++ avahi_client_cb, NULL, ++ &error) != NULL) ++ AvahiCupsClientConnecting = 1; ++ else ++ cupsdLogMessage (CUPSD_LOG_WARN, "Avahi client failed: %d", error); ++ } + } +} +#endif /* HAVE_AVAHI */ @@ -183,13 +292,13 @@ index eb3c862..48dcef9 100644 /* * 'cupsdStartBrowsing()' - Start sending and receiving broadcast information. */ -@@ -1542,13 +1590,16 @@ cupsdStartBrowsing(void) +@@ -1542,13 +1597,16 @@ cupsdStartBrowsing(void) else BrowseSocket = -1; -#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) - if (BrowseLocalProtocols & BROWSE_DNSSD) + if ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_DNSSD) { +#ifdef HAVE_DNSSD DNSServiceErrorType error; /* Error from service creation */ @@ -201,7 +310,7 @@ index eb3c862..48dcef9 100644 /* * First create a "master" connection for all registrations... */ -@@ -1573,6 +1624,7 @@ cupsdStartBrowsing(void) +@@ -1573,6 +1631,7 @@ cupsdStartBrowsing(void) fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); cupsdAddSelect(fd, (cupsd_selfunc_t)dnssdUpdate, NULL, NULL); @@ -209,7 +318,16 @@ index eb3c862..48dcef9 100644 /* * Then get the port we use for registrations. If we are not listening -@@ -1606,9 +1658,16 @@ cupsdStartBrowsing(void) +@@ -1598,17 +1657,23 @@ cupsdStartBrowsing(void) + */ + + if (BrowseRemoteProtocols & BROWSE_DNSSD) +- DNSSDPrinters = cupsArrayNew((cups_array_func_t)dnssdComparePrinters, +- NULL); ++ DNSSDPrinters = cupsArrayNew(NULL, NULL); + + /* + * Set the computer name and register the web interface... */ cupsdUpdateDNSSDName(); @@ -225,9 +343,9 @@ index eb3c862..48dcef9 100644 + } +#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */ - /* - * Enable LPD and SMB printer sharing as needed through external programs... -@@ -1834,10 +1893,10 @@ cupsdStopBrowsing(void) + #ifdef HAVE_LIBSLP + if ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_SLP) +@@ -1834,10 +1899,10 @@ cupsdStopBrowsing(void) BrowseSocket = -1; } @@ -241,7 +359,7 @@ index eb3c862..48dcef9 100644 #ifdef HAVE_LIBSLP if (((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_SLP) && -@@ -1902,7 +1961,7 @@ cupsdStopPolling(void) +@@ -1902,7 +1967,7 @@ cupsdStopPolling(void) } @@ -250,7 +368,7 @@ index eb3c862..48dcef9 100644 /* * 'cupsdUpdateDNSSDName()' - Update the computer name we use for browsing... */ -@@ -1910,8 +1969,14 @@ cupsdStopPolling(void) +@@ -1910,8 +1975,14 @@ cupsdStopPolling(void) void cupsdUpdateDNSSDName(void) { @@ -265,7 +383,7 @@ index eb3c862..48dcef9 100644 # ifdef HAVE_SYSTEMCONFIGURATION SCDynamicStoreRef sc; /* Context for dynamic store */ CFDictionaryRef btmm; /* Back-to-My-Mac domains */ -@@ -2042,6 +2107,7 @@ cupsdUpdateDNSSDName(void) +@@ -2042,6 +2113,7 @@ cupsdUpdateDNSSDName(void) else strlcpy(webif, "CUPS Web Interface", sizeof(webif)); @@ -273,7 +391,7 @@ index eb3c862..48dcef9 100644 if (WebIFRef) DNSServiceRefDeallocate(WebIFRef); -@@ -2054,9 +2120,45 @@ cupsdUpdateDNSSDName(void) +@@ -2054,9 +2126,45 @@ cupsdUpdateDNSSDName(void) NULL)) != kDNSServiceErr_NoError) cupsdLogMessage(CUPSD_LOG_ERROR, "DNS-SD web interface registration failed: %d", error); @@ -320,7 +438,7 @@ index eb3c862..48dcef9 100644 #ifdef HAVE_LDAP -@@ -2334,13 +2436,15 @@ dnssdAddAlias(const void *key, /* I - Key */ +@@ -2334,13 +2442,15 @@ dnssdAddAlias(const void *key, /* I - K "Bad Back to My Mac domain in dynamic store!"); } # endif /* HAVE_COREFOUNDATION */ @@ -337,7 +455,7 @@ index eb3c862..48dcef9 100644 dnssdBuildTxtRecord( int *txt_len, /* O - TXT record length */ cupsd_printer_t *p, /* I - Printer information */ -@@ -2379,7 +2483,12 @@ dnssdBuildTxtRecord( +@@ -2379,7 +2489,12 @@ dnssdBuildTxtRecord( keyvalue[i ][0] = "ty"; keyvalue[i++][1] = p->make_model ? p->make_model : "Unknown"; @@ -351,12 +469,24 @@ index eb3c862..48dcef9 100644 httpAssembleURIf(HTTP_URI_CODING_ALL, adminurl_str, sizeof(adminurl_str), "http", NULL, admin_hostname, DNSSDPort, "/%s/%s", (p->type & CUPS_PRINTER_CLASS) ? "classes" : "printers", -@@ -2462,7 +2571,12 @@ dnssdBuildTxtRecord( +@@ -2462,19 +2577,12 @@ dnssdBuildTxtRecord( * Then pack them into a proper txt record... */ +#ifdef HAVE_DNSSD return (dnssdPackTxtRecord(txt_len, keyvalue, i)); +-} +- +- +-/* +- * 'dnssdComparePrinters()' - Compare the registered names of two printers. +- */ +- +-static int /* O - Result of comparison */ +-dnssdComparePrinters(cupsd_printer_t *a,/* I - First printer */ +- cupsd_printer_t *b)/* I - Second printer */ +-{ +- return (_cups_strcasecmp(a->reg_name, b->reg_name)); +#endif /* HAVE_DNSSD */ +#ifdef HAVE_AVAHI + return (avahiPackTxtRecord(keyvalue, i)); @@ -364,7 +494,7 @@ index eb3c862..48dcef9 100644 } -@@ -2489,6 +2612,10 @@ dnssdDeregisterPrinter( +@@ -2489,6 +2597,10 @@ dnssdDeregisterPrinter( { cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdDeregisterPrinter(%s)", p->name); @@ -375,7 +505,7 @@ index eb3c862..48dcef9 100644 /* * Closing the socket deregisters the service */ -@@ -2524,6 +2651,24 @@ dnssdDeregisterPrinter( +@@ -2524,6 +2636,24 @@ dnssdDeregisterPrinter( free(p->printer_txt); p->printer_txt = NULL; } @@ -400,7 +530,7 @@ index eb3c862..48dcef9 100644 /* * Remove the printer from the array of DNS-SD printers, then clear the -@@ -2533,8 +2678,10 @@ dnssdDeregisterPrinter( +@@ -2533,8 +2663,10 @@ dnssdDeregisterPrinter( cupsArrayRemove(DNSSDPrinters, p); cupsdClearString(&p->reg_name); } @@ -411,7 +541,7 @@ index eb3c862..48dcef9 100644 /* * 'dnssdPackTxtRecord()' - Pack an array of key/value pairs into the * TXT record format. -@@ -2644,8 +2791,10 @@ dnssdRegisterCallback( +@@ -2644,8 +2776,10 @@ dnssdRegisterCallback( LastEvent |= CUPSD_EVENT_PRINTER_MODIFIED; } } @@ -422,7 +552,7 @@ index eb3c862..48dcef9 100644 /* * 'dnssdRegisterPrinter()' - Start sending broadcast information for a printer * or update the broadcast contents. -@@ -2654,20 +2803,40 @@ dnssdRegisterCallback( +@@ -2654,20 +2788,40 @@ dnssdRegisterCallback( static void dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */ { @@ -466,7 +596,7 @@ index eb3c862..48dcef9 100644 /* * If per-printer sharing was just disabled make sure we're not * registered before returning. -@@ -2686,12 +2855,36 @@ dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */ +@@ -2686,12 +2840,36 @@ dnssdRegisterPrinter(cupsd_printer_t *p) if (p->info && strlen(p->info) > 0) { if (DNSSDComputerName) @@ -505,7 +635,7 @@ index eb3c862..48dcef9 100644 else strlcpy(name, p->name, sizeof(name)); -@@ -2712,6 +2905,7 @@ dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */ +@@ -2712,6 +2890,7 @@ dnssdRegisterPrinter(cupsd_printer_t *p) * Register IPP and (optionally) LPD... */ @@ -513,7 +643,7 @@ index eb3c862..48dcef9 100644 ipp_len = 0; /* anti-compiler-warning-code */ ipp_txt = dnssdBuildTxtRecord(&ipp_len, p, 0); -@@ -2884,6 +3078,209 @@ dnssdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */ +@@ -2884,6 +3063,209 @@ dnssdRegisterPrinter(cupsd_printer_t *p) if (printer_txt) free(printer_txt); @@ -723,7 +853,7 @@ index eb3c862..48dcef9 100644 } -@@ -2896,6 +3293,10 @@ dnssdStop(void) +@@ -2896,6 +3278,10 @@ dnssdStop(void) { cupsd_printer_t *p; /* Current printer */ @@ -734,15 +864,31 @@ index eb3c862..48dcef9 100644 /* * De-register the individual printers -@@ -2906,6 +3307,7 @@ dnssdStop(void) - p = (cupsd_printer_t *)cupsArrayNext(Printers)) - dnssdDeregisterPrinter(p); - -+#ifdef HAVE_DNSSD - /* +@@ -2910,12 +3296,23 @@ dnssdStop(void) * Shutdown the rest of the service refs... */ -@@ -2926,14 +3328,17 @@ dnssdStop(void) + ++#ifdef HAVE_DNSSD + if (WebIFRef) + { + DNSServiceRefDeallocate(WebIFRef); + WebIFRef = NULL; + } ++#endif /* HAVE_DNSSD */ ++#ifdef HAVE_AVAHI ++ if (AvahiWebIFGroup) ++ { ++ avahi_entry_group_reset (AvahiWebIFGroup); ++ avahi_entry_group_free (AvahiWebIFGroup); ++ AvahiWebIFGroup = NULL; ++ } ++#endif /* HAVE_AVAHI */ + ++#ifdef HAVE_DNSSD + if (RemoteRef) + { + DNSServiceRefDeallocate(RemoteRef); +@@ -2926,14 +3323,17 @@ dnssdStop(void) DNSServiceRefDeallocate(DNSSDRef); DNSSDRef = NULL; @@ -760,7 +906,7 @@ index eb3c862..48dcef9 100644 /* * 'dnssdUpdate()' - Handle DNS-SD queries. */ -@@ -2955,6 +3360,147 @@ dnssdUpdate(void) +@@ -2955,6 +3355,153 @@ dnssdUpdate(void) #endif /* HAVE_DNSSD */ @@ -875,10 +1021,16 @@ index eb3c862..48dcef9 100644 + /* + * No Avahi daemon, client is waiting. + */ -+ AvahiCupsClientConnecting = 1; + cupsdLogMessage (CUPSD_LOG_DEBUG, "Avahi client connecting"); + break; + ++ case AVAHI_CLIENT_S_REGISTERING: ++ /* ++ * Not yet registered. ++ */ ++ cupsdLogMessage (CUPSD_LOG_DEBUG, "Avahi client registering"); ++ break; ++ + case AVAHI_CLIENT_FAILURE: + /* + * Avahi client failed, close it to allow a clean restart. @@ -908,13 +1060,12 @@ index eb3c862..48dcef9 100644 /* * 'get_auth_info_required()' - Get the auth-info-required value to advertise. */ -diff --git a/scheduler/dirsvc.h b/scheduler/dirsvc.h -index 99079bd..d53a179 100644 ---- a/scheduler/dirsvc.h -+++ b/scheduler/dirsvc.h +diff -up cups-1.5.2/scheduler/dirsvc.h.avahi-5-services cups-1.5.2/scheduler/dirsvc.h +--- cups-1.5.2/scheduler/dirsvc.h.avahi-5-services 2011-03-21 02:12:14.000000000 +0000 ++++ cups-1.5.2/scheduler/dirsvc.h 2012-03-14 15:08:25.711611808 +0000 @@ -31,6 +31,10 @@ - * file is missing or damaged, see the license at "http://www.cups.org/". - */ + # endif /* HAVE_LDAP_SSL_H */ + #endif /* HAVE_LDAP */ +#ifdef HAVE_AVAHI +# include @@ -924,9 +1075,9 @@ index 99079bd..d53a179 100644 * Browse protocols... */ @@ -131,19 +135,22 @@ VAR int PollPipe VALUE(0); - BrowseLocalProtocols - VALUE(BROWSE_ALL); - /* Protocols to support for local printers */ + VAR cupsd_statbuf_t *PollStatusBuffer VALUE(NULL); + /* Status buffer for pollers */ + -#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) VAR char *DNSSDComputerName VALUE(NULL), @@ -948,7 +1099,7 @@ index 99079bd..d53a179 100644 + /* List of dynamic ServerAlias's */ VAR DNSServiceRef DNSSDRef VALUE(NULL), /* Master DNS-SD service reference */ - WebIFRef VALUE(NULL); + WebIFRef VALUE(NULL), @@ -152,6 +159,17 @@ VAR DNSServiceRef DNSSDRef VALUE(NULL), /* Remote printer browse reference */ #endif /* HAVE_DNSSD */ @@ -964,29 +1115,30 @@ index 99079bd..d53a179 100644 + /* Web interface entry group */ +#endif /* HAVE_AVAHI */ + - VAR char *LPDConfigFile VALUE(NULL), - /* LPD configuration file */ - *SMBConfigFile VALUE(NULL); -@@ -195,11 +213,12 @@ extern void cupsdRegisterPrinter(cupsd_printer_t *p); - - extern void cupsdDeregisterPrinter(cupsd_printer_t *p, int removeit); - extern void cupsdRegisterPrinter(cupsd_printer_t *p); + #ifdef HAVE_LIBSLP + VAR SLPHandle BrowseSLPHandle VALUE(NULL); + /* SLP API handle */ +@@ -195,13 +213,14 @@ extern void cupsdRegisterPrinter(cupsd_p + extern void cupsdRestartPolling(void); + extern void cupsdSaveRemoteCache(void); + extern void cupsdSendBrowseList(void); +extern void cupsdStartAvahiClient(void); extern void cupsdStartBrowsing(void); + extern void cupsdStartPolling(void); extern void cupsdStopBrowsing(void); + extern void cupsdStopPolling(void); -#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) extern void cupsdUpdateDNSSDName(void); -#endif /* HAVE_DNSSD */ +#endif /* defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */ - - - /* -diff --git a/scheduler/ipp.c b/scheduler/ipp.c -index a048baa..9a3ab11 100644 ---- a/scheduler/ipp.c -+++ b/scheduler/ipp.c -@@ -6087,7 +6087,7 @@ copy_printer_attrs( + #ifdef HAVE_LDAP + extern void cupsdUpdateLDAPBrowse(void); + #endif /* HAVE_LDAP */ +diff -up cups-1.5.2/scheduler/ipp.c.avahi-5-services cups-1.5.2/scheduler/ipp.c +--- cups-1.5.2/scheduler/ipp.c.avahi-5-services 2012-03-14 15:04:17.665305560 +0000 ++++ cups-1.5.2/scheduler/ipp.c 2012-03-14 15:08:25.715611813 +0000 +@@ -6099,7 +6099,7 @@ copy_printer_attrs( ippAddDate(con->response, IPP_TAG_PRINTER, "printer-current-time", ippTimeToDate(curtime)); @@ -995,7 +1147,7 @@ index a048baa..9a3ab11 100644 if (!ra || cupsArrayFind(ra, "printer-dns-sd-name")) { if (printer->reg_name) -@@ -6097,7 +6097,7 @@ copy_printer_attrs( +@@ -6109,7 +6109,7 @@ copy_printer_attrs( ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_NOVALUE, "printer-dns-sd-name", 0); } @@ -1004,11 +1156,10 @@ index a048baa..9a3ab11 100644 if (!ra || cupsArrayFind(ra, "printer-error-policy")) ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_NAME, -diff --git a/scheduler/main.c b/scheduler/main.c -index 1e60572..6c210e6 100644 ---- a/scheduler/main.c -+++ b/scheduler/main.c -@@ -120,6 +120,10 @@ main(int argc, /* I - Number of command-line args */ +diff -up cups-1.5.2/scheduler/main.c.avahi-5-services cups-1.5.2/scheduler/main.c +--- cups-1.5.2/scheduler/main.c.avahi-5-services 2012-03-14 15:06:36.511476986 +0000 ++++ cups-1.5.2/scheduler/main.c 2012-03-14 15:08:25.718611817 +0000 +@@ -120,6 +120,10 @@ main(int argc, /* I - Number of comm cupsd_listener_t *lis; /* Current listener */ time_t current_time, /* Current time */ activity, /* Client activity timer */ @@ -1016,20 +1167,20 @@ index 1e60572..6c210e6 100644 + avahi_client_time, /* Time for next Avahi client + check */ +#endif /* HAVE_AVAHI */ + browse_time, /* Next browse send time */ senddoc_time, /* Send-Document time */ expire_time, /* Subscription expire time */ - report_time, /* Malloc/client/job report time */ -@@ -662,6 +666,9 @@ main(int argc, /* I - Number of command-line args */ +@@ -672,6 +676,9 @@ main(int argc, /* I - Number of comm */ current_time = time(NULL); +#ifdef HAVE_AVAHI + avahi_client_time = current_time; +#endif /* HAVE_AVAHI */ + browse_time = current_time; event_time = current_time; expire_time = current_time; - fds = 1; -@@ -884,6 +891,16 @@ main(int argc, /* I - Number of command-line args */ +@@ -894,6 +901,16 @@ main(int argc, /* I - Number of comm tmo = cupsdNextTimeout (&tmo_delay); if (tmo && tmo_delay == 0) cupsdRunTimeout (tmo); @@ -1046,10 +1197,9 @@ index 1e60572..6c210e6 100644 #endif /* HAVE_AVAHI */ #ifndef __APPLE__ -diff --git a/scheduler/printers.c b/scheduler/printers.c -index 4686c4c..fac7bbc 100644 ---- a/scheduler/printers.c -+++ b/scheduler/printers.c +diff -up cups-1.5.2/scheduler/printers.c.avahi-5-services cups-1.5.2/scheduler/printers.c +--- cups-1.5.2/scheduler/printers.c.avahi-5-services 2012-03-14 15:04:17.646305537 +0000 ++++ cups-1.5.2/scheduler/printers.c 2012-03-14 15:08:25.720611819 +0000 @@ -883,9 +883,9 @@ cupsdDeletePrinter( cupsdClearString(&p->alert); cupsdClearString(&p->alert_description); @@ -1062,7 +1212,7 @@ index 4686c4c..fac7bbc 100644 cupsArrayDelete(p->filetypes); -@@ -3765,7 +3765,7 @@ add_printer_formats(cupsd_printer_t *p) /* I - Printer */ +@@ -3787,7 +3787,7 @@ add_printer_formats(cupsd_printer_t *p) attr->values[i].string.text = _cupsStrAlloc(mimetype); } @@ -1071,7 +1221,7 @@ index 4686c4c..fac7bbc 100644 { char pdl[1024]; /* Buffer to build pdl list */ mime_filter_t *filter; /* MIME filter looping var */ -@@ -3821,7 +3821,7 @@ add_printer_formats(cupsd_printer_t *p) /* I - Printer */ +@@ -3843,7 +3843,7 @@ add_printer_formats(cupsd_printer_t *p) cupsdSetString(&p->pdl, pdl); } @@ -1080,10 +1230,9 @@ index 4686c4c..fac7bbc 100644 } -diff --git a/scheduler/printers.h b/scheduler/printers.h -index 1751578..fb04651 100644 ---- a/scheduler/printers.h -+++ b/scheduler/printers.h +diff -up cups-1.5.2/scheduler/printers.h.avahi-5-services cups-1.5.2/scheduler/printers.h +--- cups-1.5.2/scheduler/printers.h.avahi-5-services 2011-03-18 18:42:46.000000000 +0000 ++++ cups-1.5.2/scheduler/printers.h 2012-03-14 15:08:25.721611820 +0000 @@ -16,6 +16,9 @@ #ifdef HAVE_DNSSD # include