• Patch: Elm ME+ 2.5 PLalpha50 -> Elm ME+ 2.5 PLalpha51 [5/6] (5/5)

    From Kari Hurtta@21:1/5 to All on Tue Feb 11 20:06:30 2020
    [continued from previous message]

    + static void qd_quota_step_page P_((struct quota_display * qd,
    + struct cancel_data * cd,
    + enum qd_step_mode qd_step));
    + static void qd_quota_step_page(qd,cd,qd_step)
    + struct quota_display * qd;
    + struct cancel_data * cd;
    + enum qd_step_mode qd_step;
    + {
    + int current_line = 2;
    + int add = 0;
    +
    + if (QUOTA_DISPLAY_magic != qd->magic)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "qd_quota_step_page",
    + "Bad magic number (quota_diplay)",0);
    +
    + menu_MoveCursor(qd->quota_page,current_line,0);
    + menu_CleartoEOS(qd->quota_page);
    +
    + qd_draw_forward(qd->quota_page,qd,qd_step,add,
    + current_line,cd,
    + qd->PARAM);
    +
    + }
    +
    + static void qd_quota_page_update P_((struct quota_display * qd,
    + struct menu_context *ptr,
    + struct menu_param *list,
    + struct cancel_data * cd));
    +
    + static void qd_quota_page_update(qd,ptr,list,cd)
    + struct quota_display * qd;
    + struct menu_context * ptr;
    + struct menu_param * list;
    + struct cancel_data * cd;
    + {
    + int current_line = 0;
    + int add = 0;
    +
    + if (QUOTA_DISPLAY_magic != qd->magic)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "qd_quota_page_update",
    + "Bad magic number (quota_diplay)",0);
    +
    + menu_ClearScreen(ptr); /* Clears also need update flag */
    +
    + menu_StartXX(ptr,pg_BOLD);
    + menu_print_format_center(ptr,current_line,
    + CATGETS(elm_msg_cat, MeSet,
    + MeQuotaScreenTitle,
    + "Mail Quota Screen [ELM %s]"),
    + version_buff
    + );
    + menu_EndXX(ptr,pg_BOLD);
    +
    + current_line += 2;
    +
    + if (current_line > qd->top_line) {
    + add = current_line - qd->top_line;
    +
    + qd->top_line = current_line;
    + }
    +
    +
    + qd_draw_forward(ptr,qd,qd_step_this,add,current_line,cd,list);
    +
    + }
    +
    +
    + S_(subpage_simple_redraw qd_update_quota_page)
    + static int qd_update_quota_page P_((struct menu_context *ptr,
    + struct menu_param *list));
    + static int qd_update_quota_page(ptr,list)
    + struct menu_context *ptr;
    + struct menu_param *list;
    + {
    + struct menu_anon_param * anon_disp_self =
    + mp_lookup_anon(list, qd_disp_self);
    +
    + struct quota_display * qd = anon_disp_self->qd;
    + struct cancel_data * cd = NULL;
    +
    +
    + if (QUOTA_DISPLAY_magic != qd->magic)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "qd_update_quota_page",
    + "Bad magic number (quota_diplay)",0);
    +
    + DPRINT(Debug,25, (&Debug,
    + "qd_update_quota_page: ptr=%p\n",
    + ptr));
    +
    + setup_mbx_cancel_message(&cd,mbx_checking_mailbox);
    +
    + qd_quota_page_update(qd,ptr,list,cd);
    +
    +
    + free_cancel(&cd);
    +
    + return 1;
    + }
    +
    + static void qdisp_set_page P_((struct quota_display *qd));
    + static void qdisp_set_page(qd)
    + struct quota_display *qd;
    + {
    + int LINES, COLUMNS;
    +
    + if (QUOTA_DISPLAY_magic != qd->magic)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "qdisp_set_page",
    + "Bad magic number (quota_diplay)",0);
    +
    + menu_get_sizes(qd->current_page,&LINES, &COLUMNS);
    +
    + if (LINES > 5) {
    + if (!qd->quota_page)
    + qd->quota_page =
    + new_menu_subpage(qd->current_page,0,LINES-4,
    + qd_update_quota_page,
    + qd->PARAM);
    + else
    + menu_subpage_relocate(qd->quota_page,
    + qd->current_page,0,LINES-4);
    + } else if (qd->quota_page)
    + erase_menu_context(& (qd->quota_page));
    +
    + }
    +
    + struct quota_display * new_quota_display(mquota,parent_page,cd)
    + struct mail_quota * mquota;
    + struct menu_context * parent_page;
    + struct cancel_data * cd;
    + {
    + int have_screen = RawState();
    +
    +
    + struct quota_display *ret =
    + safe_zero_alloc(sizeof (*ret));
    +
    + ret->magic = QUOTA_DISPLAY_magic;
    +
    + ret->refcount = 1;
    +
    + ret->mail_quota_list = NULL;
    + ret->mail_quota_count = 0;
    +
    + ret->current_page = new_menu_context();
    + ret->quota_page = NULL;
    +
    + ret->top_mail_quota = 0;
    + ret->top_quotarootl = 0;
    +
    + ret->top_line = 2; /* Line 0 is title ?? */
    +
    + /* just build self reference */
    +
    + ret->self.qd = ret;
    +
    + ret->PARAM[qd_disp_self].t = mp_anon_param;
    +
    + ret->PARAM[qd_disp_quotaroot_width].t = mp_integer;
    + ret->PARAM[qd_disp_resource_width].t = mp_integer;
    + ret->PARAM[qd_disp_usage_width].t = mp_integer;
    + ret->PARAM[qd_disp_limit_width].t = mp_integer;
    + ret->PARAM[qd_disp_percent_width].t = mp_integer;
    +
    +
    + ret->PARAM[qd_disp_resource_col].t = mp_integer;
    + ret->PARAM[qd_disp_usage_col].t = mp_integer;
    + ret->PARAM[qd_disp_percent_col].t = mp_integer;
    +
    + ret->PARAM[qd_disp_COUNT].t = mp_END;
    +
    + mp_list_set_anon(ret->PARAM,qd_disp_self,& (ret->self ));
    +
    + qd_setup_columns(ret->current_page,ret->PARAM,qd_setup_initial,NULL);
    +
    +
    + if (have_screen) {
    +
    + qdisp_set_page(ret);
    +
    + if (ret->quota_page)
    + qd_quota_page_update(ret,ret->quota_page,
    + ret->PARAM,cd);
    + }
    +
    + return ret;
    + }
    +
    + struct menu_context * quota_display_current_page(quotad)
    + struct quota_display * quotad;
    + {
    +
    + if (QUOTA_DISPLAY_magic != quotad->magic)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_current_page",
    + "Bad magic number (quota_diplay)",0);
    +
    + return quotad->current_page;
    + }
    +
    + enum qd_create_flag { qd_search = 0, qd_create = 1 };
    +
    + /* Return 1 on succeed */
    + static int quota_display_quota_index P_((struct quota_display * quotad,
    + struct mail_quota * mquota,
    + size_t * index_ref,
    + enum qd_create_flag create));
    + static int quota_display_quota_index(quotad,mquota,index_ref,create)
    + struct quota_display * quotad;
    + struct mail_quota * mquota;
    + size_t * index_ref;
    + enum qd_create_flag create;
    + {
    + size_t i;
    +
    + if (QUOTA_DISPLAY_magic != quotad->magic)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_quota_index",
    + "Bad magic number (quota_diplay)",0);
    +
    + if (index_ref)
    + *index_ref = quotad-> mail_quota_count;
    +
    + for (i = 0; i < quotad-> mail_quota_count; i++) {
    + if (quotad-> mail_quota_list[i].mquota == mquota) {
    +
    + if (index_ref)
    + *index_ref = i;
    +
    + return 1;
    + }
    + }
    +
    + if (i != quotad-> mail_quota_count)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_quota_index",
    + "Bad index",0);
    +
    + switch (create) {
    + size_t newcount;
    +
    + case qd_search:
    + break;
    +
    + case qd_create:
    + newcount = quotad-> mail_quota_count+1;
    + quotad-> mail_quota_list
    + = safe_array_realloc(quotad-> mail_quota_list,
    + newcount,
    + sizeof(quotad-> mail_quota_list[0]));
    +
    + /* bzero is defined hdrs/elm_defs.h */
    + bzero (& (quotad-> mail_quota_list[i]),
    + sizeof (quotad-> mail_quota_list[i]));
    +
    +
    + quotad-> mail_quota_list[i].mquota = mquota;
    + inc_mail_quota_refcount(quotad-> mail_quota_list[i].mquota);
    + quotad-> mail_quota_count = newcount;
    +
    + /* Drawing algorithm */
    +
    + quotad-> mail_quota_list[i].virtual_mq_start_line = 0;
    +
    + if (index_ref)
    + *index_ref = i;
    +
    + return 1;
    + }
    +
    + return 0;
    + }
    +
    + void quota_display_add_quota(quotad,mquota,cd)
    + struct quota_display * quotad;
    + struct mail_quota * mquota;
    + struct cancel_data * cd;
    +
    + {
    + size_t idx;
    +
    + if (QUOTA_DISPLAY_magic != quotad->magic)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_add_quota",
    + "Bad magic number (quota_diplay)",0);
    +
    + /* Should always succeed */
    + if (quota_display_quota_index(quotad,mquota,&idx,qd_create)) {
    +
    + int have_screen = RawState();
    +
    + DPRINT(Debug,12,(&Debug,
    + "quota_display_add_quota: quota added idx=%d, have_screen=%d\n",
    + idx,have_screen));
    +
    +
    + if (have_screen &&
    + quotad->current_page &&
    + quotad->quota_page) {
    +
    + DPRINT(Debug,12,(&Debug,
    + "quota_display_add_quota: Redrawing\n"));
    +
    + switch (menu_redraw_done(quotad->quota_page,
    + menu_disable_redraw_callback /* Avoid calling qd_update_quota_page() */)) {
    + case menu_redraw_need:
    + DPRINT(Debug,12,(&Debug,
    + "quota_display_add_quota: Need full\n"));
    + qd_quota_page_update(quotad,
    + quotad->quota_page,
    + quotad->PARAM,
    + cd);
    + break;
    + case menu_redraw_none:
    + qd_quota_step_page(quotad,cd,qd_step_this);
    + break;
    + case menu_done_redraw:
    + DPRINT(Debug,12,(&Debug,
    + "quota_display_add_quota: Was already done\n"));
    + break;
    +
    + }
    +
    +
    +
    + }
    + }
    + }
    +
    + /* Return 1 on succeed , if create set also deletes previous folder_disp_name */
    + static int quota_display_qlist_index P_((struct quota_display * quotad, + size_t mquota_idx,
    + struct mail_quotaroot_list * qlist,
    + struct string * folder_disp_name,
    + size_t * index_ref,
    + enum qd_create_flag create)); + static int quota_display_qlist_index(quotad,mquota_idx,qlist,folder_disp_name,
    + index_ref,create)
    + struct quota_display * quotad;
    + size_t mquota_idx;
    + struct mail_quotaroot_list * qlist;
    + struct string * folder_disp_name;
    + size_t * index_ref;
    + enum qd_create_flag create;
    + {
    + size_t i;
    +
    + int index_set = 0;
    + size_t res_index = 0;
    +
    + int found_it = 0;
    +
    + if (QUOTA_DISPLAY_magic != quotad->magic)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_qlist_index",
    + "Bad magic number (quota_diplay)",0);
    +
    + if ( mquota_idx >= quotad-> mail_quota_count ||
    + ! quotad-> mail_quota_list)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_qlist_index",
    + "Bad mquota_idx (quota_diplay)",0);
    +
    + if (index_ref)
    + *index_ref = quotad-> mail_quota_list[mquota_idx].mail_quotarootl_count;
    +
    + for (i = 0; i < quotad-> mail_quota_list[mquota_idx].mail_quotarootl_count; i++) {
    + size_t j;
    +
    + int found_qlist =
    + ( quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[i].quota_list
    + == qlist );
    +
    + if (found_qlist) {
    + res_index = i;
    + index_set = 1;
    + }
    +
    + for (j = 0;
    + j < quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[i]. + folder_disp_name_count; j++) {
    +
    + if (quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[i].
    + folder_disp_name_list[j] &&
    +
    + 0 == string_cmp(quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[i].
    + folder_disp_name_list[j],
    + folder_disp_name,
    + -999 /* not comparable */)) {
    +
    + if (found_qlist) {
    + if (index_ref)
    + *index_ref = i;
    +
    + found_it = 1;
    + } else {
    + switch (create) {
    + case qd_search: /* Ignore bad qlist */
    + break;
    + case qd_create:
    + free_string(& (quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[i].
    + folder_disp_name_list[j]));
    + break;
    + }
    + }
    +
    + }
    + }
    + }
    +
    + if (i != quotad-> mail_quota_list[mquota_idx].mail_quotarootl_count)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_qlist_index",
    + "Bad index (1)",0);
    +
    + if (index_set) {
    +
    + if (res_index >= quotad-> mail_quota_list[mquota_idx].mail_quotarootl_count)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_qlist_index",
    + "Bad index (2)",0);
    +
    + if (quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[res_index].quota_list
    + != qlist)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_qlist_index",
    + "Bad index (3)",0);
    + }
    +
    + if (found_it) {
    + if (index_ref) {
    + if (*index_ref >= quotad-> mail_quota_list[mquota_idx].mail_quotarootl_count)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_qlist_index",
    + "Bad index (4)",0);
    +
    + if (quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[*index_ref].quota_list
    + != qlist)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_qlist_index",
    + "Bad index (5)",0);
    + }
    + return 1;
    + }
    +
    + switch (create) {
    + size_t j;
    + size_t new_namecount;
    +
    + case qd_search:
    + break;
    +
    +
    + case qd_create:
    + if (!index_set) {
    + size_t newcount = quotad-> mail_quota_list[mquota_idx].mail_quotarootl_count +1;
    +
    + quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list =
    + safe_array_realloc(quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list,
    + newcount,
    + sizeof(quotad-> mail_quota_list[mquota_idx]. + mail_quotarootl_list[0]));
    +
    + /* bzero is defined hdrs/elm_defs.h */
    +
    + bzero(& (quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[i]),
    + sizeof (quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[i]));
    +
    + quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[i].
    + quota_list = qlist;
    + inc_mail_quotaroot_list_refcount(quotad-> mail_quota_list[mquota_idx].
    + mail_quotarootl_list[i].quota_list);
    +
    +
    +
    +
    + quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[i]. virtual_ql_start_line = 0;
    + quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[i]. virtual_tb_start_line = 0;
    +
    +
    + quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[i].folder_disp_name_list =
    + NULL;
    + quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[i].folder_disp_name_count =
    + 0;
    +
    +
    + quotad-> mail_quota_list[mquota_idx].mail_quotarootl_count = newcount;
    + res_index = i;
    + }
    +
    + for (j = 0;
    + j < quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[res_index].
    + folder_disp_name_count; j++) {
    +
    + if (quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[res_index].
    + folder_disp_name_list[j]) {
    +
    + if ( 0 == string_cmp(quotad-> mail_quota_list[mquota_idx].
    + mail_quotarootl_list[res_index].
    + folder_disp_name_list[j],
    + folder_disp_name,
    + -999 /* not comparable */)) {
    +
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_qlist_index",
    + "folder_disp_name already on list",0);
    +
    + }
    +
    + } else {
    + goto slot_found;
    + }
    + }
    +
    + if (j != quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[res_index].
    + folder_disp_name_count) {
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_qlist_index",
    + "Bad index (6)",0);
    + }
    +
    + new_namecount = quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[res_index].
    + folder_disp_name_count + 1;
    + quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[res_index].
    + folder_disp_name_list =
    + safe_array_realloc(quotad-> mail_quota_list[mquota_idx].
    + mail_quotarootl_list[res_index].folder_disp_name_list,
    + new_namecount,
    + sizeof(quotad-> mail_quota_list[mquota_idx].
    + mail_quotarootl_list[res_index].folder_disp_name_list[0]));
    + quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[res_index].
    + folder_disp_name_list[j] = NULL;
    + quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[res_index].
    + folder_disp_name_count = new_namecount;
    +
    + slot_found:
    + if (quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[res_index].
    + folder_disp_name_list[j]) {
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_qlist_index",
    + "Slot not empty",0);
    + }
    +
    + quotad-> mail_quota_list[mquota_idx].mail_quotarootl_list[res_index].
    + folder_disp_name_list[j] =
    + dup_string(folder_disp_name);
    +
    + if (index_ref)
    + *index_ref = res_index;
    +
    + return 1;
    + }
    +
    + return 0;
    + }
    +
    + void quota_display_add_qlist(quotad,qlist,folder_disp_name,cd)
    + struct quota_display * quotad;
    + struct mail_quotaroot_list * qlist;
    + struct string * folder_disp_name;
    + struct cancel_data * cd;
    + {
    + struct mail_quota * mquota;
    + size_t mquota_idx;
    +
    + if (QUOTA_DISPLAY_magic != quotad->magic)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_add_qlist",
    + "Bad magic number (quota_diplay)",0);
    +
    + /* Increments refcount! */
    + mquota = quotaroot_list_mquota(qlist);
    +
    + /* Should always succeed */
    + if (quota_display_quota_index(quotad,mquota,&mquota_idx,qd_create)) {
    +
    + size_t qlist_idx;
    +
    + /* Should always succeed */
    + if (quota_display_qlist_index(quotad,mquota_idx,qlist,folder_disp_name, + &qlist_idx,qd_create)) {
    +
    +
    + int have_screen = RawState();
    +
    + DPRINT(Debug,12,(&Debug,
    + "quota_display_add_qlist: quota list added, mquota_idx=%d qlist_idx=%d folder_disp_name=%S have_screen=%d\n",
    +
    + mquota_idx,qlist_idx,folder_disp_name,have_screen));
    +
    + if (have_screen &&
    + quotad->current_page &&
    + quotad->quota_page
    + ) {
    +
    + DPRINT(Debug,12,(&Debug,
    + "quota_display_add_qlist: Redrawing\n"));
    +
    + switch (menu_redraw_done(quotad->quota_page,
    + menu_disable_redraw_callback /* Avoid calling qd_update_quota_page() */)) {
    + case menu_redraw_need:
    + DPRINT(Debug,12,(&Debug,
    + "quota_display_add_qlist: Need full\n")); + qd_quota_page_update(quotad,
    + quotad->quota_page,
    + quotad->PARAM,
    + cd);
    + break;
    + case menu_redraw_none:
    + qd_quota_step_page(quotad,cd,qd_step_this);
    + break;
    + case menu_done_redraw:
    + DPRINT(Debug,12,(&Debug,
    + "quota_display_add_qlist: Was already done\n"));
    + break;
    + }
    + }
    + }
    + }
    +
    + free_mail_quota(&mquota);
    + }
    +
    + /* Return '\0', EOF, or letter from cmds (may be NULL) */
    +
    + int quota_display_show(quotad,cmds)
    + struct quota_display * quotad;
    + struct elm_commands * cmds; /* may be NULL */
    + {
    + int have_screen = RawState();
    + int retch = '\0';
    +
    + if (QUOTA_DISPLAY_magic != quotad->magic)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "quota_display_show",
    + "Bad magic number (quota_diplay)",0);
    +
    + if (have_screen &&
    + quotad->current_page) {
    +
    + struct menu_context * prompt_area = NULL;
    +
    + struct elm_commands * disp_cmds = give_quotadisp_commands();
    + struct cancel_data * cd = NULL;
    + struct elm_commands * all_cmds = NULL;
    +
    + int do_redraw = 0;
    +
    + int LINES, COLUMNS;
    +
    + setup_mbx_cancel_message(&cd,mbx_checking_mailbox);
    +
    + menu_get_sizes(quotad->current_page,&LINES, &COLUMNS);
    +
    + while (!retch && !is_canceled(cd)) {
    + int cmd = '\0';
    + int lin,col;
    +
    + menu_set_default(quotad->current_page);
    +
    + #ifdef BACKGROUD_PROCESSES
    + if (handle_sigchld)
    + sigchld_handler();
    + #endif
    +
    + if (0) {
    + redraw:
    + do_redraw = 1;
    + }
    +
    +
    + resize_mark:
    + if (menu_resized(quotad->current_page)) {
    + DPRINT(Debug,12,(&Debug,"quota_display_show: resized\n"));
    +
    + menu_get_sizes(quotad->current_page,&LINES, &COLUMNS);
    +
    + do_redraw = 1;
    +
    + if (LINES > 3) {
    + if (prompt_area)
    + menu_subpage_relocate(prompt_area,quotad->current_page,LINES-4,4);
    +
    + else
    + new_menu_subpage(quotad->current_page,LINES-4,4,
    + subpage_simple_noredraw,NULL);
    +
    + } else if (prompt_area)
    + erase_menu_context(&prompt_area);
    +
    + qdisp_set_page(quotad);
    + } else {
    + switch (menu_redraw_done(quotad->current_page, menu_disable_redraw_callback)) {
    + case menu_redraw_none: break;
    + case menu_done_redraw:
    + DPRINT(Debug,12,(&Debug,"quota_display_show: current page done redraw\n"));
    + break;
    + case menu_redraw_need:
    + DPRINT(Debug,12,(&Debug,"quota_display_show: current page need redraw\n"));
    + do_redraw = 1;
    + break;
    + }
    + }
    +
    + if (LINES > 4 && !prompt_area) {
    + DPRINT(Debug,12,(&Debug,"Creating prompt area\n"));
    +
    + prompt_area =
    + new_menu_subpage(quotad->current_page,LINES-4,4,
    + subpage_simple_noredraw,NULL);
    +
    + }
    +
    + if (do_redraw) {
    + DPRINT(Debug,12,(&Debug,"quota_display_show: Need redraw\n")); +
    + menu_ClearScreen(quotad->current_page);
    + }
    +
    + if (quotad->quota_page) {
    + switch(menu_redraw_done(quotad->quota_page,menu_disable_redraw_callback)) {
    + case menu_redraw_none: break;
    + case menu_done_redraw:
    + DPRINT(Debug,12,(&Debug,"quota_display_show: quota page done redraw\n"));
    + break;
    + case menu_redraw_need:
    + DPRINT(Debug,12,(&Debug,"quota_display_show: quota page need redraw\n"));
    + goto quota_page_redraw;
    + }
    +
    + if (menu_resized(quotad->quota_page) ||
    + do_redraw) {
    +
    + quota_page_redraw:
    + DPRINT(Debug,12,(&Debug,"quota_display_show: Redrawing quota page\n"));
    +
    + qd_quota_page_update(quotad,
    + quotad->quota_page,
    + quotad->PARAM,
    + cd);
    + }
    + } else {
    + DPRINT(Debug,12,(&Debug,"quota_display_show: No quota page\n"));
    + break;
    + }
    +
    + do_redraw = 0;
    +
    + if (is_canceled(cd)) {
    + DPRINT(Debug,12,(&Debug,"quota_display_show: Prompt canceled\n"));
    + break;
    + }
    +
    + if (prompt_area) {
    +
    + if (menu_need_redraw(prompt_area) ||
    + menu_resized(prompt_area)) {
    + DPRINT(Debug,12,(&Debug,"quota_display_show: Redrawing or resizing prompt area\n"));
    +
    + menu_ClearScreen(prompt_area); /* Clears also need update flag */
    + }
    +
    + menu_StartXX(prompt_area,pg_STANDOUT);
    +
    + if (quotad->is_end)
    + menu_PutLineX(prompt_area,0, 0,
    + CATGETS(elm_msg_cat, MeSet,
    + MeMQPromptEnd,
    + "Press 'q' or <return> to quit a quota screen ('?' for help):"));
    + else
    + menu_PutLineX(prompt_area,0, 0,
    + CATGETS(elm_msg_cat, MeSet,
    + MeMQPrompt,
    + "Press 'q' to quit a quota screen, or <return> to continue ('?' for help):"));
    +
    + menu_EndXX(prompt_area,pg_STANDOUT);
    +
    + menu_GetXYLocation(prompt_area,&lin,&col);
    + menu_CleartoEOLN(prompt_area);
    +
    + show_last_error();
    +
    + FlushBuffer();
    +
    + menu_MoveCursor(prompt_area,lin, col);
    +
    + /* Accept cursor keys and specially pageup / pagedown keys */
    +
    + cmd = menu_ReadCh(prompt_area,REDRAW_MARK|READCH_resize|READCH_CURSOR);
    +
    + if (isascii(cmd) &&
    + isprint(cmd)) {
    + DPRINT(Debug,8,(&Debug,"quota_display_show: ... command: '%c'\n",
    + cmd));
    + } else {
    + DPRINT(Debug,8,(&Debug,"quota_display_show: ... command: %d\n",
    + cmd));
    + }
    +
    + if (cmd == REDRAW_MARK) {
    +
    + DPRINT(Debug,4, (&Debug,"quota_display_show: .... redrawing\n"));
    +
    + do_redraw = 1;
    + continue;
    + }
    + if (cmd == RESIZE_MARK) {
    +
    + DPRINT(Debug,10, (&Debug,"quota_display_show: .... resizing\n"));
    + goto resize_mark;
    + }
    +
    + if (cmd == EOF) {
    + DPRINT(Debug,10, (&Debug,"quota_display_show: .... EOF\n"));
    + retch = EOF;
    + break;
    + }
    +
    + clear_error();
    +
    + /* Put cursor pack to correct place */
    + menu_MoveCursor(prompt_area,lin,col);
    +
    + switch (cmd) {
    +
    + case ctrl('L'):
    + goto redraw;
    +
    + case '\n':
    + case '\r':
    + if (quotad->is_end) {
    + DPRINT(Debug,12,(&Debug,"quota_display_show: End of quota listing reached.\n"));
    + goto out;
    + }
    + /* FALLTHRU */
    + case ' ':
    + case '+':
    + case RIGHT_MARK:
    + case PAGEDOWN_MARK:
    +
    + qd_quota_step_page(quotad,cd,qd_step_next);
    + break;
    +
    + case '-':
    + case LEFT_MARK:
    + case PAGEUP_MARK:
    +
    + qd_quota_step_page(quotad,cd,qd_step_prev);
    +
    + break;
    +
    +
    + case '?':
    + case HELP_MARK:
    +
    + menu_Writechar(prompt_area,cmd);
    +
    + FlushBuffer();
    +
    + if (cmds) {
    + if (!all_cmds)
    + all_cmds = give_merged_commands(disp_cmds,cmds,pg_BOLD,0);
    +
    + retch = help_generic(all_cmds,0,quotad->current_page,prompt_area);
    + } else
    + retch = help_generic(disp_cmds,0,quotad->current_page,prompt_area);
    + break;
    +
    + case 'q':
    +
    + menu_Writechar(prompt_area,cmd);
    + FlushBuffer();
    + goto out;
    +
    + default:
    + if (cmds) {
    + const struct elm_command * ret_cmd =
    + lookup_elm_command(cmds,cmd);
    +
    + if (ret_cmd) {
    + menu_Writechar(prompt_area,cmd);
    + FlushBuffer();
    + retch = cmd;
    + goto out;
    + }
    + }
    +
    + DPRINT(Debug,10,(&Debug,
    + "quota_display_show: command %d not found\n",
    + cmd));
    +
    + menu_Write_to_screen(prompt_area,
    + FRM("%c??"), 07);
    + FlushBuffer();
    + if (sleepmsg > 0)
    + error_sleep((sleepmsg + 1) / 2);
    +
    + break;
    + }
    +
    + } else {
    + DPRINT(Debug,10, (&Debug,"quota_display_show: Too few lines: LINES=%d\n",
    + LINES));
    + goto out;
    + }
    + }
    +
    + out:
    + free_cancel(&cd);
    + if (all_cmds)
    + free_commands(&all_cmds);
    + free_commands(&disp_cmds);
    +
    + if (prompt_area)
    + erase_menu_context(&prompt_area);
    +
    +
    + }
    +
    + DPRINT(Debug,12,(&Debug,"quota_display_show=%d",retch));
    +
    + switch (retch) {
    + case EOF: DPRINT(Debug,12,(&Debug," EOF")); break;
    + default:
    + if (isascii(retch) && isprint(retch)) {
    + DPRINT(Debug,12,(&Debug," '%c'",retch));
    + }
    + break;
    + }
    + DPRINT(Debug,12,(&Debug,"\n"));
    +
    + return retch;
    + }
    +
    + void free_quota_display(quotad, parent_page)
    + struct quota_display ** quotad;
    + struct menu_context * parent_page;
    + {
    + if (QUOTA_DISPLAY_magic != (*quotad)->magic)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "free_quota_display",
    + "Bad magic number (quota_diplay)",0);
    +
    + if ((*quotad)->refcount < 1)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "free_quota_diplay",
    + "Bad refcount",0);
    +
    + (*quotad)->refcount--;
    + if ((*quotad)->refcount > 0) {
    + /* Just reset this reference */
    +
    + *quotad = NULL;
    + return;
    + }
    +
    + if ((*quotad)->mail_quota_list) {
    + size_t i;
    +
    + for (i = 0; i < (*quotad)-> mail_quota_count; i++) {
    + if ((*quotad)-> mail_quota_list[i].mquota)
    + free_mail_quota(&((*quotad)-> mail_quota_list[i].mquota));
    +
    + if ((*quotad)-> mail_quota_list[i].mail_quotarootl_list) {
    + size_t j;
    +
    + for (j = 0; j < (*quotad)-> mail_quota_list[i].mail_quotarootl_count; j++) {
    +
    + if ((*quotad)-> mail_quota_list[i].mail_quotarootl_list[j].quota_list)
    + free_mail_quotaroot_list(& ((*quotad)-> mail_quota_list[i].
    + mail_quotarootl_list[j].quota_list));
    +
    + if ((*quotad)-> mail_quota_list[i].mail_quotarootl_list[j]. + folder_disp_name_list) {
    + size_t k;
    +
    + for (k = 0; k < (*quotad)-> mail_quota_list[i].mail_quotarootl_list[j].
    + folder_disp_name_count; k++) {
    +
    + if ((*quotad)-> mail_quota_list[i].mail_quotarootl_list[j].
    + folder_disp_name_list[k]) {
    + free_string(& ((*quotad)-> mail_quota_list[i]. + mail_quotarootl_list[j].
    + folder_disp_name_list[k]));
    + }
    + }
    +
    + free((*quotad)-> mail_quota_list[i].mail_quotarootl_list[j].
    + folder_disp_name_list);
    + (*quotad)->mail_quota_list[i].mail_quotarootl_list[j]. + folder_disp_name_list = NULL;
    + }
    + (*quotad)->mail_quota_list[i].mail_quotarootl_list[j].
    + folder_disp_name_count = 0;
    + }
    +
    +
    + free((*quotad)-> mail_quota_list[i].mail_quotarootl_list);
    + (*quotad)-> mail_quota_list[i].mail_quotarootl_list = NULL;
    + }
    + (*quotad)-> mail_quota_list[i].mail_quotarootl_count = 0;
    + }
    +
    + free((*quotad)->mail_quota_list);
    + (*quotad)->mail_quota_list = NULL;
    + }
    + (*quotad)->mail_quota_count = 0;
    +
    +
    + if ((*quotad)->quota_page)
    + erase_menu_context(& ((*quotad)->quota_page));
    +
    + if ((*quotad)->current_page)
    + erase_menu_context(& ((*quotad)->current_page));
    +
    + if (parent_page)
    + menu_set_default(parent_page);
    +
    + (*quotad)->magic = 0; /* Invalidate */
    +
    + free(*quotad);
    + *quotad = NULL;
    + }
    +
    +
    + /*
    + * Local Variables:
    + * mode:c
    + * c-basic-offset:4
    + * buffer-file-coding-system: iso-8859-1
    + * End:
    + */

    --
    / Kari Hurtta

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)