Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
b2f68393
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b2f68393
编写于
2月 10, 2014
作者:
P
prr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8032693: javax.print.PrintService does not find any CUPS-Printers on Linux
Reviewed-by: jgodinez, serb
上级
e2fd6ef5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
104 addition
and
8 deletion
+104
-8
src/solaris/classes/sun/print/CUPSPrinter.java
src/solaris/classes/sun/print/CUPSPrinter.java
+8
-1
src/solaris/classes/sun/print/IPPPrintService.java
src/solaris/classes/sun/print/IPPPrintService.java
+6
-3
src/solaris/classes/sun/print/UnixPrintServiceLookup.java
src/solaris/classes/sun/print/UnixPrintServiceLookup.java
+22
-4
test/javax/print/PrintServiceLookup/CountPrintServices.java
test/javax/print/PrintServiceLookup/CountPrintServices.java
+68
-0
未找到文件。
src/solaris/classes/sun/print/CUPSPrinter.java
浏览文件 @
b2f68393
...
...
@@ -252,6 +252,7 @@ public class CUPSPrinter {
try
{
return
urlConnection
.
getOutputStream
();
}
catch
(
Exception
e
)
{
IPPPrintService
.
debug_println
(
debugPrefix
+
e
);
}
return
null
;
}
...
...
@@ -282,6 +283,9 @@ public class CUPSPrinter {
if
(
responseMap
!=
null
&&
responseMap
.
length
>
0
)
{
defaultMap
=
responseMap
[
0
];
}
else
{
IPPPrintService
.
debug_println
(
debugPrefix
+
" empty response map for GET_DEFAULT."
);
}
if
(
defaultMap
==
null
)
{
...
...
@@ -310,7 +314,10 @@ public class CUPSPrinter {
if
(
attribClass
!=
null
)
{
printerInfo
[
0
]
=
attribClass
.
getStringValue
();
attribClass
=
(
AttributeClass
)
defaultMap
.
get
(
"device-uri"
);
attribClass
=
(
AttributeClass
)
defaultMap
.
get
(
"printer-uri-supported"
);
IPPPrintService
.
debug_println
(
debugPrefix
+
"printer-uri-supported="
+
attribClass
);
if
(
attribClass
!=
null
)
{
printerInfo
[
1
]
=
attribClass
.
getStringValue
();
}
else
{
...
...
src/solaris/classes/sun/print/IPPPrintService.java
浏览文件 @
b2f68393
...
...
@@ -1906,9 +1906,8 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
new
HashMap
[
respList
.
size
()]);
}
else
{
debug_println
(
debugPrefix
+
"readIPPResponse client error, IPP status code-"
+
Integer
.
toHexString
(
response
[
2
])+
" & "
+
Integer
.
toHexString
(
response
[
3
]));
"readIPPResponse client error, IPP status code: 0x"
+
toHex
(
response
[
2
])
+
toHex
(
response
[
3
]));
return
null
;
}
...
...
@@ -1921,6 +1920,10 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
}
}
private
static
String
toHex
(
byte
v
)
{
String
s
=
Integer
.
toHexString
(
v
&
0xff
);
return
(
s
.
length
()
==
2
)
?
s
:
"0"
+
s
;
}
public
String
toString
()
{
return
"IPP Printer : "
+
getName
();
...
...
src/solaris/classes/sun/print/UnixPrintServiceLookup.java
浏览文件 @
b2f68393
...
...
@@ -238,9 +238,25 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
String
[]
printers
=
null
;
// array of printer names
String
[]
printerURIs
=
null
;
//array of printer URIs
getDefaultPrintService
();
try
{
getDefaultPrintService
();
}
catch
(
Throwable
t
)
{
IPPPrintService
.
debug_println
(
debugPrefix
+
"Exception getting default printer : "
+
t
);
}
if
(
CUPSPrinter
.
isCupsRunning
())
{
printerURIs
=
CUPSPrinter
.
getAllPrinters
();
try
{
printerURIs
=
CUPSPrinter
.
getAllPrinters
();
IPPPrintService
.
debug_println
(
"CUPS URIs = "
+
printerURIs
);
if
(
printerURIs
!=
null
)
{
for
(
int
p
=
0
;
p
<
printerURIs
.
length
;
p
++)
{
IPPPrintService
.
debug_println
(
"URI="
+
printerURIs
[
p
]);
}
}
}
catch
(
Throwable
t
)
{
IPPPrintService
.
debug_println
(
debugPrefix
+
"Exception getting all CUPS printers : "
+
t
);
}
if
((
printerURIs
!=
null
)
&&
(
printerURIs
.
length
>
0
))
{
printers
=
new
String
[
printerURIs
.
length
];
for
(
int
i
=
0
;
i
<
printerURIs
.
length
;
i
++)
{
...
...
@@ -595,8 +611,10 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
(
CUPSPrinter
.
isCupsRunning
()));
if
(
CUPSPrinter
.
isCupsRunning
())
{
String
[]
printerInfo
=
CUPSPrinter
.
getDefaultPrinter
();
defaultPrinter
=
printerInfo
[
0
];
psuri
=
printerInfo
[
1
];
if
(
printerInfo
!=
null
&&
printerInfo
.
length
>=
2
)
{
defaultPrinter
=
printerInfo
[
0
];
psuri
=
printerInfo
[
1
];
}
}
else
{
if
(
isMac
()
||
isSysV
())
{
defaultPrinter
=
getDefaultPrinterNameSysV
();
...
...
test/javax/print/PrintServiceLookup/CountPrintServices.java
0 → 100644
浏览文件 @
b2f68393
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
javax.print.PrintService
;
import
javax.print.PrintServiceLookup
;
import
javax.print.attribute.AttributeSet
;
import
javax.print.attribute.HashAttributeSet
;
import
javax.print.attribute.standard.PrinterName
;
/*
* @test
* @bug 8032693
* @summary Test that lpstat and JDK agree whether there are printers.
*/
public
class
CountPrintServices
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
os
=
System
.
getProperty
(
"os.name"
).
toLowerCase
();
System
.
out
.
println
(
"OS is "
+
os
);
if
(!
os
.
equals
(
"linux"
))
{
System
.
out
.
println
(
"Linux specific test. No need to continue"
);
return
;
}
PrintService
services
[]
=
PrintServiceLookup
.
lookupPrintServices
(
null
,
null
);
if
(
services
.
length
>
0
)
{
System
.
out
.
println
(
"Services found. No need to test further."
);
return
;
}
String
[]
lpcmd
=
{
"lpstat"
,
"-a"
};
Process
proc
=
Runtime
.
getRuntime
().
exec
(
lpcmd
);
proc
.
waitFor
();
InputStreamReader
ir
=
new
InputStreamReader
(
proc
.
getInputStream
());
BufferedReader
br
=
new
BufferedReader
(
ir
);
int
count
=
0
;
String
printer
;
while
((
printer
=
br
.
readLine
())
!=
null
)
{
System
.
out
.
println
(
"lpstat:: "
+
printer
);
count
++;
}
if
(
count
>
0
)
{
throw
new
RuntimeException
(
"Services exist, but not found by JDK."
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录