root/src/filemanager/filegui.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


   1 /** \file  filegui.h
   2  *  \brief Header: file management GUI
   3  */
   4 
   5 #ifndef MC__FILEGUI_H
   6 #define MC__FILEGUI_H
   7 
   8 #include <sys/stat.h>
   9 #include <sys/types.h>
  10 #include <inttypes.h>  // uintmax_t
  11 
  12 #include "lib/global.h"
  13 #include "lib/vfs/vfs.h"
  14 
  15 /*** typedefs(not structures) and defined constants **********************************************/
  16 
  17 typedef int (*mc_stat_fn) (const vfs_path_t *vpath, struct stat *buf);
  18 
  19 /*** enums ***************************************************************************************/
  20 
  21 typedef enum
  22 {
  23     FILEGUI_DIALOG_ONE_ITEM,
  24     FILEGUI_DIALOG_MULTI_ITEM,
  25     FILEGUI_DIALOG_DELETE_ITEM
  26 } filegui_dialog_type_t;
  27 
  28 typedef enum
  29 {
  30     OP_COPY = 0,
  31     OP_MOVE = 1,
  32     OP_DELETE = 2
  33 } FileOperation;
  34 
  35 typedef enum
  36 {
  37     RECURSIVE_YES = 0,
  38     RECURSIVE_NO = 1,
  39     RECURSIVE_ALWAYS = 2,
  40     RECURSIVE_NEVER = 3,
  41     RECURSIVE_ABORT = 4
  42 } FileCopyMode;
  43 
  44 /* ATTENTION: avoid overlapping with B_* values (lib/widget/dialog.h) */
  45 typedef enum
  46 {
  47     FILE_CONT = 10,
  48     FILE_RETRY,
  49     FILE_SKIP,
  50     FILE_ABORT,
  51     FILE_IGNORE,
  52     FILE_IGNORE_ALL,
  53     FILE_SUSPEND
  54 } FileProgressStatus;
  55 
  56 /* First argument passed to real functions */
  57 enum OperationMode
  58 {
  59     Foreground,
  60     Background
  61 };
  62 
  63 /*** structures declarations (and typedefs of structures)*****************************************/
  64 
  65 struct mc_search_struct;
  66 
  67 /* This structure describes a context for file operations.  It is used to update
  68  * the progress windows and pass around options.
  69  */
  70 typedef struct
  71 {
  72     // Operation type (copy, move, delete)
  73     FileOperation operation;
  74 
  75     filegui_dialog_type_t dialog_type;
  76 
  77     // File operation options
  78     // The mask of files to actually operate on
  79     char *dest_mask;
  80     // Whether to dive into subdirectories for recursive operations
  81     gboolean dive_into_subdirs;
  82     // Whether to stat or lstat
  83     gboolean follow_links;
  84     // Whether to recompute symlinks
  85     gboolean stable_symlinks;
  86     /* Preserve the original files' owner, group, permissions, and
  87      * timestamps (owner, group only as root). */
  88     gboolean preserve;
  89     /* If running as root, preserve the original uid/gid (we don't want to
  90      * try chown for non root) preserve_uidgid = preserve && uid == 0 */
  91     gboolean preserve_uidgid;
  92     // The bits to preserve in created files' modes on file copy
  93     mode_t umask_kill;
  94     /* When moving directories cross filesystem boundaries delete the
  95      * successfully copied files when all files below the directory and its
  96      * subdirectories were processed.
  97      *
  98      * If erase_at_end is FALSE files will be deleted immediately after their
  99      * successful copy (Note: this behavior is not tested and at the moment
 100      * it can't be changed at runtime). */
 101     gboolean erase_at_end;
 102 
 103     // Whether to do a reget
 104     off_t do_reget;
 105     // Controls appending to files
 106     gboolean do_append;
 107 
 108     // Pointer to the stat function we will use
 109     mc_stat_fn stat_func;
 110     // search handler
 111     struct mc_search_struct *search_handle;
 112     // toggle if all errors should be ignored
 113     gboolean ignore_all;
 114     // Whether the file operation is in pause
 115     gboolean suspended;
 116     gboolean ask_overwrite;
 117     // Result from the recursive query
 118     FileCopyMode recursive_result;
 119 
 120     // PID of the child for background operations
 121     pid_t pid;
 122 
 123     // One file statuses
 124     // File transfer start time
 125     gint64 transfer_start;
 126     // Counters for progress indicators
 127     uintmax_t progress_bytes;
 128     // The estimated time of arrival in seconds
 129     double eta_secs;
 130     // Transferred bytes per second
 131     long bps;
 132 
 133     // Total statuses
 134     // Whether the panel total has been computed
 135     gboolean totals_computed;
 136     // Files transfer start time
 137     gint64 total_transfer_start;
 138     // Counters for progress indicators
 139     size_t total_progress_count;
 140     size_t total_count;
 141     uintmax_t total_progress_bytes;
 142     uintmax_t total_bytes;
 143     // The estimated time of arrival in seconds
 144     double total_eta_secs;
 145     // Transferred bytes per second
 146     long total_bps;
 147     // Used in OP_MOVE between copy and remove directories
 148     size_t prev_total_progress_count;
 149 
 150     // Time of pauses in query dialogs
 151     gint64 pauses;
 152 
 153     // User interface data goes here
 154     void *ui;
 155 } file_op_context_t;
 156 
 157 /*** global variables defined in .c file *********************************************************/
 158 
 159 extern const char *op_names[3];
 160 
 161 /*** declarations of public functions ************************************************************/
 162 
 163 file_op_context_t *file_op_context_new (FileOperation op);
 164 void file_op_context_destroy (file_op_context_t *ctx);
 165 
 166 void file_progress_ui_create (file_op_context_t *ctx, gboolean with_eta,
 167                               filegui_dialog_type_t dialog_type);
 168 void file_progress_ui_destroy (file_op_context_t *ctx);
 169 
 170 char *file_mask_dialog (file_op_context_t *ctx, gboolean only_one, const char *format,
 171                         const void *text, const char *def_text, gboolean *do_bg);
 172 
 173 FileProgressStatus file_progress_check_buttons (file_op_context_t *ctx);
 174 
 175 void file_progress_show (file_op_context_t *ctx, off_t done, off_t total, const char *stalled_msg,
 176                          gboolean force_update);
 177 void file_progress_show_count (file_op_context_t *ctx);
 178 void file_progress_show_total (file_op_context_t *ctx, uintmax_t copied_bytes, gint64 tv_current,
 179                                gboolean show_summary);
 180 void file_progress_show_source (file_op_context_t *ctx, const vfs_path_t *vpath);
 181 void file_progress_show_target (file_op_context_t *ctx, const vfs_path_t *vpath);
 182 gboolean file_progress_show_deleting (file_op_context_t *ctx, const vfs_path_t *vpath,
 183                                       size_t *count);
 184 
 185 /* The following functions are implemented separately by each port */
 186 FileProgressStatus file_progress_real_query_replace (file_op_context_t *ctx,
 187                                                      enum OperationMode mode, const char *src,
 188                                                      struct stat *src_stat, const char *dst,
 189                                                      struct stat *dst_stat);
 190 
 191 /*** inline functions ****************************************************************************/
 192 
 193 #endif

/* [previous][next][first][last][top][bottom][index][help]  */