]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Make auto-configure wait for auto-configure job to complete.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Sat, 4 Oct 2008 15:34:08 +0000 (15:34 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Sat, 4 Oct 2008 15:34:08 +0000 (15:34 +0000)
More UI cleanup.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@8012 7a7537e8-13f0-0310-91df-b6672ffda945

cgi-bin/admin.c
templates/Makefile
templates/autoconfigure.tmpl [new file with mode: 0644]
templates/class-confirm.tmpl
templates/option-boolean.tmpl
templates/option-header.tmpl
templates/option-pickmany.tmpl
templates/option-pickone.tmpl
templates/printer-configured.tmpl
templates/printer-confirm.tmpl
templates/set-printer-options-header.tmpl

index 59a3566da272f518f7f223f7ef5214421edf4eac..e5ed77a60a5a833041cb90645ac1df28bf23227d 100644 (file)
@@ -3197,19 +3197,34 @@ do_set_options(http_t *http,            /* I - HTTP connection */
     int                        job_id;         /* Command file job */
     char               refresh[1024];  /* Refresh URL */
     http_status_t      status;         /* Document status */
+    cups_option_t      hold_option;    /* job-hold-until option */
     static const char  *autoconfigure =/* Command file */
                        "#CUPS-COMMAND\n"
                        "AutoConfigure\n";
+    static const char const *job_attrs[] =
+                       {
+                         "job-state",
+                         "job-printer-state-message"
+                       };
 
+    cgiStartMultipart();
+    cgiStartHTML(title);
+    cgiCopyTemplateLang("autoconfigure.tmpl");
+    cgiEndHTML();
+    fflush(stdout);
+
+    hold_option.name  = "job-hold-until";
+    hold_option.value = "no-hold";
 
     if ((job_id = cupsCreateJob(CUPS_HTTP_DEFAULT, printer, "Auto-Configure",
-                                0, NULL)) < 1)
+                                1, &hold_option)) < 1)
     {
       cgiSetVariable("ERROR", cgiText(_("Unable to send auto-configure command "
                                         "to printer driver!")));
       cgiStartHTML(title);
       cgiCopyTemplateLang("error.tmpl");
       cgiEndHTML();
+      cgiEndMultipart();
       return;
     }
 
@@ -3227,11 +3242,55 @@ do_set_options(http_t *http,            /* I - HTTP connection */
       cgiStartHTML(title);
       cgiCopyTemplateLang("error.tmpl");
       cgiEndHTML();
+      cgiEndMultipart();
 
       cupsCancelJob(printer, job_id);
       return;
     }
 
+   /*
+    * Wait for the job to complete...
+    */
+
+    for (;;)
+    {
+     /*
+      * Get the current job state...
+      */
+
+      snprintf(uri, sizeof(uri), "ipp://localhost/jobs/%d", job_id);
+      request = ippNewRequest(IPP_GET_JOB_ATTRIBUTES);
+      ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri",
+                   NULL, uri);
+      if (getenv("REMOTE_USER"))
+       ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+                    "requesting-user-name", NULL, getenv("REMOTE_USER"));
+      ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+                    "requested-attributes", 2, NULL, job_attrs);
+
+      response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/");
+      attr     = ippFindAttribute(response, "job-state", IPP_TAG_ENUM);
+      if (!attr || attr->values[0].integer >= IPP_JOB_STOPPED)
+      {
+        ippDelete(response);
+       break;
+      }
+
+     /*
+      * Job not complete, so update the status...
+      */
+
+      cgiSetIPPVars(response, NULL, NULL, NULL, 0);
+      ippDelete(response);
+
+      cgiStartHTML(title);
+      cgiCopyTemplateLang("autoconfigure.tmpl");
+      cgiEndHTML();
+      fflush(stdout);
+
+      sleep(5);
+    }
+
    /*
     * Redirect successful updates back to the printer page...
     */
@@ -3245,6 +3304,7 @@ do_set_options(http_t *http,              /* I - HTTP connection */
 
     cgiCopyTemplateLang("printer-configured.tmpl");
     cgiEndHTML();
+    cgiEndMultipart();
     return;
   }
 
index 44da1b4d746b8f878eb44b189d724ab5607afb9c..fb25f7d0bf84939300daf60e3e43f37e20753e0b 100644 (file)
@@ -24,6 +24,7 @@ FILES =       \
                add-printer.tmpl \
                add-rss-subscription.tmpl \
                admin.tmpl \
+               autoconfigure.tmpl \
                choose-device.tmpl \
                choose-make.tmpl \
                choose-model.tmpl \
diff --git a/templates/autoconfigure.tmpl b/templates/autoconfigure.tmpl
new file mode 100644 (file)
index 0000000..93aa493
--- /dev/null
@@ -0,0 +1,11 @@
+<DIV CLASS="indent">
+
+<H2 CLASS="title">Set Default Options for {printer_name}</H2>
+
+<P><IMG SRC="/images/wait.gif" WIDTH="16" HEIGHT="16" ALIGN="ABSMIDDLE"
+ALT="Busy Indicator"> Query job {job_state=3?pending:{job_state=4?held:
+{job_state=5?processing:{job_state=6?stopped:
+{job_state=7?canceled:{job_state=8?aborted:completed}}}}}}{job_printer_state_message?,
+<EM>"{job_printer_state_message}"</EM>:}</P>
+
+</DIV>
index d5641498ce8e767c520c1103ff750689476531f3..c14d354820edb60db9726aa2eea791c7112e8570 100644 (file)
@@ -1,5 +1,7 @@
 <DIV CLASS="indent">
 
+<H2 CLASS="title">Delete Class {printer_name}</H2>
+
 <P><B>Warning:</B> Are you sure you want to delete class
 {printer_name}?</P>
 
index 72c85189a403a85603f36d127a3fe98a99dad614..2d0dd551a1dc5f7e0353c834575c8e9e4a642d54 100644 (file)
@@ -1,5 +1,5 @@
 <TR>
-<TH CLASS="label"{conflicted=1? CLASS="conflict":}><A NAME="{keyword}">{keytext}</A>:</TH>
+<TH {conflicted=1?CLASS="conflict":CLASS="label"} WIDTH="50%"><A NAME="{keyword}">{keytext}</A>:</TH>
 <TD>
 {[choices]<INPUT TYPE="RADIO" NAME="{keyword}" {choices={defchoice}?CHECKED:} VALUE="{choices}">{text}}
 </TD>
index cafc9f9fef0318fdb91c38cc9c2e29885988fffd..f34865c375bb69747566ba9eba6cd3ed38f8eefe 100644 (file)
@@ -1,3 +1,3 @@
-<H2 CLASS="title">{printer_name}: {group}</H2>
+<H3 CLASS="title">{group}</H3>
 
-<TABLE>
+<TABLE WIDTH="100%">
index d2534af75ae7e4712e69d3312b738716c3e4211e..067075aec0eaebb3b32e54b7121c370376c4bcfb 100644 (file)
@@ -1,5 +1,5 @@
 <TR>
-<TH CLASS="label"{conflicted=1? CLASS="conflict":}><A NAME="{keyword}">{keytext}</A>:</TH>
+<TH {conflicted=1?CLASS="conflict":CLASS="label"} WIDTH="50%"><A NAME="{keyword}">{keytext}</A>:</TH>
 <TD><SELECT NAME="{keyword}" MULTIPLE SIZE="10">
 {[choices]<OPTION {choices={defchoice}?SELECTED:} VALUE="{choices}">{text}}
 </SELECT></TD>
index a2ce9d8c8cdd3869130da9fd0d58e843597a3075..05b83ee8a7122be7685bffafb7e7697e9bd3897b 100644 (file)
@@ -1,5 +1,5 @@
 <TR>
-<TH CLASS="label"{conflicted=1? CLASS="conflict":}><A NAME="{keyword}">{keytext}</A>:</TH>
+<TH {conflicted=1?CLASS="conflict":CLASS="label"} WIDTH="50%"><A NAME="{keyword}">{keytext}</A>:</TH>
 <TD><SELECT NAME="{keyword}" ID="select-{keyword}" ONCHANGE="update_paramtable('{keyword}')">
 {[choices]<OPTION {choices={defchoice}?SELECTED:} VALUE="{choices}">{text}}
 </SELECT>
index b80db4569a30989148b19a55967f7949b582e432..6f8104e2310cabe7e55bcc094c2dfdb92395a68e 100644 (file)
@@ -1,6 +1,8 @@
 <DIV CLASS="indent">
 
-<P>{OP=set-class-options?Class <A HREF="/classes/{printer_name}">:Printer <A HREF="/printers/{printer_name}">}{printer_name}</A> has
-been configured successfully.
+<H2 CLASS="title">Set Default Options for {printer_name}</H2>
+
+<P>{OP=set-class-options?Class <A HREF="/classes/{printer_name}">:Printer <A HREF="/printers/{printer_name}">}{printer_name}</A>
+default options have been set successfully.
 
 </DIV>
index 4cac6c366157ec373fe8641abf1f23534493ebbe..db16d691b3e75bfaca34e058663fd68221c2e9d6 100644 (file)
@@ -1,5 +1,7 @@
 <DIV CLASS="indent">
 
+<H2 CLASS="title">Delete Printer {printer_name}</H2>
+
 <P><B>Warning:</B> Are you sure you want to delete printer
 {printer_name}?</P>
 
index dad328a83a1409c71ed2b18438bbba33e764d9bb..124094ececf58ca3c15ac6317bc4a81815b1c6a3 100644 (file)
@@ -1,9 +1,11 @@
 <DIV CLASS="indent">
 
+<H2 CLASS="title">Set Default Options for {printer_name}</H2>
+
 <FORM METHOD="POST" ACTION="/admin">
 <INPUT TYPE="HIDDEN" NAME="PRINTER_NAME" VALUE="{printer_name}">
 <INPUT TYPE="HIDDEN" NAME="OP" VALUE="{op}">
-{HAVE_AUTOCONFIGURE?<INPUT TYPE="SUBMIT" NAME="AUTOCONFIGURE" VALUE="Auto-Configure Options">:}
+{HAVE_AUTOCONFIGURE?<INPUT TYPE="SUBMIT" NAME="AUTOCONFIGURE" VALUE="Query Printer for Default Options">:}
 
 <SCRIPT TYPE="text/javascript"><!--
 function update_paramtable(option)