added newsgroup list dialog
authorHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Mon, 23 Apr 2001 17:57:45 +0000 (17:57 +0000)
committerHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Mon, 23 Apr 2001 17:57:45 +0000 (17:57 +0000)
src/Makefile.am
src/Makefile.in
src/defs.h
src/folderview.c
src/news.c
src/news.h
src/nntp.c
src/nntp.h

index ceaed97bfbc032b7ff4245d1c379697aff978ca1..46ad5d2d1ee2b8232d3e9a09874d196600ac8e29 100644 (file)
@@ -71,7 +71,8 @@ sylpheed_SOURCES = \
        select-keys.c select-keys.h \
        manual.c manual.h \
        addr_compl.c addr_compl.h \
-       export.c export.h
+       export.c export.h \
+       grouplist_dialog.c grouplist_dialog.h
 
 EXTRA_DIST = \
        pixmaps/clip.xpm \
index f17318769da9ae9b32f733d108f2fee36a17344c..7bd3e919e78f8afc356f399ba5ec88f7231a6c23 100644 (file)
@@ -60,6 +60,7 @@ POST_UNINSTALL = :
 host_alias = @host_alias@
 host_triplet = @host@
 AS = @AS@
+BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@
 CATALOGS = @CATALOGS@
 CATOBJEXT = @CATOBJEXT@
 CC = @CC@
@@ -71,7 +72,6 @@ GDK_IMLIB_LIBS = @GDK_IMLIB_LIBS@
 GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
 GDK_PIXBUF_CONFIG = @GDK_PIXBUF_CONFIG@
 GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
-GENCAT = @GENCAT@
 GLIB_CFLAGS = @GLIB_CFLAGS@
 GLIB_CONFIG = @GLIB_CONFIG@
 GLIB_LIBS = @GLIB_LIBS@
@@ -83,16 +83,14 @@ GPGME_LIBS = @GPGME_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_CONFIG = @GTK_CONFIG@
 GTK_LIBS = @GTK_LIBS@
-GT_NO = @GT_NO@
-GT_YES = @GT_YES@
 IMLIB_CFLAGS = @IMLIB_CFLAGS@
 IMLIB_CONFIG = @IMLIB_CONFIG@
 IMLIB_LIBS = @IMLIB_LIBS@
-INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
-INSTOBJEXT = @INSTOBJEXT@
-INTLDEPS = @INTLDEPS@
+INTLBISON = @INTLBISON@
 INTLLIBS = @INTLLIBS@
 INTLOBJS = @INTLOBJS@
+INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@
+LIBICONV = @LIBICONV@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
 LT_AGE = @LT_AGE@
@@ -111,13 +109,12 @@ RANLIB = @RANLIB@
 USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
 USE_NLS = @USE_NLS@
 VERSION = @VERSION@
-l = @l@
 localedir = @localedir@
 manualdir = @manualdir@
 
 bin_PROGRAMS = sylpheed
 
-sylpheed_SOURCES =     intl.h  defs.h  main.c main.h   mainwindow.c mainwindow.h       folderview.c folderview.h       summaryview.c summaryview.h     messageview.c messageview.h     headerview.c headerview.h       textview.c textview.h   imageview.c imageview.h         mimeview.c mimeview.h   summary_search.c summary_search.h       folder.c folder.h       procmsg.c procmsg.h     procheader.c procheader.h       filter.c filter.h       compose.c compose.h     gtkshruler.c gtkshruler.h       gtksctree.c gtksctree.h         menu.c menu.h   prefs.c prefs.h         prefs_common.c prefs_common.h   prefs_filter.c prefs_filter.h   prefs_account.c prefs_account.h         account.c account.h     addressbook.c addressbook.h     filesel.c filesel.h     foldersel.c foldersel.h         statusbar.c statusbar.h         headerwindow.c headerwindow.h   logwindow.c logwindow.h         sourcewindow.c sourcewindow.h   manage_window.c manage_window.h         alertpanel.c alertpanel.h       inputdialog.c inputdialog.h     progressdialog.c progressdialog.h       about.c about.h         setup.c setup.h         utils.c utils.h         gtkutils.c gtkutils.h   codeconv.c codeconv.h   unmime.c unmime.h       base64.c base64.h       uuencode.c uuencode.h   md5c.c md5.h md5global.h        md5ify.c md5ify.h       rfc822.c rfc822.h       socket.c socket.h       automaton.c automaton.h         session.c session.h     smtp.c smtp.h   esmtp.c esmtp.h         pop.c pop.h     mh.c mh.h       mbox.c mbox.h   send.c send.h   recv.c recv.h   inc.c inc.h     import.c import.h       nntp.c nntp.h   news.c news.h   imap.c imap.h   xml.c xml.h     html.c html.h   procmime.c procmime.h   rfc2015.c rfc2015.h     passphrase.c passphrase.h       select-keys.c select-keys.h     manual.c manual.h       addr_compl.c addr_compl.h       export.c export.h
+sylpheed_SOURCES =     intl.h  defs.h  main.c main.h   mainwindow.c mainwindow.h       folderview.c folderview.h       summaryview.c summaryview.h     messageview.c messageview.h     headerview.c headerview.h       textview.c textview.h   imageview.c imageview.h         mimeview.c mimeview.h   summary_search.c summary_search.h       folder.c folder.h       procmsg.c procmsg.h     procheader.c procheader.h       filter.c filter.h       compose.c compose.h     gtkshruler.c gtkshruler.h       gtksctree.c gtksctree.h         menu.c menu.h   prefs.c prefs.h         prefs_common.c prefs_common.h   prefs_filter.c prefs_filter.h   prefs_account.c prefs_account.h         account.c account.h     addressbook.c addressbook.h     filesel.c filesel.h     foldersel.c foldersel.h         statusbar.c statusbar.h         headerwindow.c headerwindow.h   logwindow.c logwindow.h         sourcewindow.c sourcewindow.h   manage_window.c manage_window.h         alertpanel.c alertpanel.h       inputdialog.c inputdialog.h     progressdialog.c progressdialog.h       about.c about.h         setup.c setup.h         utils.c utils.h         gtkutils.c gtkutils.h   codeconv.c codeconv.h   unmime.c unmime.h       base64.c base64.h       uuencode.c uuencode.h   md5c.c md5.h md5global.h        md5ify.c md5ify.h       rfc822.c rfc822.h       socket.c socket.h       automaton.c automaton.h         session.c session.h     smtp.c smtp.h   esmtp.c esmtp.h         pop.c pop.h     mh.c mh.h       mbox.c mbox.h   send.c send.h   recv.c recv.h   inc.c inc.h     import.c import.h       nntp.c nntp.h   news.c news.h   imap.c imap.h   xml.c xml.h     html.c html.h   procmime.c procmime.h   rfc2015.c rfc2015.h     passphrase.c passphrase.h       select-keys.c select-keys.h     manual.c manual.h       addr_compl.c addr_compl.h       export.c export.h       grouplist_dialog.c grouplist_dialog.h
 
 
 EXTRA_DIST =   pixmaps/clip.xpm        pixmaps/deleted.xpm     pixmaps/dir-close.xpm   pixmaps/dir-open.xpm    pixmaps/folder.xpm      pixmaps/forwarded.xpm   pixmaps/group.xpm       pixmaps/inbox.xpm       pixmaps/mark.xpm        pixmaps/new.xpm         pixmaps/outbox.xpm      pixmaps/regular.xpm     pixmaps/replied.xpm     pixmaps/trash.xpm       pixmaps/unread.xpm      pixmaps/linewrap.xpm    pixmaps/stock_mail.xpm  pixmaps/stock_mail_attach.xpm   pixmaps/stock_mail_receive.xpm  pixmaps/stock_mail_receive_all.xpm      pixmaps/stock_mail_send.xpm     pixmaps/stock_mail_compose.xpm  pixmaps/stock_mail_reply.xpm    pixmaps/stock_mail_reply_to_all.xpm     pixmaps/stock_mail_forward.xpm  pixmaps/stock_preferences.xpm   pixmaps/stock_properties.xpm    pixmaps/stock_search.xpm        pixmaps/stock_close.xpm         pixmaps/stock_exec.xpm  pixmaps/stock_trash.xpm         pixmaps/stock_up_arrow.xpm      pixmaps/stock_down_arrow.xpm    pixmaps/stock_paste.xpm         pixmaps/tb_address_book.xpm     pixmaps/sylpheed-logo.xpm
@@ -151,7 +148,7 @@ gtkutils.o codeconv.o unmime.o base64.o uuencode.o md5c.o md5ify.o \
 rfc822.o socket.o automaton.o session.o smtp.o esmtp.o pop.o mh.o \
 mbox.o send.o recv.o inc.o import.o nntp.o news.o imap.o xml.o html.o \
 procmime.o rfc2015.o passphrase.o select-keys.o manual.o addr_compl.o \
-export.o
+export.o grouplist_dialog.o
 sylpheed_DEPENDENCIES =  $(top_builddir)/libkcc/libkcc.a
 sylpheed_LDFLAGS = 
 CFLAGS = @CFLAGS@
@@ -164,27 +161,27 @@ DIST_COMMON =  Makefile.am Makefile.in
 
 DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
-TAR = gtar
+TAR = tar
 GZIP_ENV = --best
 DEP_FILES =  .deps/about.P .deps/account.P .deps/addr_compl.P \
 .deps/addressbook.P .deps/alertpanel.P .deps/automaton.P .deps/base64.P \
 .deps/codeconv.P .deps/compose.P .deps/esmtp.P .deps/export.P \
 .deps/filesel.P .deps/filter.P .deps/folder.P .deps/foldersel.P \
-.deps/folderview.P .deps/gtksctree.P .deps/gtkshruler.P \
-.deps/gtkutils.P .deps/headerview.P .deps/headerwindow.P .deps/html.P \
-.deps/imageview.P .deps/imap.P .deps/import.P .deps/inc.P \
-.deps/inputdialog.P .deps/logwindow.P .deps/main.P .deps/mainwindow.P \
-.deps/manage_window.P .deps/manual.P .deps/mbox.P .deps/md5c.P \
-.deps/md5ify.P .deps/menu.P .deps/messageview.P .deps/mh.P \
-.deps/mimeview.P .deps/news.P .deps/nntp.P .deps/passphrase.P \
-.deps/pop.P .deps/prefs.P .deps/prefs_account.P .deps/prefs_common.P \
-.deps/prefs_filter.P .deps/procheader.P .deps/procmime.P \
-.deps/procmsg.P .deps/progressdialog.P .deps/recv.P .deps/rfc2015.P \
-.deps/rfc822.P .deps/select-keys.P .deps/send.P .deps/session.P \
-.deps/setup.P .deps/smtp.P .deps/socket.P .deps/sourcewindow.P \
-.deps/statusbar.P .deps/summary_search.P .deps/summaryview.P \
-.deps/textview.P .deps/unmime.P .deps/utils.P .deps/uuencode.P \
-.deps/xml.P
+.deps/folderview.P .deps/grouplist_dialog.P .deps/gtksctree.P \
+.deps/gtkshruler.P .deps/gtkutils.P .deps/headerview.P \
+.deps/headerwindow.P .deps/html.P .deps/imageview.P .deps/imap.P \
+.deps/import.P .deps/inc.P .deps/inputdialog.P .deps/logwindow.P \
+.deps/main.P .deps/mainwindow.P .deps/manage_window.P .deps/manual.P \
+.deps/mbox.P .deps/md5c.P .deps/md5ify.P .deps/menu.P \
+.deps/messageview.P .deps/mh.P .deps/mimeview.P .deps/news.P \
+.deps/nntp.P .deps/passphrase.P .deps/pop.P .deps/prefs.P \
+.deps/prefs_account.P .deps/prefs_common.P .deps/prefs_filter.P \
+.deps/procheader.P .deps/procmime.P .deps/procmsg.P \
+.deps/progressdialog.P .deps/recv.P .deps/rfc2015.P .deps/rfc822.P \
+.deps/select-keys.P .deps/send.P .deps/session.P .deps/setup.P \
+.deps/smtp.P .deps/socket.P .deps/sourcewindow.P .deps/statusbar.P \
+.deps/summary_search.P .deps/summaryview.P .deps/textview.P \
+.deps/unmime.P .deps/utils.P .deps/uuencode.P .deps/xml.P
 SOURCES = $(sylpheed_SOURCES)
 OBJECTS = $(sylpheed_OBJECTS)
 
index b1cf11006acf9c7892c6cf3f846be63a4c376c69..498a8625202e0ea78bfdfb2be6823ffaba0e8fa9 100644 (file)
@@ -40,6 +40,7 @@
 #define TRASH_DIR              "trash"
 #define RC_DIR                 ".sylpheed"
 #define NEWS_CACHE_DIR         "newscache"
+#define GROUPLIST_FILE         "grouplist"
 #define IMAP_CACHE_DIR         "imapcache"
 #define MIME_TMP_DIR           "mimetmp"
 #define COMMON_RC              "sylpheedrc"
index 1d48475130cbca2598db6558d157ec0f4eb06143..bccd0f41c5974c02eeec94f10f54af46737a22e2 100644 (file)
@@ -1474,8 +1474,7 @@ static void folderview_new_news_group_cb(FolderView *folderview, guint action,
        g_return_if_fail(item->folder->type == F_NEWS);
        g_return_if_fail(item->folder->account != NULL);
 
-       new_group = input_dialog(_("Subscribe newsgroup"),
-                                _("Input subscribing newsgroup:"), NULL);
+       new_group = grouplist_dialog(item);
        if (!new_group) return;
 
        if (GTK_CTREE_ROW(folderview->selected)->parent != NULL)
index 279b8f960622a8408007f7b2aeb32959867d0fa6..e1b025410f64352755b6d6880e5d87375b1109f4 100644 (file)
@@ -28,6 +28,7 @@
 #include <dirent.h>
 #include <unistd.h>
 
+#include "defs.h"
 #include "intl.h"
 #include "news.h"
 #include "nntp.h"
@@ -482,3 +483,79 @@ static void news_delete_all_article(FolderItem *item)
 
        debug_print(_("done.\n"));
 }
+
+GSList * news_get_group_list(FolderItem *item)
+{
+       gchar *path, *filename;
+       gint ok;
+       NNTPSession *session;
+       GSList * group_list = NULL;
+       FILE * f;
+       gchar buf[NNTPBUFSIZE];
+       int len;
+
+       if (item == NULL)
+         return NULL;
+
+       path = folder_item_get_path(item);
+
+       if (!is_dir_exist(path))
+               make_dir_hier(path);
+
+       filename = g_strconcat(path, G_DIR_SEPARATOR_S, GROUPLIST_FILE, NULL);
+       g_free(path);
+
+       session = news_session_get(item->folder);
+
+       if (session == NULL)
+         return NULL;
+
+       if (is_file_exist(filename)) {
+               debug_print(_("group list has been already cached.\n"));
+       }
+       else
+         {
+           ok = nntp_list(SESSION(session)->sock);
+           if (ok != NN_SUCCESS)
+             return NULL;
+           
+           if (recv_write_to_file(SESSION(session)->sock, filename)
+               < 0) {
+             log_warning(_("can't retrieve group list\n"));
+             return NULL;
+           }
+         }
+
+       f = fopen(filename, "r");
+       while (fgets(buf, NNTPBUFSIZE, f))
+         {
+           char * s;
+
+           len = 0;
+           while ((buf[len] != 0) && (buf[len] != ' '))
+             len++;
+           buf[len] = 0;
+           s = g_strdup(buf);
+
+           group_list = g_slist_append(group_list, s);
+         }
+       fclose(f);
+       g_free(filename);
+
+       group_list = g_slist_sort(group_list, (GCompareFunc) g_strcasecmp);
+
+       return group_list;
+}
+
+void news_reset_group_list(FolderItem *item)
+{
+       gchar *path, *filename;
+
+       debug_print(_("\tDeleting cached group list... "));
+       path = folder_item_get_path(item);
+       filename = g_strconcat(path, G_DIR_SEPARATOR_S, GROUPLIST_FILE, NULL);
+       g_free(path);
+       if (remove(filename) != 0)
+         log_warning(_("can't delete cached group list %s\n"), filename);
+       g_free(filename);
+}
index 90da8f06734153c43fe769fa63ec502ece793025..0ea35476008824a7c6e8a82b10b02f90f2556962 100644 (file)
@@ -55,4 +55,7 @@ void news_scan_group                  (Folder         *folder,
 gint news_post                         (Folder         *folder,
                                         const gchar    *file);
 
+GSList * news_get_group_list(FolderItem *item);
+void news_reset_group_list();
+
 #endif /* __NEWS_H__ */
index e0ae5f5da0a7ae893201e3034af334c65f1084b9..0c7ed6e2ca30a028f0df6bda97a4bd4aa70480cc 100644 (file)
@@ -259,3 +259,22 @@ static gint nntp_gen_recv(gint sock, gchar *buf, gint size)
 
        return NN_SUCCESS;
 }
+
+gint nntp_list(gint sock)
+{
+       GList * result = NULL;
+
+       gint ok;
+       gint resp;
+       gchar buf[NNTPBUFSIZE];
+
+       nntp_gen_send(sock, "LIST");
+
+       if ((ok = nntp_ok(sock, buf)) != NN_SUCCESS)
+               return NN_ERROR;
+
+       if (verbose)
+               log_print("NNTP< %s\n", buf);
+
+       return NN_SUCCESS;
+}
index 891ba44699abe191e764110076e7cd6bb5b83c9c..8eb9742a32055d7c0877ebe847fc06973d27f993 100644 (file)
@@ -45,5 +45,6 @@ gint nntp_newgroups(gint sock);
 gint nntp_newnews(gint sock);
 gint nntp_mode(gint sock, gboolean stream);
 gint nntp_ok(gint sock, gchar *argbuf);
+gint nntp_list(gint sock);
 
 #endif /* __NNTP_H__ */