text parameter declared const

1999-08-28  bertrand  <Bertrand.Guiheneuf@aful.org>

	* camel/camel-mime-part.c (camel_mime_part_set_text):
	text parameter declared const

	* camel/camel-mime-part-utils.c (camel_mime_part_store_stream_in_buffer):
	actually test correctly nb_bytes_read_chunk is >0

	* camel/gstring-util.c:
	* camel/gmime-content-field.c:
	* camel/providers/MH/camel-mh-folder.c:
	* camel/camel-stream-fs.c:
	include string.h

	* camel/camel-stream-mem.c (_write): return
	the numver of written bytes.

	* camel/camel-stream-buffered-fs.c (_eos):
	return sthg

	* camel/camel-stream.c (default_camel_seek):
	return something.

* Started to work on new recipient code.
* fixed various leaks.

svn path=/trunk/; revision=1146
This commit is contained in:
bertrand
1999-08-29 15:57:47 +00:00
committed by Bertrand Guiheneuf
parent e826255bf1
commit 68a9dad22b
17 changed files with 237 additions and 24 deletions

View File

@ -1,3 +1,26 @@
1999-08-28 bertrand <Bertrand.Guiheneuf@aful.org>
* camel/camel-mime-part.c (camel_mime_part_set_text):
text parameter declared const
* camel/camel-mime-part-utils.c (camel_mime_part_store_stream_in_buffer):
actually test correctly nb_bytes_read_chunk is >0
* camel/gstring-util.c:
* camel/gmime-content-field.c:
* camel/providers/MH/camel-mh-folder.c:
* camel/camel-stream-fs.c:
include string.h
* camel/camel-stream-mem.c (_write): return
the numver of written bytes.
* camel/camel-stream-buffered-fs.c (_eos):
return sthg
* camel/camel-stream.c (default_camel_seek):
return something.
1999-08-26 bertrand <Bertrand.Guiheneuf@aful.org>
* camel/camel-mime-part.c (_get_content_object):

View File

@ -39,10 +39,10 @@ camel_mime_part_construct_headers_from_stream (CamelMimePart *mime_part,
Rfc822Header *cur_header;
int i;
CAMEL_LOG_FULL_DEBUG ("CamelMimePart:: "
CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils:: "
"Entering _construct_headers_from_stream\n");
g_assert (stream);
CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_headers_from_stream "
CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::construct_headers_from_stream "
"parsing headers\n");
/*
* parse all header lines
@ -58,8 +58,8 @@ camel_mime_part_construct_headers_from_stream (CamelMimePart *mime_part,
g_array_free (header_array, TRUE);
CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_headers_from_stream "
"headers parsed \n");
CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::construct_headers_from_stream "
"headers parsed. Leaving \n");
}
}
@ -79,7 +79,7 @@ camel_mime_part_construct_content_from_stream (CamelMimePart *mime_part,
/*
* find content mime type
*/
CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_content_from_stream "
CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::construct_content_from_stream "
"parsing content\n");
content_type = camel_mime_part_get_content_type (mime_part);
@ -91,7 +91,7 @@ camel_mime_part_construct_content_from_stream (CamelMimePart *mime_part,
* using text/plain is the default
*/
if (!mime_type) {
CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_content_from_stream "
CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::construct_content_from_stream "
"content type field not found "
"using default \"text/plain\"\n");
mime_type = g_strdup ("text/plain");
@ -105,7 +105,7 @@ camel_mime_part_construct_content_from_stream (CamelMimePart *mime_part,
content_object_type =
data_wrapper_repository_get_data_wrapper_type (mime_type);
CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_content_from_stream content"
CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::construct_content_from_stream content"
" type object type used: %s\n",
gtk_type_name (content_object_type));
@ -124,10 +124,10 @@ camel_mime_part_construct_content_from_stream (CamelMimePart *mime_part,
gtk_object_unref (GTK_OBJECT (content_object));
CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_from_stream "
CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::construct_from_stream "
"content parsed\n");
CAMEL_LOG_FULL_DEBUG ("CamelMimePart:: Leaving _construct_from_stream\n");
CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils:: Leaving _construct_from_stream\n");
}
@ -141,6 +141,8 @@ camel_mime_part_store_stream_in_buffer (CamelMimePart *mime_part,
GByteArray *buffer;
#define STREAM_READ_CHUNK_SZ 100
CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::store_stream_in_buffer entering\n");
if (mime_part->temp_message_buffer == NULL)
mime_part->temp_message_buffer = g_byte_array_new ();
@ -152,7 +154,7 @@ camel_mime_part_store_stream_in_buffer (CamelMimePart *mime_part,
STREAM_READ_CHUNK_SZ);
nb_bytes_read_total += nb_bytes_read_chunk;
while (nb_bytes_read_chunk) {
while (nb_bytes_read_chunk >0) {
g_byte_array_set_size (buffer, nb_bytes_read_total + STREAM_READ_CHUNK_SZ);
nb_bytes_read_chunk = camel_stream_read (stream,
buffer->data + nb_bytes_read_total,
@ -161,5 +163,6 @@ camel_mime_part_store_stream_in_buffer (CamelMimePart *mime_part,
}
g_byte_array_set_size (buffer, nb_bytes_read_total);
CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::store_stream_in_buffer entering\n");
}

View File

@ -575,11 +575,12 @@ _get_content_object (CamelMedium *medium)
CamelMimePart *mime_part = CAMEL_MIME_PART (medium);
CamelStream *stream;
CAMEL_LOG_FULL_DEBUG ("CamelMimePart::get_content_object entering\n");
/*
* test if there is not pending content stored in the
* temporary buffer
*/
if ((!medium->content ) || (mime_part->temp_message_buffer)) {
if ((!medium->content ) && (mime_part->temp_message_buffer)) {
stream = camel_stream_mem_new_with_buffer (mime_part->temp_message_buffer,
CAMEL_STREAM_MEM_READ);
camel_mime_part_construct_content_from_stream (mime_part, stream);
@ -587,8 +588,13 @@ _get_content_object (CamelMedium *medium)
* Beware : this will destroy the temp buffer as well
*/
gtk_object_unref (GTK_OBJECT (stream));
} else {
CAMEL_LOG_FULL_DEBUG ("CamelMimePart::get_content_object part has a pointer "
"to a content object as well as a temp buffer\n");
}
CAMEL_LOG_FULL_DEBUG ("CamelMimePart::get_content_object leaving\n");
return parent_class->get_content_object (medium);
}
@ -758,10 +764,11 @@ _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
CamelMimePart *mime_part = CAMEL_MIME_PART (data_wrapper);
CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_from_stream entering\n");
camel_mime_part_construct_headers_from_stream (mime_part, stream);
camel_mime_part_store_stream_in_buffer (mime_part, stream);
CAMEL_LOG_FULL_DEBUG ("CamelMimePart:: Leaving _construct_from_stream\n");
CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_from_stream leaving\n");
}
@ -781,7 +788,7 @@ _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
*
**/
void
camel_mime_part_set_text (CamelMimePart *camel_mime_part, gchar *text)
camel_mime_part_set_text (CamelMimePart *camel_mime_part, const gchar *text)
{
CamelSimpleDataWrapper *simple_data_wrapper;
CamelMedium *medium = CAMEL_MEDIUM (camel_mime_part);

View File

@ -125,7 +125,7 @@ const GList *camel_mime_part_get_header_lines (CamelMimePart *mime_part);
GMimeContentField *camel_mime_part_get_content_type (CamelMimePart *mime_part);
/* utility functions */
void camel_mime_part_set_text (CamelMimePart *camel_mime_part, gchar *text);
void camel_mime_part_set_text (CamelMimePart *camel_mime_part, const gchar *text);

112
camel/camel-recipient.c Normal file
View File

@ -0,0 +1,112 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-recipient.h : handle recipients (addresses) and recipiemt lists */
/*
*
* Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> .
*
* 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 "glib.h"
#include "hash-table-utils.h"
CamelRecipientTable *
camel_recipient_new ()
{
CamelRecipientTable *recipient_table;
recipient_table = g_new0 (CamelRecipientTable, 1);
recipient_table->recipient_table = g_hash_table_new (g_strcase_cmp, g_strcase_hash);
recipient_table->ref_count = 1;
return recipient_table;
}
void
camel_recipient_ref (CamelRecipientTable *recipient_table)
{
g_return_if_fail (recipient_table);
recipient_table->ref_count += 1;
}
static void
_free_recipient_list (gpointer key, gpointer value, gpointer user_data)
{
GList *recipient_list = (GList *)value;
gchar *recipient_name = (gchar *key);
while (recipient_list) {
g_free (recipient_list->data);
recipient_list = recipient_list->next
}
g_free (recipient_name);
}
void
camel_recipient_free (CamelRecipientTable *recipient_table)
{
g_return_if_fail (recipient_table);
/* free each recipient list */
g_hash_table_foreach (recipient_table->recipient_table, _free_recipient_list);
g_hash_table_destroy (recipient_table->recipient_table);
}
void
camel_recipient_unref (CamelRecipientTable *recipient_table)
{
g_return_if_fail (recipient_table);
recipient_table->ref_count -= 1;
if (recipient_table->ref_count <1)
camel_recipient_free (recipient_table);
}
void
camel_recipient_add (CamelRecipientTable *recipient_table,
const gchar *recipient_type,
const gchar *recipient)
{
GList *recipients_list;
GList *existent_list;
/* see if there is already a list for this recipient type */
existent_list = (GList *)g_hash_table_lookup (recipient_table->recipient_table, recipient_type);
/* append the new recipient to the recipient list
if the existent_list is NULL, then a new GList is
automagically created */
recipients_list = g_list_append (existent_list, (gpointer)recipient);
if (!existent_list) /* if there was no recipient of this type create the section */
g_hash_table_insert (mime_message->recipients, recipient_type, recipients_list);
else
g_free (recipient_type);
}

55
camel/camel-recipient.h Normal file
View File

@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-recipient.h : handle recipients (addresses) and recipiemt lists */
/*
*
* Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@aful.org> .
*
* 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_RECIPIENT_H
#define CAMEL_RECIPIENT_H 1
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus }*/
typedef struct {
GHashTable *recipient_table;
gint ref_count;
} CamelRecipient;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* CAMEL_RECIPIENT_H */

View File

@ -20,6 +20,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
#include <config.h>
#include "camel-stream-buffered-fs.h"
#include <sys/types.h>
@ -241,6 +243,7 @@ _available (CamelStream *stream)
static gboolean
_eos (CamelStream *stream)
{
return FALSE;
}

View File

@ -27,6 +27,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include "camel-log.h"
static CamelStreamClass *parent_class=NULL;
@ -295,6 +296,7 @@ static gint
_available (CamelStream *stream)
{
g_warning ("Not implemented yet");
return -1;
}
@ -310,6 +312,7 @@ static gboolean
_eos (CamelStream *stream)
{
g_warning ("Not implemented yet");
return FALSE;
}

View File

@ -188,7 +188,8 @@ _write (CamelStream *stream, const gchar *buffer, gint n)
g_return_val_if_fail (camel_stream_mem->position>=0, -1);
camel_stream_mem->buffer = g_byte_array_append (camel_stream_mem->buffer, (const guint8 *)buffer, n);
camel_stream_mem->position += n;
return n;
}
@ -219,6 +220,7 @@ static gint
_available (CamelStream *stream)
{
g_warning ("Not implemented yet");
return -1;
}
@ -234,6 +236,7 @@ static gboolean
_eos (CamelStream *stream)
{
g_warning ("Not implemented yet");
return FALSE;
}

View File

@ -46,6 +46,7 @@ static gint
default_camel_seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy)
{
/* nothing */
return -1;
}
static void

View File

@ -25,7 +25,7 @@
#include "gmime-content-field.h"
#include "string-utils.h"
#include "camel-log.h"
#include <string.h>
/**

View File

@ -26,7 +26,7 @@
#include <config.h>
#include "gstring-util.h"
#include "camel-log.h"
#include <string.h>
/**
* g_string_equals : test if two string are equal

View File

@ -28,6 +28,7 @@
#include <fcntl.h>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "camel-mh-folder.h"
#include "camel-mh-store.h"

View File

@ -43,7 +43,7 @@ main (int argc, char**argv)
multipart = camel_multipart_new ();
body_part = camel_mime_body_part_new ();
camel_mime_part_set_text (CAMEL_MIME_PART (body_part), g_strdup ("This is a test.\nThis is only a test.\n"));
camel_mime_part_set_text (CAMEL_MIME_PART (body_part), "This is a test.\nThis is only a test.\n");
camel_multipart_add_part (multipart, body_part);
camel_medium_set_content_object (CAMEL_MEDIUM (message), CAMEL_DATA_WRAPPER (multipart));
@ -62,5 +62,6 @@ main (int argc, char**argv)
gtk_object_unref (GTK_OBJECT (body_part));
printf ("Test1 finished\n");
return 1;
}

View File

@ -24,5 +24,6 @@ main (int argc, char**argv)
printf ("Type found %s\n", gtk_type_name (type) );
printf ("Test3 finished\n");
return 1;
}

View File

@ -36,7 +36,7 @@ main (int argc, char**argv)
printf ("\n------------- Listing root Mh folder subfolders --------\n");
while (mh_subfolders_name) {
printf ("\t\"%s\"\n", mh_subfolders_name->data);
printf ("\t\"%s\"\n", (gchar *)mh_subfolders_name->data);
mh_subfolders_name = mh_subfolders_name->next;
}
printf ("--------------------------------------------------------\n\n");
@ -44,7 +44,7 @@ main (int argc, char**argv)
inbox_folder = camel_store_get_folder (store, "inbox");
if (!inbox_folder) {
printf ("** Error: could not get inbox folder from store\n");
return;
return 1;
}
/* test existence */
@ -53,7 +53,7 @@ main (int argc, char**argv)
printf ("MH folder inbox exists, continuing tests\n");
else {
printf ("MH folder inbox does not exist. Stopping \n");
return;
return 1;
}
printf ("\n Inbox folder contains %d messages\n", camel_folder_get_message_count (inbox_folder));
@ -62,7 +62,7 @@ main (int argc, char**argv)
printf ("--------------------------------------------------------\n\n");
return 1;
}

View File

@ -20,5 +20,5 @@ main (int argc, char**argv)
new_provider = camel_provider_register_as_module ("../camel/providers/MH/.libs/libcamelmh.so");
return 1;
}