| 17 |
#include "section_list_display.h" |
#include "section_list_display.h" |
| 18 |
#include "section_list_loader.h" |
#include "section_list_loader.h" |
| 19 |
#include "article_cache.h" |
#include "article_cache.h" |
| 20 |
|
#include "article_post.h" |
| 21 |
#include "common.h" |
#include "common.h" |
| 22 |
#include "io.h" |
#include "io.h" |
| 23 |
#include "screen.h" |
#include "screen.h" |
| 24 |
#include "log.h" |
#include "log.h" |
| 25 |
|
#include "user_priv.h" |
| 26 |
|
#include "article_view_log.h" |
| 27 |
#include "str_process.h" |
#include "str_process.h" |
| 28 |
#include <time.h> |
#include <time.h> |
| 29 |
#include <sys/param.h> |
#include <sys/param.h> |
| 40 |
CHANGE_PAGE = 2, |
CHANGE_PAGE = 2, |
| 41 |
REFRESH_SCREEN = 3, |
REFRESH_SCREEN = 3, |
| 42 |
CHANGE_NAME_DISPLAY = 4, |
CHANGE_NAME_DISPLAY = 4, |
| 43 |
|
POST_ARTICLE = 5, |
| 44 |
|
EDIT_ARTICLE = 6, |
| 45 |
}; |
}; |
| 46 |
|
|
| 47 |
static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname) |
static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname) |
| 54 |
int len; |
int len; |
| 55 |
int i; |
int i; |
| 56 |
char article_flag; |
char article_flag; |
| 57 |
|
int is_viewed; |
| 58 |
time_t tm_now; |
time_t tm_now; |
| 59 |
|
|
| 60 |
time(&tm_now); |
time(&tm_now); |
| 63 |
|
|
| 64 |
for (i = 0; i < article_count; i++) |
for (i = 0; i < article_count; i++) |
| 65 |
{ |
{ |
| 66 |
article_flag = ' '; |
if (p_articles[i]->uid == BBS_priv.uid) |
| 67 |
|
{ |
| 68 |
|
is_viewed = 1; |
| 69 |
|
} |
| 70 |
|
else |
| 71 |
|
{ |
| 72 |
|
is_viewed = article_view_log_is_viewed(p_articles[i]->aid, &BBS_article_view_log); |
| 73 |
|
if (is_viewed < 0) |
| 74 |
|
{ |
| 75 |
|
log_error("article_view_log_is_viewed(aid=%d) error\n", p_articles[i]->aid); |
| 76 |
|
is_viewed = 0; |
| 77 |
|
} |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
article_flag = (is_viewed ? ' ' : 'N'); |
| 81 |
|
|
| 82 |
if (p_articles[i]->excerption) |
if (p_articles[i]->excerption) |
| 83 |
{ |
{ |
| 84 |
article_flag = 'm'; |
article_flag = (is_viewed ? 'm' : 'M'); |
| 85 |
} |
} |
| 86 |
else if (p_articles[i]->lock) |
else if (p_articles[i]->lock && is_viewed) |
| 87 |
{ |
{ |
| 88 |
article_flag = 'x'; |
article_flag = 'x'; |
| 89 |
} |
} |
| 196 |
return VIEW_ARTICLE; |
return VIEW_ARTICLE; |
| 197 |
} |
} |
| 198 |
break; |
break; |
| 199 |
|
case Ctrl('P'): |
| 200 |
|
return POST_ARTICLE; |
| 201 |
|
case 'E': |
| 202 |
|
return EDIT_ARTICLE; |
| 203 |
case KEY_HOME: |
case KEY_HOME: |
| 204 |
*p_page_id = 0; |
*p_page_id = 0; |
| 205 |
case KEY_PGUP: |
case KEY_PGUP: |
| 296 |
} |
} |
| 297 |
*p_key = 0; |
*p_key = 0; |
| 298 |
break; |
break; |
| 299 |
|
case 'r': // Reply article |
| 300 |
|
return 1; |
| 301 |
case KEY_UP: |
case KEY_UP: |
| 302 |
case KEY_PGUP: |
case KEY_PGUP: |
| 303 |
case KEY_HOME: |
case KEY_HOME: |
| 443 |
break; |
break; |
| 444 |
} |
} |
| 445 |
|
|
| 446 |
ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 1, 0, |
ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 0, |
| 447 |
display_article_key_handler, DATA_READ_HELP); |
display_article_key_handler, DATA_READ_HELP); |
| 448 |
|
|
| 449 |
if (article_cache_unload(&cache) < 0) |
if (article_cache_unload(&cache) < 0) |
| 452 |
break; |
break; |
| 453 |
} |
} |
| 454 |
|
|
| 455 |
|
// Update article_view_log |
| 456 |
|
if (article_view_log_set_viewed(p_articles[selected_index]->aid, &BBS_article_view_log) < 0) |
| 457 |
|
{ |
| 458 |
|
log_error("article_view_log_set_viewed(aid=%d) error\n", p_articles[selected_index]->aid); |
| 459 |
|
} |
| 460 |
|
|
| 461 |
switch (ret) |
switch (ret) |
| 462 |
{ |
{ |
| 463 |
case KEY_UP: |
case KEY_UP: |
| 543 |
loop = 1; |
loop = 1; |
| 544 |
} |
} |
| 545 |
break; |
break; |
| 546 |
|
case 'r': // Reply article |
| 547 |
|
if (article_reply(p_section, p_articles[selected_index]) < 0) |
| 548 |
|
{ |
| 549 |
|
log_error("article_post(aid=%d, REPLY) error\n", p_articles[selected_index]->aid); |
| 550 |
|
} |
| 551 |
|
loop = 1; |
| 552 |
|
break; |
| 553 |
} |
} |
| 554 |
} while (loop); |
} while (loop); |
| 555 |
|
|
| 567 |
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
| 568 |
{ |
{ |
| 569 |
log_error("section_list_draw_screen() error\n"); |
log_error("section_list_draw_screen() error\n"); |
| 570 |
|
return -2; |
| 571 |
|
} |
| 572 |
|
break; |
| 573 |
|
case POST_ARTICLE: |
| 574 |
|
if (article_post(p_section) < 0) |
| 575 |
|
{ |
| 576 |
|
log_error("article_post(sid=%d, NEW) error\n", p_section->sid); |
| 577 |
|
} |
| 578 |
|
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
| 579 |
|
{ |
| 580 |
|
log_error("section_list_draw_screen() error\n"); |
| 581 |
|
return -2; |
| 582 |
|
} |
| 583 |
|
break; |
| 584 |
|
case EDIT_ARTICLE: |
| 585 |
|
if (p_articles[selected_index]->uid != BBS_priv.uid) |
| 586 |
|
{ |
| 587 |
|
break; |
| 588 |
|
} |
| 589 |
|
if (article_modify(p_section, p_articles[selected_index]) < 0) |
| 590 |
|
{ |
| 591 |
|
log_error("article_post(aid=%d, EDIT) error\n", p_articles[selected_index]->aid); |
| 592 |
|
} |
| 593 |
|
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
| 594 |
|
{ |
| 595 |
|
log_error("section_list_draw_screen() error\n"); |
| 596 |
return -2; |
return -2; |
| 597 |
} |
} |
| 598 |
break; |
break; |