From 728bd7471eb48701106ef65af331a0173a5d3903 Mon Sep 17 00:00:00 2001 From: piaip Date: Sun, 3 Jul 2005 11:41:14 +0000 Subject: - multi-signature browsing mode - song order: quick abort git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2881 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/common.h | 6 +++--- include/proto.h | 2 +- include/pttstruct.h | 11 +++++++++++ mbbsd/cal.c | 21 +++++++++++++++++--- mbbsd/edit.c | 36 ++++++++++++++++++++++++++++------- mbbsd/mail.c | 3 ++- mbbsd/user.c | 55 +++++++++++++++++++++++++++++++++++++++++------------ 7 files changed, 107 insertions(+), 27 deletions(-) diff --git a/include/common.h b/include/common.h index 430f72d7..1b5fe792 100644 --- a/include/common.h +++ b/include/common.h @@ -62,7 +62,7 @@ #define MSG_WORKING "處理中,請稍候..." #define MSG_CANCEL "取消。" -#define MSG_USR_LEFT "User 已經離開了" +#define MSG_USR_LEFT "使用者已經離開了" #define MSG_NOBODY "目前無人上線" #define MSG_DEL_OK "刪除完畢" @@ -71,8 +71,8 @@ #define MSG_DEL_NY "請確定刪除(Y/N)?[N] " #define MSG_FWD_OK "文章轉寄完成!" -#define MSG_FWD_ERR1 "轉寄失誤: system error" -#define MSG_FWD_ERR2 "轉寄失誤: address error" +#define MSG_FWD_ERR1 "轉寄失誤: 系統錯誤 system error" +#define MSG_FWD_ERR2 "轉寄失誤: 位址錯誤 address error" #define MSG_SURE_NY "請您確定(Y/N)?[N] " #define MSG_SURE_YN "請您確定(Y/N)?[Y] " diff --git a/include/proto.h b/include/proto.h index 8a922f2c..69d5987c 100644 --- a/include/proto.h +++ b/include/proto.h @@ -697,7 +697,7 @@ int kill_user(int num); int u_editcalendar(void); void user_display(const userec_t *u, int real); void uinfo_query(userec_t *u, int real, int unum); -int showsignature(char *fname, int *j); +int showsignature(char *fname, int *j, SigInfo *psi); void kick_all(char *user); void mail_violatelaw(const char* crime, const char* police, const char* reason, const char* result); void showplans(const char *uid); diff --git a/include/pttstruct.h b/include/pttstruct.h index d7dc1a00..82846de6 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -642,6 +642,17 @@ typedef struct int recno; } TagItem; +/* + * signature information + */ +typedef struct +{ + int total; /* total sig files found */ + int max; /* max number of available sig */ + int show_start; /* by which page to start display */ + int show_max; /* max covered range in last display */ +} SigInfo; + /* type in gomo.c, structure passing through socket */ typedef struct { char x; diff --git a/mbbsd/cal.c b/mbbsd/cal.c index bf4572b6..26cce228 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -134,20 +134,35 @@ osong(const char *defaultid) clrtobot(); prints("親愛的 %s 歡迎來到歐桑自動點歌系統\n", cuser.userid); trans_buffer[0] = '\0'; + if (!defaultid) { - getdata(13, 0, "要點給誰呢:[可直接按 Enter 先選歌]", + + getdata(13, 0, "要點給誰呢: [另可按 " + ANSI_COLOR(1) "Enter" ANSI_RESET + " 先選歌或是輸入 " ANSI_COLOR(1) "n" ANSI_RESET + " 離開]", destid, sizeof(destid), DOECHO); while (!destid[0]) { + a_menu("點歌歌本", SONGBOOK, 0, trans_buffer); clear(); - getdata(13, 0, "要點給誰呢:[可按 Enter 重新選歌]", + getdata(13, 0, "要點給誰呢: [另可按 " + ANSI_COLOR(1) "Enter" ANSI_RESET + " 先選歌或是輸入 " ANSI_COLOR(1) "n" ANSI_RESET + " 離開]", destid, sizeof(destid), DOECHO); } + if (destid[1] == 0 && + (destid[0] == 'n' || destid[0] == 'N')) + { + unlockutmpmode(); + return 0; + } } else strlcpy(destid, defaultid, sizeof(destid)); /* Heat:點歌者匿名功能 */ - getdata(14, 0, "要匿名嗎?[y/n]:", ano, sizeof(ano), LCECHO); + getdata(14, 0, "要匿名嗎?[y/N]:", ano, sizeof(ano), LCECHO); if (!destid[0]) { unlockutmpmode(); diff --git a/mbbsd/edit.c b/mbbsd/edit.c index e1a1fa74..bcc8e28e 100644 --- a/mbbsd/edit.c +++ b/mbbsd/edit.c @@ -1445,11 +1445,10 @@ void addsignature(FILE * fp, int ifuseanony) { FILE *fs; - int i, num; + int i; char buf[WRAPMARGIN + 1]; char fpath[STRLEN]; - static char msg[] = "請選擇簽名檔 (1-9, 0=不加 X=隨機)[X]: "; char ch; if (!strcmp(cuser.userid, STR_GUEST)) { @@ -1458,10 +1457,33 @@ addsignature(FILE * fp, int ifuseanony) return; } if (!ifuseanony) { - num = showsignature(fpath, &i); - if (num){ - msg[34] = ch = isdigit(cuser.signature) ? cuser.signature : 'X'; - getdata(0, 0, msg, buf, 4, DOECHO); + + int browsing = 0; + SigInfo si; + memset(&si, 0, sizeof(si)); + +browse_sigs: + showsignature(fpath, &i, &si); + + if (si.max > 0){ + unsigned char msg[64]; + + ch = isdigit(cuser.signature) ? cuser.signature : 'X'; + sprintf(msg, + (browsing || (si.max > si.show_max)) ? + "請選擇簽名檔 (1-9, 0=不加 n=翻頁 x=隨機)[%c]: ": + "請選擇簽名檔 (1-9, 0=不加 x=隨機)[%c]: ", + ch); + getdata(0, 0, msg, buf, 4, LCECHO); + + if(buf[0] == 'n') + { + si.show_start = si.show_max + 1; + if(si.show_start > si.max) + si.show_start = 0; + browsing = 1; + goto browse_sigs; + } if (!buf[0]) buf[0] = ch; @@ -1469,7 +1491,7 @@ addsignature(FILE * fp, int ifuseanony) if (isdigit((int)buf[0])) ch = buf[0]; else - ch = '1' + random() % num; + ch = '1' + random() % si.max; cuser.signature = buf[0]; if (ch != '0') { diff --git a/mbbsd/mail.c b/mbbsd/mail.c index f58293bb..300f2e96 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -1471,7 +1471,8 @@ send_inner_mail(const char *fpath, const char *title, const char *receiver) sethomepath(genbuf, rightid); stampfile(genbuf, &mymail); if (!strcmp(rightid, cuser.userid)) { - strlcpy(mymail.owner, "[" BBSNAME "]", sizeof(mymail.owner)); + /* Using BBSNAME may be too loooooong. */ + strlcpy(mymail.owner, "[站內]", sizeof(mymail.owner)); mymail.filemode = FILE_READ; } else strlcpy(mymail.owner, cuser.userid, sizeof(mymail.owner)); diff --git a/mbbsd/user.c b/mbbsd/user.c index 448664ec..ac8af2da 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -997,30 +997,46 @@ showplans(const char *uid) prints("《個人名片》%s 目前沒有名片", uid); } +/* + * return value: how many items displayed */ int -showsignature(char *fname, int *j) +showsignature(char *fname, int *j, SigInfo *si) { FILE *fp; char buf[256]; - int i, num = 0; + int i, lines = scr_lns; char ch; clear(); move(2, 0); + lines -= 3; + setuserfile(fname, "sig.0"); *j = strlen(fname) - 1; + si->total = 0; + si->max = 0; for (ch = '1'; ch <= '9'; ch++) { fname[*j] = ch; if ((fp = fopen(fname, "r"))) { - prints(ANSI_COLOR(36) "【 簽名檔.%c 】" ANSI_RESET "\n", ch); - for (i = 0; i < MAX_SIGLINES && fgets(buf, sizeof(buf), fp); i++) - outs(buf); - num++; + si->total ++; + si->max = ch - '1'; + if(lines > 0 && si->max >= si->show_start) + { + prints(ANSI_COLOR(36) "【 簽名檔.%c 】" ANSI_RESET "\n", ch); + lines--; + if(lines > MAX_SIGLINES/2) + si->show_max = si->max; + for (i = 0; lines > 0 && i < MAX_SIGLINES && + fgets(buf, sizeof(buf), fp) != NULL; i++) + outs(buf), lines--; + } fclose(fp); } } - return num; + if(lines > 0) + si->show_max = si->max; + return si->max; } int @@ -1028,18 +1044,33 @@ u_editsig(void) { int aborted; char ans[4]; - int j; - char genbuf[200]; + int j, browsing = 0; + char genbuf[MAXPATHLEN]; + SigInfo si; - showsignature(genbuf, &j); + memset(&si, 0, sizeof(si)); - getdata(0, 0, "簽名檔 (E)編輯 (D)刪除 (Q)取消?[Q] ", +browse_sigs: + + showsignature(genbuf, &j, &si); + getdata(0, 0, (browsing || (si.max > si.show_max)) ? + "簽名檔 (E)編輯 (D)刪除 (N)翻頁 (Q)取消?[Q] ": + "簽名檔 (E)編輯 (D)刪除 (Q)取消?[Q] ", ans, sizeof(ans), LCECHO); + if(ans[0] == 'n') + { + si.show_start = si.show_max + 1; + if(si.show_start > si.max) + si.show_start = 0; + browsing = 1; + goto browse_sigs; + } + aborted = 0; if (ans[0] == 'd') aborted = 1; - if (ans[0] == 'e') + else if (ans[0] == 'e') aborted = 2; if (aborted) { -- cgit v1.2.3