aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/GlobalSatProtocolDecoder.java22
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/Mta6Protocol.java5
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java5
-rw-r--r--src/org/traccar/protocol/XexunProtocol.java5
7 files changed, 22 insertions, 47 deletions
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index b71ace1a1..3628730e3 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -147,7 +147,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
position.set(Event.KEY_BATTERY, parser.group(index++));
- if (Boolean.valueOf(Context.getProps().getProperty(getProtocolName() + ".ack")) && channel != null) {
+ if (Context.getConfig().getBoolean(getProtocolName() + ".ack") && channel != null) {
channel.write("+SACK:" + parser.group(index++) + "$", remoteAddress);
}
diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
index c411b4c25..04b88114f 100644
--- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
+++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
@@ -17,14 +17,10 @@ package org.traccar.protocol;
import java.net.SocketAddress;
import java.util.Calendar;
-import java.util.Properties;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.helper.UnitsConverter;
@@ -33,22 +29,14 @@ import org.traccar.model.Position;
public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
- // Default values
- private String format0 = "TSPRXAB27GHKLMnaicz*U!";
- private String format1 = "SARY*U!";
+ private String format0;
+ private String format1;
public GlobalSatProtocolDecoder(GlobalSatProtocol protocol) {
super(protocol);
-
- Properties properties = Context.getProps();
- if (properties != null) {
- if (properties.containsKey(protocol + ".format0")) {
- format0 = properties.getProperty(protocol + ".format0");
- }
- if (properties.containsKey(protocol + ".format1")) {
- format1 = properties.getProperty(protocol + ".format1");
- }
- }
+
+ format0 = Context.getConfig().getString(protocol + ".format0", "TSPRXAB27GHKLMnaicz*U!");
+ format1 = Context.getConfig().getString(protocol + ".format1", "SARY*U!");
}
public void setFormat0(String format) {
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 5e527dd9c..06c3985dc 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -15,10 +15,12 @@
*/
package org.traccar.protocol;
+import java.net.SocketAddress;
+import java.util.Calendar;
+import java.util.TimeZone;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.helper.Crc;
@@ -26,11 +28,6 @@ import org.traccar.helper.UnitsConverter;
import org.traccar.model.Event;
import org.traccar.model.Position;
-import java.net.SocketAddress;
-import java.util.Calendar;
-import java.util.Properties;
-import java.util.TimeZone;
-
public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
private boolean forceTimeZone = false;
@@ -38,11 +35,10 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
public Gt06ProtocolDecoder(Gt06Protocol protocol) {
super(protocol);
-
- Properties properties = Context.getProps();
- if (properties != null && properties.containsKey(protocol + ".timezone")) {
+
+ if (Context.getConfig().hasKey(protocol + ".timezone")) {
forceTimeZone = true;
- timeZone.setRawOffset(Integer.valueOf(properties.getProperty(protocol + ".timezone")) * 1000);
+ timeZone.setRawOffset(Context.getConfig().getInteger(protocol + ".timezone") * 1000);
}
}
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index f0b3ee9e6..4df757d22 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -16,17 +16,15 @@
package org.traccar.protocol;
import java.net.InetSocketAddress;
-import java.nio.charset.Charset;
import java.net.SocketAddress;
+import java.nio.charset.Charset;
import java.util.Calendar;
-import java.util.Properties;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.helper.Crc;
@@ -117,14 +115,12 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
}
private String getMeiligaoServer(Channel channel) {
- Properties p = Context.getProps();
-
- if (p != null && p.containsKey(getProtocolName() + ".server")) {
- return p.getProperty(getProtocolName() + ".server");
- } else {
+ String server = Context.getConfig().getString(getProtocolName() + ".server");
+ if (server == null) {
InetSocketAddress address = (InetSocketAddress) channel.getLocalAddress();
- return address.getAddress().getHostAddress() + ":" + address.getPort();
+ server = address.getAddress().getHostAddress() + ":" + address.getPort();
}
+ return server;
}
@Override
diff --git a/src/org/traccar/protocol/Mta6Protocol.java b/src/org/traccar/protocol/Mta6Protocol.java
index 7d4ea68f7..8232b850c 100644
--- a/src/org/traccar/protocol/Mta6Protocol.java
+++ b/src/org/traccar/protocol/Mta6Protocol.java
@@ -15,6 +15,7 @@
*/
package org.traccar.protocol;
+import java.util.List;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
@@ -23,8 +24,6 @@ import org.traccar.BaseProtocol;
import org.traccar.Context;
import org.traccar.TrackerServer;
-import java.util.List;
-
public class Mta6Protocol extends BaseProtocol {
public Mta6Protocol() {
@@ -39,7 +38,7 @@ public class Mta6Protocol extends BaseProtocol {
pipeline.addLast("httpDecoder", new HttpRequestDecoder());
pipeline.addLast("httpEncoder", new HttpResponseEncoder());
pipeline.addLast("objectDecoder", new Mta6ProtocolDecoder(
- Mta6Protocol.this, !Boolean.valueOf(Context.getProps().getProperty(getName() + ".can"))));
+ Mta6Protocol.this, !Context.getConfig().getBoolean(getName() + ".can")));
}
});
}
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index 1b34f3f81..e884f4be2 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -20,10 +20,7 @@ import java.util.Calendar;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.helper.UnitsConverter;
@@ -123,7 +120,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
position.setLongitude(longitude);
// Speed
- if (Boolean.valueOf(Context.getProps().getProperty(getProtocolName() + ".mph"))) {
+ if (Context.getConfig().getBoolean(getProtocolName() + ".mph")) {
position.setSpeed(UnitsConverter.knotsFromMph(Double.valueOf(parser.group(index++))));
} else {
position.setSpeed(UnitsConverter.knotsFromKph(Double.valueOf(parser.group(index++))));
diff --git a/src/org/traccar/protocol/XexunProtocol.java b/src/org/traccar/protocol/XexunProtocol.java
index 52d022b05..ea3ed8c10 100644
--- a/src/org/traccar/protocol/XexunProtocol.java
+++ b/src/org/traccar/protocol/XexunProtocol.java
@@ -15,6 +15,7 @@
*/
package org.traccar.protocol;
+import java.util.List;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
@@ -23,8 +24,6 @@ import org.traccar.BaseProtocol;
import org.traccar.Context;
import org.traccar.TrackerServer;
-import java.util.List;
-
public class XexunProtocol extends BaseProtocol {
public XexunProtocol() {
@@ -36,7 +35,7 @@ public class XexunProtocol extends BaseProtocol {
serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
- boolean full = Boolean.valueOf(Context.getProps().getProperty(getName() + ".extended"));
+ boolean full = Context.getConfig().getBoolean(getName() + ".extended");
if (full) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); // tracker bug \n\r
} else {