bugfix for newsgroups list dialog
authorHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Sat, 20 Oct 2001 12:22:07 +0000 (12:22 +0000)
committerHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Sat, 20 Oct 2001 12:22:07 +0000 (12:22 +0000)
ChangeLog.claws
configure.in
src/grouplistdialog.c
src/news.c
src/news.h

index 83bd39e5efffb6ec0c733ad5163459c577ba9126..0596f6e8a533f0dc78d075267c6b78933cabd085 100644 (file)
@@ -1,3 +1,13 @@
+2001-10-18 [hoa]        0.6.3claws29
+
+       * src/grouplistdialog.c
+               bugfix (another ?) to give the right
+               newsgroups list for each news server.
+
+       * src/news.c
+       * src/news.h
+               improve the newsgroups list cache
+
 2001-10-20 [paul]      0.6.3claws28
 
        * sync with sylpheed 0.6.3cvs9
@@ -12,7 +22,7 @@
 
 2001-10-18 [hoa]        0.6.3claws27
 
-       * src/grouplistdialog.[c]
+       * src/grouplistdialog.c
                bugfix when we refresh was clicked (bug 472701)
 
 2001-10-19 [christoph] 0.6.3claws26
index ef8b8ef477498b03906e2dfa5f7e40d4c04eb759..ffbd6bd8a6500b75200042bf740c6364e53002a7 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=6
 MICRO_VERSION=3
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws28
+EXTRA_VERSION=claws29
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
index 6aa6502523f8041fa997846d00f537cd66b7882a..6a7ff8bb242ab2496bab115228ae3447b3ba692d 100644 (file)
@@ -262,15 +262,13 @@ static void grouplist_dialog_set_list(gchar * pattern)
 
        grouplist_clear();
 
+       recv_set_ui_func(grouplist_recv_func, NULL);
+       group_list = news_get_group_list(news_folder);
+       recv_set_ui_func(NULL, NULL);
        if (group_list == NULL) {
-         recv_set_ui_func(grouplist_recv_func, NULL);
-         group_list = news_get_group_list(news_folder);
-         recv_set_ui_func(NULL, NULL);
-         if (group_list == NULL) {
-           alertpanel_error(_("Can't retrieve newsgroup list."));
-           locked = FALSE;
-           return;
-         }
+               alertpanel_error(_("Can't retrieve newsgroup list."));
+               locked = FALSE;
+               return;
        }
 
        dont_unsubscribed = TRUE;
@@ -383,9 +381,7 @@ static void refresh_clicked(GtkWidget *widget, gpointer data)
  
        if (locked) return;
 
-       news_group_list_free(group_list);
-       group_list = NULL;
-       news_remove_group_list(news_folder);
+       news_cancel_group_list_cache(news_folder);
 
        str = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
        grouplist_dialog_set_list(str);
index 637a549fb74d67180188b5583ba8c24de7608765..3247836dff454ea60493c93c6d299a99a8a7ff37 100644 (file)
@@ -80,6 +80,8 @@ static GSList *news_delete_old_articles        (GSList        *alist,
                                          gint           first);
 static void news_delete_all_articles    (FolderItem    *item);
 
+static void news_group_list_free(GSList * list);
+
 
 static Session *news_session_new(const gchar *server, gushort port,
                                 const gchar *userid, const gchar *passwd)
@@ -108,6 +110,7 @@ static Session *news_session_new(const gchar *server, gushort port,
        SESSION(session)->phase     = SESSION_READY;
        SESSION(session)->data      = NULL;
        session->group = NULL;
+       session->group_list = NULL;
 
        return SESSION(session);
 }
@@ -118,6 +121,9 @@ void news_session_destroy(NNTPSession *session)
        session->nntp_sock = NULL;
        SESSION(session)->sock = NULL;
 
+       news_group_list_free(session->group_list);
+       session->group_list = NULL;
+
        g_free(session->group);
 }
 
@@ -312,7 +318,7 @@ static void group_info_free(struct NNTPGroupInfo * info)
   g_free(info);
 }
 
-void news_group_list_free(GSList * list)
+static void news_group_list_free(GSList * list)
 {
   g_slist_foreach(list, (GFunc) group_info_free, NULL);
   g_slist_free(list);
@@ -331,6 +337,7 @@ GSList *news_get_group_list(Folder *folder)
        GSList *list = NULL;
        GSList *last = NULL;
        gchar buf[NNTPBUFSIZE];
+       NNTPSession *session;
 
        g_return_val_if_fail(folder != NULL, NULL);
        g_return_val_if_fail(folder->type == F_NEWS, NULL);
@@ -341,15 +348,18 @@ GSList *news_get_group_list(Folder *folder)
        filename = g_strconcat(path, G_DIR_SEPARATOR_S, NEWSGROUP_LIST, NULL);
        g_free(path);
 
-       if ((fp = fopen(filename, "r")) == NULL) {
-               NNTPSession *session;
+       session = news_session_get(folder);
+       if (!session) {
+               g_free(filename);
+               return NULL;
+       }
 
-               session = news_session_get(folder);
-               if (!session) {
-                       g_free(filename);
-                       return NULL;
-               }
+       if (session->group_list) {
+               g_free(filename);
+               return session->group_list;
+       }
 
+       if ((fp = fopen(filename, "r")) == NULL) {
                if (nntp_list(session->nntp_sock) != NN_SUCCESS) {
                        g_free(filename);
                        statusbar_pop_all();
@@ -421,18 +431,28 @@ GSList *news_get_group_list(Folder *folder)
 
        list = g_slist_sort(list, (GCompareFunc) news_group_info_compare);
 
+       session->group_list = list;
+
        statusbar_pop_all();
 
        return list;
 }
 
-void news_remove_group_list(Folder *folder)
+void news_cancel_group_list_cache(Folder *folder)
 {
        gchar *path, *filename;
+       NNTPSession *session;
 
        g_return_if_fail(folder != NULL);
        g_return_if_fail(folder->type == F_NEWS);
 
+       session = news_session_get(folder);
+       if (!session)
+               return;
+
+       news_group_list_free(session->group_list);
+       session->group_list = NULL;
+
        path = folder_item_get_path(FOLDER_ITEM(folder->node->data));
        filename = g_strconcat(path, G_DIR_SEPARATOR_S, NEWSGROUP_LIST, NULL);
        g_free(path);
index d4bc34c8d54effeafa71f1a414058ab3cf99a3c8..a3d8654a765f7c7797719aecf087fa81595dd1c6 100644 (file)
@@ -36,6 +36,8 @@ struct _NNTPSession
 
        NNTPSockInfo *nntp_sock;
        gchar *group;
+       
+       GSList * group_list;
 };
 
 struct NNTPGroupInfo {
@@ -59,9 +61,8 @@ gchar *news_fetch_msg                 (Folder         *folder,
 void news_scan_group                   (Folder         *folder,
                                         FolderItem     *item);
 
-void news_group_list_free               (GSList * list);
 GSList *news_get_group_list            (Folder         *folder);
-void news_remove_group_list            (Folder         *folder);
+void news_cancel_group_list_cache      (Folder         *folder);
 
 gint news_post                         (Folder         *folder,
                                         const gchar    *file);