aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/BaseProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/BaseProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/BaseProtocolDecoder.java14
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;
}