diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2014-10-22 09:43:19 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2014-10-22 09:43:19 +1300 |
commit | 91395e9ac0dd5de366b87bb5d082990b15a946e9 (patch) | |
tree | 57aea8c58bbd8d197d61e6b7013937c44f950de7 /src/org/traccar/protocol/MeiligaoProtocolDecoder.java | |
parent | 8876e964cf26a090d11fd855642c95bc02a17c7f (diff) | |
parent | 0d59336ac1fbe9934260e56811c3bcafa0aeaeca (diff) | |
download | trackermap-server-91395e9ac0dd5de366b87bb5d082990b15a946e9.tar.gz trackermap-server-91395e9ac0dd5de366b87bb5d082990b15a946e9.tar.bz2 trackermap-server-91395e9ac0dd5de366b87bb5d082990b15a946e9.zip |
Merge pull request #918 from jon-stumpf/enhancement-eliminate-hardcoded-protocol-names
Eliminate hardcoded protocol names
Diffstat (limited to 'src/org/traccar/protocol/MeiligaoProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/MeiligaoProtocolDecoder.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 6221ce4e7..7dcfdb200 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -18,15 +18,18 @@ package org.traccar.protocol; import java.net.InetSocketAddress; 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.ServerManager; +import org.traccar.database.DataManager; import org.traccar.helper.Crc; import org.traccar.helper.Log; import org.traccar.model.ExtendedInfoFormatter; @@ -34,8 +37,8 @@ import org.traccar.model.Position; public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { - public MeiligaoProtocolDecoder(ServerManager serverManager) { - super(serverManager); + public MeiligaoProtocolDecoder(DataManager dataManager, String protocol, Properties properties) { + super(dataManager, protocol, properties); } private static final Pattern pattern = Pattern.compile( @@ -114,10 +117,10 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { } private String getMeiligaoServer(Channel channel) { + Properties p = getProperties(); - if (getServerManager() != null && - getServerManager().getProperties().containsKey("meiligao.server")) { - return getServerManager().getProperties().getProperty("meiligao.server"); + if (p != null && p.containsKey(getProtocol() + ".server")) { + return p.getProperty(getProtocol() + ".server"); } else { InetSocketAddress address = (InetSocketAddress) channel.getLocalAddress(); return address.getAddress().getHostAddress() + ":" + address.getPort(); @@ -160,7 +163,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("meiligao"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); // Custom data if (command == MSG_ALARM) { |