aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/nntp
diff options
context:
space:
mode:
Diffstat (limited to 'camel/providers/nntp')
-rw-r--r--camel/providers/nntp/.cvsignore8
-rw-r--r--camel/providers/nntp/Makefile.am47
-rw-r--r--camel/providers/nntp/camel-nntp-folder.c399
-rw-r--r--camel/providers/nntp/camel-nntp-folder.h73
-rw-r--r--camel/providers/nntp/camel-nntp-newsrc.c469
-rw-r--r--camel/providers/nntp/camel-nntp-newsrc.h27
-rw-r--r--camel/providers/nntp/camel-nntp-provider.c80
-rw-r--r--camel/providers/nntp/camel-nntp-store.c513
-rw-r--r--camel/providers/nntp/camel-nntp-store.h87
-rw-r--r--camel/providers/nntp/camel-nntp-utils.c218
-rw-r--r--camel/providers/nntp/camel-nntp-utils.h42
-rw-r--r--camel/providers/nntp/libcamelnntp.urls2
-rw-r--r--camel/providers/nntp/test-newsrc.c10
13 files changed, 0 insertions, 1975 deletions
diff --git a/camel/providers/nntp/.cvsignore b/camel/providers/nntp/.cvsignore
deleted file mode 100644
index 1f5b9d35fb..0000000000
--- a/camel/providers/nntp/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.deps
-Makefile
-Makefile.in
-.libs
-.deps
-*.lo
-*.la
-test-newsrc
diff --git a/camel/providers/nntp/Makefile.am b/camel/providers/nntp/Makefile.am
deleted file mode 100644
index d9122e9026..0000000000
--- a/camel/providers/nntp/Makefile.am
+++ /dev/null
@@ -1,47 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-libcamelnntpincludedir = $(includedir)/camel
-
-providerdir = $(pkglibdir)/camel-providers/$(VERSION)
-
-provider_LTLIBRARIES = libcamelnntp.la
-provider_DATA = libcamelnntp.urls
-
-INCLUDES = -I../.. \
- -I$(top_srcdir)/camel \
- -I$(top_srcdir)/intl \
- -I$(top_srcdir)/libibex \
- -I$(top_srcdir)/e-util \
- -I$(top_srcdir) \
- -I$(includedir) \
- $(GTK_INCLUDEDIR) \
- -DG_LOG_DOMAIN=\"camel-nntp-provider\"
-
-libcamelnntp_la_SOURCES = \
- camel-nntp-folder.c \
- camel-nntp-newsrc.c \
- camel-nntp-provider.c \
- camel-nntp-store.c \
- camel-nntp-utils.c
-
-libcamelnntpinclude_HEADERS = \
- camel-nntp-folder.h \
- camel-nntp-newsrc.h \
- camel-nntp-store.h \
- camel-nntp-utils.h
-
-libcamelnntp_la_LDFLAGS = -version-info 0:0:0
-
-EXTRA_DIST = libcamelnntp.urls
-
-#noinst_PROGRAMS = test-newsrc
-
-#LDADD = \
- #$(top_builddir)/camel/libcamel.la \
- #$(top_builddir)/e-util/libeutil.la \
- #$(top_builddir)/libibex/libibex.la \
- #$(GNOME_LIBDIR) \
- #$(GNOMEUI_LIBS) $(INTLLIBS) $(EXTRA_GNOME_LIBS)
-# $(BONOBO_LIBS)
-
-#test_newsrc_LDADD = libcamelnntp.la $(LDADD)
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
deleted file mode 100644
index 091d35e591..0000000000
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ /dev/null
@@ -1,399 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-nntp-folder.c : Abstract class for an email folder */
-
-/*
- * Author : Chris Toshok <toshok@helixcode.com>
- *
- * Copyright (C) 2000 Helix Code .
- *
- * 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 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-
-#include <config.h>
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <fcntl.h>
-
-#include "camel-folder-summary.h"
-#include "camel-nntp-store.h"
-#include "camel-nntp-folder.h"
-#include "camel-nntp-store.h"
-#include "camel-nntp-utils.h"
-
-#include "string-utils.h"
-#include "camel-stream-mem.h"
-#include "camel-stream-buffer.h"
-#include "camel-data-wrapper.h"
-#include "camel-mime-message.h"
-#include "camel-folder-summary.h"
-
-#include "camel-exception.h"
-
-static CamelFolderClass *parent_class=NULL;
-
-/* Returns the class for a CamelNNTPFolder */
-#define CNNTPF_CLASS(so) CAMEL_NNTP_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-#define CNNTPS_CLASS(so) CAMEL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-
-
-static void
-nntp_folder_init (CamelFolder *folder, CamelStore *parent_store,
- CamelFolder *parent_folder, const gchar *name,
- gchar *separator, gboolean path_begins_with_sep,
- CamelException *ex)
-{
- const gchar *root_dir_path;
- CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
-
- /* call parent method */
- parent_class->init (folder, parent_store, parent_folder,
- name, separator, path_begins_with_sep,
- ex);
- if (camel_exception_is_set (ex)) return;
-
- /* set flags */
-
- if (!strcmp (name, "/")) {
- /* the root folder is the only folder that has "subfolders" */
- folder->can_hold_folders = TRUE;
- folder->can_hold_messages = FALSE;
- }
- else {
- folder->can_hold_folders = FALSE;
- folder->can_hold_messages = TRUE;
- folder->has_summary_capability = TRUE;
- }
-
- /* XX */
- nntp_folder->group_name = g_strdup (strrchr (name, '/') + 1);
-
-#if 0
- /* get (or create) uid list */
- if (!(nntp_load_uid_list (nntp_folder) > 0))
- nntp_generate_uid_list (nntp_folder);
-#endif
-
- root_dir_path = camel_nntp_store_get_toplevel_dir (CAMEL_NNTP_STORE(folder->parent_store));
-
-
- /* load the summary if we have that ability */
- if (folder->has_summary_capability) {
- nntp_folder->summary_file_path = g_strdup_printf ("%s/%s-ev-summary",
- root_dir_path,
- nntp_folder->group_name);
-
- nntp_folder->summary = camel_folder_summary_new ();
- camel_folder_summary_set_filename (nntp_folder->summary,
- nntp_folder->summary_file_path);
-
- if (-1 == camel_folder_summary_load (nntp_folder->summary)) {
- /* Bad or nonexistant summary file */
- camel_nntp_get_headers (CAMEL_FOLDER( folder )->parent_store,
- nntp_folder, ex);
- if (camel_exception_get_id (ex))
- return;
-
- /* XXX check return value */
- camel_folder_summary_save (nntp_folder->summary);
- }
- }
-
-
-}
-
-static void
-nntp_folder_sync (CamelFolder *folder, gboolean expunge,
- CamelException *ex)
-{
- CamelNNTPStore *store;
-
- camel_folder_summary_save (CAMEL_NNTP_FOLDER(folder)->summary);
-
- store = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder));
-
- if (store->newsrc)
- camel_nntp_newsrc_write (store->newsrc);
-}
-
-static CamelFolder*
-nntp_folder_get_subfolder (CamelFolder *folder,
- const gchar *folder_name,
- gboolean create,
- CamelException *ex)
-{
- g_assert (0);
- return NULL;
-}
-
-static gint
-nntp_folder_get_message_count (CamelFolder *folder)
-{
- CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER(folder);
-
- g_assert (folder);
- g_assert (nntp_folder->summary);
-
- return camel_folder_summary_count(nntp_folder->summary);
-}
-
-static guint32
-nntp_folder_get_message_flags (CamelFolder *folder, const char *uid)
-{
- CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
- CamelMessageInfo *info = camel_folder_summary_uid (nntp_folder->summary, uid);
-
- return info->flags;
-}
-
-static void
-nntp_folder_set_message_flags (CamelFolder *folder, const char *uid,
- guint32 flags, guint32 set)
-{
- CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
- CamelMessageInfo *info = camel_folder_summary_uid (nntp_folder->summary, uid);
-
- info->flags = set;
-
- if (set & CAMEL_MESSAGE_SEEN) {
- int article_num;
- CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (camel_folder_get_parent_store (folder));
-
- sscanf (uid, "%d", &article_num);
-
- camel_nntp_newsrc_mark_article_read (nntp_store->newsrc,
- nntp_folder->group_name,
- article_num);
- }
-
- camel_folder_summary_touch (nntp_folder->summary);
-}
-
-static CamelMimeMessage *
-nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
-{
- CamelStream *nntp_istream;
- CamelStream *message_stream;
- CamelMimeMessage *message = NULL;
- CamelStore *parent_store;
- char *buf;
- int buf_len;
- int buf_alloc;
- int status;
- gboolean done;
- char *message_id;
-
- /* get the parent store */
- parent_store = camel_folder_get_parent_store (folder);
-
- message_id = strchr (uid, ',') + 1;
- status = camel_nntp_command (CAMEL_NNTP_STORE( parent_store ), NULL, "ARTICLE %s", message_id);
-
- nntp_istream = CAMEL_NNTP_STORE (parent_store)->istream;
-
- /* if the message_id was not found, raise an exception and return */
- if (status != CAMEL_NNTP_OK) {
- camel_exception_setv (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- "message %s not found.",
- message_id);
- return NULL;
- }
-
- /* XXX ick ick ick. read the entire message into a buffer and
- then create a stream_mem for it. */
- buf_alloc = 2048;
- buf_len = 0;
- buf = g_malloc(buf_alloc);
- done = FALSE;
-
- buf[0] = 0;
-
- while (!done) {
- char *line = camel_stream_buffer_read_line ( CAMEL_STREAM_BUFFER ( nntp_istream ));
- int line_length;
-
- /* XXX check exception */
-
- line_length = strlen ( line );
-
- if (!strcmp(line, ".")) {
- done = TRUE;
- g_free (line);
- }
- else {
- if (buf_len + line_length > buf_alloc) {
- buf_alloc *= 2;
- buf = g_realloc (buf, buf_alloc);
- }
- strcat(buf, line);
- strcat(buf, "\n");
- buf_len += strlen(line) + 1;
- g_free (line);
- }
- }
-
- /* create a stream bound to the message */
- message_stream = camel_stream_mem_new_with_buffer(buf, buf_len);
-
- message = camel_mime_message_new ();
- if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)message, message_stream) == -1) {
- camel_object_unref (CAMEL_OBJECT (message));
- camel_object_unref (CAMEL_OBJECT (message_stream));
- camel_exception_setv (ex,
- CAMEL_EXCEPTION_FOLDER_INVALID_UID, /* XXX */
- "Could not create message for message_id %s.", message_id);
-
- return NULL;
- }
- camel_object_unref (CAMEL_OBJECT (message_stream));
-
- /* init other fields? */
- camel_object_ref (CAMEL_OBJECT (folder));
-
-#if 0
- gtk_signal_connect (CAMEL_OBJECT (message), "message_changed", message_changed, folder);
-#endif
-
- return message;
-}
-
-static GPtrArray *
-nntp_folder_get_uids (CamelFolder *folder)
-{
- CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
- GPtrArray *out;
- CamelMessageInfo *message_info;
- int i;
- int count = camel_folder_summary_count (nntp_folder->summary);
-
- out = g_ptr_array_new ();
- g_ptr_array_set_size (out, count);
-
- for (i = 0; i < count; i++) {
- message_info = camel_folder_summary_index (nntp_folder->summary, i);
- out->pdata[i] = g_strdup (message_info->uid);
- }
-
- return out;
-}
-
-static GPtrArray *
-nntp_folder_get_summary (CamelFolder *folder)
-{
- CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
-
- return nntp_folder->summary->messages;
-}
-
-static GPtrArray *
-nntp_folder_get_subfolder_names (CamelFolder *folder)
-{
- if (!strcmp (folder->name, "/")) {
- CamelStore *store = camel_folder_get_parent_store (folder);
-
- if (CAMEL_NNTP_STORE (store)->newsrc) {
- GPtrArray *array = camel_nntp_newsrc_get_subscribed_group_names (CAMEL_NNTP_STORE (store)->newsrc);
- return array;
- }
- }
-
- return NULL;
-}
-
-static void
-nntp_folder_free_subfolder_names (CamelFolder *folder, GPtrArray *subfolders)
-{
- if (subfolders) {
- CamelStore *store = camel_folder_get_parent_store (folder);
- camel_nntp_newsrc_free_group_names (CAMEL_NNTP_STORE (store)->newsrc, subfolders);
- }
-}
-
-static GPtrArray*
-nntp_folder_search_by_expression (CamelFolder *folder, const char *expression, CamelException *ex)
-{
- g_assert (0);
- return NULL;
-}
-
-static const CamelMessageInfo*
-nntp_folder_get_message_info (CamelFolder *folder, const char *uid)
-{
- CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
-
- return camel_folder_summary_uid (nntp_folder->summary, uid);
-}
-
-static void
-nntp_folder_finalize (CamelObject *object)
-{
- CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (object);
-
- g_free (nntp_folder->summary_file_path);
-}
-
-static void
-camel_nntp_folder_class_init (CamelNNTPFolderClass *camel_nntp_folder_class)
-{
- CamelFolderClass *camel_folder_class = CAMEL_FOLDER_CLASS (camel_nntp_folder_class);
-
- parent_class = CAMEL_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_folder_get_type ()));
-
- /* virtual method definition */
-
- /* virtual method overload */
- camel_folder_class->init = nntp_folder_init;
- camel_folder_class->sync = nntp_folder_sync;
- camel_folder_class->get_subfolder = nntp_folder_get_subfolder;
- camel_folder_class->get_message_count = nntp_folder_get_message_count;
- camel_folder_class->set_message_flags = nntp_folder_set_message_flags;
- camel_folder_class->get_message_flags = nntp_folder_get_message_flags;
- camel_folder_class->get_message = nntp_folder_get_message;
- camel_folder_class->get_uids = nntp_folder_get_uids;
- camel_folder_class->free_uids = camel_folder_free_deep;
- camel_folder_class->get_summary = nntp_folder_get_summary;
- camel_folder_class->free_summary = camel_folder_free_nop;
- camel_folder_class->get_subfolder_names = nntp_folder_get_subfolder_names;
- camel_folder_class->free_subfolder_names = nntp_folder_free_subfolder_names;
- camel_folder_class->search_by_expression = nntp_folder_search_by_expression;
- camel_folder_class->get_message_info = nntp_folder_get_message_info;
-}
-
-CamelType
-camel_nntp_folder_get_type (void)
-{
- static CamelType camel_nntp_folder_type = CAMEL_INVALID_TYPE;
-
- if (camel_nntp_folder_type == CAMEL_INVALID_TYPE) {
- camel_nntp_folder_type = camel_type_register (CAMEL_FOLDER_TYPE, "CamelNNTPFolder",
- sizeof (CamelNNTPFolder),
- sizeof (CamelNNTPFolderClass),
- (CamelObjectClassInitFunc) camel_nntp_folder_class_init,
- NULL,
- (CamelObjectInitFunc) NULL,
- (CamelObjectFinalizeFunc) nntp_folder_finalize);
- }
-
- return camel_nntp_folder_type;
-}
diff --git a/camel/providers/nntp/camel-nntp-folder.h b/camel/providers/nntp/camel-nntp-folder.h
deleted file mode 100644
index 9bbd1466b9..0000000000
--- a/camel/providers/nntp/camel-nntp-folder.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-nntp-folder.h : NNTP group (folder) support. */
-
-/*
- *
- * Author : Chris Toshok <toshok@helixcode.com>
- *
- * Copyright (C) 2000 Helix Code .
- *
- * 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 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-
-#ifndef CAMEL_NNTP_FOLDER_H
-#define CAMEL_NNTP_FOLDER_H 1
-
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus }*/
-
-#include "camel-folder.h"
-
-/* #include "camel-store.h" */
-
-#define CAMEL_NNTP_FOLDER_TYPE (camel_nntp_folder_get_type ())
-#define CAMEL_NNTP_FOLDER(obj) (CAMEL_CHECK_CAST((obj), CAMEL_NNTP_FOLDER_TYPE, CamelNNTPFolder))
-#define CAMEL_NNTP_FOLDER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_NNTP_FOLDER_TYPE, CamelNNTPFolderClass))
-#define IS_CAMEL_NNTP_FOLDER(o) (CAMEL_CHECK_TYPE((o), CAMEL_NNTP_FOLDER_TYPE))
-
-
-typedef struct {
- CamelFolder parent_object;
-
- gchar *group_name;
- gchar *summary_file_path; /* contains the messages summary */
- CamelFolderSummary *summary;
-} CamelNNTPFolder;
-
-
-
-typedef struct {
- CamelFolderClass parent_class;
-
- /* Virtual methods */
-
-} CamelNNTPFolderClass;
-
-
-/* public methods */
-
-/* Standard Camel function */
-CamelType camel_nntp_folder_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* CAMEL_NNTP_FOLDER_H */
diff --git a/camel/providers/nntp/camel-nntp-newsrc.c b/camel/providers/nntp/camel-nntp-newsrc.c
deleted file mode 100644
index 81594d3dcd..0000000000
--- a/camel/providers/nntp/camel-nntp-newsrc.c
+++ /dev/null
@@ -1,469 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-nntp-newsrc.c - .newsrc parsing/regurgitating code */
-/*
- *
- * Copyright (C) 2000 Helix Code, Inc. <toshok@helixcode.com>
- *
- * 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 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#include <config.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <glib.h>
-#include "camel-nntp-newsrc.h"
-
-typedef struct {
- guint low;
- guint high;
-} ArticleRange;
-
-typedef struct {
- char *name;
- GArray *ranges;
- gboolean subscribed;
-} NewsrcGroup;
-
-struct CamelNNTPNewsrc {
- gchar *filename;
- GHashTable *groups;
- GHashTable *subscribed_groups;
- gboolean dirty;
-} ;
-
-static NewsrcGroup *
-camel_nntp_newsrc_group_add (CamelNNTPNewsrc *newsrc, char *group_name, gboolean subscribed)
-{
- NewsrcGroup *new_group = g_malloc(sizeof(NewsrcGroup));
-
- new_group->name = g_strdup(group_name);
- new_group->subscribed = subscribed;
- new_group->ranges = g_array_new (FALSE, FALSE, sizeof (ArticleRange));
-
- g_hash_table_insert (newsrc->groups, new_group->name, new_group);
- if (subscribed)
- g_hash_table_insert (newsrc->subscribed_groups, new_group->name, new_group);
-
- newsrc->dirty = TRUE;
-
- return new_group;
-}
-
-static long
-camel_nntp_newsrc_group_get_highest_article_read(CamelNNTPNewsrc *newsrc, NewsrcGroup *group)
-{
- if (group->ranges->len == 0)
- return 0;
-
- return g_array_index(group->ranges, ArticleRange, group->ranges->len - 1).high;
-}
-
-static void
-camel_nntp_newsrc_group_mark_range_read(CamelNNTPNewsrc *newsrc, NewsrcGroup *group, long low, long high)
-{
- int i;
-
- if (group->ranges->len == 1
- && g_array_index (group->ranges, ArticleRange, 0).low == 0
- && g_array_index (group->ranges, ArticleRange, 0).high == 0) {
- g_array_index (group->ranges, ArticleRange, 0).low = low;
- g_array_index (group->ranges, ArticleRange, 0).high = high;
-
- newsrc->dirty = TRUE;
- }
- else {
- ArticleRange tmp_range;
-
- for (i = 0; i < group->ranges->len; i ++) {
- guint range_low = g_array_index (group->ranges, ArticleRange, i).low;
- guint range_high = g_array_index (group->ranges, ArticleRange, i).high;
-
- /* if it's already part of a range, return immediately. */
- if (low >= range_low &&
- low <= range_high &&
- high >= range_low &&
- high <= range_high) {
- return;
- }
- /* if we have a new lower bound for this range, set it. */
- else if (low <= range_low
- && high >= range_low
- && high <= range_high) {
- g_array_index (group->ranges, ArticleRange, i).low = low;
- newsrc->dirty = TRUE;
- return;
- }
- /* if we have a new upper bound for this range, set it. */
- else if (high >= range_high
- && low >= range_low
- && low <= range_high) {
- g_array_index (group->ranges, ArticleRange, i).high = high;
- newsrc->dirty = TRUE;
- return;
- }
- /* if we would be inserting another range that
- starts one index higher than an existing
- one, make the upper value of the existing
- range the upper value of the new one. */
- else if (low == range_high + 1) {
- g_array_index (group->ranges, ArticleRange, i).high = high;
- newsrc->dirty = TRUE;
- return;
- }
- /* if we would be inserting another range that
- ends one index lower than an existing one,
- group the existing range by setting its low
- to the new low */
- else if (high == range_low - 1) {
- g_array_index (group->ranges, ArticleRange, i).low = low;
- newsrc->dirty = TRUE;
- return;
- }
- /* if the range lies entirely outside another
- range, doesn't coincide with it's
- endpoints, and has lower values, insert it
- into the middle of the list. */
- else if (low < range_low
- && high < range_low) {
- tmp_range.low = low;
- tmp_range.high = high;
-
- group->ranges = g_array_insert_val (group->ranges, i, tmp_range);
- newsrc->dirty = TRUE;
-
- return;
- }
- }
-
- /* if we made it here, the range needs to go at the end */
- tmp_range.low = low;
- tmp_range.high = high;
- group->ranges = g_array_append_val (group->ranges, tmp_range);
- newsrc->dirty = TRUE;
- }
-}
-
-int
-camel_nntp_newsrc_get_highest_article_read (CamelNNTPNewsrc *newsrc, char *group_name)
-{
- NewsrcGroup *group;
-
- group = g_hash_table_lookup (newsrc->groups, group_name);
-
- return camel_nntp_newsrc_group_get_highest_article_read (newsrc, group);
-}
-
-void
-camel_nntp_newsrc_mark_article_read (CamelNNTPNewsrc *newsrc, char *group_name, int num)
-{
- camel_nntp_newsrc_mark_range_read (newsrc, group_name, num, num);
-}
-
-void
-camel_nntp_newsrc_mark_range_read(CamelNNTPNewsrc *newsrc, char *group_name, long low, long high)
-{
- NewsrcGroup *group;
-
- /* swap them if they're in the wrong order. */
- if (low > high) {
- long tmp;
-
- tmp = high;
- high = low;
- low = tmp;
- }
-
- group = g_hash_table_lookup (newsrc->groups, group_name);
-
- camel_nntp_newsrc_group_mark_range_read (newsrc, group, low, high);
-}
-
-gboolean
-camel_nntp_newsrc_article_is_read (CamelNNTPNewsrc *newsrc, char *group_name, long num)
-{
- int i;
- NewsrcGroup *group;
-
- group = g_hash_table_lookup (newsrc->groups, group_name);
-
- for (i = 0; i < group->ranges->len; i++) {
- if (num >= g_array_index (group->ranges, ArticleRange, i).low &&
- num <= g_array_index (group->ranges, ArticleRange, i).high) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-struct newsrc_ptr_array {
- GPtrArray *ptr_array;
- gboolean subscribed_only;
-};
-
-static void
-get_group_foreach (char *group_name, NewsrcGroup *group, struct newsrc_ptr_array *npa)
-{
- if (group->subscribed || !npa->subscribed_only) {
- g_ptr_array_add (npa->ptr_array, group_name);
- }
-}
-
-GPtrArray *
-camel_nntp_newsrc_get_subscribed_group_names (CamelNNTPNewsrc *newsrc)
-{
- struct newsrc_ptr_array npa;
-
- g_return_val_if_fail (newsrc, NULL);
-
- npa.ptr_array = g_ptr_array_new();
- npa.subscribed_only = TRUE;
-
- g_hash_table_foreach (newsrc->subscribed_groups,
- (GHFunc)get_group_foreach, &npa);
-
- return npa.ptr_array;
-}
-
-GPtrArray *
-camel_nntp_newsrc_get_all_group_names (CamelNNTPNewsrc *newsrc)
-{
- struct newsrc_ptr_array npa;
-
- g_return_val_if_fail (newsrc, NULL);
-
- npa.ptr_array = g_ptr_array_new();
- npa.subscribed_only = FALSE;
-
- g_hash_table_foreach (newsrc->groups,
- (GHFunc)get_group_foreach, &npa);
-
- return npa.ptr_array;
-}
-
-void
-camel_nntp_newsrc_free_group_names (CamelNNTPNewsrc *newsrc, GPtrArray *group_names)
-{
- g_ptr_array_free (group_names, TRUE);
-}
-
-struct newsrc_fp {
- CamelNNTPNewsrc *newsrc;
- FILE *fp;
-};
-
-static void
-camel_nntp_newsrc_write_group_line(gpointer key, NewsrcGroup *group, struct newsrc_fp *newsrc_fp)
-{
- CamelNNTPNewsrc *newsrc;
- FILE *fp;
- int i;
- int line_length = 0;
-
- fp = newsrc_fp->fp;
- newsrc = newsrc_fp->newsrc;
-
- fprintf (fp, "%s%c", group->name, group->subscribed ? ':' : '!');
-
- line_length += strlen(group->name) + 1;
-
- if (group->ranges->len == 1
- && g_array_index (group->ranges, ArticleRange, 0).low == 0
- && g_array_index (group->ranges, ArticleRange, 0).high == 0) {
- fprintf (fp, "\n");
-
- return; /* special case since our parsing code will insert this
- bogus range if there were no read articles. The code
- to add a range is smart enough to remove this one if we
- ever mark an article read, but we still need to deal with
- it if that code doesn't get hit. */
- }
-
- fprintf (fp, " ");
- line_length += 1;
-
- for (i = 0; i < group->ranges->len; i ++) {
- char range_buffer[100];
- guint low = g_array_index (group->ranges, ArticleRange, i).low;
- guint high = g_array_index (group->ranges, ArticleRange, i).high;
-
- if (low == high)
- sprintf(range_buffer, "%d", low);
- else if (low == high - 1)
- sprintf(range_buffer, "%d,%d", low, high);
- else
- sprintf(range_buffer, "%d-%d", low, high);
-
- if (i != group->ranges->len - 1)
- strcat(range_buffer, ",");
-
- /* this constant (991) gives the same line breaking as faried's .newsrc file */
- if (line_length + strlen(range_buffer) > 991 /*XXX*/) {
- char range_buffer2[101];
- int num_to_print = 991 - line_length;
-
- strcpy(range_buffer2, range_buffer);
- range_buffer2[num_to_print] = '!';
- range_buffer2[num_to_print+1] = '\n';
- range_buffer2[num_to_print+2] = '\0';
-
- fprintf (fp, range_buffer2);
-
- fprintf (fp, range_buffer + num_to_print);
-
- line_length = strlen(range_buffer) - num_to_print;
- }
- else {
- fprintf (fp, range_buffer);
- line_length += strlen(range_buffer);
- }
- }
-
- fprintf (fp, "\n");
-}
-
-void
-camel_nntp_newsrc_write_to_file(CamelNNTPNewsrc *newsrc, FILE *fp)
-{
- struct newsrc_fp newsrc_fp;
-
- g_return_if_fail (newsrc);
-
- newsrc_fp.newsrc = newsrc;
- newsrc_fp.fp = fp;
-
- g_hash_table_foreach (newsrc->groups,
- (GHFunc)camel_nntp_newsrc_write_group_line,
- &newsrc_fp);
-}
-
-void
-camel_nntp_newsrc_write(CamelNNTPNewsrc *newsrc)
-{
- FILE *fp;
-
- g_return_if_fail (newsrc);
-
- if (!newsrc->dirty)
- return;
-
- if ((fp = fopen(newsrc->filename, "w")) == NULL) {
- g_warning ("Couldn't open newsrc file '%s'.\n", newsrc->filename);
- return;
- }
-
- camel_nntp_newsrc_write_to_file(newsrc, fp);
-
- fclose(fp);
-}
-
-static void
-camel_nntp_newsrc_parse_line(CamelNNTPNewsrc *newsrc, char *line)
-{
- char *p, sep, *comma, *dash;
- gboolean is_subscribed;
- NewsrcGroup *group;
-
- p = strchr(line, ':');
-
- if (p) {
- is_subscribed = TRUE;
- }
- else {
- p = strchr(line, '!');
- if (p)
- is_subscribed = FALSE;
- else
- return; /* bogus line. */
- }
-
- sep = *p;
- *p = '\0';
-
- group = camel_nntp_newsrc_group_add (newsrc, line, is_subscribed);
-
- *p = sep;
-
- p++;
-
- do {
- guint high, low;
-
- comma = strchr(p, ',');
-
- if (comma)
- *comma = '\0';
-
- dash = strchr(p, '-');
-
- if (!dash) { /* there wasn't a dash. must be just one number */
- high = low = atol(p);
- }
- else { /* there was a dash. */
- *dash = '\0';
- low = atol(p);
- *dash = '-';
- p = dash + 1;
- high = atol(p);
- }
-
- camel_nntp_newsrc_group_mark_range_read (newsrc, group, low, high);
-
- if (comma) {
- *comma = ',';
- p = comma + 1;
- }
-
- } while(comma);
-}
-
-#define MAX_LINE_LENGTH 1500
-#define BUFFER_LENGTH (20 * MAX_LINE_LENGTH)
-
-CamelNNTPNewsrc *
-camel_nntp_newsrc_read_for_server (const char *server)
-{
- FILE *fp;
- char buf[BUFFER_LENGTH];
- CamelNNTPNewsrc *newsrc = g_new0(CamelNNTPNewsrc, 1);
-
- newsrc->filename = g_strdup_printf ("%s/.newsrc-%s", g_get_home_dir(), server);
- newsrc->groups = g_hash_table_new (g_str_hash, g_str_equal);
- newsrc->subscribed_groups = g_hash_table_new (g_str_hash, g_str_equal);
-
- if ((fp = fopen(newsrc->filename, "r")) == NULL) {
- g_free (newsrc->filename);
- g_free (newsrc);
- return NULL;
- }
-
- while (fgets(buf, MAX_LINE_LENGTH, fp) != NULL) {
- /* we silently ignore (and lose!) lines longer than 20 * 1500 chars.
- Too bad for them. */
- while(strlen(buf) < sizeof(buf)
- && buf[strlen(buf) - 2] == '!') {
- fgets(&buf[strlen(buf) - 2], MAX_LINE_LENGTH, fp);
- }
-
- camel_nntp_newsrc_parse_line(newsrc, buf);
- }
-
- fclose(fp);
-
- return newsrc;
-}
diff --git a/camel/providers/nntp/camel-nntp-newsrc.h b/camel/providers/nntp/camel-nntp-newsrc.h
deleted file mode 100644
index 3f4be6de8d..0000000000
--- a/camel/providers/nntp/camel-nntp-newsrc.h
+++ /dev/null
@@ -1,27 +0,0 @@
-
-#ifndef _CAMEL_NNTP_NEWSRC_H_
-#define _CAMEL_NNTP_NEWSRC_H_
-
-#include <stdio.h>
-#include "glib.h"
-
-typedef struct CamelNNTPNewsrc CamelNNTPNewsrc;
-
-int camel_nntp_newsrc_get_highest_article_read (CamelNNTPNewsrc *newsrc, char *group_name);
-void camel_nntp_newsrc_mark_article_read (CamelNNTPNewsrc *newsrc,
- char *group_name, int num);
-void camel_nntp_newsrc_mark_range_read (CamelNNTPNewsrc *newsrc,
- char *group_name, long low, long high);
-
-gboolean camel_nntp_newsrc_article_is_read (CamelNNTPNewsrc *newsrc,
- char *group_name, long num);
-
-GPtrArray *camel_nntp_newsrc_get_subscribed_group_names (CamelNNTPNewsrc *newsrc);
-GPtrArray *camel_nntp_newsrc_get_all_group_names (CamelNNTPNewsrc *newsrc);
-void camel_nntp_newsrc_free_group_names (CamelNNTPNewsrc *newsrc, GPtrArray *group_names);
-
-void camel_nntp_newsrc_write_to_file (CamelNNTPNewsrc *newsrc, FILE *fp);
-void camel_nntp_newsrc_write (CamelNNTPNewsrc *newsrc);
-CamelNNTPNewsrc *camel_nntp_newsrc_read_for_server (const char *server);
-
-#endif /* _CAMEL_NNTP_NEWSRC_H_ */
diff --git a/camel/providers/nntp/camel-nntp-provider.c b/camel/providers/nntp/camel-nntp-provider.c
deleted file mode 100644
index 214fd4b0fa..0000000000
--- a/camel/providers/nntp/camel-nntp-provider.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-nntp-provider.c: nntp provider registration code */
-
-/*
- * Authors :
- * Chris Toshok <toshok@helixcode.com>
- *
- * Copyright (C) 2000 Helix Code, Inc. (www.helixcode.com)
- *
- * 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 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#include "config.h"
-#include "camel-nntp-store.h"
-#include "camel-provider.h"
-#include "camel-session.h"
-
-static CamelProvider news_provider = {
- "news",
- "USENET news",
-
- "This is a read-only provider for USENET newsgroups.",
-
- "news",
-
- CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_STORAGE,
-
- { 0, 0 },
-
- NULL
-};
-
-static CamelProvider nntp_provider = {
- "nntp",
- "USENET news via NNTP",
-
- "This is a provider for reading from and posting to"
- "USENET newsgroups.",
-
- "news",
-
- CAMEL_PROVIDER_IS_REMOTE,
-
- { 0, 0 },
-
- NULL
-};
-
-void
-camel_provider_module_init (CamelSession *session)
-{
- news_provider.object_types[CAMEL_PROVIDER_STORE] =
- camel_nntp_store_get_type();
-#ifdef NOTYET
- nntp_provider.object_types[CAMEL_PROVIDER_TRANSPORT] =
- camel_nntp_transport_get_type();
-#endif
-
- news_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal);
- nntp_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal);
-
- camel_session_register_provider (session, &news_provider);
- camel_session_register_provider (session, &nntp_provider);
-}
-
-
-
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
deleted file mode 100644
index 74952015a4..0000000000
--- a/camel/providers/nntp/camel-nntp-store.c
+++ /dev/null
@@ -1,513 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-nntp-store.c : class for an nntp store */
-
-/*
- *
- * Copyright (C) 2000 Helix Code, Inc. <toshok@helixcode.com>
- *
- * 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 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <dirent.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "libgnome/libgnome.h"
-
-#include "camel-folder-summary.h"
-#include "camel-nntp-store.h"
-#include "camel-nntp-folder.h"
-#include "camel-stream-buffer.h"
-#include "camel-stream-fs.h"
-#include "camel-exception.h"
-#include "camel-url.h"
-#include "string-utils.h"
-
-#define NNTP_PORT 119
-
-static CamelServiceClass *service_class = NULL;
-
-/* Returns the class for a CamelNNTPStore */
-#define CNNTPS_CLASS(so) CAMEL_NNTP_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-#define CNNTPF_CLASS(so) CAMEL_NNTP_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-
-static gboolean ensure_news_dir_exists (CamelNNTPStore *store);
-
-static gboolean
-nntp_store_connect (CamelService *service, CamelException *ex)
-{
- struct hostent *h;
- struct sockaddr_in sin;
- int fd;
- char *buf;
- CamelNNTPStore *store = CAMEL_NNTP_STORE (service);
-
- if (!ensure_news_dir_exists(store)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Could not open directory for news server: %s",
- strerror (errno));
- return FALSE;
- }
-
- if (!service_class->connect (service, ex))
- return FALSE;
-
- h = camel_service_gethost (service, ex);
- if (!h)
- return FALSE;
-
- sin.sin_family = h->h_addrtype;
- sin.sin_port = htons (service->url->port ? service->url->port : NNTP_PORT);
- memcpy (&sin.sin_addr, h->h_addr, sizeof (sin.sin_addr));
-
- fd = socket (h->h_addrtype, SOCK_STREAM, 0);
- if (fd == -1 ||
- connect (fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- "Could not connect to %s (port %s): %s",
- service->url->host, service->url->port,
- strerror(errno));
- if (fd > -1)
- close (fd);
- return FALSE;
- }
-
- store->ostream = camel_stream_fs_new_with_fd (fd);
- store->istream = camel_stream_buffer_new (store->ostream,
- CAMEL_STREAM_BUFFER_READ);
-
- /* Read the greeting */
- buf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (store->istream));
- if (!buf) {
- return -1;
- }
-
- g_free (buf);
-
- /* get a list of extensions that the server supports */
- if (CAMEL_NNTP_OK == camel_nntp_command (store, NULL, "LIST EXTENSIONS")) {
- char *ext_response = camel_nntp_command_get_additional_data(store);
-
- g_free (ext_response);
- }
-
- return TRUE;
-}
-
-static gboolean
-nntp_store_disconnect (CamelService *service, CamelException *ex)
-{
- CamelNNTPStore *store = CAMEL_NNTP_STORE (service);
-
- if (!service->connected)
- return TRUE;
-
- camel_nntp_command (store, NULL, "QUIT");
-
- if (store->newsrc)
- camel_nntp_newsrc_write (store->newsrc);
-
- if (!service_class->disconnect (service, ex))
- return FALSE;
-
- camel_object_unref (CAMEL_OBJECT (store->ostream));
- camel_object_unref (CAMEL_OBJECT (store->istream));
- store->ostream = NULL;
- store->istream = NULL;
- return TRUE;
-}
-
-static char *
-nntp_store_get_name (CamelService *service, gboolean brief)
-{
- /* Same info for long and brief... */
- return g_strdup_printf ("USENET news via %s", service->url->host);
-}
-
-static CamelFolder *
-nntp_store_get_folder (CamelStore *store, const gchar *folder_name,
- gboolean get_folder, CamelException *ex)
-{
- CamelNNTPFolder *new_nntp_folder;
- CamelFolder *new_folder;
- CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store);
-
- /* if we haven't already read our .newsrc, read it now */
- if (!nntp_store->newsrc)
- nntp_store->newsrc =
- camel_nntp_newsrc_read_for_server (CAMEL_SERVICE(store)->url->host);
-
- /* check if folder has already been created */
- /* call the standard routine for that when */
- /* it is done ... */
-
- new_nntp_folder = CAMEL_NNTP_FOLDER (camel_object_new (CAMEL_NNTP_FOLDER_TYPE));
- new_folder = CAMEL_FOLDER (new_nntp_folder);
-
- /* XXX We shouldn't be passing NULL here, but it's equivalent to
- * what was there before, and there's no
- * CamelNNTPFolder::get_subfolder yet anyway...
- */
- CF_CLASS (new_folder)->init (new_folder, store, NULL,
- folder_name, ".", FALSE, ex);
-
- return new_folder;
-}
-
-static char *
-nntp_store_get_folder_name (CamelStore *store, const char *folder_name,
- CamelException *ex)
-{
- return g_strdup (folder_name);
-}
-
-static void
-finalize (CamelObject *object)
-{
- CamelException ex;
-
- camel_exception_init (&ex);
- nntp_store_disconnect (CAMEL_SERVICE (object), &ex);
- camel_exception_clear (&ex);
-}
-
-static void
-camel_nntp_store_class_init (CamelNNTPStoreClass *camel_nntp_store_class)
-{
- CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS (camel_nntp_store_class);
- CamelServiceClass *camel_service_class = CAMEL_SERVICE_CLASS (camel_nntp_store_class);
-
- service_class = CAMEL_SERVICE_CLASS (camel_type_get_global_classfuncs (camel_service_get_type ()));
-
- /* virtual method overload */
- camel_service_class->connect = nntp_store_connect;
- camel_service_class->disconnect = nntp_store_disconnect;
- camel_service_class->get_name = nntp_store_get_name;
-
- camel_store_class->get_folder = nntp_store_get_folder;
- camel_store_class->get_folder_name = nntp_store_get_folder_name;
-}
-
-
-
-static void
-camel_nntp_store_init (gpointer object, gpointer klass)
-{
- CamelService *service = CAMEL_SERVICE (object);
-
- service->url_flags = CAMEL_SERVICE_URL_NEED_HOST;
-}
-
-CamelType
-camel_nntp_store_get_type (void)
-{
- static CamelType camel_nntp_store_type = CAMEL_INVALID_TYPE;
-
- if (camel_nntp_store_type == CAMEL_INVALID_TYPE) {
- camel_nntp_store_type = camel_type_register (CAMEL_STORE_TYPE, "CamelNNTPStore",
- sizeof (CamelNNTPStore),
- sizeof (CamelNNTPStoreClass),
- (CamelObjectClassInitFunc) camel_nntp_store_class_init,
- NULL,
- (CamelObjectInitFunc) camel_nntp_store_init,
- (CamelObjectFinalizeFunc) finalize);
- }
-
- return camel_nntp_store_type;
-}
-
-
-/**
- * camel_nntp_command: Send a command to a NNTP server.
- * @store: the NNTP store
- * @ret: a pointer to return the full server response in
- * @fmt: a printf-style format string, followed by arguments
- *
- * This command sends the command specified by @fmt and the following
- * arguments to the connected NNTP store specified by @store. It then
- * reads the server's response and parses out the status code. If
- * the caller passed a non-NULL pointer for @ret, camel_nntp_command
- * will set it to point to an buffer containing the rest of the
- * response from the NNTP server. (If @ret was passed but there was
- * no extended response, @ret will be set to NULL.) The caller must
- * free this buffer when it is done with it.
- *
- * Return value: one of CAMEL_NNTP_OK (command executed successfully),
- * CAMEL_NNTP_ERR (command encounted an error), or CAMEL_NNTP_FAIL
- * (a protocol-level error occurred, and Camel is uncertain of the
- * result of the command.)
- **/
-int
-camel_nntp_command (CamelNNTPStore *store, char **ret, char *fmt, ...)
-{
- char *cmdbuf, *respbuf;
- va_list ap;
- int status;
- int resp_code;
- CamelException *ex;
-
- va_start (ap, fmt);
- cmdbuf = g_strdup_vprintf (fmt, ap);
- va_end (ap);
-
- ex = camel_exception_new();
-
- /* make sure we're connected */
- if (store->ostream == NULL)
- nntp_store_connect (CAMEL_SERVICE (store), ex);
-
- if (camel_exception_get_id (ex)) {
- camel_exception_free (ex);
- return CAMEL_NNTP_FAIL;
- }
-
- /* Send the command */
- camel_stream_write (store->ostream, cmdbuf, strlen (cmdbuf));
- g_free (cmdbuf);
- camel_stream_write (store->ostream, "\r\n", 2);
-
- /* Read the response */
- respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (store->istream));
-
- if (!respbuf) {
- if (ret)
- *ret = g_strdup (g_strerror (errno));
- return CAMEL_NNTP_FAIL;
- }
-
- resp_code = atoi (respbuf);
-
- if (resp_code < 400)
- status = CAMEL_NNTP_OK;
- else if (resp_code < 500)
- status = CAMEL_NNTP_ERR;
- else
- status = CAMEL_NNTP_FAIL;
-
- if (ret) {
- *ret = strchr (respbuf, ' ');
- if (*ret)
- *ret = g_strdup (*ret + 1);
- }
- g_free (respbuf);
-
- return status;
-}
-
-/**
- * camel_nntp_command_get_additional_data: get "additional data" from
- * a NNTP command.
- * @store: the NNTP store
- *
- * This command gets the additional data returned by
- * This command gets the additional data returned by "multi-line" POP
- * commands, such as LIST, RETR, TOP, and UIDL. This command _must_
- * be called after a successful (CAMEL_NNTP_OK) call to
- * camel_nntp_command for a command that has a multi-line response.
- * The returned data is un-byte-stuffed, and has lines termined by
- * newlines rather than CR/LF pairs.
- *
- * Return value: the data, which the caller must free.
- **/
-char *
-camel_nntp_command_get_additional_data (CamelNNTPStore *store)
-{
- CamelStreamBuffer *stream = CAMEL_STREAM_BUFFER (store->istream);
- GPtrArray *data;
- char *buf;
- int i, status = CAMEL_NNTP_OK;
-
- data = g_ptr_array_new ();
- while (1) {
- buf = camel_stream_buffer_read_line (stream);
- if (!buf) {
- status = CAMEL_NNTP_FAIL;
- break;
- }
-
- if (!strcmp (buf, "."))
- break;
- if (*buf == '.')
- memmove (buf, buf + 1, strlen (buf));
- g_ptr_array_add (data, buf);
- }
-
- if (status == CAMEL_NNTP_OK) {
- /* Append an empty string to the end of the array
- * so when we g_strjoinv it, we get a "\n" after
- * the last real line.
- */
- g_ptr_array_add (data, "");
- g_ptr_array_add (data, NULL);
- buf = g_strjoinv ("\n", (char **)data->pdata);
- } else
- buf = NULL;
-
- for (i = 0; i < data->len - 2; i++)
- g_free (data->pdata[i]);
- g_ptr_array_free (data, TRUE);
-
- return buf;
-}
-
-void
-camel_nntp_store_subscribe_group (CamelStore *store,
- const gchar *group_name)
-{
- gchar *root_dir = camel_nntp_store_get_toplevel_dir(CAMEL_NNTP_STORE(store));
- char *ret = NULL;
- CamelException *ex = camel_exception_new();
-
- if (camel_exception_get_id (ex)) {
- g_free (root_dir);
- camel_exception_free (ex);
- return;
- }
-
- if (CAMEL_NNTP_OK == camel_nntp_command ( CAMEL_NNTP_STORE (store),
- &ret, "GROUP %s", group_name)) {
- /* we create an empty summary file here, so that when
- the group is opened we'll know we need to build it. */
- gchar *summary_file;
- int fd;
- summary_file = g_strdup_printf ("%s/%s-ev-summary", root_dir, group_name);
-
- fd = open (summary_file, O_CREAT | O_RDWR, 0666);
- close (fd);
-
- g_free (summary_file);
- }
- if (ret) g_free (ret);
-
- g_free (root_dir);
- camel_exception_free (ex);
-}
-
-void
-camel_nntp_store_unsubscribe_group (CamelStore *store,
- const gchar *group_name)
-{
- gchar *root_dir = camel_nntp_store_get_toplevel_dir(CAMEL_NNTP_STORE(store));
- gchar *summary_file;
-
- summary_file = g_strdup_printf ("%s/%s-ev-summary", root_dir, group_name);
- if (g_file_exists (summary_file))
- unlink (summary_file);
- g_free (summary_file);
-
- g_free (root_dir);
-}
-
-GList *
-camel_nntp_store_list_subscribed_groups(CamelStore *store)
-{
- GList *group_name_list = NULL;
- struct stat stat_buf;
- gint stat_error = 0;
- gchar *entry_name;
- gchar *full_entry_name;
- gchar *real_group_name;
- struct dirent *dir_entry;
- DIR *dir_handle;
- gchar *root_dir = camel_nntp_store_get_toplevel_dir(CAMEL_NNTP_STORE(store));
-
- dir_handle = opendir (root_dir);
- g_return_val_if_fail (dir_handle, NULL);
-
- /* read the first entry in the directory */
- dir_entry = readdir (dir_handle);
- while ((stat_error != -1) && (dir_entry != NULL)) {
-
- /* get the name of the next entry in the dir */
- entry_name = dir_entry->d_name;
- full_entry_name = g_strdup_printf ("%s/%s", root_dir, entry_name);
- stat_error = stat (full_entry_name, &stat_buf);
- g_free (full_entry_name);
-
- /* is it a normal file ending in -ev-summary ? */
- if ((stat_error != -1) && S_ISREG (stat_buf.st_mode)) {
- gboolean summary_suffix_found;
-
- real_group_name = string_prefix (entry_name, "-ev-summary",
- &summary_suffix_found);
-
- if (summary_suffix_found)
- /* add the folder name to the list */
- group_name_list = g_list_append (group_name_list,
- real_group_name);
- }
- /* read next entry */
- dir_entry = readdir (dir_handle);
- }
-
- closedir (dir_handle);
-
- return group_name_list;
-}
-
-gchar *
-camel_nntp_store_get_toplevel_dir (CamelNNTPStore *store)
-{
- CamelURL *url = CAMEL_SERVICE (store)->url;
- char *top_dir;
-
- g_assert(url != NULL);
-
- top_dir = g_strdup_printf( "%s/evolution/news/%s",
- g_get_home_dir (),
- url->host );
-
- return top_dir;
-}
-
-static gboolean
-ensure_news_dir_exists (CamelNNTPStore *store)
-{
- gchar *dir = camel_nntp_store_get_toplevel_dir (store);
- struct stat sb;
- int rv;
-
- rv = stat (dir, &sb);
- if (-1 == rv && errno != ENOENT) {
- g_free (dir);
- return FALSE;
- }
-
- if (S_ISDIR (sb.st_mode)) {
- g_free (dir);
- return TRUE;
- }
- else {
- rv = mkdir (dir, 0777);
- g_free (dir);
-
- if (-1 == rv)
- return FALSE;
- else
- return TRUE;
- }
-}
diff --git a/camel/providers/nntp/camel-nntp-store.h b/camel/providers/nntp/camel-nntp-store.h
deleted file mode 100644
index 3099f84962..0000000000
--- a/camel/providers/nntp/camel-nntp-store.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-nntp-store.h : class for an nntp store */
-
-/*
- *
- * Copyright (C) 2000 Helix Code, Inc. <toshok@helixcode.com>
- *
- * 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 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-
-#ifndef CAMEL_NNTP_STORE_H
-#define CAMEL_NNTP_STORE_H 1
-
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus }*/
-
-#include "camel-store.h"
-#include "camel-nntp-newsrc.h"
-
-#define CAMEL_NNTP_STORE_TYPE (camel_nntp_store_get_type ())
-#define CAMEL_NNTP_STORE(obj) (CAMEL_CHECK_CAST((obj), CAMEL_NNTP_STORE_TYPE, CamelNNTPStore))
-#define CAMEL_NNTP_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_NNTP_STORE_TYPE, CamelNNTPStoreClass))
-#define IS_CAMEL_NNTP_STORE(o) (CAMEL_CHECK_TYPE((o), CAMEL_NNTP_STORE_TYPE))
-
-
-typedef struct {
- CamelStore parent_object;
-
-#define CAMEL_NNTP_EXT_XOVER 0x01
- guint32 extensions;
-
- CamelNNTPNewsrc *newsrc;
-
- CamelStream *istream, *ostream;
-} CamelNNTPStore;
-
-
-
-typedef struct {
- CamelStoreClass parent_class;
-
-} CamelNNTPStoreClass;
-
-
-/* public methods */
-void camel_nntp_store_open (CamelNNTPStore *store, CamelException *ex);
-void camel_nntp_store_close (CamelNNTPStore *store, gboolean expunge,
- CamelException *ex);
-
-void camel_nntp_store_subscribe_group (CamelStore *store, const gchar *group_name);
-void camel_nntp_store_unsubscribe_group (CamelStore *store, const gchar *group_name);
-GList *camel_nntp_store_list_subscribed_groups(CamelStore *store);
-
-gchar *camel_nntp_store_get_toplevel_dir (CamelNNTPStore *store);
-
-/* support functions */
-enum { CAMEL_NNTP_OK, CAMEL_NNTP_ERR, CAMEL_NNTP_FAIL };
-int camel_nntp_command (CamelNNTPStore *store, char **ret, char *fmt, ...);
-char *camel_nntp_command_get_additional_data (CamelNNTPStore *store);
-
-/* Standard Camel function */
-CamelType camel_nntp_store_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* CAMEL_NNTP_STORE_H */
-
-
diff --git a/camel/providers/nntp/camel-nntp-utils.c b/camel/providers/nntp/camel-nntp-utils.c
deleted file mode 100644
index e0a331f2a7..0000000000
--- a/camel/providers/nntp/camel-nntp-utils.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-nntp-utils.c : utilities used by the nntp code. */
-
-/*
- * Author : Chris Toshok <toshok@helixcode.com>
- *
- * Copyright (C) 2000 Helix Code .
- *
- * 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 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#include "camel-folder-summary.h"
-#include "camel-nntp-folder.h"
-#include "camel-nntp-store.h"
-#include "camel-nntp-utils.h"
-#include "camel-stream-buffer.h"
-#include "camel-stream-mem.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-static void
-get_XOVER_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
- int first_message, int last_message, CamelException *ex)
-{
- int status;
- CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
-
- status = camel_nntp_command (nntp_store, NULL,
- "XOVER %d-%d",
- first_message,
- last_message);
-
- if (status == CAMEL_NNTP_OK) {
- CamelStream *nntp_istream = nntp_store->istream;
- gboolean done = FALSE;
-
- while (!done) {
- char *line;
-
- line = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER ( nntp_istream ));
-
- if (*line == '.') {
- done = TRUE;
- }
- else {
- CamelMessageInfo *new_info = g_new0(CamelMessageInfo, 1);
- char **split_line = g_strsplit (line, "\t", 7);
-
- new_info->subject = g_strdup(split_line[1]);
- new_info->from = g_strdup(split_line[2]);
- new_info->to = g_strdup(nntp_folder->group_name);
- new_info->date_sent = header_decode_date(split_line[3], NULL);
-#if 0
- /* XXX do we need to fill in both dates? */
- new_info->headers.date_received = g_strdup(split_line[3]);
-#endif
- new_info->size = atoi(split_line[5]);
- new_info->uid = g_strdup_printf ("%s,%s", split_line[0], split_line[4]);
- new_info->message_id = g_strdup(split_line[4]);
- g_strfreev (split_line);
-
- if (camel_nntp_newsrc_article_is_read (nntp_store->newsrc,
- nntp_folder->group_name,
- atoi (split_line[0])))
- new_info->flags |= CAMEL_MESSAGE_SEEN;
-
- camel_folder_summary_add (nntp_folder->summary, new_info);
- }
- g_free (line);
- }
- }
-}
-
-#if 0
-static GArray*
-get_HEAD_headers(CamelNNTPStore *nntp_store, CamelFolder *folder,
- int first_message, int last_message, CamelException *ex)
-{
- int i;
- int status;
-
- for (i = first_message; i < last_message; i ++) {
- status = camel_nntp_command (nntp_store, NULL,
- "HEAD %d", i);
-
- if (status == CAMEL_NNTP_OK) {
- gboolean done = FALSE;
- char *buf;
- int buf_len;
- int buf_alloc;
- int h;
- CamelStream *header_stream;
- GArray *header_array;
- CamelStream *nntp_istream;
- CamelMessageInfo *new_info = g_new0(CamelMessageInfo, 1);
-
- buf_alloc = 2048;
- buf_len = 0;
- buf = g_malloc(buf_alloc);
- done = FALSE;
-
- buf[0] = 0;
-
- nntp_istream = nntp_store->istream;
-
- while (!done) {
- char *line;
- int line_length;
-
- line = camel_stream_buffer_read_line (
- CAMEL_STREAM_BUFFER ( nntp_istream ));
- line_length = strlen ( line );
-
- if (*line == '.') {
- done = TRUE;
- }
- else {
- if (buf_len + line_length > buf_alloc) {
- buf_alloc *= 2;
- buf = g_realloc (buf, buf_alloc);
- }
- strcat(buf, line);
- strcat(buf, "\n");
- buf_len += strlen(line);
- g_free (line);
- }
- }
-
- /* create a stream from which to parse the headers */
- header_stream = camel_stream_mem_new_with_buffer(buf,
- buf_len,
- CAMEL_STREAM_MEM_READ);
-
- header_array = get_header_array_from_stream (header_stream);
-
- memset (&info, 0, sizeof(info));
-
- for (h = 0; h < header_array->len; h ++) {
- Rfc822Header *header = &((Rfc822Header*)header_array->data)[h];
- if (!g_strcasecmp(header->name, "From"))
- new_info->from = g_strdup(header->value);
- else if (!g_strcasecmp(header->name, "To"))
- new_info->to = g_strdup(header->value);
- else if (!g_strcasecmp(header->name, "Subject"))
- new_info->subject = g_strdup(header->value);
- else if (!g_strcasecmp(header->name, "Message-ID")) {
- new_info->uid = g_strdup_printf("%d,%s", i, header->value);
- new_info->message_id = g_strdup(header->value);
- }
- else if (!g_strcasecmp(header->name, "Date")) {
- new_info->date_sent = header_decode_date (header->value);
-#if 0
- new_info->date_sent = g_strdup(header->value);
- new_info->date_received = g_strdup(header->value);
-#endif
- }
- }
-
- camel_folder_summary_add (nntp_folder->summary, new_info);
- }
- else if (status == CAMEL_NNTP_FAIL) {
- /* nasty things are afoot */
- g_warning ("failure doing HEAD\n");
- break;
- }
- }
-}
-#endif
-
-void
-camel_nntp_get_headers (CamelStore *store,
- CamelNNTPFolder *nntp_folder,
- CamelException *ex)
-{
- CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store);
- CamelFolder *folder = CAMEL_FOLDER (nntp_folder);
- char *ret;
- int first_message, nb_message, last_message;
- int status;
-
- status = camel_nntp_command (nntp_store, &ret,
- "GROUP %s", CAMEL_NNTP_FOLDER (folder)->group_name);
-
- sscanf (ret, "%d %d %d", &nb_message, &first_message, &last_message);
- g_free (ret);
-
- if (status != CAMEL_NNTP_OK) {
- /* XXX throw invalid group exception */
- printf ("invalid group\n");
- return;
- }
-
-#if 0
- if (nntp_store->extensions & CAMEL_NNTP_EXT_XOVER) {
-#endif
- get_XOVER_headers (nntp_store, folder, first_message, last_message, ex);
-#if 0
- }
- else {
- get_HEAD_headers (nntp_store, folder, first_message, last_message, ex);
- }
-#endif
-}
-
diff --git a/camel/providers/nntp/camel-nntp-utils.h b/camel/providers/nntp/camel-nntp-utils.h
deleted file mode 100644
index f28697c744..0000000000
--- a/camel/providers/nntp/camel-nntp-utils.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-nntp-utils.h : Utilities for the NNTP provider */
-
-/*
- *
- * Author : Chris Toshok <toshok@helixcode.com>
- *
- * Copyright (C) 1999 Helix Code .
- *
- * 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 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-
-#ifndef CAMEL_NNTP_UTILS_H
-#define CAMEL_NNTP_UTILS_H 1
-
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus }*/
-
-void camel_nntp_get_headers (CamelStore *store, CamelNNTPFolder *nntp_folder, CamelException *ex);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* CAMEL_NNTP_UTILS_H */
diff --git a/camel/providers/nntp/libcamelnntp.urls b/camel/providers/nntp/libcamelnntp.urls
deleted file mode 100644
index dee2e70f14..0000000000
--- a/camel/providers/nntp/libcamelnntp.urls
+++ /dev/null
@@ -1,2 +0,0 @@
-news
-nntp
diff --git a/camel/providers/nntp/test-newsrc.c b/camel/providers/nntp/test-newsrc.c
deleted file mode 100644
index c4b985e565..0000000000
--- a/camel/providers/nntp/test-newsrc.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <stdio.h>
-#include <glib.h>
-#include "camel-nntp-newsrc.h"
-
-int
-main(int argc, char *argv[])
-{
- CamelNNTPNewsrc *newsrc = camel_nntp_newsrc_read_for_server (argv[1]);
- camel_nntp_newsrc_write_to_file (newsrc, stdout);
-}