From 2ee21abf2b450c9a72c8c45ff01ca28a622cee57 Mon Sep 17 00:00:00 2001 From: Felix Schumacher Date: Wed, 6 Aug 2008 16:41:59 +0200 Subject: [PATCH] jcifs-1.2.13 from tgz Mon Jan 22 15:26:01 EST 2007 jcifs-1.2.13 released. A new SmbFile.getShareSecurity() method that uses a new MsrpcShareGetInfo/ShareInfo502 RPC has been added. This will return the ACL for a share as opposed to the ACL for the directory shared. See the API documentation for details. Several DFS issues have been identified and fixed. If JCIFS receives a NoRouteToHostException on port 445 it will now try to fallback to port 139. This code has been tested fairly well already. There have been no changes since b4. --- README.txt | 11 +++++ build.xml | 4 +- patches/Print.patch | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++ patches/README.txt | 10 +++++ 4 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 patches/Print.patch diff --git a/README.txt b/README.txt index bba3e4f..0f9fb33 100644 --- a/README.txt +++ b/README.txt @@ -1,3 +1,14 @@ +Mon Jan 22 15:26:01 EST 2007 +jcifs-1.2.13 released. + +A new SmbFile.getShareSecurity() method that uses a new +MsrpcShareGetInfo/ShareInfo502 RPC has been added. This will return the +ACL for a share as opposed to the ACL for the directory shared. See the +API documentation for details. Several DFS issues have been identified +and fixed. If JCIFS receives a NoRouteToHostException on port 445 it +will now try to fallback to port 139. This code has been tested fairly +well already. There have been no changes since b4. + Mon Jan 15 15:47:47 EST 2007 jcifs-1.2.13b4 released diff --git a/build.xml b/build.xml index 8f8ccac..7a65afe 100644 --- a/build.xml +++ b/build.xml @@ -1,7 +1,7 @@ - - + + diff --git a/patches/Print.patch b/patches/Print.patch new file mode 100644 index 0000000..7a221f5 --- /dev/null +++ b/patches/Print.patch @@ -0,0 +1,115 @@ +diff -Nuar old-src/jcifs/smb/SmbTree.java src/jcifs/smb/SmbTree.java +--- old-src/jcifs/smb/SmbTree.java 2007-01-16 06:00:31.231245500 -0500 ++++ src/jcifs/smb/SmbTree.java 2007-01-16 05:55:40.148493000 -0500 +@@ -90,6 +90,8 @@ + throw new SmbException( "Invalid operation for " + service + " service" ); + } + break; ++ case ServerMessageBlock.SMB_COM_WRITE: ++ if (service.equals("LPT1:")) break; + default: + throw new SmbException( "Invalid operation for " + service + " service" + request ); + } +diff -Nuar old-examples/PrintHtml.java examples/PrintHtml.java +--- old-examples/PrintHtml.java 1969-12-31 19:00:00.000000000 -0500 ++++ examples/PrintHtml.java 2007-01-16 06:07:11.461278000 -0500 +@@ -0,0 +1,99 @@ ++import java.awt.Dimension; ++import java.awt.Graphics; ++import java.awt.Graphics2D; ++ ++import java.awt.print.PageFormat; ++import java.awt.print.Printable; ++ ++import java.io.BufferedReader; ++import java.io.FileReader; ++import java.io.OutputStream; ++import java.io.PrintWriter; ++import java.io.StringWriter; ++ ++import javax.print.Doc; ++import javax.print.DocFlavor; ++import javax.print.DocPrintJob; ++import javax.print.PrintService; ++import javax.print.SimpleDoc; ++import javax.print.StreamPrintServiceFactory; ++ ++import javax.swing.JEditorPane; ++import javax.swing.JFrame; ++import javax.swing.RepaintManager; ++ ++import javax.swing.text.html.HTMLEditorKit; ++ ++import jcifs.Config; ++ ++import jcifs.smb.SmbFileOutputStream; ++ ++public class PrintHtml { ++ ++ public static void main(String[] args) throws Exception { ++ Config.setProperty("jcifs.smb.client.useNTSmbs", "false"); ++ String htmlFile = args[0]; ++ String printerUrl = args[1]; ++ StringWriter collector = new StringWriter(); ++ PrintWriter writer = new PrintWriter(collector); ++ BufferedReader reader = new BufferedReader(new FileReader(htmlFile)); ++ String line; ++ while ((line = reader.readLine()) != null) writer.println(line); ++ writer.flush(); ++ String content = collector.toString(); ++ final JEditorPane pane = new JEditorPane(); ++ pane.setEditorKit(new HTMLEditorKit()); ++ pane.setText(content); ++ JFrame frame = new JFrame(); ++ frame.getContentPane().add(pane); ++ frame.pack(); ++ Printable printable = new Printable() { ++ public int print(Graphics g, PageFormat format, int pageIndex) { ++ RepaintManager currentManager = ++ RepaintManager.currentManager(pane); ++ boolean doubleBuffering = ++ currentManager.isDoubleBufferingEnabled(); ++ if (doubleBuffering) { ++ currentManager.setDoubleBufferingEnabled(false); ++ } ++ try { ++ Dimension size = pane.getSize(); ++ double panelWidth = size.width; ++ double panelHeight = size.height; ++ double pageHeight = format.getImageableHeight(); ++ double pageWidth = format.getImageableWidth(); ++ double scale = pageWidth / panelWidth; ++ int totalNumPages = (int) ++ Math.ceil(scale * panelHeight / pageHeight); ++ if (pageIndex >= totalNumPages) { ++ return Printable.NO_SUCH_PAGE; ++ } ++ Graphics2D g2 = (Graphics2D) g; ++ g2.translate(format.getImageableX(), ++ format.getImageableY()); ++ g2.translate(0f, -pageIndex * pageHeight); ++ g2.scale(scale, scale); ++ pane.paint(g2); ++ return Printable.PAGE_EXISTS; ++ } finally { ++ if (doubleBuffering) { ++ currentManager.setDoubleBufferingEnabled(true); ++ } ++ } ++ } ++ }; ++ DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; ++ Doc doc = new SimpleDoc(printable, flavor, null); ++ StreamPrintServiceFactory[] factories = ++ StreamPrintServiceFactory.lookupStreamPrintServiceFactories( ++ null, "application/postscript"); ++ OutputStream output = new SmbFileOutputStream(printerUrl); ++ PrintService service = factories[0].getPrintService(output); ++ DocPrintJob job = service.createPrintJob(); ++ job.print(doc, null); ++ output.flush(); ++ output.close(); ++ System.exit(0); ++ } ++ ++} diff --git a/patches/README.txt b/patches/README.txt index 538a146..f99d203 100644 --- a/patches/README.txt +++ b/patches/README.txt @@ -2,6 +2,16 @@ These patches are not supported. They are provided here only for your conveinience. If you port a patch to a newer version of jCIFS please resubmit it to the mailing list. +Print.patch + +This minor patch and example program demonstrates how to emit +PostScript rendered from an AWT/Swing Graphics context and send it +directly to a shared printer. Note that currently you also need to set +jcifs.smb.client.useNTSmbs = false (as otherwise the server spits back +an invalid parameter error). If users determine that this feature works +reliably with a wide variety of printers we will incorporate it into +the distribution (and fix the useNTSmbs goof). + DnsSrv.patch This patch adds JNDI _ldap._tcp.dc._msdcs. lookups so that the -- 2.11.0