int inbox_path_text_tool(struct pine *ps, int cmd, CONF_S **cl, unsigned int flags) { char **apval; int rv = 0; char new_inbox_path[2*MAXFOLDER+1]; char *def = NULL; CONTEXT_S *cntxt; if(cmd != MC_EXIT && fixed_var((*cl)->var, NULL, NULL)) return(rv); apval = APVAL((*cl)->var, ew); switch(cmd){ case MC_ADD: case MC_EDIT: cntxt = ps->context_list; if(cmd == MC_EDIT && (*cl)->var){ if(ew == Post && (*cl)->var->post_user_val.p) def = (*cl)->var->post_user_val.p; else if(ew == Main && (*cl)->var->main_user_val.p) def = (*cl)->var->main_user_val.p; else if((*cl)->var->current_val.p) def = (*cl)->var->current_val.p; } rv = add_new_folder(cntxt, ew, V_INBOX_PATH, new_inbox_path, sizeof(new_inbox_path), NULL, def); rv = rv ? 1 : 0; ps->mangled_screen = 1; break; default: rv = text_tool(ps, cmd, cl, flags); break; } /* * This is just like the end of text_tool. */ if(rv == 1){ /* * Now go and set the current_val based on user_val changes * above. Turn off command line settings... */ set_current_val((*cl)->var, TRUE, FALSE); fix_side_effects(ps, (*cl)->var, 0); if((*cl)->value) fs_give((void **) &(*cl)->value); (*cl)->value = pretty_value(ps, *cl); exception_override_warning((*cl)->var); } return(rv); }
int to_charsets_text_tool(struct pine *ps, int cmd, CONF_S **cl, unsigned int flags) { int rv = 0; char **newval = NULL; void (*prev_screen)(struct pine *) = ps->prev_screen, (*redraw)(void) = ps->redrawer; OPT_SCREEN_S *saved_screen = NULL; char **apval; char *charset = NULL; switch(cmd){ case MC_CHOICE: if(fixed_var((*cl)->var, NULL, NULL)) break; apval = APVAL((*cl)->var, ew); if(apval){ int cac_flags = CAC_ALL; ps->redrawer = NULL; ps->next_screen = SCREEN_FUN_NULL; saved_screen = opt_screen; if((*cl)->var == &ps->vars[V_POST_CHAR_SET]) cac_flags = CAC_POSTING; #ifndef _WINDOWS else if((*cl)->var == &ps->vars[V_CHAR_SET] || (*cl)->var == &ps->vars[V_KEY_CHAR_SET]) cac_flags = CAC_DISPLAY; #endif /* !_WINDOWS */ charset = choose_a_charset(cac_flags); removing_leading_and_trailing_white_space(charset); if(charset && *charset){ rv = 1; if(apval && *apval) fs_give((void **) apval); *apval = charset; charset = NULL; newval = &(*cl)->value; /* this stuff is from bottom of text_toolit() */ /* * At this point, if changes occurred, var->user_val.X is set. * So, fix the current_val, and handle special cases... * * NOTE: we don't worry about the "fixed variable" case here, because * editing such vars should have been prevented above... */ /* * Now go and set the current_val based on user_val changes * above. Turn off command line settings... */ set_current_val((*cl)->var, TRUE, FALSE); fix_side_effects(ps, (*cl)->var, 0); if(newval){ if(*newval) fs_give((void **) newval); *newval = pretty_value(ps, *cl); } exception_override_warning((*cl)->var); } else{ ps->next_screen = prev_screen; ps->redrawer = redraw; rv = 0; } if(charset) fs_give((void **) &charset); opt_screen = saved_screen; ps->mangled_screen = 1; } break; default: rv = text_tool(ps, cmd, cl, flags); break; } return(rv); }
int stayopen_list_tool(struct pine *ps, int cmd, CONF_S **cl, unsigned int flags) { int rv = 0; char **newval = NULL; char **ltmp = NULL; char *folder = NULL; void (*prev_screen)(struct pine *) = ps->prev_screen, (*redraw)(void) = ps->redrawer; OPT_SCREEN_S *saved_screen = NULL; switch(cmd){ case MC_CHOICE: if(fixed_var((*cl)->var, NULL, NULL)) break; ps->redrawer = NULL; ps->next_screen = SCREEN_FUN_NULL; saved_screen = opt_screen; folder = folder_for_config(FOR_OPTIONSCREEN); removing_leading_and_trailing_white_space(folder); if(folder && *folder){ ltmp = (char **) fs_get(2 * sizeof(char *)); ltmp[0] = cpystr(folder); ltmp[1] = NULL; config_add_list(ps, cl, ltmp, &newval, 0); if(ltmp) fs_give((void **) <mp); rv = 1; /* this stuff is from bottom of text_toolit() */ /* * At this point, if changes occurred, var->user_val.X is set. * So, fix the current_val, and handle special cases... * * NOTE: we don't worry about the "fixed variable" case here, because * editing such vars should have been prevented above... */ /* * Now go and set the current_val based on user_val changes * above. Turn off command line settings... */ set_current_val((*cl)->var, TRUE, FALSE); fix_side_effects(ps, (*cl)->var, 0); /* * Delay setting the displayed value until "var.current_val" is set * in case current val get's changed due to a special case above. */ if(newval){ if(*newval) fs_give((void **) newval); *newval = pretty_value(ps, *cl); } exception_override_warning((*cl)->var); if(folder) fs_give((void **) &folder); } else{ ps->next_screen = prev_screen; ps->redrawer = redraw; rv = 0; } opt_screen = saved_screen; ps->mangled_screen = 1; break; default: rv = text_tool(ps, cmd, cl, flags); break; } return(rv); }
int incoming_monitoring_list_tool(struct pine *ps, int cmd, CONF_S **cl, unsigned int flags) { int rv = 0; CONTEXT_S *cntxt; char **the_list; CONF_S *ctmp; char ***alval; OPT_SCREEN_S *saved_screen; if(cmd != MC_EXIT && fixed_var((*cl)->var, NULL, NULL)) return(rv); switch(cmd){ case MC_ADD: case MC_EDIT: cntxt = ps->context_list; if(!(cntxt && cntxt->use & CNTXT_INCMNG)){ q_status_message1(SM_ORDER, 3, 3, _("Turn on incoming folders with Config feature \"%s\""), pretty_feature_name(feature_list_name(F_ENABLE_INCOMING), -1)); return(rv); } saved_screen = opt_screen; the_list = adjust_list_of_monitored_incoming(cntxt, ew, V_INCCHECKLIST); /* adjust top if it might be necessary */ for(ctmp = (*cl)->varnamep; ctmp && ctmp->varnamep == (*cl)->varnamep; ctmp = next_confline(ctmp)) if(ctmp == opt_screen->top_line) opt_screen->top_line = (*cl)->varnamep; if(the_list){ alval = ALVAL((*cl)->var, ew); free_list_array(alval); if(!*the_list){ q_status_message(SM_ORDER, 0, 3, _("Using default, monitor all incoming folders")); if(alval){ /* * Remove config lines except for first one. */ *cl = (*cl)->varnamep; while((*cl)->next && (*cl)->next->varnamep == (*cl)->varnamep) snip_confline(&(*cl)->next); } } else config_add_list(ps, cl, the_list, NULL, 0); /* only have to free the top-level pointer */ fs_give((void **) &the_list); rv = 1; } else{ if(LVAL((*cl)->var, ew)) q_status_message(SM_ORDER, 0, 3, _("List is unchanged")); else q_status_message(SM_ORDER, 0, 3, _("Using default, monitor all incoming folders")); } opt_screen = saved_screen; ps->mangled_screen = 1; break; default: rv = text_tool(ps, cmd, cl, flags); /* if we deleted last one, reverts to default */ if(cmd == MC_DELETE && rv == 1 && (*cl)->varmem == 0 && (!(*cl)->next || (*cl)->next->varnamep != (*cl))) q_status_message(SM_ORDER, 0, 3, _("Using default, monitor all incoming folders")); break; } /* * This is just like the end of text_tool. */ if(rv == 1){ /* * Now go and set the current_val based on user_val changes * above. Turn off command line settings... */ set_current_val((*cl)->var, TRUE, FALSE); fix_side_effects(ps, (*cl)->var, 0); if((*cl)->value) fs_give((void **) &(*cl)->value); (*cl)->value = pretty_value(ps, *cl); exception_override_warning((*cl)->var); } return(rv); }
/* * Compare saved user_val with current user_val to see if it changed. * If any have changed, change it back and take the appropriate action. */ void revert_to_saved_smime_config(struct pine *ps, SAVED_CONFIG_S *vsave) { struct variable *vreal; SAVED_CONFIG_S *v; int i, n; int changed = 0; char *pval, **apval, **lval, ***alval; v = vsave; for(vreal = ps->vars; vreal->name; vreal++,v++){ if(!(smime_related_var(ps, vreal) || vreal==&ps->vars[V_FEATURE_LIST])) continue; if(vreal->is_list){ lval = LVAL(vreal, ew); alval = ALVAL(vreal, ew); if((v->saved_user_val.l && !lval) || (!v->saved_user_val.l && lval)) changed++; else if(!v->saved_user_val.l && !lval) ;/* no change, nothing to do */ else for(i = 0; v->saved_user_val.l[i] || lval[i]; i++) if((v->saved_user_val.l[i] && (!lval[i] || strcmp(v->saved_user_val.l[i], lval[i]))) || (!v->saved_user_val.l[i] && lval[i])){ changed++; break; } if(changed){ char **list; if(alval){ if(*alval) free_list_array(alval); /* copy back the original one */ if(v->saved_user_val.l){ list = v->saved_user_val.l; n = 0; /* count how many */ while(list[n]) n++; *alval = (char **)fs_get((n+1) * sizeof(char *)); for(i = 0; i < n; i++) (*alval)[i] = cpystr(v->saved_user_val.l[i]); (*alval)[n] = NULL; } } } } else{ pval = PVAL(vreal, ew); apval = APVAL(vreal, ew); if((v->saved_user_val.p && (!pval || strcmp(v->saved_user_val.p, pval))) || (!v->saved_user_val.p && pval)){ /* It changed, fix it */ changed++; if(apval){ /* free the changed value */ if(*apval) fs_give((void **)apval); if(v->saved_user_val.p) *apval = cpystr(v->saved_user_val.p); } } } if(changed){ if(vreal == &ps->vars[V_FEATURE_LIST]) set_feature_list_current_val(vreal); else set_current_val(vreal, TRUE, FALSE); fix_side_effects(ps, vreal, 1); } } }