mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -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 SMTP_PORT = "465";
|
||||||
private static final String POP_PORT = "995";
|
private static final String POP_PORT = "995";
|
||||||
private static final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
|
private static final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
|
||||||
private static final Address fromAddress;
|
|
||||||
private static final Properties sessionProperties = new Properties();
|
private static final Properties sessionProperties = new Properties();
|
||||||
static {
|
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.transport.protocol", "smtp");
|
||||||
sessionProperties.setProperty("mail.smtp.host", SMTP_HOST);
|
sessionProperties.setProperty("mail.smtp.host", SMTP_HOST);
|
||||||
sessionProperties.setProperty("mail.smtp.auth", "true");
|
sessionProperties.setProperty("mail.smtp.auth", "true");
|
||||||
|
@ -80,9 +74,16 @@ final class DecodeEmailTask extends TimerTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Authenticator emailAuthenticator;
|
private final Authenticator emailAuthenticator;
|
||||||
|
private final Address fromAddress;
|
||||||
|
|
||||||
DecodeEmailTask(Authenticator emailAuthenticator) {
|
DecodeEmailTask(String emailAddress, Authenticator emailAuthenticator) {
|
||||||
this.emailAuthenticator = emailAuthenticator;
|
this.emailAuthenticator = emailAuthenticator;
|
||||||
|
try {
|
||||||
|
fromAddress = new InternetAddress(emailAddress, "ZXing By Email");
|
||||||
|
} catch (UnsupportedEncodingException uee) {
|
||||||
|
// Can't happen?
|
||||||
|
throw new RuntimeException(uee);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -73,6 +73,7 @@ public final class DecodeServlet extends HttpServlet {
|
||||||
private static final Logger log = Logger.getLogger(DecodeServlet.class.getName());
|
private static final Logger log = Logger.getLogger(DecodeServlet.class.getName());
|
||||||
|
|
||||||
static final Hashtable<DecodeHintType, Object> HINTS;
|
static final Hashtable<DecodeHintType, Object> HINTS;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
HINTS = new Hashtable<DecodeHintType, Object>(3);
|
HINTS = new Hashtable<DecodeHintType, Object>(3);
|
||||||
HINTS.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
|
HINTS.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
|
||||||
|
@ -107,7 +108,7 @@ public final class DecodeServlet extends HttpServlet {
|
||||||
|
|
||||||
Authenticator emailAuthenticator = new EmailAuthenticator(emailAddress, emailPassword);
|
Authenticator emailAuthenticator = new EmailAuthenticator(emailAddress, emailPassword);
|
||||||
emailTimer = new Timer("Email decoder timer", true);
|
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");
|
log.info("DecodeServlet configured");
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,20 +19,20 @@ package com.google.zxing.web;
|
||||||
import javax.servlet.Filter;
|
import javax.servlet.Filter;
|
||||||
import javax.servlet.FilterChain;
|
import javax.servlet.FilterChain;
|
||||||
import javax.servlet.FilterConfig;
|
import javax.servlet.FilterConfig;
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sean Owen
|
* @author Sean Owen
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package com.google.zxing.web;
|
package com.google.zxing.web;
|
||||||
|
|
||||||
import javax.mail.Authenticator;
|
import javax.mail.Authenticator;
|
||||||
|
import javax.mail.PasswordAuthentication;
|
||||||
|
|
||||||
final class EmailAuthenticator extends Authenticator {
|
final class EmailAuthenticator extends Authenticator {
|
||||||
|
|
||||||
|
@ -28,4 +29,9 @@ final class EmailAuthenticator extends Authenticator {
|
||||||
this.emailPassword = emailPassword;
|
this.emailPassword = emailPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(emailUsername, emailPassword);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ final class IPTrie {
|
||||||
private static final class IPTrieNode {
|
private static final class IPTrieNode {
|
||||||
final IPTrieNode[] children;
|
final IPTrieNode[] children;
|
||||||
final int[] values;
|
final int[] values;
|
||||||
|
|
||||||
private IPTrieNode(boolean terminal) {
|
private IPTrieNode(boolean terminal) {
|
||||||
if (terminal) {
|
if (terminal) {
|
||||||
children = null;
|
children = null;
|
||||||
|
|
|
@ -22,15 +22,27 @@
|
||||||
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
||||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
<head><title>No Barcode Found</title></head>
|
<head>
|
||||||
|
<title>No Barcode Found</title>
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p><b>Bad URL</b></p>
|
<p>
|
||||||
<p>The image you uploaded could not be decoded, or was too large. Go "Back" in your browser and try another image.</p>
|
<b>Bad URL</b>
|
||||||
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
</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>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
_uacct = "UA-788492-5";
|
var pageTracker = _gat._getTracker("UA-788492-5");
|
||||||
urchinTracker();
|
pageTracker._initData();
|
||||||
|
pageTracker._trackPageview();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -22,15 +22,27 @@
|
||||||
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
||||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
<head><title>No Barcode Found</title></head>
|
<head>
|
||||||
|
<title>No Barcode Found</title>
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p><b>Bad URL</b></p>
|
<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>
|
<b>Bad URL</b>
|
||||||
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
</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>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
_uacct = "UA-788492-5";
|
var pageTracker = _gat._getTracker("UA-788492-5");
|
||||||
urchinTracker();
|
pageTracker._initData();
|
||||||
|
pageTracker._trackPageview();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -22,31 +22,49 @@
|
||||||
<jsp:directive.page contentType="text/html" session="false"/>
|
<jsp:directive.page contentType="text/html" session="false"/>
|
||||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
<head><title>ZXing Decoder Online</title></head>
|
<head>
|
||||||
|
<title>ZXing Decoder Online</title>
|
||||||
|
</head>
|
||||||
<body>
|
<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
|
<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>
|
in an image online. Enter a URL below.
|
||||||
|
</p>
|
||||||
|
|
||||||
<form action="decode" method="get">
|
<form action="decode" method="get">
|
||||||
<p><input type="text" size="50" name="u"/><input type="submit"/></p>
|
<p>
|
||||||
|
<input type="text" size="50" name="u"/>
|
||||||
|
<input type="submit"/>
|
||||||
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<p>Or try uploading a file:</p>
|
<p>Or try uploading a file:</p>
|
||||||
|
|
||||||
<form action="decode" method="post" enctype="multipart/form-data">
|
<form action="decode" method="post" enctype="multipart/form-data">
|
||||||
<p><input type="file" size="50" name="f"/><input type="submit"/></p>
|
<p>
|
||||||
|
<input type="file" size="50" name="f"/>
|
||||||
|
<input type="submit"/>
|
||||||
|
</p>
|
||||||
</form>
|
</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 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>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
_uacct = "UA-788492-5";
|
var pageTracker = _gat._getTracker("UA-788492-5");
|
||||||
urchinTracker();
|
pageTracker._initData();
|
||||||
|
pageTracker._trackPageview();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -22,19 +22,42 @@
|
||||||
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
||||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
<head><title>Download ZXing Reader</title></head>
|
<head>
|
||||||
|
<title>Download ZXing Reader</title>
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p><strong>Welcome to zxing!</strong></p>
|
<p>
|
||||||
<p><a href="BarcodeReader.jad">Download</a> the ZXing Barcode Reader.</p>
|
<strong>Welcome to zxing!</strong>
|
||||||
<p><strong>Having problems with the regular version?</strong></p>
|
</p>
|
||||||
<p><a href="BarcodeReaderBasic.jad">Download</a> the ZXing Barcode Reader Basic version.</p>
|
<p>
|
||||||
<p><strong>An Android client is available for the curious:</strong></p>
|
<a href="BarcodeReader.jad">Download</a>
|
||||||
<p><a href="BarcodeReader.apk">Download</a> the Android client.</p>
|
the ZXing Barcode Reader.
|
||||||
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
</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>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
_uacct = "UA-788492-5";
|
var pageTracker = _gat._getTracker("UA-788492-5");
|
||||||
urchinTracker();
|
pageTracker._initData();
|
||||||
|
pageTracker._trackPageview();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -22,16 +22,27 @@
|
||||||
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
<jsp:directive.page contentType="application/xhtml+xml" session="false"/>
|
||||||
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
<jsp:scriptlet>response.setHeader("Cache-Control", "public");</jsp:scriptlet>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||||
<head><title>No Barcode Found</title></head>
|
<head>
|
||||||
|
<title>No Barcode Found</title>
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p><b>No Barcode Found</b></p>
|
<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
|
<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>
|
supported format, or the software was simply unable to find it. Go "Back" in your browser and try another image.
|
||||||
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
</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>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
_uacct = "UA-788492-5";
|
var pageTracker = _gat._getTracker("UA-788492-5");
|
||||||
urchinTracker();
|
pageTracker._initData();
|
||||||
|
pageTracker._trackPageview();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue