aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/MainEventHandler.java4
-rw-r--r--src/org/traccar/notification/NotificationMail.java37
-rw-r--r--src/org/traccar/protocol/GatorProtocol.java4
-rw-r--r--src/org/traccar/protocol/OsmAndProtocolDecoder.java13
-rw-r--r--src/org/traccar/protocol/TzoneProtocol.java2
5 files changed, 34 insertions, 26 deletions
diff --git a/src/org/traccar/MainEventHandler.java b/src/org/traccar/MainEventHandler.java
index c01760283..3f7e68b2a 100644
--- a/src/org/traccar/MainEventHandler.java
+++ b/src/org/traccar/MainEventHandler.java
@@ -25,6 +25,7 @@ import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler;
import org.jboss.netty.handler.timeout.IdleStateEvent;
import org.traccar.helper.Log;
import org.traccar.model.Position;
+import org.traccar.protocol.TeltonikaProtocolDecoder;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
@@ -78,7 +79,8 @@ public class MainEventHandler extends IdleStateAwareChannelHandler {
Log.info(formatChannel(e.getChannel()) + " disconnected");
closeChannel(e.getChannel());
- if (ctx.getPipeline().get("httpDecoder") == null) {
+ if (ctx.getPipeline().get("httpDecoder") == null
+ && !(ctx.getPipeline().get("objectDecoder") instanceof TeltonikaProtocolDecoder)) {
Context.getConnectionManager().removeActiveDevice(e.getChannel());
}
}
diff --git a/src/org/traccar/notification/NotificationMail.java b/src/org/traccar/notification/NotificationMail.java
index 944200f2f..f9d42968f 100644
--- a/src/org/traccar/notification/NotificationMail.java
+++ b/src/org/traccar/notification/NotificationMail.java
@@ -48,19 +48,26 @@ public final class NotificationMail {
result.put("mail.smtp.port", config.getString("mail.smtp.port", "25"));
if (config.getBoolean("mail.smtp.starttls.enable")) {
- result.put("mail.smtp.starttls.enable",
- config.getBoolean("mail.smtp.starttls.enable"));
+ result.put("mail.smtp.starttls.enable", config.getBoolean("mail.smtp.starttls.enable"));
} else if (config.getBoolean("mail.smtp.ssl.enable")) {
- result.put("mail.smtp.socketFactory.port",
- result.getProperty("mail.smtp.port"));
- result.put("mail.smtp.socketFactory.class",
- "javax.net.ssl.SSLSocketFactory");
+ result.put("mail.smtp.ssl.enable", config.getBoolean("mail.smtp.ssl.enable"));
}
+ result.put("mail.smtp.ssl.trust", config.getBoolean("mail.smtp.ssl.trust"));
result.put("mail.smtp.auth", config.getBoolean("mail.smtp.auth"));
- result.put("mail.smtp.user", config.getString("mail.smtp.username", null));
- result.put("mail.smtp.password", config.getString("mail.smtp.password", null));
- result.put("mail.smtp.from", config.getString("mail.smtp.from", null));
+
+ String username = config.getString("mail.smtp.username");
+ if (username != null) {
+ result.put("mail.smtp.user", username);
+ }
+ String password = config.getString("mail.smtp.password");
+ if (password != null) {
+ result.put("mail.smtp.password", password);
+ }
+ String from = config.getString("mail.smtp.from");
+ if (from != null) {
+ result.put("mail.smtp.from", from);
+ }
}
return result;
}
@@ -77,12 +84,10 @@ public final class NotificationMail {
result.put("mail.smtp.starttls.enable", tls);
} else if (object.getAttributes().containsKey("mail.smtp.ssl.enable")) {
boolean ssl = Boolean.parseBoolean((String) object.getAttributes().get("mail.smtp.ssl.enable"));
- if (ssl) {
- result.put("mail.smtp.socketFactory.port",
- result.getProperty("mail.smtp.port"));
- result.put("mail.smtp.socketFactory.class",
- "javax.net.ssl.SSLSocketFactory");
- }
+ result.put("mail.smtp.ssl.enable", ssl);
+ }
+ if (object.getAttributes().containsKey("mail.smtp.ssl.trust")) {
+ result.put("mail.smtp.ssl.trust", object.getAttributes().get("mail.smtp.ssl.trust"));
}
boolean auth = Boolean.parseBoolean((String) object.getAttributes().get("mail.smtp.auth"));
result.put("mail.smtp.auth", auth);
@@ -117,7 +122,7 @@ public final class NotificationMail {
return;
}
}
- mailSession = Session.getDefaultInstance(mailServerProperties, null);
+ mailSession = Session.getInstance(mailServerProperties, null);
mailMessage = new MimeMessage(mailSession);
diff --git a/src/org/traccar/protocol/GatorProtocol.java b/src/org/traccar/protocol/GatorProtocol.java
index 3776bcfd3..3d899fa1f 100644
--- a/src/org/traccar/protocol/GatorProtocol.java
+++ b/src/org/traccar/protocol/GatorProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ public class GatorProtocol extends BaseProtocol {
serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 3, 2, 1, 0));
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 3, 2));
pipeline.addLast("objectDecoder", new GatorProtocolDecoder(GatorProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
index f9f04d7e3..c5884a4d0 100644
--- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java
+++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
@@ -73,9 +73,7 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
case "deviceid":
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, value);
if (deviceSession == null) {
- if (channel != null) {
- sendResponse(channel, HttpResponseStatus.BAD_REQUEST);
- }
+ sendResponse(channel, HttpResponseStatus.BAD_REQUEST);
return null;
}
position.setDeviceId(deviceSession.getDeviceId());
@@ -132,11 +130,14 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
position.setTime(new Date());
}
- if (channel != null) {
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
+ if (deviceSession != null) {
sendResponse(channel, HttpResponseStatus.OK);
+ return position;
+ } else {
+ sendResponse(channel, HttpResponseStatus.BAD_REQUEST);
+ return null;
}
-
- return position;
}
}
diff --git a/src/org/traccar/protocol/TzoneProtocol.java b/src/org/traccar/protocol/TzoneProtocol.java
index 2d98e3f79..fcf673a57 100644
--- a/src/org/traccar/protocol/TzoneProtocol.java
+++ b/src/org/traccar/protocol/TzoneProtocol.java
@@ -34,7 +34,7 @@ public class TzoneProtocol extends BaseProtocol {
serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 2));
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 2, 2, 0));
pipeline.addLast("objectDecoder", new TzoneProtocolDecoder(TzoneProtocol.this));
}
});