Skip to content

Server Communication

Willi Bölke edited this page Jun 2, 2020 · 8 revisions

In General

The Package ServerCommunication contains all Classens wich directly communicates with the the Server

FtpClient

Wraps the Apache FTPClient to our needs.

Methods

Name Returns Parameters Description Notes
connect() 0 = success 1 = Server refused connection 2 = SocketException 3 = IOException connects to the server sepecified in Variables
isConnected() true = connected false = not connected returns if the instannce is connected
closeConnection() void closes the connection
getDirList(String path) FTPFile[] which contains all directories in path the path Retrieves all directories in path from the FTPServer
getFileList(String path) FTPFile[] which contains all files in path the pah Retrieves all files in path from the FTPServer
getAllFilesList(String path) FTPFile[] which contains all files in path the path Retrieves all files in path and includes files from sub dirs
downloadFile(String remoteFileName, String downloadPath) true = success false = not successfull remoteFileName = the name of the file to be downloaded, downloadPath = the directory path downloads a file from the FTPServer and writes it to the device local storage

FtpTaskDirListing

Lists directories hosted on the remote FTPServer. Extends : AsyncTask<Void,Void,String> See also : FtpClient.getDirList

Methods

Name Returns Parameters Description Notes
FtpTaskDirListing(Context,String, AsyncResponse) context, the path, a implementation of AsyncResponse wich will be executed onPreExecute() Constructor
doInBackground(Void... params) String null Initializes an instance of FtpClient() and uses its getDirList() method to retreive the directories in path
onPostExecute(String result) void if there where any data to retrieve = executest asycRespons.getRemoteDirectories()

FtpTaskFileListing

Lists files hosted on the remote FTPServer. Extends : AsyncTask<Void,Void,String> See also : FtpClient.getFileList

Methods

Name Returns Parameters Description Notes
FtpTaskFileListing(Context,String, AsyncResponse) context, the path, a implementation of AsyncResponse wich will be executed onPreExecute() Constructor
doInBackground(Void... params) String null Initializes an instance of FtpClient() and uses its getFileList() method to retreive the files in path
onPostExecute(String result) void if there where any data to retrieve = executest asycRespons.hetOHDMFiles()

FtpTaskFileDownloading

Lists files hosted on the remote FTPServer. Extends : AsyncTask<RemoteFile, Integer, Long> See also : FtpClient.downloadFile

Methods

Name Returns Parameters Description Notes
FtpTaskFileDownloading(Context,String) context, the path Constructor
doInBackground(Void... params) String null Initializes an instance of FtpClient() and uses its downloadFile(filename, path) method to downlaod the files
onPostExecute(Long params) void just makes a Toast message

Variables

Contains all needed information about the Server such as IP address, ports and (ftp) user ingerdients. You need to chane the in case you host your own Server on a different location.

AsyncResponse

Lists files hosted on the remote FTPServer. Extends : AsyncTask<RemoteFile, Integer, Long> Used in : FtpTaskFileListing; FtpTaskDirListing

Methods

Name Returns Parameters Description Notes
getOhdmFiles(Context,ArrayList remoteFiles) void list of the retrieved RemoteFile Needs to be implemented when using FtpTaskFileListing
getRemoteDirectories(ArrayList remoteDirectories) void list of the retrieved RemkoteDirectory Needs to be implemented when using FtpTaskDirListing

Download:

Clone this wiki locally