]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Implement Identify-Printer and add tests.
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Fri, 7 Aug 2015 13:22:27 +0000 (13:22 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Fri, 7 Aug 2015 13:22:27 +0000 (13:22 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12839 a1ca3aef-8c08-0410-bb20-df032aa958be

test/identify-printer-display.test [new file with mode: 0644]
test/identify-printer-multiple.test [new file with mode: 0644]
test/ippserver.c

diff --git a/test/identify-printer-display.test b/test/identify-printer-display.test
new file mode 100644 (file)
index 0000000..4957a26
--- /dev/null
@@ -0,0 +1,21 @@
+# Make the printer display a message
+{
+       # The name of the test...
+       NAME "Identify Printer with Message"
+
+       # The operation to use
+       OPERATION Identify-Printer
+
+       # Attributes, starting in the operation group...
+       GROUP operation-attributes-tag
+       ATTR charset attributes-charset utf-8
+       ATTR language attributes-natural-language en
+       ATTR uri printer-uri $uri
+       ATTR name requesting-user-name $user
+       ATTR keyword identify-actions display
+       ATTR text message "Hello\, World!"
+
+       # What statuses are OK?
+       STATUS successful-ok
+       STATUS successful-ok-ignored-or-substituted-attributes
+}
diff --git a/test/identify-printer-multiple.test b/test/identify-printer-multiple.test
new file mode 100644 (file)
index 0000000..79b2580
--- /dev/null
@@ -0,0 +1,21 @@
+# Make the printer display a message and beep
+{
+       # The name of the test...
+       NAME "Identify Printer with Message and Beep"
+
+       # The operation to use
+       OPERATION Identify-Printer
+
+       # Attributes, starting in the operation group...
+       GROUP operation-attributes-tag
+       ATTR charset attributes-charset utf-8
+       ATTR language attributes-natural-language en
+       ATTR uri printer-uri $uri
+       ATTR name requesting-user-name $user
+       ATTR keyword identify-actions sound,display
+       ATTR text message "Hello\, World!"
+
+       # What statuses are OK?
+       STATUS successful-ok
+       STATUS successful-ok-ignored-or-substituted-attributes
+}
index c7dbf042e9c88748f96546dd225bb35fc9f6ef21..cac45ecdcff6ab14b28844dab9b238665ef0a9e2 100644 (file)
@@ -3726,7 +3726,21 @@ static void
 ipp_identify_printer(
     _ipp_client_t *client)             /* I - Client */
 {
-  /* TODO: Do something */
+  ipp_attribute_t      *actions,       /* identify-actions */
+                       *message;       /* message */
+
+
+  actions = ippFindAttribute(client->request, "identify-actions", IPP_TAG_KEYWORD);
+  message = ippFindAttribute(client->request, "message", IPP_TAG_TEXT);
+
+  if (!actions || ippContainsString(actions, "sound"))
+  {
+    putchar(0x07);
+    fflush(stdout);
+  }
+
+  if (ippContainsString(actions, "display"))
+    printf("IDENTIFY from %s: %s\n", client->hostname, message ? ippGetString(message, 0, NULL) : "No message supplied");
 
   respond_ipp(client, IPP_STATUS_OK, NULL);
 }