mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Reformatted code, updated to new Analytics tags, fixed a problem with EmailAuthenticator
git-svn-id: https://zxing.googlecode.com/svn/trunk@386 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
08c7c6fadb
commit
13b637fa53
|
@ -55,14 +55,8 @@ final class DecodeEmailTask extends TimerTask {
|
|||
private static final String SMTP_PORT = "465";
|
||||
private static final String POP_PORT = "995";
|
||||
private static final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
|
||||
private static final Address fromAddress;
|
||||
private static final Properties sessionProperties = new Properties();
|
||||
static {
|
||||
try {
|
||||
fromAddress = new InternetAddress("w@zxing.org", "ZXing By Email");
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
throw new RuntimeException(uee);
|
||||
}
|
||||
sessionProperties.setProperty("mail.transport.protocol", "smtp");
|
||||
sessionProperties.setProperty("mail.smtp.host", SMTP_HOST);
|
||||
sessionProperties.setProperty("mail.smtp.auth", "true");
|
||||
|
@ -80,9 +74,16 @@ final class DecodeEmailTask extends TimerTask {
|
|||
}
|
||||
|
||||
private final Authenticator emailAuthenticator;
|
||||
private final Address fromAddress;
|
||||
|
||||
DecodeEmailTask(Authenticator emailAuthenticator) {
|
||||
DecodeEmailTask(String emailAddress, Authenticator emailAuthenticator) {
|
||||
this.emailAuthenticator = emailAuthenticator;
|
||||
try {
|
||||
fromAddress = new InternetAddress(emailAddress, "ZXing By Email");
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
// Can't happen?
|
||||
throw new RuntimeException(uee);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -73,6 +73,7 @@ public final class DecodeServlet extends HttpServlet {
|
|||
private static final Logger log = Logger.getLogger(DecodeServlet.class.getName());
|
||||
|
||||
static final Hashtable<DecodeHintType, Object> HINTS;
|
||||
|
||||
static {
|
||||
HINTS = new Hashtable<DecodeHintType, Object>(3);
|
||||
HINTS.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
|
||||
|
@ -107,7 +108,7 @@ public final class DecodeServlet extends HttpServlet {
|
|||
|
||||
Authenticator emailAuthenticator = new EmailAuthenticator(emailAddress, emailPassword);
|
||||
emailTimer = new Timer("Email decoder timer", true);
|
||||
emailTimer.schedule(new DecodeEmailTask(emailAuthenticator), 0L, EMAIL_CHECK_INTERVAL);
|
||||
emailTimer.schedule(new DecodeEmailTask(emailAddress, emailAuthenticator), 0L, EMAIL_CHECK_INTERVAL);
|
||||
|
||||
log.info("DecodeServlet configured");
|
||||
}
|
||||
|
|
|
@ -19,20 +19,20 @@ package com.google.zxing.web;
|
|||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author Sean Owen
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package com.google.zxing.web;
|
||||
|
||||
import javax.mail.Authenticator;
|
||||
import javax.mail.PasswordAuthentication;
|
||||
|
||||
final class EmailAuthenticator extends Authenticator {
|
||||
|
||||
|
@ -28,4 +29,9 @@ final class EmailAuthenticator extends Authenticator {
|
|||
this.emailPassword = emailPassword;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(emailUsername, emailPassword);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ final class IPTrie {
|
|||
private static final class IPTrieNode {
|
||||
final IPTrieNode[] children;
|
||||
final int[] values;
|
||||
|
||||
private IPTrieNode(boolean terminal) {
|
||||
if (terminal) {
|
||||
children = null;
|
||||
|
|
|
@ -15,23 +15,35 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns="http://www.w3.org/1999/xhtml" version="2.1">
|
||||
<jsp:output
|
||||
<jsp:output
|
||||
omit-xml-declaration="false" doctype-root-element="html"
|
||||
doctype-public="-//WAPFORUM//DTD XHTML Mobile 1.1//EN"
|
||||
doctype-system="http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd"/>
|
||||
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head><title>No Barcode Found</title></head>
|
||||
<body>
|
||||
<p><b>Bad URL</b></p>
|
||||
<p>The image you uploaded could not be decoded, or was too large. Go "Back" in your browser and try another image.</p>
|
||||
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
_uacct = "UA-788492-5";
|
||||
urchinTracker();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>No Barcode Found</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<b>Bad URL</b>
|
||||
</p>
|
||||
<p>The image you uploaded could not be decoded, or was too large. Go "Back" in your browser and try another
|
||||
image.
|
||||
</p>
|
||||
<script type="text/javascript">
|
||||
var gaJsHost = (("https:" == document.location.protocol) ?
|
||||
"https://ssl." : "http://www.");
|
||||
document.write(unescape("%3Cscript src='" + gaJsHost +
|
||||
"google-analytics.com/ga.js'
|
||||
type='text/javascript'%3E%3C/script%3E"));
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var pageTracker = _gat._getTracker("UA-788492-5");
|
||||
pageTracker._initData();
|
||||
pageTracker._trackPageview();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</jsp:root>
|
||||
|
|
|
@ -15,23 +15,35 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns="http://www.w3.org/1999/xhtml" version="2.1">
|
||||
<jsp:output
|
||||
<jsp:output
|
||||
omit-xml-declaration="false" doctype-root-element="html"
|
||||
doctype-public="-//WAPFORUM//DTD XHTML Mobile 1.1//EN"
|
||||
doctype-system="http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd"/>
|
||||
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head><title>No Barcode Found</title></head>
|
||||
<body>
|
||||
<p><b>Bad URL</b></p>
|
||||
<p>You didn't specify a URL, or the URL was not valid, or did not return an image. Go "Back" in your browser and try again.</p>
|
||||
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
_uacct = "UA-788492-5";
|
||||
urchinTracker();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>No Barcode Found</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<b>Bad URL</b>
|
||||
</p>
|
||||
<p>You didn't specify a URL, or the URL was not valid, or did not return an image. Go "Back" in your browser and
|
||||
try again.
|
||||
</p>
|
||||
<script type="text/javascript">
|
||||
var gaJsHost = (("https:" == document.location.protocol) ?
|
||||
"https://ssl." : "http://www.");
|
||||
document.write(unescape("%3Cscript src='" + gaJsHost +
|
||||
"google-analytics.com/ga.js'
|
||||
type='text/javascript'%3E%3C/script%3E"));
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var pageTracker = _gat._getTracker("UA-788492-5");
|
||||
pageTracker._initData();
|
||||
pageTracker._trackPageview();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</jsp:root>
|
||||
|
|
|
@ -15,40 +15,58 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns="http://www.w3.org/1999/xhtml" version="2.1">
|
||||
<jsp:output
|
||||
<jsp:output
|
||||
omit-xml-declaration="false" doctype-root-element="html"
|
||||
doctype-public="-//W3C//DTD XHTML 1.1//EN"
|
||||
doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"/>
|
||||
<jsp:directive.page contentType="text/html" session="false"/>
|
||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head><title>ZXing Decoder Online</title></head>
|
||||
<body>
|
||||
<jsp:directive.page contentType="text/html" session="false"/>
|
||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>ZXing Decoder Online</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>ZXing Decoder Online</h1>
|
||||
<h1>ZXing Decoder Online</h1>
|
||||
|
||||
<p><b>Under Construction</b>: This is a simple page that will let you decode a 1D or 2D barcode found
|
||||
in an image online. Enter a URL below.</p>
|
||||
<p><b>Under Construction</b>: This is a simple page that will let you decode a 1D or 2D barcode found
|
||||
in an image online. Enter a URL below.
|
||||
</p>
|
||||
|
||||
<form action="decode" method="get">
|
||||
<p><input type="text" size="50" name="u"/><input type="submit"/></p>
|
||||
</form>
|
||||
<form action="decode" method="get">
|
||||
<p>
|
||||
<input type="text" size="50" name="u"/>
|
||||
<input type="submit"/>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<p>Or try uploading a file:</p>
|
||||
<p>Or try uploading a file:</p>
|
||||
|
||||
<form action="decode" method="post" enctype="multipart/form-data" >
|
||||
<p><input type="file" size="50" name="f"/><input type="submit"/></p>
|
||||
</form>
|
||||
<form action="decode" method="post" enctype="multipart/form-data">
|
||||
<p>
|
||||
<input type="file" size="50" name="f"/>
|
||||
<input type="submit"/>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<p>See the <a href="http://code.google.com/p/zxing">project page</a> for details.</p>
|
||||
<p>See the
|
||||
<a href="http://code.google.com/p/zxing">project page</a>
|
||||
for details.
|
||||
</p>
|
||||
|
||||
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
_uacct = "UA-788492-5";
|
||||
urchinTracker();
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var gaJsHost = (("https:" == document.location.protocol) ?
|
||||
"https://ssl." : "http://www.");
|
||||
document.write(unescape("%3Cscript src='" + gaJsHost +
|
||||
"google-analytics.com/ga.js'
|
||||
type='text/javascript'%3E%3C/script%3E"));
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var pageTracker = _gat._getTracker("UA-788492-5");
|
||||
pageTracker._initData();
|
||||
pageTracker._trackPageview();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</body>
|
||||
</html>
|
||||
</jsp:root>
|
||||
|
|
|
@ -15,27 +15,50 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns="http://www.w3.org/1999/xhtml" version="2.1">
|
||||
<jsp:output
|
||||
<jsp:output
|
||||
omit-xml-declaration="false" doctype-root-element="html"
|
||||
doctype-public="-//WAPFORUM//DTD XHTML Mobile 1.1//EN"
|
||||
doctype-system="http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd"/>
|
||||
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head><title>Download ZXing Reader</title></head>
|
||||
<body>
|
||||
<p><strong>Welcome to zxing!</strong></p>
|
||||
<p><a href="BarcodeReader.jad">Download</a> the ZXing Barcode Reader.</p>
|
||||
<p><strong>Having problems with the regular version?</strong></p>
|
||||
<p><a href="BarcodeReaderBasic.jad">Download</a> the ZXing Barcode Reader Basic version.</p>
|
||||
<p><strong>An Android client is available for the curious:</strong></p>
|
||||
<p><a href="BarcodeReader.apk">Download</a> the Android client.</p>
|
||||
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
_uacct = "UA-788492-5";
|
||||
urchinTracker();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>Download ZXing Reader</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<strong>Welcome to zxing!</strong>
|
||||
</p>
|
||||
<p>
|
||||
<a href="BarcodeReader.jad">Download</a>
|
||||
the ZXing Barcode Reader.
|
||||
</p>
|
||||
<p>
|
||||
<strong>Having problems with the regular version?</strong>
|
||||
</p>
|
||||
<p>
|
||||
<a href="BarcodeReaderBasic.jad">Download</a>
|
||||
the ZXing Barcode Reader Basic version.
|
||||
</p>
|
||||
<p>
|
||||
<strong>An Android client is available for the curious:</strong>
|
||||
</p>
|
||||
<p>
|
||||
<a href="BarcodeReader.apk">Download</a>
|
||||
the Android client.
|
||||
</p>
|
||||
<script type="text/javascript">
|
||||
var gaJsHost = (("https:" == document.location.protocol) ?
|
||||
"https://ssl." : "http://www.");
|
||||
document.write(unescape("%3Cscript src='" + gaJsHost +
|
||||
"google-analytics.com/ga.js'
|
||||
type='text/javascript'%3E%3C/script%3E"));
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var pageTracker = _gat._getTracker("UA-788492-5");
|
||||
pageTracker._initData();
|
||||
pageTracker._trackPageview();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</jsp:root>
|
||||
|
|
|
@ -15,24 +15,35 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns="http://www.w3.org/1999/xhtml" version="2.1">
|
||||
<jsp:output
|
||||
<jsp:output
|
||||
omit-xml-declaration="false" doctype-root-element="html"
|
||||
doctype-public="-//WAPFORUM//DTD XHTML Mobile 1.1//EN"
|
||||
doctype-system="http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd"/>
|
||||
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head><title>No Barcode Found</title></head>
|
||||
<body>
|
||||
<p><b>No Barcode Found</b></p>
|
||||
<p>No barcode was found in this image. Either it did not contain a barcode, or did not contain one in a
|
||||
supported format, or the software was simply unable to find it. Go "Back" in your browser and try another image.</p>
|
||||
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
_uacct = "UA-788492-5";
|
||||
urchinTracker();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>No Barcode Found</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<b>No Barcode Found</b>
|
||||
</p>
|
||||
<p>No barcode was found in this image. Either it did not contain a barcode, or did not contain one in a
|
||||
supported format, or the software was simply unable to find it. Go "Back" in your browser and try another image.
|
||||
</p>
|
||||
<script type="text/javascript">
|
||||
var gaJsHost = (("https:" == document.location.protocol) ?
|
||||
"https://ssl." : "http://www.");
|
||||
document.write(unescape("%3Cscript src='" + gaJsHost +
|
||||
"google-analytics.com/ga.js'
|
||||
type='text/javascript'%3E%3C/script%3E"));
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var pageTracker = _gat._getTracker("UA-788492-5");
|
||||
pageTracker._initData();
|
||||
pageTracker._trackPageview();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</jsp:root>
|
||||
|
|
Loading…
Reference in a new issue