diff options
author | Till Kamppeter <till.kamppeter@gmail.com> | 2020-08-26 13:03:00 +0200 |
---|---|---|
committer | Didier Raboud <odyx@debian.org> | 2020-11-05 08:54:07 +0100 |
commit | 7d985866120165410b9a15448261c834768878e4 (patch) | |
tree | 53cbe98866c3a867ebb8dc66baebbad3f31a52b3 | |
parent | 4ce59a657c867d36f7434b2548917be3953670a9 (diff) |
Fix fax numbers supplied via GTK print dialog, removing a "Custom." prefix; do not choke if the GTK dialog sends "None" as phone number or pre-dial prefix
-rw-r--r-- | backend/ipp.c | 61 |
1 files changed, 48 insertions, 13 deletions
diff --git a/backend/ipp.c b/backend/ipp.c index a4039ba04..40a321c26 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -2828,7 +2828,19 @@ new_request( */ _httpDecodeURI(phone, keyword, sizeof(phone)); - for (ptr = phone; *ptr;) + ptr = phone; + + /* Weed out "Custom." in the beginning, this allows to put the + "phone" option as custom string option into the PPD so that + print dialogs not supporting fax display the option and + allow entering the phone number. Print dialogs also send "None" + if no phone number got entered, filter this, too. */ + if (!_cups_strcasecmp(phone, "None")) + *ptr = '\0'; + if (!_cups_strncasecmp(phone, "Custom.", 7)) + _cups_strcpy(ptr, ptr + 7); + + for (; *ptr;) { if (*ptr == ',') *ptr = 'p'; @@ -2838,20 +2850,43 @@ new_request( ptr ++; } - httpAssembleURI(HTTP_URI_CODING_ALL, tel_uri, sizeof(tel_uri), "tel", NULL, NULL, 0, phone); - ippAddString(destination, IPP_TAG_JOB, IPP_TAG_URI, "destination-uri", NULL, tel_uri); - - if ((keyword = cupsGetOption("faxPrefix", num_options, - options)) != NULL && *keyword) - { - char predial[1024]; /* Pre-dial string */ + if (strlen(phone) > 0) + { + httpAssembleURI(HTTP_URI_CODING_ALL, tel_uri, sizeof(tel_uri), + "tel", NULL, NULL, 0, phone); + ippAddString(destination, IPP_TAG_JOB, IPP_TAG_URI, + "destination-uri", NULL, tel_uri); + fprintf(stderr, "DEBUG: Faxing to phone %s; destination-uri: %s\n", + phone, tel_uri); + + if ((keyword = cupsGetOption("faxPrefix", num_options, + options)) != NULL && *keyword) + { + char predial[1024]; /* Pre-dial string */ + + _httpDecodeURI(predial, keyword, sizeof(predial)); + ptr = predial; + if (!_cups_strcasecmp(ptr, "None")) + *ptr = '\0'; + if (!_cups_strncasecmp(ptr, "Custom.", 7)) + ptr += 7; + if (strlen(ptr) > 0) + { + ippAddString(destination, IPP_TAG_JOB, IPP_TAG_TEXT, + "pre-dial-string", NULL, ptr); + fprintf(stderr, "DEBUG: Pre-dialing %s; pre-dial-string: %s\n", + ptr, ptr); + } + else + fprintf(stderr, "WARNING: Pre-dial number for fax not valid! Sending fax without pre-dial number.\n"); + } - _httpDecodeURI(predial, keyword, sizeof(predial)); - ippAddString(destination, IPP_TAG_JOB, IPP_TAG_TEXT, "pre-dial-string", NULL, predial); + ippAddCollection(request, IPP_TAG_JOB, "destination-uris", + destination); + ippDelete(destination); } - - ippAddCollection(request, IPP_TAG_JOB, "destination-uris", destination); - ippDelete(destination); + else + fprintf(stderr, "ERROR: Phone number for fax not valid! Fax cannot be sent.\n"); } } else |