diff options
author | Anton Tananaev <anton@traccar.org> | 2022-05-30 11:49:39 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-05-30 11:49:39 -0700 |
commit | 154ff3b2175e67b3fac531cb9c5c5c68880f5e12 (patch) | |
tree | f448a59c75b64deea60b1bd6e79d66790f62a4a8 /src/main/java/org/traccar/BaseProtocolDecoder.java | |
parent | b1a971eedb18a11af2cdc70ba5f8004bae89defd (diff) | |
download | trackermap-server-154ff3b2175e67b3fac531cb9c5c5c68880f5e12.tar.gz trackermap-server-154ff3b2175e67b3fac531cb9c5c5c68880f5e12.tar.bz2 trackermap-server-154ff3b2175e67b3fac531cb9c5c5c68880f5e12.zip |
Inject media manager
Diffstat (limited to 'src/main/java/org/traccar/BaseProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/BaseProtocolDecoder.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/BaseProtocolDecoder.java b/src/main/java/org/traccar/BaseProtocolDecoder.java index a40756796..505e7926f 100644 --- a/src/main/java/org/traccar/BaseProtocolDecoder.java +++ b/src/main/java/org/traccar/BaseProtocolDecoder.java @@ -15,6 +15,8 @@ */ package org.traccar; +import com.google.inject.Inject; +import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; import io.netty.channel.socket.DatagramChannel; import io.netty.handler.codec.http.HttpRequestDecoder; @@ -25,6 +27,7 @@ import org.traccar.config.Keys; import org.traccar.database.CommandsManager; import org.traccar.database.ConnectionManager; import org.traccar.database.IdentityManager; +import org.traccar.database.MediaManager; import org.traccar.database.StatisticsManager; import org.traccar.helper.UnitsConverter; import org.traccar.model.Command; @@ -53,11 +56,22 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { private final StatisticsManager statisticsManager; private final Protocol protocol; + private MediaManager mediaManager; + public BaseProtocolDecoder(Protocol protocol) { this.protocol = protocol; statisticsManager = Main.getInjector() != null ? Main.getInjector().getInstance(StatisticsManager.class) : null; } + @Inject + public void setMediaManager(MediaManager mediaManager) { + this.mediaManager = mediaManager; + } + + public String writeMediaFile(String uniqueId, ByteBuf buf, String extension) { + return mediaManager.writeFile(uniqueId, buf, extension); + } + public String getProtocolName() { return protocol != null ? protocol.getName() : PROTOCOL_UNKNOWN; } |