| 1 |
/*************************************************************************** |
/* SPDX-License-Identifier: GPL-3.0-or-later */ |
| 2 |
section_list_display.c - description |
/* |
| 3 |
------------------- |
* section_list_display |
| 4 |
Copyright : (C) 2004-2025 by Leaflet |
* - user interactive feature of section articles list |
| 5 |
Email : leaflet@leafok.com |
* |
| 6 |
***************************************************************************/ |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
| 7 |
|
*/ |
|
/*************************************************************************** |
|
|
* * |
|
|
* This program is free software; you can redistribute it and/or modify * |
|
|
* it under the terms of the GNU General Public License as published by * |
|
|
* the Free Software Foundation; either version 3 of the License, or * |
|
|
* (at your option) any later version. * |
|
|
* * |
|
|
***************************************************************************/ |
|
| 8 |
|
|
| 9 |
#include "article_cache.h" |
#include "article_cache.h" |
| 10 |
#include "article_favor.h" |
#include "article_favor.h" |
| 53 |
UNSET_FAVOR_ARTICLE, |
UNSET_FAVOR_ARTICLE, |
| 54 |
FIRST_TOPIC_ARTICLE, |
FIRST_TOPIC_ARTICLE, |
| 55 |
LAST_TOPIC_ARTICLE, |
LAST_TOPIC_ARTICLE, |
| 56 |
|
LAST_SECTION_ARTICLE, |
| 57 |
SCAN_NEW_ARTICLE, |
SCAN_NEW_ARTICLE, |
| 58 |
SCAN_ARTICLE_BACKWARD_BY_USER, |
SCAN_ARTICLE_BACKWARD_BY_USER, |
| 59 |
SCAN_ARTICLE_FORWARD_BY_USER, |
SCAN_ARTICLE_FORWARD_BY_USER, |
| 271 |
log_error("KEY_NULL\n"); |
log_error("KEY_NULL\n"); |
| 272 |
return EXIT_SECTION; |
return EXIT_SECTION; |
| 273 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 274 |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time) |
| 275 |
{ |
{ |
| 276 |
log_error("User input timeout\n"); |
log_error("User input timeout\n"); |
| 277 |
return EXIT_SECTION; |
return EXIT_SECTION; |
| 361 |
break; |
break; |
| 362 |
case '$': |
case '$': |
| 363 |
case KEY_END: |
case KEY_END: |
| 364 |
|
if (*p_page_id + 1 == total_page && *p_selected_index + 1 == item_count) // Press END at end of list |
| 365 |
|
{ |
| 366 |
|
return LAST_SECTION_ARTICLE; |
| 367 |
|
} |
| 368 |
if (total_page > 0) |
if (total_page > 0) |
| 369 |
{ |
{ |
| 370 |
*p_page_id = total_page - 1; |
*p_page_id = total_page - 1; |
| 707 |
// Update current aid location |
// Update current aid location |
| 708 |
if (p_articles[selected_index] != NULL) |
if (p_articles[selected_index] != NULL) |
| 709 |
{ |
{ |
| 710 |
section_aid_locations[section_index] = (p_articles[selected_index]->visible ? p_articles[selected_index]->aid : 0); |
if (selected_index >= ontop_start_offset) |
| 711 |
|
{ |
| 712 |
|
ret = last_article_in_section(p_section, &p_article_locate); |
| 713 |
|
if (ret < 0) |
| 714 |
|
{ |
| 715 |
|
log_error("last_article_in_section(sid=%d) error\n", p_section->sid); |
| 716 |
|
return -3; |
| 717 |
|
} |
| 718 |
|
else if (ret == 0) |
| 719 |
|
{ |
| 720 |
|
section_aid_locations[section_index] = 0; |
| 721 |
|
} |
| 722 |
|
else // ret > 0 |
| 723 |
|
{ |
| 724 |
|
section_aid_locations[section_index] = p_article_locate->aid; |
| 725 |
|
} |
| 726 |
|
} |
| 727 |
|
else |
| 728 |
|
{ |
| 729 |
|
section_aid_locations[section_index] = (p_articles[selected_index]->visible ? p_articles[selected_index]->aid : 0); |
| 730 |
|
} |
| 731 |
} |
} |
| 732 |
return 0; |
return 0; |
| 733 |
case CHANGE_PAGE: |
case CHANGE_PAGE: |
| 1102 |
} |
} |
| 1103 |
} |
} |
| 1104 |
break; |
break; |
| 1105 |
|
case LAST_SECTION_ARTICLE: |
| 1106 |
|
page_id_cur = page_id; |
| 1107 |
|
ret = last_article_in_section(p_section, &p_article_locate); |
| 1108 |
|
if (ret < 0) |
| 1109 |
|
{ |
| 1110 |
|
log_error("last_article_in_section(sid=%d) error\n", p_section->sid); |
| 1111 |
|
return -3; |
| 1112 |
|
} |
| 1113 |
|
else if (ret == 0) |
| 1114 |
|
{ |
| 1115 |
|
break; |
| 1116 |
|
} |
| 1117 |
|
ret = locate_article_in_section(p_section, p_article_locate, 0, 0, |
| 1118 |
|
&page_id, &selected_index, &article_count); |
| 1119 |
|
if (ret < 0) |
| 1120 |
|
{ |
| 1121 |
|
log_error("locate_article_in_section(sid=%d, aid=%d, direction=0, step=0) error\n", |
| 1122 |
|
p_section->sid, p_article_locate->aid); |
| 1123 |
|
return -3; |
| 1124 |
|
} |
| 1125 |
|
else if (ret > 0 && page_id != page_id_cur) // found and page changed |
| 1126 |
|
{ |
| 1127 |
|
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 1128 |
|
if (ret < 0) |
| 1129 |
|
{ |
| 1130 |
|
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 1131 |
|
return -3; |
| 1132 |
|
} |
| 1133 |
|
} |
| 1134 |
|
break; |
| 1135 |
case SCAN_NEW_ARTICLE: |
case SCAN_NEW_ARTICLE: |
| 1136 |
ret = scan_unread_article_in_section(p_section, p_articles[selected_index], &p_article_locate); |
ret = scan_unread_article_in_section(p_section, p_articles[selected_index], &p_article_locate); |
| 1137 |
if (ret < 0) |
if (ret < 0) |
| 1398 |
log_error("KEY_NULL\n"); |
log_error("KEY_NULL\n"); |
| 1399 |
return 0; |
return 0; |
| 1400 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 1401 |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time) |
| 1402 |
{ |
{ |
| 1403 |
log_error("User input timeout\n"); |
log_error("User input timeout\n"); |
| 1404 |
return 0; |
return 0; |