diff --git a/utils/ccenter/mailareas.c b/utils/ccenter/mailareas.c index 85cf8bd..b599e5d 100644 --- a/utils/ccenter/mailareas.c +++ b/utils/ccenter/mailareas.c @@ -150,7 +150,7 @@ void delete_mail_area(int confer, int area) { free(conf.mail_conferences[confer]->mail_areas[area]); for (i=area;imail_area_count - 1;i++) { - conf.mail_conferences[confer]->mail_areas[area] = conf.mail_conferences[confer]->mail_areas[area+1]; + conf.mail_conferences[confer]->mail_areas[i] = conf.mail_conferences[confer]->mail_areas[i+1]; } conf.mail_conferences[confer]->mail_area_count--; conf.mail_conferences[confer]->mail_areas = (struct mail_area **)realloc(conf.mail_conferences[confer]->mail_areas, sizeof(struct mail_area *) * conf.mail_conferences[confer]->mail_area_count); @@ -207,27 +207,43 @@ void edit_mail_area(int confer, int area) { destroyCDKScroll(editAreaList); } +void add_new_mail_area(int confer) { + char areapath[PATH_MAX]; + conf.mail_conferences[confer]->mail_areas = (struct mail_area **)realloc(conf.mail_conferences[confer]->mail_areas, sizeof(struct mail_area *) * (conf.mail_conferences[confer]->mail_area_count + 1)); + conf.mail_conferences[confer]->mail_areas[conf.mail_conferences[confer]->mail_area_count] = (struct mail_area *)malloc(sizeof(struct mail_area)); + conf.mail_conferences[confer]->mail_areas[conf.mail_conferences[confer]->mail_area_count]->name = strdup("New Area"); + snprintf(areapath, PATH_MAX, "%s/new_area", conf.bbs_path); + conf.mail_conferences[confer]->mail_areas[conf.mail_conferences[confer]->mail_area_count]->path = strdup(areapath); + conf.mail_conferences[confer]->mail_areas[conf.mail_conferences[confer]->mail_area_count]->qwkname = strdup("NEWAREA"); + conf.mail_conferences[confer]->mail_areas[conf.mail_conferences[confer]->mail_area_count]->read_sec_level = conf.newuserlvl; + conf.mail_conferences[confer]->mail_areas[conf.mail_conferences[confer]->mail_area_count]->write_sec_level = conf.newuserlvl; + conf.mail_conferences[confer]->mail_areas[conf.mail_conferences[confer]->mail_area_count]->type = TYPE_LOCAL_AREA; + conf.mail_conferences[confer]->mail_area_count++; + edit_mail_area(confer, conf.mail_conferences[confer]->mail_area_count - 1); +} + void edit_mail_areas(int confer) { char **itemlist; int selection; int i; + int area_count; while (1) { itemlist = (char **)malloc(sizeof(char *) * (conf.mail_conferences[confer]->mail_area_count + 1)); itemlist[0] = strdup("Add Area"); - - for (i=0;imail_area_count;i++) { + area_count = conf.mail_conferences[confer]->mail_area_count; + for (i=0;imail_areas[i]->name); } - CDKSCROLL *mailAreaList = newCDKScroll(cdkscreen, 7, 7, RIGHT, 12, 30, "Mail Areas", itemlist, conf.mail_conferences[confer]->mail_area_count + 1, FALSE, A_STANDOUT, TRUE, FALSE); + CDKSCROLL *mailAreaList = newCDKScroll(cdkscreen, 7, 7, RIGHT, 12, 30, "Mail Areas", itemlist, area_count + 1, FALSE, A_STANDOUT, TRUE, FALSE); selection = activateCDKScroll(mailAreaList, 0); if (mailAreaList->exitType == vESCAPE_HIT) { destroyCDKScroll(mailAreaList); - for (i=0;imail_area_count+1;i++) { + for (i=0;imail_area_count+1;i++) { + for (i=0;iexitType == vESCAPE_HIT || (dialog->exitType == vNORMAL && selection == 1)) { + // do nothing + } else { + for (area=0;areamail_area_count;area++) { + snprintf(filename, PATH_MAX, "%s.jdt", conf.mail_conferences[confer]->mail_areas[area]->path); + unlink(filename); + snprintf(filename, PATH_MAX, "%s.jdx", conf.mail_conferences[confer]->mail_areas[area]->path); + unlink(filename); + snprintf(filename, PATH_MAX, "%s.jhr", conf.mail_conferences[confer]->mail_areas[area]->path); + unlink(filename); + snprintf(filename, PATH_MAX, "%s.jlr", conf.mail_conferences[confer]->mail_areas[area]->path); + unlink(filename); + snprintf(filename, PATH_MAX, "%s.cmhw", conf.mail_conferences[confer]->mail_areas[area]->path); + unlink(filename); + } + unlink(conf.mail_conferences[confer]->path); + } + destroyCDKDialog(dialog); + + for (area=0;areamail_area_count;area++) { + free(conf.mail_conferences[confer]->mail_areas[area]->name); + free(conf.mail_conferences[confer]->mail_areas[area]->path); + free(conf.mail_conferences[confer]->mail_areas[area]->qwkname); + free(conf.mail_conferences[confer]->mail_areas[area]); + free(conf.mail_conferences[confer]->mail_areas); + } + + free(conf.mail_conferences[confer]->mail_areas); + free(conf.mail_conferences[confer]->name); + free(conf.mail_conferences[confer]->path); + if (conf.mail_conferences[confer]->tagline) { + free(conf.mail_conferences[confer]->tagline); + } + if (conf.mail_conferences[confer]->fidoaddr) { + free(conf.mail_conferences[confer]->fidoaddr); + } + for (i=confer;imail_areas = (struct mail_area **)malloc(sizeof(struct mail_area *)); + conf.mail_conferences[conf.mail_conference_count]->mail_areas[0] = (struct mail_area *)malloc(sizeof(struct mail_area)); + conf.mail_conferences[conf.mail_conference_count]->mail_areas[0]->name = strdup("New Area"); + snprintf(areapath, PATH_MAX, "%s/new_area", conf.bbs_path); + conf.mail_conferences[conf.mail_conference_count]->mail_areas[0]->path = strdup(areapath); + conf.mail_conferences[conf.mail_conference_count]->mail_areas[0]->qwkname = strdup("NEWAREA"); + conf.mail_conferences[conf.mail_conference_count]->mail_areas[0]->read_sec_level = conf.newuserlvl; + conf.mail_conferences[conf.mail_conference_count]->mail_areas[0]->write_sec_level = conf.newuserlvl; + conf.mail_conferences[conf.mail_conference_count]->mail_areas[0]->type = TYPE_LOCAL_AREA; + conf.mail_conferences[conf.mail_conference_count]->mail_area_count = 1; + + conf.mail_conferences[conf.mail_conference_count]->name = strdup("New Conference"); + snprintf(areapath, PATH_MAX, "%s/new_conf.ini", conf.config_path); + conf.mail_conferences[conf.mail_conference_count]->path = strdup(areapath); + conf.mail_conferences[conf.mail_conference_count]->tagline = strdup(conf.default_tagline); + conf.mail_conferences[conf.mail_conference_count]->networked = 0; + conf.mail_conferences[conf.mail_conference_count]->nettype = NETWORK_FIDO; + conf.mail_conferences[conf.mail_conference_count]->realnames = 0; + conf.mail_conferences[conf.mail_conference_count]->sec_level = conf.newuserlvl; + conf.mail_conferences[conf.mail_conference_count]->fidoaddr = (struct fido_addr *)malloc(sizeof(struct fido_addr)); + memcpy(conf.mail_conferences[conf.mail_conference_count]->fidoaddr, conf.main_aka, sizeof(struct fido_addr)); + conf.mail_conferences[conf.mail_conference_count]->wwivnode = 0; + + conf.mail_conference_count ++; + + edit_mail_conference(conf.mail_conference_count-1); +} + void mail_conferences() { char **itemlist; int selection; int i; + int confcount; while (1) { itemlist = (char **)malloc(sizeof(char *) * (conf.mail_conference_count + 1)); - + confcount = conf.mail_conference_count; itemlist[0] = strdup("Add Conference"); - for (i=0;iname); } - CDKSCROLL *mailConfList = newCDKScroll(cdkscreen, 3, 3, RIGHT, 12, 30, "Mail Conferences", itemlist, conf.mail_conference_count + 1, FALSE, A_STANDOUT, TRUE, FALSE); + CDKSCROLL *mailConfList = newCDKScroll(cdkscreen, 3, 3, RIGHT, 12, 30, "Mail Conferences", itemlist, confcount + 1, FALSE, A_STANDOUT, TRUE, FALSE); selection = activateCDKScroll(mailConfList, 0); if (mailConfList->exitType == vESCAPE_HIT) { destroyCDKScroll(mailConfList); - for (i=0;i