#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
Dim sftp1 As SFtp
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
sftp1.Initialize("sftp1", "xxx", "xxxx", "test.com", 2222)
sftp1.SetKnownHostsStore(File.DirApp, "hosts.txt")
sftp1.GetCurrentPath
MainForm.Show
End Sub
Sub Button1_Click
'xui.MsgboxAsync("Hello World!", "B4X")
sftp1.UploadFile(File.DirApp,"1001_1.pdf","/test.pdf")
End Sub
Sub sftp1_CommandCompleted (Command As String, Success As Boolean, ReplyCode As Int, ReplyString As String)
Log ("command=" & Command)
Log ("success=" & Success)
Log ("replyCODE=" & ReplyCode)
Log ("replystring=" & ReplyString)
End Sub
Sub sftp1_PromptYesNo (Message As String)
Dim res As Int = fx.Msgbox2(MainForm,Message, "", "Yes", "", "No",Null)
'The next line might be a bit confusing. It is a condition.
'The value will be True if res equals to DialogResponse.POSITIVE.
sftp1.SetPromptResult(res = fx.DialogResponse.POSITIVE)
'sftp1.SetPromptResult(True)
End Sub
Sub sftp1_ShowMessage (Message As String)
fx.Msgbox(MainForm,Message, "")
End Sub
Sub sftp1_UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
Dim s As String
s = "Uploaded " & Round(TotalUploaded / 1000) & "KB"
If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
Log(s)
End Sub
Sub sftp1_UploadCompleted (ServerPath As String, Success As Boolean)
Log(ServerPath & ", Success=" & Success)
If Success = False Then Log(LastException.Message)
End Sub