/[LeafOK_CVS]/lbbs/src/section_list_display.c
ViewVC logotype

Diff of /lbbs/src/section_list_display.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.53 by sysadm, Wed Oct 15 01:05:18 2025 UTC Revision 1.58 by sysadm, Wed Oct 29 01:48:46 2025 UTC
# Line 30  Line 30 
30  #include "section_list_loader.h"  #include "section_list_loader.h"
31  #include "screen.h"  #include "screen.h"
32  #include "str_process.h"  #include "str_process.h"
33    #include "user_info_display.h"
34  #include "user_priv.h"  #include "user_priv.h"
35  #include <string.h>  #include <string.h>
36  #include <time.h>  #include <time.h>
# Line 50  enum select_cmd_t Line 51  enum select_cmd_t
51          EDIT_ARTICLE,          EDIT_ARTICLE,
52          DELETE_ARTICLE,          DELETE_ARTICLE,
53          QUERY_ARTICLE,          QUERY_ARTICLE,
54            QUERY_USER,
55          SET_FAVOR_ARTICLE,          SET_FAVOR_ARTICLE,
56          UNSET_FAVOR_ARTICLE,          UNSET_FAVOR_ARTICLE,
57          FIRST_TOPIC_ARTICLE,          FIRST_TOPIC_ARTICLE,
# Line 255  static enum select_cmd_t section_list_se Line 257  static enum select_cmd_t section_list_se
257          {          {
258                  ch = igetch(100);                  ch = igetch(100);
259    
260                  switch (ch)                  if (ch != KEY_NULL && ch != KEY_TIMEOUT)
261                  {                  {
                 case KEY_ESC:  
                 case KEY_LEFT:  
262                          BBS_last_access_tm = time(NULL);                          BBS_last_access_tm = time(NULL);
263                  case KEY_NULL:                   // broken pipe                  }
264                          return EXIT_SECTION; // exit section  
265                    switch (ch)
266                    {
267                    case KEY_NULL: // broken pipe
268                            log_error("KEY_NULL\n");
269                            return EXIT_SECTION;
270                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
271                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
272                          {                          {
273                                  return EXIT_SECTION; // exit section                                  log_error("User input timeout\n");
274                                    return EXIT_SECTION;
275                          }                          }
276                          continue;                          continue;
277                    case KEY_ESC:
278                    case KEY_LEFT:
279                            return EXIT_SECTION;
280                  case 'n':                  case 'n':
                         BBS_last_access_tm = time(NULL);  
281                          return CHANGE_NAME_DISPLAY;                          return CHANGE_NAME_DISPLAY;
282                  case CR:                  case CR:
                         igetch_reset();  
283                  case 'r':                  case 'r':
284                  case KEY_RIGHT:                  case KEY_RIGHT:
285                          if (item_count > 0)                          if (item_count > 0)
286                          {                          {
                                 BBS_last_access_tm = time(NULL);  
287                                  return VIEW_ARTICLE;                                  return VIEW_ARTICLE;
288                          }                          }
289                          break;                          break;
# Line 301  static enum select_cmd_t section_list_se Line 307  static enum select_cmd_t section_list_se
307                                  return QUERY_ARTICLE;                                  return QUERY_ARTICLE;
308                          }                          }
309                          break;                          break;
310                    case Ctrl('A'):
311                            if (item_count > 0)
312                            {
313                                    return QUERY_USER;
314                            }
315                            break;
316                  case 'F':                  case 'F':
317                          if (item_count > 0)                          if (item_count > 0)
318                          {                          {
# Line 401  static enum select_cmd_t section_list_se Line 413  static enum select_cmd_t section_list_se
413                  case 'H':                  case 'H':
414                          return SHOW_TOP10;                          return SHOW_TOP10;
415                  default:                  default:
416                            break;
417                  }                  }
418    
419                  if (old_page_id != *p_page_id)                  if (old_page_id != *p_page_id)
# Line 425  static enum select_cmd_t section_list_se Line 438  static enum select_cmd_t section_list_se
438                          old_selected_index = *p_selected_index;                          old_selected_index = *p_selected_index;
439                  }                  }
440    
                 BBS_last_access_tm = time(NULL);  
441                  if (BBS_last_access_tm - last_refresh_tm >= BBS_section_list_load_interval)                  if (BBS_last_access_tm - last_refresh_tm >= BBS_section_list_load_interval)
442                  {                  {
443                          return CHANGE_PAGE; // force section list refresh                          return CHANGE_PAGE; // force section list refresh
# Line 545  int section_list_display(const char *sna Line 557  int section_list_display(const char *sna
557          ARTICLE article_new;          ARTICLE article_new;
558          int page_id_cur;          int page_id_cur;
559          const ARTICLE *p_article_locate;          const ARTICLE *p_article_locate;
560            USER_INFO user_info;
561    
562          p_section = section_list_find_by_name(sname);          p_section = section_list_find_by_name(sname);
563          if (p_section == NULL)          if (p_section == NULL)
# Line 562  int section_list_display(const char *sna Line 575  int section_list_display(const char *sna
575    
576          section_index = get_section_index(p_section);          section_index = get_section_index(p_section);
577    
578          if ((ret = section_list_rd_lock(p_section)) < 0)          if (get_section_info(p_section, NULL, stitle, master_list) < 0)
579          {          {
580                  log_error("section_list_rd_lock(sid = 0) error\n");                  log_error("get_section_info(sid=%d) error\n", p_section->sid);
581                  return -2;                  return -4;
         }  
   
         strncpy(stitle, p_section->stitle, sizeof(stitle) - 1);  
         stitle[sizeof(stitle) - 1] = '\0';  
         strncpy(master_list, p_section->master_list, sizeof(master_list) - 1);  
         master_list[sizeof(master_list) - 1] = '\0';  
   
         if ((ret = section_list_rd_unlock(p_section)) < 0)  
         {  
                 log_error("section_list_rd_unlock(sid = 0) error\n");  
                 return -2;  
582          }          }
583    
584          if (aid == 0)          if (aid == 0)
# Line 939  int section_list_display(const char *sna Line 941  int section_list_display(const char *sna
941                                  return -2;                                  return -2;
942                          }                          }
943                          break;                          break;
944                    case QUERY_USER:
945                            if ((ret = query_user_info_by_uid(p_articles[selected_index]->uid, &user_info)) < 0)
946                            {
947                                    log_error("query_user_info_by_uid(uid=%d) error\n", p_articles[selected_index]->uid);
948                                    return -2;
949                            }
950                            else if (ret == 0)
951                            {
952                                    clearscr();
953                                    prints("该用户已升天");
954                                    press_any_key();
955                            }
956                            else if (user_info_display(&user_info) < 0) // && ret > 0
957                            {
958                                    log_error("user_info_display(uid=%d) error\n", p_articles[selected_index]->uid);
959                            }
960    
961                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
962                            {
963                                    log_error("section_list_draw_screen() error\n");
964                                    return -2;
965                            }
966                            break;
967                  case SET_FAVOR_ARTICLE:                  case SET_FAVOR_ARTICLE:
968                          ret = article_favor_set(p_articles[selected_index]->tid == 0                          ret = article_favor_set(p_articles[selected_index]->tid == 0
969                                                                                  ? p_articles[selected_index]->aid                                                                                  ? p_articles[selected_index]->aid
# Line 1090  int section_list_ex_dir_display(SECTION_ Line 1115  int section_list_ex_dir_display(SECTION_
1115                  {                  {
1116                          iflush();                          iflush();
1117                          ch = igetch(100);                          ch = igetch(100);
1118    
1119                            if (ch != KEY_NULL && ch != KEY_TIMEOUT)
1120                            {
1121                                    BBS_last_access_tm = time(NULL);
1122                            }
1123    
1124                          switch (ch)                          switch (ch)
1125                          {                          {
1126                          case KEY_NULL: // broken pipe                          case KEY_NULL: // broken pipe
1127                                    log_error("KEY_NULL\n");
1128                                  return 0;                                  return 0;
1129                          case KEY_TIMEOUT:                          case KEY_TIMEOUT:
1130                                  if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)                                  if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
1131                                  {                                  {
1132                                            log_error("User input timeout\n");
1133                                          return 0;                                          return 0;
1134                                  }                                  }
1135                                  continue;                                  continue;
1136                          case CR:                          case CR:
                                 igetch_reset();  
1137                          default:                          default:
1138                                  switch (menu_control(&ex_menu_set, ch))                                  switch (menu_control(&ex_menu_set, ch))
1139                                  {                                  {
# Line 1120  int section_list_ex_dir_display(SECTION_ Line 1152  int section_list_ex_dir_display(SECTION_
1152                                  }                                  }
1153                          }                          }
1154    
                         BBS_last_access_tm = time(NULL);  
   
1155                          if (ch == EXITMENU)                          if (ch == EXITMENU)
1156                          {                          {
1157                                  break;                                  break;


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1