diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2010-10-30 01:55:31 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2010-10-30 01:55:31 +0800 |
commit | 0c51f8346a512ce96689f96511cae3ff96998881 (patch) | |
tree | bd76a4dce647f9c18228da5c2749abfc5967a45a | |
parent | 60b82f9698a38b5da6e6a6f58e01feff076913eb (diff) | |
download | pttbbs-0c51f8346a512ce96689f96511cae3ff96998881.tar pttbbs-0c51f8346a512ce96689f96511cae3ff96998881.tar.gz pttbbs-0c51f8346a512ce96689f96511cae3ff96998881.tar.bz2 pttbbs-0c51f8346a512ce96689f96511cae3ff96998881.tar.lz pttbbs-0c51f8346a512ce96689f96511cae3ff96998881.tar.xz pttbbs-0c51f8346a512ce96689f96511cae3ff96998881.tar.zst pttbbs-0c51f8346a512ce96689f96511cae3ff96998881.zip |
add 'x' to recycle bin -- thanks to LydiaWu for this
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5183 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/mbbsd/mail.c | 9 | ||||
-rw-r--r-- | pttbbs/mbbsd/psb.c | 39 |
2 files changed, 39 insertions, 9 deletions
diff --git a/pttbbs/mbbsd/mail.c b/pttbbs/mbbsd/mail.c index f7963fdd..7c3acc54 100644 --- a/pttbbs/mbbsd/mail.c +++ b/pttbbs/mbbsd/mail.c @@ -1232,8 +1232,10 @@ mail_del(int ent, const fileheader_t * fhdr, const char *direct) setupmailusage(); setdirpath(genbuf, direct, fhdr->filename); #ifdef USE_TIME_CAPSULE - timecapsule_archive_new_revision( - genbuf, fhdr, sizeof(*fhdr), NULL, 0); + // bypass those recovered files + if (strcmp(fhdr->owner, "[" RECYCLE_BIN_NAME "]") != 0) + timecapsule_archive_new_revision( + genbuf, fhdr, sizeof(*fhdr), NULL, 0); #endif // USE_TIME_CAPSULE unlink(genbuf); loadmailusage(); @@ -1853,8 +1855,7 @@ mail_waterball(int ent GCC_UNUSED, fileheader_t * fhdr, const char *direct GCC_U #ifdef USE_TIME_CAPSULE static int mail_recycle_bin(int ent, fileheader_t * fhdr, const char *direct) { - psb_recycle_bin(direct, "個人信箱"); - return FULLUPDATE; + return psb_recycle_bin(direct, "個人信箱"); } #else // USE_TIME_CAPSULE static int diff --git a/pttbbs/mbbsd/psb.c b/pttbbs/mbbsd/psb.c index 38bb1a44..e912e1bb 100644 --- a/pttbbs/mbbsd/psb.c +++ b/pttbbs/mbbsd/psb.c @@ -377,6 +377,7 @@ psb_view_edit_history(const char *base, const char *subject, typedef struct { const char *dirbase; const char *subject; + int modify_mailbox; int viewbase; fileheader_t *records; } pvrb_ctx; @@ -395,7 +396,8 @@ pvrb_header(void *ctx) { static int pvrb_footer(void *ctx) { vs_footer(" 已刪檔案 ", - " (↑/↓/PgUp/PgDn/0-9)移動 (Enter/r/→)選擇 \t(q/←)跳出"); + " (↑/↓/PgUp/PgDn/0-9)移動 (Enter/r/→)選擇 (x)存入信箱" + "\t(q/←)跳出"); move(b_lines-1, 0); return 0; } @@ -418,8 +420,35 @@ pvrb_input_processor(int key, int curr, int total, int rows, void *ctx) { int maxrev; pvrb_ctx *cx = (pvrb_ctx*) ctx; fileheader_t *fh = &cx->records[total - curr - 1]; + const char *err_no_rev = "抱歉,本文歷史資料已被系統清除。"; switch (key) { + // TODO add 'x' to pull this mail back to mailbox + case 'x': + setdirpath(fname, cx->dirbase, fh->filename); + maxrev = timecapsule_get_max_revision_number(fname); + if (maxrev < 1) { + vmsg(err_no_rev); + } else { + char revfname[PATHLEN]; + char ans[3]; + timecapsule_get_by_revision( + fname, maxrev, revfname, sizeof(revfname)); + getdata(b_lines-2, 0, "確定要把此份文件回存至信箱嗎? [y/N]: ", + ans, sizeof(ans), LCECHO); + if (*ans == 'y') { + if (mail_log2id(cuser.userid, fh->title, + revfname, "[" RECYCLE_BIN_NAME "]", + 1, 0) == 0) { + cx->modify_mailbox = 1; + vmsg("儲存完成,請至信箱檢查備忘錄信件"); + } else + vmsg("儲存失敗,請至 " BN_BUGREPORT " 看板報告,謝謝"); + return PSB_EOF; + } + } + return PSB_NOP; + case KEY_ENTER: case KEY_RIGHT: case 'r': @@ -433,7 +462,7 @@ pvrb_input_processor(int key, int curr, int total, int rows, void *ctx) { } else if (maxrev > 1) { psb_view_edit_history(fname, fh->title, maxrev, 0); } else { - vmsg("抱歉,本文歷史資料已被系統清除。"); + vmsg(err_no_rev); } return PSB_NOP; } @@ -490,7 +519,7 @@ psb_recycle_bin(const char *base, const char *title) { nrecords = timecapsule_get_max_archive_number(base, sizeof(fileheader_t)); if (!nrecords) { vmsg("目前" RECYCLE_BIN_NAME "內無任何內容。"); - return 0; + return FULLUPDATE; } pvrb_welcome(); @@ -505,13 +534,13 @@ psb_recycle_bin(const char *base, const char *title) { pvrbctx.records = (fileheader_t*) malloc (sizeof(fileheader_t) * nrecords); if (!pvrbctx.records) { vmsgf("內部錯誤,請至" BN_BUGREPORT "看板報告,謝謝"); - return 0; + return FULLUPDATE; } timecapsule_get_archive_blobs(base, viewbase, nrecords, pvrbctx.records, sizeof(fileheader_t)); psb_main(&ctx); free(pvrbctx.records); - return 0; + return pvrbctx.modify_mailbox ? DIRCHANGED : FULLUPDATE; } /////////////////////////////////////////////////////////////////////////// |