B4A Library New Net library - Android FTP, SMTP and POP3

Discussion in 'Additional libraries, classes and official updates' started by Erel, Aug 17, 2011.

Thread Status:
Not open for further replies.
  1. Mikonios

    Mikonios Active Member Licensed User

    Hi,

    I need capture FTP1.SendCommand("CD", DirFtp) response.

    This code no work ::
    Code:
    Sub FTP_CommandCompleted (ServerPath As String, Success As Boolean)
        
    If Not(Success) Then
            
    Log("SendCommandComplete failed : " & LastException)
            Csr.LogMemory1(
    "   X02_MySndCmd   :: (Err)""3")
            X55_SndMyFtpSale(
    "    FTP_SendCommandComplete NoControlado")
        
    Else
            
    Log("SendCommandComplete Ok: ")
            X55_SndMyFtpSale(
    "    FTP_SendCommandComplete Ok")
        
    End If
    End Sub
    And can't find xample documentation for FTP_CommandCompleted ::
    ((( http://www.b4x.com/android/help/net.html#ftp_sendcommand )))
    SendCommand (Command As String, Parameters As String) Sends an FTP command.
    The CommandCompleted event will be raised with the server reply. Should only be used with commands that return the reply in the command channel (not the data channel).
    It is possible that Success will be false and LastException will not be initialized.

    Anywhere can say me what´s correct sintax, or mode to get response, Pleased ??
     
    Last edited: Apr 11, 2016
  2. Mikonios

    Mikonios Active Member Licensed User

    Ok, this is SOLUTION my problema :::

    Code:
    Sub FTP_CommandCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
        
    If Not(Success) Then
            
    Log("SendCommandComplete failed : " & LastException)
            Csr.LogMemory1(
    "   X02_MySmbPut.Upload    :: (Err)""3")
            X55_SndMyFtpSale(
    "    FTP_SendCommandComplete NoControlado")
        
    Else
            
    Log("SendCommandComplete Ok: ")
            X55_SndMyFtpSale(
    "    FTP_SendCommandComplete Ok")
        
    End If   
    End Sub
     
  3. Walter Adriano da Silva

    Walter Adriano da Silva Member Licensed User

    Is TLS supported now?
     
  4. DonManfred

    DonManfred Expert Licensed User

    I guess yes:
     
  5. JohnC

    JohnC Well-Known Member Licensed User

    I just verified (using android 5.0+ and this latest NET lib) that when a file is being transferred (uploading from device), the UI of my app hangs until the file is completed. I thought that the transfer is executed in a background thread, so why would it hang my apps' UI?
     
    Last edited: May 30, 2016
  6. DonManfred

    DonManfred Expert Licensed User

    if i upload a file with ftp my ui does not hang.... i can work with the app till the complete event is raised....
    What do you do that your app hangs?
     
  7. JohnC

    JohnC Well-Known Member Licensed User

    Everything freezes.....the horizontal scrolling of a table, pressing buttons, everything.
     
  8. DonManfred

    DonManfred Expert Licensed User

    Do you block the mainthread?
    How does your code looks like?


    This works for me without blocking anything

    Code:
    If FirstTime Then
            
    'FTP.Initialize("FTP", "hdro-die-schwarze-hand.de", 21, "w00d7468", "3BzsLDPeoWDJWCVn")
            FTP.Initialize("FTP""host"21"user""password")
        
    End If
       
        
    Dim flist As List = File.ListFiles(File.Combine(File.DirRootExternal,"Download"))
        
    Log(flist)
        
    Log(File.Combine(File.DirRootExternal,"Download"))
        
    FTP.UploadFile(File.Combine(File.DirRootExternal,"Download"),"test.iso",False"/test.iso")
        
    'FTP.UploadFile(File.DirAssets,File.Combine(File.DirRootExternal,"Download/test.iso"),False, "/test.iso")
    End Sub

    Sub FTP_UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
      s = 
    "Uploaded " & (TotalUploaded / 1024 / 1024) & "MB"
      
    If Total > 0 Then s = s & " out of " & (Total / 1024 / 1024) & "MB"
      
    If s.EqualsIgnoreCase(old) Then
        
    Else
            old = s
            Label1.Text = s
            
    Log(s)
        
    End If
    End Sub
    Sub FTP_UploadCompleted (ServerPath As String, Success As Boolean)
      
    Log(ServerPath & ", Success=" & Success)
      Label1.Text = 
    "Upload (18mb) completed!"
        
    If Success = False Then Log(LastException.Message)
    End Sub
     
  9. JohnC

    JohnC Well-Known Member Licensed User

    This is my upload progress event sub - it shouldn't hang anything:

    Code:
    Sub FTP_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 & "(" & ServerPath & ")")
    End Sub
     
  10. JohnC

    JohnC Well-Known Member Licensed User

    Erel,

    My client and I can reproduce this condition at will and on multiple devices (some android 5.0 the others 6.0).

    I am using your latest "NET" lib (v1.62).

    If this makes a difference, the FTP.Initialize line and it's event subs are in a service module because I need to have the FTP happen in the background while the user is using another activity.

    How can I prevent an FTP transfer from locking the UI of another activity?
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    All transfers happen in the background. Please start a new thread in the questions forum and post a small example that causes the UI to freeze.
     
  12. rtek1000

    rtek1000 Active Member Licensed User

    Hello guys,

    SMTP from Gmail is impossible now for me.

    The response error received on log redirects to page treatment of incorrect/insecure login, and offers an alternative from page:
    https://support.google.com/accounts/answer/6010255?hl=en

    "some apps or devices that do not use modern security standards"

    To turn more insecure this acount but yet can not send any e-mail.

    I try both ways, TLS and SSL.

    Can you post a functional sample, please?
     
  13. DonManfred

    DonManfred Expert Licensed User

    Last edited: Jun 6, 2016
    Erel likes this.
  14. rtek1000

    rtek1000 Active Member Licensed User

    Hello again,

    SMTP works fine now,
    I made less secure options again:

    https://www.google.com/settings/security/lesssecureapps

    and I changed password too.

    Code:
    Sub Send_Message(Msg1 As String)
       
    Dim SMTP1 As SMTP
       SMTP1.Initialize(
    "smtp.gmail.com"465"user@gmail.com""password""smtpEventResponse")
       SMTP1.To.Add(
    "user@gmail.com"'change to real address
       SMTP1.Subject = "Test1"
       SMTP1.Body =  
    "123123123"
       SMTP1.UseSSL = 
    True
       SMTP1.Send
    End Sub
    Sub smtpEventResponse_MessageSent(Success As Boolean)
       
    Log(Success)
       
    Log(LastException)
    End Sub
    Thank you.
     
  15. rtek1000

    rtek1000 Active Member Licensed User

    Hello,

    It would be possible to reverse engineer the gmail app to see how it is modern authentication, or it is legally prevented?
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    It is not possible.
     
  17. Don Oso

    Don Oso Active Member Licensed User

    Its possible to send email without authentication?

    im trying to send the email to a local relay server ?

    Thanks
    Javier
     
  18. Erel

    Erel Administrator Staff Member Licensed User

    The SMTP always sends the AUTH command. Do you get any error in MessageSent event?
     
  19. Don Oso

    Don Oso Active Member Licensed User

    Yes I get errors when i try to send a message without AUTH or with empty values in user and password parameters . but i wonder maybe there another method to send messages without auth

    I think that the best soluton here , its put authentication to the local SMTP server in my case. o_O

    thanks
     
  20. Erel

    Erel Administrator Staff Member Licensed User

    Currently no.
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice