FTP client

...
  • Progress Update
    • * Proper error handling has been added for socket functions in FTPC (#6436 and #6437).
    • * Work on building a GUI login screen has started keeping in mind
      • * how well GUI code can be separated from the core FTPC code.
      • * if we can have both the CLI and GUI interface available.
    Last edited by nisargshah95 on Wed Jun 01, 2016 11:03 pm, edited 2 times in total.
  • The GUI for login screen has been finished (integration with FTPC is remaining). I have attached the code to run it as a standalone program. Any feedback regarding the design/code is welcome :)

    Screenshot:
    Image

    Code:
    Spoiler:

    Code: Select all

    use32
        org 0x0
        db 'MENUET01'
        dd 0x1
        dd start
        dd i_end
        dd mem
        dd mem
        dd 0x0
        dd cur_dir_path
    
    include 'macros.inc'
    include 'box_lib.mac'
    include 'load_lib.mac'
        @use_library         ;use load lib macros
    start:
    ;universal load library/libraries
    sys_load_library  library_name, cur_dir_path, library_path, system_path, \
    err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i
    ;if return code =-1 then exit, else nornary work
        cmp      eax,-1
        jz       exit
        mcall    40,0x27          ; set up a mask for expected events
    
    red_win:
        call     draw_window
    align 4
    still:
        mcall    10     ; wait for event
        dec      eax
        jz       red_win
        dec      eax
        jz       key
        dec      eax
        jz       button
    
        push    dword edit_usr
        call    [edit_box_mouse]
    
        push    dword edit_pass
        call    [edit_box_mouse]
    
        push    dword edit_server
        call    [edit_box_mouse]
    
        push    dword edit_port
        call    [edit_box_mouse]
    
        push    dword edit_path
        call    [edit_box_mouse]
    
        jmp     still
    
    button:
        mcall   17      ; will be modified to submit the data entered on clicking
                        ; 'connect' button
        test    ah,ah
        jz      still
    exit:
        mcall   -1
    key:
        mcall   2
    
        push    dword edit_usr
        call    [edit_box_key]
    
        push    dword edit_pass
        call    [edit_box_key]
    
        push    dword edit_server
        call    [edit_box_key]
    
        push    dword edit_port
        call    [edit_box_key]
    
        push    dword edit_path
        call    [edit_box_key]
    
        jmp     still
    
    
    align 4
    draw_window:
        mcall   12,1
        mcall   0,(320*65536+390),(300*65536+180),0x34AABBCC,0x805080DD,hed
    
        push    dword edit_usr
        call    [edit_box_draw]
    
        push    dword edit_pass
        call    [edit_box_draw]
    
        push    dword edit_server
        call    [edit_box_draw]
    
        push    dword edit_port
        call    [edit_box_draw]
    
        push    dword edit_path
        call    [edit_box_draw]
    
        call    draw_button
        call    draw_strings
    
        mcall   12,2
       ret
    
    draw_button:
        mcall   8,<162,65>,<120,25>,2,0x007887a6    ; connect button
        ret
    
    draw_strings:   ; draw strings for boxes and buttons
        mcall   4,<3,5>,0xb0000000,gui_str_usr
        mcall   4,<3,25>,0xb0000000,gui_str_pass
        mcall   4,<3,45>,0xb0000000,gui_str_server
        mcall   4,<3,65>,0xb0000000,gui_str_port
        mcall   4,<3,85>,0xb0000000,gui_str_path
        mcall   4,<167,125>,0xb0ffffff,str_connect_button
        ret
    
    
    system_path     db '/sys/lib/'
    library_name    db 'box_lib.obj',0
    
    err_message_found_lib    db 'cannot load library box_lib.obj',0
    str_connect_button       db 'Connect',0
    gui_str_usr              db 'Username:',0
    gui_str_pass             db 'Password:',0
    gui_str_server           db 'Server:',0
    gui_str_port             db 'Port:',0
    gui_str_path             db 'Path:',0
    
    head_f_i:
    head_f_l              db 'System error',0
    err_message_import    db 'Error on load import library box_lib.obj',0
    
    myimport:
    
    edit_box_draw    dd    aEdit_box_draw
    edit_box_key     dd    aEdit_box_key
    edit_box_mouse   dd    aEdit_box_mouse
    version_ed       dd    aVersion_ed
    
        dd    0
        dd    0
    
    aEdit_box_draw   db 'edit_box',0
    aEdit_box_key    db 'edit_box_key',0
    aEdit_box_mouse  db 'edit_box_mouse',0
    aVersion_ed      db 'version_ed',0
    
    edit_usr edit_box 300,75,5, 0xffffff,0x6f9480,0,0xAABBCC,0,99,usr_buf,mouse_dd,ed_focus
    edit_pass edit_box 300,75,25,0xffffff,0x6a9480,0,0xAABBCC,0,99,pass_buf,mouse_dd,ed_pass
    edit_server edit_box 300,75,45,0xffffff,0x6a9480,0,0xAABBCC,0,99,host_buf,mouse_dd,ed_focus
    edit_port edit_box 50,75,65,0xffffff,0x6a9480,0,0xAABBCC,0,99,port_buf,mouse_dd,ed_focus
    edit_path edit_box 300,75,85,0xffffff,0x6a9480,0,0xAABBCC,0,99,path_buf,mouse_dd,ed_focus
    
    hed db     'FTP Client',0
    hed_end:
    
    rb  256
    
    usr_buf      rb 100
    pass_buf     rb 100
    host_buf     rb 100
    port_buf     rb 100
    path_buf     rb 100
    
    ; sc      system_colors
    
    mouse_dd        rd 1
    p_info    process_information
    cur_dir_path    rb 4096
    library_path    rb 4096
    i_end:
    rb 1024
    mem:
    
    Last edited by nisargshah95 on Thu Jun 02, 2016 12:49 pm, edited 3 times in total.
  • Nice design! :)
    IMHO There is more usual to use label 'connect' instead 'login'. Maybe it is only for me :wink:
    Kolibri <3
  • Yes it does seem more appropriate. I have changed it. Thanks!
  • So me and ashmew2 had a discussion today on the overall code structure of the FTP client for easy integration of GUI (while keeping CLI). The plan is to keep both GUI and CLI interfaces, although only one would be active during the program execution. For example, if the user wants CLI, he/she can run ftpc with -cli argument. Here is a block diagram that we came up with during the discussion -
    Image
    1. GUI and CLI blocks would have code to get input parameters (username, hostname, etc), display data (files and directories) and such
    2. Arg Handler block would take arguments from either the GUI or CLI block and formulate it into proper command form which would be passed to the core FTP block.
    3. OS-specific command block would execute OS-specific commands as a part of some FTP command - changing local directory, creating/writing files on local filesystem.
    4. Output block would fetch result from server and forward it to GUI/CLI block to display.
    By Tuesday I will make necessary refactoring and proceed with the GUI. Any suggestions are welcome :)
  • The refactoring is done but before we push the code we decided to fix few issues with FTPC -
    • No warnings/errors are produced when lcwd <path/to/folder> is executed when the path is invalid. Fix this to prevent unwanted behaviour.
    • Display some sort of progress to know how much of data has been downloaded.
    • FTPC seems to freeze while closing data socket after downloading large file. Investigate it and try to fix it.
    I have attached FTPC source files for download. Feel free to check it out and report any issues :).
    Attachments
    ftpc.zip (10.23 KiB)
    Downloaded 326 times
  • Regarding importing boxlib library, you can actually import it like any other library.

    Code: Select all

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;Include Area;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    include 'struct.inc'
    include 'proc32.inc'
    include 'macros.inc'
    include 'config.inc'
    include 'network.inc'
    include 'debug-fdo.inc'
    include 'dll.inc'
    include 'box_lib.mac'
    include 'load_lib.mac'
    @use_library              ;use load lib macros
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;Import Area;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    align 4
    @IMPORT:
    
    library       \
           box_lib, 'box_lib.obj'
    
    import  box_lib                           ,\
            edit_box_draw     ,'edit_box'     ,\
            edit_box_key      ,'edit_box_key' ,\
            edit_box_mouse    ,'edit_box_mouse'       
    
    
    That's all you need. :)

    You can check working code here :
    https://github.com/ChokshiUtsav/BitTorr ... ontend.asm
  • So here is the final source code and binary after refactoring and resolving the issues posted earlier. Do check it out and let me know if there are any issues :)

    Changes -
    • Added error handling for filesystem errors (disk full, access denied, etc)
    • Added download progress (shows number of bytes downloaded instead of dots)
    Issues -
    Filesystem errors (specially "disk full" errors when downloading to /rd/1) are not handled as gracefully as expected. You need to reconnect to server. An alternative is to check for available disk space before starting the download but I could not find a sysfunc that would provide free disk space.
    Attachments
    ftp.zip (25.41 KiB)
    Downloaded 329 times
  • Utsav_Chokshi wrote:Regarding importing boxlib library, you can actually import it like any other library.
    Thanks Utsav, I'll check it out when working on the GUI :D
  • Progress Update
    * Completed refactoring which makes it easy to implement both console and GUI interfaces together.
    I have started work on main GUI. The major components will be -
    * tree_list from boxlib (used as file browser for local and remote directories). tree list for local directory has been implemented (support for parsing ".." will be implemented separately)
    * text edit from boxlib (used to display server messages and errors) (not implemented)
    * progress bar (not implemented)
  • Progress Update
    • Integration of GUI with FTPC is underway -
    • tree list for listing local files has been implemented. another for remote files is on the verge of completion.
    • textedit element is working - displays server messages, errors and stuff.
    • Main GUI has been integrated with the login screen.
    • Next in the queue are "download", "upload", "delete" and "make directory" buttons.
  • Progress Update
    So the tree list to view remote files is complete. Now files can be downloaded and uploaded to server via GUI (progress bar is not working yet). I will be integrating other commands (cdup, mkd, rmd, rdir, dele) shortly.

    Image
    Image
  • Progress Update
    Sorry I forgot to post updates.
    So the following work has been done since last update -
    • Progress bar is working (for uploads and downloads)
    • Add support for logging to file (by default created in /usbhd0/1/ftpc.log, configurable via ftpc.ini. Add a line logfile=/path/to/log.txt).
    • Add support for the remaining commands
    • Bug fixes
    Known issues
    • Failure while uploading large files (this issue applies to core FTP functionality)
    • Button to cancel downloads is work in progress. Having issues with implementing ABOR command. Right now the Cancel button simply disconnects from the server.
    I have attached a binary. Any feedback regarding the user interface or bugs is welcome :D.
    Image
    Attachments
    ftpc.zip (6.33 KiB)
    Downloaded 327 times
  • Feedback:
    I think the blue color is a bit too much on the eyes and there is too much extra space.
    I like the gray-like blue buttons.
  • Who is online

    Users browsing this forum: No registered users and 3 guests