* Add new variable close-connection-timeout, which tells Alpine to close
[alpine.git] / pith / state.h
blob30c45527636cbd5c7808be38e99d26845b59046e
1 /*
2 * $Id: state.h 1074 2008-06-04 00:08:43Z hubert@u.washington.edu $
4 * ========================================================================
5 * Copyright 2013-2018 Eduardo Chappa
6 * Copyright 2006-2008 University of Washington
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * ========================================================================
17 #ifndef PITH_STATE_INCLUDED
18 #define PITH_STATE_INCLUDED
21 #include "../pith/conftype.h"
22 #include "../pith/indxtype.h"
23 #include "../pith/bitmap.h"
24 #include "../pith/charset.h"
25 #include "../pith/context.h"
26 #include "../pith/keyword.h"
27 #include "../pith/atttype.h"
28 #include "../pith/msgno.h"
29 #include "../pith/pattern.h"
30 #include "../pith/pipe.h"
31 #include "../pith/send.h"
32 #include "../pith/sorttype.h"
33 #include "../pith/stream.h"
34 #include "../pith/color.h"
35 #include "../pith/user.h"
39 * Printing control structure
41 typedef struct print_ctrl {
42 #ifndef DOS
43 PIPE_S *pipe; /* control struct for pipe to write text */
44 FILE *fp; /* file pointer to write printed text into */
45 char *result; /* file containing print command's output */
46 #endif
47 #ifdef OS2
48 int ispipe;
49 #endif
50 int err; /* bit indicating something went awry */
51 } PRINT_S;
55 * Keeps track of display dimensions
57 struct ttyo {
58 int screen_rows,
59 screen_cols,
60 header_rows, /* number of rows for titlebar and whitespace */
61 footer_rows; /* number of rows for status and keymenu */
65 * HEADER_ROWS is always 2. 1 for the titlebar and 1 for the
66 * blank line after the titlebar. We should probably make it go down
67 * to 0 when the screen shrinks but instead we're just figuring out
68 * if there is enough room by looking at screen_rows.
69 * FOOTER_ROWS is either 3 or 1. Normally it is 3, 2 for the keymenu plus 1
70 * for the status line. If the NoKeyMenu command has been given, then it is 1.
72 #define HEADER_ROWS(X) ((X)->ttyo->header_rows)
73 #define FOOTER_ROWS(X) ((X)->ttyo->footer_rows)
76 /*----------------------------------------------------------------------
77 This structure sort of takes the place of global variables or perhaps
78 is the global variable. (It can be accessed globally as ps_global. One
79 advantage to this is that as soon as you see a reference to the structure
80 you know it is a global variable.
81 In general it is treated as global by the lower level and utility
82 routines, but it is not treated so by the main screen driving routines.
83 Each of them receives it as an argument and then sets ps_global to the
84 argument they received. This is sort of with the thought that things
85 might be coupled more loosely one day and that Pine might run where there
86 is more than one window and more than one instance. But we haven't kept
87 up with this convention very well.
88 ----*/
90 struct pine {
91 void (*next_screen)(struct pine *); /* See loop at end of main() for how */
92 void (*prev_screen)(struct pine *); /* these are used... */
93 void (*redrawer)(void); /* NULL means stay in current screen */
95 CONTEXT_S *context_list; /* list of user defined contexts */
96 CONTEXT_S *context_current; /* default open context */
97 CONTEXT_S *context_last; /* most recently open context */
99 SP_S s_pool; /* stream pool */
101 char inbox_name[MAXFOLDER+1];
102 char pine_pre_vers[10]; /* highest version previously run */
103 char vers_internal[10];
105 MAILSTREAM *mail_stream; /* ptr to current folder stream */
106 MSGNO_S *msgmap; /* ptr to current message map */
108 unsigned read_predicted:1;
110 char cur_folder[MAXPATH+1];
111 QUOTALIST *quota;
112 IDLIST *id;
113 char last_unambig_folder[MAXPATH+1];
114 char last_save_folder[MAXPATH+1];
115 CONTEXT_S *last_save_context;
116 ATTACH_S *atmts;
117 int atmts_allocated;
118 int remote_abook_validity; /* minutes, -1=never, 0=only on opens */
120 INDEX_COL_S *index_disp_format;
122 char *folders_dir;
124 unsigned signal_in_progress:1; /* we are handling a signal */
125 unsigned mangled_footer:1; /* footer needs repainting */
126 unsigned mangled_header:1; /* header needs repainting */
127 unsigned mangled_body:1; /* body of screen needs repainting */
128 unsigned mangled_screen:1; /* whole screen needs repainting */
130 unsigned in_init_seq:1; /* executing initial cmd list */
131 unsigned save_in_init_seq:1;
132 unsigned dont_use_init_cmds:1; /* use keyboard input when true */
134 unsigned give_fixed_warning:1; /* warn user about "fixed" vars */
135 unsigned fix_fixed_warning:1; /* offer to fix it */
137 unsigned user_says_cancel:1; /* user typed ^C to abort open */
139 unsigned unseen_in_view:1;
140 unsigned start_in_context:1; /* start fldr_scrn in current cntxt */
141 unsigned def_sort_rev:1; /* true if reverse sort is default */
142 unsigned restricted:1;
144 unsigned tcptimeout:1; /* a tcp timeout is in progress */
145 unsigned read_bail:1; /* we are coming back from a read bail! */
147 unsigned save_msg_rule:5;
148 unsigned fcc_rule:3;
149 unsigned ab_sort_rule:3;
150 unsigned color_style:3;
151 unsigned index_color_style:3;
152 unsigned titlebar_color_style:3;
153 unsigned fld_sort_rule:3;
154 unsigned inc_startup_rule:3;
155 unsigned pruning_rule:3;
156 unsigned reopen_rule:4;
157 unsigned goto_default_rule:3;
158 unsigned thread_disp_style:3;
159 unsigned thread_index_style:3;
161 unsigned full_header:2; /* display full headers */
162 /* 0 means normal */
163 /* 1 means display all quoted text */
164 /* 2 means full headers */
165 unsigned some_quoting_was_suppressed:1;
166 unsigned orig_use_fkeys:1;
167 unsigned try_to_create:1; /* Save should try mail_create */
168 unsigned low_speed:1; /* various opt's 4 low connect speed */
169 unsigned postpone_no_flow:1; /* don't set flowed when we postpone */
170 /* and don't reflow when we resume. */
171 unsigned mm_log_error:1;
172 unsigned show_new_version:1;
173 unsigned pre441:1;
174 unsigned first_time_user:1;
175 unsigned intr_pending:1; /* received SIGINT and haven't acted */
176 unsigned expunge_in_progress:1; /* don't want to re-enter c-client */
177 unsigned never_allow_changing_from:1; /* not even for roles */
178 unsigned newthread:1; /* start a new thread on composing */
180 unsigned readonly_pinerc:1;
181 unsigned view_all_except:1;
182 unsigned start_in_index:1; /* cmd line flag modified on startup */
183 unsigned noshow_error:1; /* c-client error callback controls */
184 unsigned noshow_warn:1;
185 unsigned noshow_timeout:1;
186 unsigned conceal_sensitive_debugging:1;
187 unsigned turn_off_threading_temporarily:1;
188 unsigned view_skipped_index:1;
189 unsigned a_format_contains_score:1;
190 unsigned ugly_consider_advancing_bit:1;
191 unsigned dont_count_flagchanges:1;
192 unsigned in_folder_screen:1;
193 unsigned noticed_change_in_unseen:1;
194 unsigned first_open_was_attempted:1;
195 unsigned force_prefer_plain:1;
196 unsigned force_no_prefer_plain:1;
198 unsigned painted_body_on_startup:1;
199 unsigned phone_home:1;
200 unsigned painted_footer_on_startup:1;
201 unsigned open_readonly_on_startup:1;
202 unsigned exit_if_no_pinerc:1;
203 unsigned pass_ctrl_chars:1;
204 unsigned pass_c1_ctrl_chars:1;
205 unsigned display_keywords_in_subject:1;
206 unsigned display_keywordinits_in_subject:1;
207 unsigned beginning_of_month:1;
208 unsigned beginning_of_year:1;
210 unsigned can_interrupt:1;
211 long int close_connection_timeout;
213 unsigned viewer_overlap:8;
214 unsigned scroll_margin:8;
215 unsigned remote_abook_history:8;
217 #if defined(DOS) || defined(OS2)
218 unsigned blank_user_id:1;
219 unsigned blank_personal_name:1;
220 unsigned blank_user_domain:1;
221 #ifdef _WINDOWS
222 unsigned update_registry:2;
223 unsigned install_flag:1;
224 #endif
225 #endif
227 unsigned debug_malloc:6;
228 unsigned debug_timestamp:1;
229 unsigned debug_flush:1;
230 unsigned debug_tcp:1;
231 unsigned debug_imap:3;
232 unsigned debug_nfiles:5;
233 unsigned debugmem:1;
234 #ifdef LOCAL_PASSWD_CACHE
235 unsigned nowrite_password_cache:1;
236 #endif
238 unsigned convert_sigs:1;
239 unsigned dump_supported_options:1;
241 unsigned noexpunge_on_close:1;
243 unsigned no_newmail_check_from_optionally_enter:1;
245 unsigned post_utf8:1;
247 unsigned start_entry; /* cmd line arg: msg # to start on */
249 bitmap_t feature_list; /* a bitmap of all the features */
250 char **feat_list_back_compat;
252 SPEC_COLOR_S *hdr_colors; /* list of configed colors for view */
253 SPEC_COLOR_S *index_token_colors; /* list of configed colors for index */
255 short init_context;
257 struct {
258 unsigned keep_attach:1;
259 unsigned strip_signature:1;
260 unsigned use_flowed:1;
261 unsigned include_header:1;
262 unsigned preserve_fields:1;
263 unsigned signature_bottom:1;
264 ACTION_S *role_chosen;
265 } reply;
267 int *initial_cmds; /* cmds to execute on startup */
268 int *free_initial_cmds; /* used to free when done */
270 char c_client_error[300]; /* when nowhow_error is set and PARSE */
272 struct ttyo *ttyo;
274 USER_S ui; /* system derived user info */
276 POST_S *post;
278 char *home_dir,
279 *hostname, /* Fully qualified hostname */
280 *localdomain, /* The (DNS) domain this host resides in */
281 *userdomain, /* The per user domain from .pinerc or */
282 *maildomain, /* Domain name for most uses */
283 #if defined(DOS) || defined(OS2)
284 *pine_dir, /* argv[0] as provided by DOS */
285 *aux_files_dir, /* User's auxiliary files directory */
286 #endif
287 #ifdef PASSFILE
288 *passfile,
289 #endif /* PASSFILE */
290 *pinerc, /* Location of user's pinerc */
291 *exceptions, /* Location of user's exceptions */
292 *pine_name; /* name we were invoked under */
293 PINERC_S *prc, /* structure for personal pinerc */
294 *post_prc, /* structure for post-loaded pinerc */
295 *pconf; /* structure for global pinerc */
297 EditWhich ew_for_except_vars;
298 EditWhich ew_for_role_take;
299 EditWhich ew_for_score_take;
300 EditWhich ew_for_filter_take;
301 EditWhich ew_for_incol_take;
302 EditWhich ew_for_other_take;
303 EditWhich ew_for_srch_take;
305 SortOrder def_sort, /* Default sort type */
306 sort_types[22];
308 int last_expire_year, last_expire_month;
310 int printer_category;
312 int status_msg_delay;
314 int active_status_interval;
316 int composer_fillcol;
318 int nmw_width;
320 int hours_to_timeout;
322 int tcp_query_timeout;
324 int sleep;
326 int inc_check_timeout;
327 int inc_check_interval; /* for local and IMAP */
328 int inc_second_check_interval; /* for other */
330 time_t check_interval_for_noncurr;
332 time_t last_nextitem_forcechk;
334 MAILSTREAM *cur_uid_stream;
335 imapuid_t cur_uid;
337 int deadlets;
339 int quote_suppression_threshold;
341 char *display_charmap; /* needs to be freed */
342 char *keyboard_charmap; /* needs to be freed */
343 void *input_cs;
345 char *posting_charmap; /* needs to be freed */
347 CONV_TABLE *conv_table;
350 * Optional tools Pine Data Engine caller might provide
352 struct {
353 char *(*display_filter)(char *, STORE_S *, gf_io_t, FILTLIST_S *);
354 char *(*display_filter_trigger)(BODY *, char *, size_t);
355 } tools;
357 KEYWORD_S *keywords;
358 SPEC_COLOR_S *kw_colors;
360 ACTION_S *default_role; /* pointer to one of regular roles */
362 char last_error[500];
363 INIT_ERR_S *init_errs;
365 PRINT_S *print;
367 #ifdef SMIME
368 int keyemptypwd; /* can we load the key without a password? */
369 char *smimedir;
370 SMIME_STUFF_S *smime;
371 char *pwdcertdir; /* path to location of certificates for password file */
372 void *pwdcert; /* this is of type PERSONAL_CERT */
373 char *pwdcertcontent; /* No comment yet */
374 void *backuppassword; /* this is of type CertList */
375 void *pwdcertlist; /* this is of type CertList */
376 #endif /* SMIME */
378 struct variable *vars;
382 /*----------------------------------------------------------------------
383 The few global variables we use in Pine Data Engine
384 ----*/
386 extern struct pine *ps_global;
388 #define SIZEOF_20KBUF (20480)
389 extern char tmp_20k_buf[];
392 /* exported protoypes */
393 struct pine *new_pine_struct(void);
394 void free_pine_struct(struct pine **);
395 void free_pinerc_strings(struct pine **);
396 void free_vars(struct pine *);
397 void free_variable_values(struct variable *);
398 PINERC_S *new_pinerc_s(char *);
399 void free_pinerc_s(PINERC_S **);
400 void free_pith_module_globals(void);
402 #endif /* PITH_STATE_INCLUDED */