diff --git a/app/app-release.apk b/app/app-release.apk new file mode 100755 index 0000000..98183fc Binary files /dev/null and b/app/app-release.apk differ diff --git a/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourFtp.java b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourFtp.java new file mode 100755 index 0000000..4124f14 --- /dev/null +++ b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourFtp.java @@ -0,0 +1,79 @@ +package com.ericsson.uecontrol.core.behaviour; + +import android.util.Log; + +import com.ericsson.uecontrol.core.UeBehaviour; +import com.ericsson.uecontrol.gui.util.Configurator.Configurable; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; + +/** + * This behaviour simulates visiting a website + * + * Created by ezivkoc on 2014-07-15. + */ +public class UeBehaviourFtp extends UeBehaviour { + + @Configurable("Host") + private String host; + @Configurable("File Path") + private String filePath; + @Configurable("Username") + private String username; + @Configurable("Password") + private String password; + + + @Override + protected void execute() throws IOException { + URL url = new URL(getFtpUrl()); + Log.v(getClass().getSimpleName(), "Downloading from FTP: " + url); + + byte[] data = new byte[100]; + URLConnection connection = url.openConnection(); + connection.setUseCaches(false); + connection.connect(); + InputStream in = connection.getInputStream(); + + long total = in.available(); + long progress = 0; + long read = 0; + + while((read = in.read(data)) != -1 && !stopExecution()){ + progress += read; + super.setProgress((float)progress/total); + super.setHandledIncomingData(read); + } + } + + private String getFtpUrl() { + String url = "ftp://"; + if(username != null && !username.isEmpty()) { + url += username; + if(password !=null && !password.isEmpty()) + url += ":"+password; + url += "@"; + } + url += host; + if(filePath != null && filePath.isEmpty()){ + if(!filePath.startsWith("/")) + filePath = "/"+filePath; + url += filePath; + } + return url; + } + + + @Override + public String getName() { + return "FTP Download"; + } + + @Override + public String toString() { + return "Will download "+ getFtpUrl(); + } +}