/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* camel-simple-data-wrapper.c : simple implementation of a data wrapper */ /* store the data in a glib byte array */ /* * * Author : * Bertrand Guiheneuf * * Copyright 1999, 2000 HelixCode (http://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 #include "camel-simple-data-wrapper.h" #include "camel-simple-data-wrapper-stream.h" #include "camel-log.h" static CamelDataWrapperClass *parent_class=NULL; /* Returns the class for a CamelDataWrapper */ #define CSDW_CLASS(so) CAMEL_SIMPLE_DATA_WRAPPER_CLASS (GTK_OBJECT(so)->klass) static void _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); static void _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); static void _finalize (GtkObject *object); static CamelStream * _get_stream (CamelDataWrapper *data_wrapper); static CamelStream * _get_output_stream (CamelDataWrapper *data_wrapper); static void camel_simple_data_wrapper_class_init (CamelSimpleDataWrapperClass *camel_simple_data_wrapper_class) { CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_simple_data_wrapper_class); GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_data_wrapper_class); parent_class = gtk_type_class (camel_data_wrapper_get_type ()); /* virtual method definition */ /* virtual method overload */ camel_data_wrapper_class->write_to_stream = _write_to_stream; camel_data_wrapper_class->construct_from_stream = _construct_from_stream; camel_data_wrapper_class->get_output_stream = _get_output_stream; camel_data_wrapper_class->get_stream = _get_stream; gtk_object_class->finalize = _finalize; } static void camel_simple_data_wrapper_init (CamelSimpleDataWrapper *wrapper) { wrapper->stream = NULL; } GtkType camel_simple_data_wrapper_get_type (void) { static GtkType camel_simple_data_wrapper_type = 0; if (!camel_simple_data_wrapper_type) { GtkTypeInfo camel_simple_data_wrapper_info = { "CamelSimpleDataWrapper", sizeof (CamelSimpleDataWrapper), sizeof (CamelSimpleDataWrapperClass), (GtkClassInitFunc) camel_simple_data_wrapper_class_init, (GtkObjectInitFunc) camel_simple_data_wrapper_init, /* reserved_1 */ NULL, /* reserved_2 */ NULL, (GtkClassInitFunc) NULL, }; camel_simple_data_wrapper_type = gtk_type_unique (camel_data_wrapper_get_type (), &camel_simple_data_wrapper_info); } return camel_simple_data_wrapper_type; } static void _finalize (GtkObject *object) { CamelSimpleDataWrapper *simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (object); CAMEL_LOG_FULL_DEBUG ("Entering CamelMimePart::finalize\n"); if (simple_data_wrapper->byte_array) g_byte_array_free (simple_data_wrapper->byte_array, TRUE); GTK_OBJECT_CLASS (parent_class)->finalize (object); CAMEL_LOG_FULL_DEBUG ("Leaving CamelMimePart::finalize\n"); } /** * camel_simple_data_wrapper_new: create a new CamelSimpleDataWrapper object * * * * Return value: **/ CamelSimpleDataWrapper * camel_simple_data_wrapper_new (void) { CamelSimpleDataWrapper *simple_data_wrapper; CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering new()\n"); simple_data_wrapper = (CamelSimpleDataWrapper *)gtk_type_new (CAMEL_SIMPLE_DATA_WRAPPER_TYPE); CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Leaving new()\n"); return simple_data_wrapper; } static void _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) { CamelSimpleDataWrapper *simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper); GByteArray *array; CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering _write_to_stream\n"); g_assert (data_wrapper); g_assert (stream); g_assert (simple_data_wrapper->byte_array); array = simple_data_wrapper->byte_array; if (array->len) camel_stream_write (stream, (gchar *)array->data, array->len); CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Leaving _write_to_stream\n"); } #define _CMSDW_TMP_BUF_SIZE 100 static void _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) { CamelSimpleDataWrapper *simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper); gint nb_bytes_read; static gchar *tmp_buf; GByteArray *array; CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering _construct_from_stream\n"); g_assert (data_wrapper); g_assert (stream); if (!tmp_buf) { CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::construct_from_stream allocating new temp buffer " "with %d bytes\n", _CMSDW_TMP_BUF_SIZE); tmp_buf = g_new (gchar, _CMSDW_TMP_BUF_SIZE); } array = simple_data_wrapper->byte_array; if (array) { CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::construct_from_stream freeing old byte array\n"); g_byte_array_free (array, FALSE); } array = g_byte_array_new (); CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::construct_from_stream new byte array address:%p\n", array); simple_data_wrapper->byte_array = array; nb_bytes_read = camel_stream_read (stream, tmp_buf, _CMSDW_TMP_BUF_SIZE); while (nb_bytes_read>0) { CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::construct_from_stream read %d bytes from stream\n", nb_bytes_read); if (nb_bytes_read>0) g_byte_array_append (array, tmp_buf, nb_bytes_read); nb_bytes_read = camel_stream_read (stream, tmp_buf, _CMSDW_TMP_BUF_SIZE); }; CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Leaving _construct_from_stream\n"); } /** * camel_simple_data_wrapper_set_text: set some text as data wrapper content * @simple_data_wrapper: SimpleDataWrapper object * @text: the text to use * * Utility routine used to set up the content of a SimpleDataWrapper object * to be a character string. **/ void camel_simple_data_wrapper_set_text (CamelSimpleDataWrapper *simple_data_wrapper, const gchar *text) { GByteArray *array; CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering set_text\n"); array = simple_data_wrapper->byte_array; if (array) { CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::set_text freeing old byte array\n"); g_byte_array_free (array, FALSE); } array = g_byte_array_new (); simple_data_wrapper->byte_array = array; g_byte_array_append (array, text, strlen (text)); CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper:: Entering set_text\n"); } static CamelStream * _get_stream (CamelDataWrapper *data_wrapper) { CamelSimpleDataWrapper *simple_data_wrapper; simple_data_wrapper = CAMEL_SIMPLE_DATA_WRAPPER (data_wrapper); if (simple_data_wrapper->stream == NULL) { CamelStream *s; s = camel_simple_data_wrapper_stream_new (simple_data_wrapper); simple_data_wrapper->stream = s; } return simple_data_wrapper->stream; } static CamelStream * _get_output_stream (CamelDataWrapper *data_wrapper) { CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::get_output_stream leaving\n"); return camel_data_wrapper_get_input_stream (data_wrapper); CAMEL_LOG_FULL_DEBUG ("CamelSimpleDataWrapper::get_output_stream leaving\n"); } 1-252-2/+3 * Use EVOLUTION_CALENDAR_CFLAGS and EVOLUTION_CALENDAR_LIBS.Ettore Perazzoli2002-01-252-10/+13 * Clean up some of the Makefiles so we dont' link every library multipleEttore Perazzoli2002-01-251-113/+123 * cal-client needs bonobo-conf nowJP Rosevear2001-12-194-188/+195 * Updated docs for repeating alarms.Federico Mena Quintero2001-10-309-226/+425 * use install hook instead of install rule to guarantee we run afterJP Rosevear2001-09-151-38/+30 * The finaleKjartan Maraas2001-08-174-636/+0 * Missed thisKjartan Maraas2001-08-171-9/+0 * Here go the restKjartan Maraas2001-08-1733-19802/+0 * I have deleted all of these files as they are being moved to the help directory.Aaron Weber2001-08-1746-8967/+0 * Nuke the old no docsKjartan Maraas2001-08-1746-8946/+0 * Back to building develKjartan Maraas2001-08-171-1/+1 * Small fix to build. Small fix. Remove an extra space. Same here. And here.Kjartan Maraas2001-08-166-10/+17 * Remove the other copy of the figuresKjartan Maraas2001-08-1623-0/+0 * Updated one line about bullet points.Kevin Breit2001-08-162-1/+5 * Added beginnings of a Norwegian translation. Forgot to add this. KindaKjartan Maraas2001-08-1649-1/+9087 * s/fig/figures/ Make it use the sgmldocs.make framework.Kjartan Maraas2001-08-1611-96/+69 * Moved imagesKjartan Maraas2001-08-1623-0/+0 * Commented out menuref. Commented out menuref. commented out menuref.Aaron Weber2001-08-155-17/+21 * Added missing ;'s after entities. s/en/C in Language. Add missing ;. SameKjartan Maraas2001-08-125-5/+12 * New files.Aaron Weber2001-08-112-0/+0 * Switched all images in entire document to *not* use file extensions, soAaron Weber2001-08-115-19/+22 * Made sharing tip an orderedlist.Aaron Weber2001-08-103-25/+66 * sync - FedericoFederico Mena Quintero2001-08-093-5/+38 * Add information about sharing mailbox files.Kevin Breit2001-08-092-1/+11 * Add information about gathering actions.Kevin Breit2001-08-042-2/+18 * Added a <tip> for scrolling through mails.Kevin Breit2001-08-032-0/+12 * Remove the copying of the index.sgml file which doesn't seem to beEttore Perazzoli2001-07-312-1/+6 * Fixed some breakage Aaron caused.Kevin Breit2001-07-312-2/+8 * revised.Aaron Weber2001-07-274-264/+427 * Reworded a few questions.Aaron Weber2001-07-242-6/+8 * Pulled instance of config-setupassist.sgml to make stuff build right.Kevin Breit2001-07-242-1/+4 * validated.Aaron Weber2001-07-244-212/+13 * Minor revisions.Aaron Weber2001-07-249-480/+411 * Changed background transparency.Aaron Weber2001-07-241-0/+0 * Fixed the first time druid stuff a little more.Kevin Breit2001-07-212-8/+14 * Updated slightly for new design.Kevin Breit2001-07-162-3/+15 * Added lots of good stuff with the first time druid.Kevin Breit2001-07-141-0/+255 * Fixing typo.Aaron Weber2001-07-131-1/+2 * svn path=/trunk/; revision=11063Aaron Weber2001-07-132-4/+71 * Add these files because we're pretty sure gtk-doc needs them.Peter Williams2001-07-122-0/+34 * Clean up make dist.Peter Williams2001-07-126-38/+50 * validation on usage-mainwindow and usage-contact.Aaron Weber2001-07-123-18/+18 * More edits.Kevin Breit2001-07-1212-211/+299 * ShhKjartan Maraas2001-07-125-116/+188 * shhKjartan Maraas2001-07-121-0/+1 * Small changes to preface.Aaron Weber2001-07-112-14/+10 * validation.Aaron Weber2001-07-111-1/+2 * Added <application> tagsKevin Breit2001-07-105-7/+15 * EditingKevin Breit2001-07-106-39/+52 * Validation.Aaron Weber2001-07-092-6/+8 * Mention UNMATCHEDKevin Breit2001-07-093-3/+24 * Spell checkKevin Breit2001-07-072-10/+12 * Spell checkKevin Breit2001-07-073-54/+58 * Added orderedlists.Kevin Breit2001-07-062-21/+84 * Added orderedlists.Kevin Breit2001-07-062-94/+132 * Added orderedlists.Kevin Breit2001-07-062-394/+484 * Chris pointed out an error in the DB versioning question.Aaron Weber2001-07-061-2/+1 * Put in lots of orderedlists...more SGML, less for the user to read.Kevin Breit2001-07-043-366/+650 * Updated slightly.Jeffrey Stedfast2001-07-033-85/+164 * Created its own file.Kevin Breit2001-07-037-406/+353 * Pulled organizing stuff, made its own file.Kevin Breit2001-07-018-1415/+1409 * Added evolution-alarm-notify.Federico Mena Quintero2001-07-011-1/+2 * Revised move/rename/copy questions, now that these functions work.Aaron Weber2001-06-272-35/+13 * Now that bug-buddy works with our bugzilla, update faq to reflect it.Aaron Weber2001-06-262-23/+26 * Put config-encryption in usage-mail.sgml. config-encryption.sgml should beKevin Breit2001-06-264-3/+153 * Elaborated on the mailing listsKevin Breit2001-06-262-0/+9 * Added info about mailing listsKevin Breit2001-06-262-115/+100 * Here too.Peter Williams2001-06-262-4/+6 * ... and comment out more exec summary stuff.Peter Williams2001-06-262-6/+10 * Fix make dist.Peter Williams2001-06-264-6/+13 * Fixed a few typosKevin Breit2001-06-252-2/+4 * Added section for importing filesKevin Breit2001-06-252-2/+63 * Removed some *'s that are causing problems.Kevin Breit2001-06-254-10/+12 * Sync - FedericoFederico Mena Quintero2001-06-259-169/+348 * Put in Contacts information in the quicktasks.Kevin Breit2001-06-232-18/+72 * Pulled some redundant information.Kevin Breit2001-06-222-9/+65 * Updated screenshots and redid layout for graphics on pages.battery8412001-06-226-28/+100 * disable executive summary build because it is no longer builtJP Rosevear2001-06-222-1/+6 * add new libJP Rosevear2001-06-222-1/+6 * Fixed .gif problemKevin Breit2001-06-224-12/+13 * Specify the file formatKevin Breit2001-06-222-2/+7 * Trying to fix the .gif problemKevin Breit2001-06-222-11/+20 * Redid graphics to add labels to them and described the labels in text.Kevin Breit2001-06-224-0/+40 * calendar/cal-client/Makefile.am: calendar/cal-util/Makefile.am:Peter Williams2001-06-226-428/+785 * Added config-encryption.sgml for buildingKevin Breit2001-06-223-0/+150 * Updated graphics for newer UI.Kevin Breit2001-06-2212-0/+4 * Redid graphics to add labels to them and described in labels in text.Kevin Breit2001-06-2210-20/+108 * Added fileKevin Breit2001-06-212-9/+160 * Moved my entires to doc/ChangeLog per request of danwKevin Breit2001-06-212-24/+57 * Updated for new UI.Kevin Breit2001-06-211-30/+18 * Updated for a newer UI (need to update at a later date.Kevin Breit2001-06-211-52/+34 * Make less monotone soundingKevin Breit2001-06-212-7/+5 * Added more postscript descriptionKevin Breit2001-06-211-3/+3 * Reworded a little bit for more descrip.Kevin Breit2001-06-211-2/+3 * Documented categorizing an event.Kevin Breit2001-06-211-2/+37 * Updated Bcc: exampleKevin Breit2001-06-201-1/+3 * Took out a reference to gloss.Kevin Breit2001-06-201-0/+10 * Made it build.Kevin Breit2001-06-201-1/+1 * Checked for validity.Aaron Weber2001-06-201-1/+7 * A couple changes to Kevin's update. Mostly just checking over.Aaron Weber2001-06-202-25/+26 * Basic editsKevin Breit2001-06-201-36/+42 * Updated to say "My Evolution"Kevin Breit2001-06-201-16/+12 * Added definition.Kevin Breit2001-06-201-73/+52 * Commented out DTD which shouldn't be thereKevin Breit2001-06-191-2/+2 * added *-undocumented.txt to .cvsignoreDamon Chaplin2001-06-142-0/+2 * added *-undocumented.txtDamon Chaplin2001-06-143-0/+7 * fixed a typo pointed out by Greg Leblanc. s/listen/listed/Duncan Mak2001-06-082-1/+5 * removed duplicate "If mozilla can..." question.Aaron Weber2001-06-071-17/+0 * Note that I think I may have CVS Tag problems at least with the changelog.Aaron Weber2001-06-076-79/+109 * added questions about KDE, redid other questions.Aaron Weber2001-06-021-444/+516 * s/Helix Code/XimianFederico Mena Quintero2001-05-252-2/+6 * Untabify.Ettore Perazzoli2001-05-231-732/+732 * Add Emacs-like local variable settings to disable `indent-tabs-mode'.Ettore Perazzoli2001-05-231-1/+5 * More (minor) indentation fixes.Ettore Perazzoli2001-05-231-7/+7 * Re-indented the FAQ document.Ettore Perazzoli2001-05-232-438/+425 * Added evolution-faq as an entity.Aaron Weber2001-05-223-537/+598 * doc/C/evolution.sgml - Pulled my name from copyright listKevin Breit2001-05-221-1/+0 * Updated to ignore more built files.Ettore Perazzoli2001-05-201-6/+8 * Added a lot of new content. Fixed old content. Validated. Still need toAaron Weber2001-05-194-600/+265 * Added two questions about importing Outlook (text from Iain). Fixed someDuncan Mak2001-05-192-2/+76 * Added a question about the need for write permissions onEttore Perazzoli2001-05-181-0/+5 * Added a question about the need for write permissions onEttore Perazzoli2001-05-181-0/+21 * Return the serialized EDestinations (rather than just a string w/ e-mailJon Trowbridge2001-05-184-54/+52 * Fixed Grammar, edited a few answers, did the vfolder thing.Aaron Weber2001-05-171-22/+30 * Get the User guide and the Evolution FAQ to be installed into separateEttore Perazzoli2001-05-162-6/+25 * Evolution users worldwide, rejoice! We have a FAQ. (Yes, it stillEttore Perazzoli2001-05-162-6/+762 * yea...Jeffrey Stedfast2001-05-161-0/+3 * I've said it before and I'll say it again... man am I a dumb schmuckJeffrey Stedfast2001-05-161-0/+536 * yes, I am a dumbassJeffrey Stedfast2001-05-161-0/+791 * oops, I guess this file does belong hereJeffrey Stedfast2001-05-161-0/+301 * updated .cvsignoreJeffrey Stedfast2001-05-162-0/+3 * Removed some evolution-*-decl.txt files since these are autogenerated byJeffrey Stedfast2001-05-166-1/+29 * added file for ScrollkeeperKevin Breit2001-05-151-0/+14 * ShushJP Rosevear2001-05-084-7/+13 * UpdateKjartan Maraas2001-04-261-0/+1 * Update this a bitKjartan Maraas2001-04-261-6/+6 * Removed generated files from CVS, updated .cvsignore files to includeJon Trowbridge2001-04-2619-1698/+141 * Changed dependency for install-data-local from "evolution" toJon Trowbridge2001-04-242-1/+6 * Port builddir != srcdir patch from the evolution-0-10-branch.Ettore Perazzoli2001-04-246-7/+20 * Re-commit ChangeLog.Ettore Perazzoli2001-04-241-2/+0 * Documentation building fixes merged from the evolution-0-10-branch:Ettore Perazzoli2001-04-245-18/+34 * changed path to the importer header files, since we've had reports thatDamon Chaplin2001-04-212-3/+9 * Fixed typoHector Garcia2001-04-201-18/+19 * Fixed bug that prevented new translationsHector Garcia2001-04-201-2/+11 * Updated Spanish TranslationHector Garcia2001-04-2016-233/+404 * s/helixcode/ximian (How I missed this page on the first go-round I don'tAaron Weber2001-04-184-19/+24 * Pull up fix from the branch:Ettore Perazzoli2001-04-185-7/+15 * Updated Spanish translation.Hector Garcia2001-03-222-2/+281 * Updated Spanish TranslationHector Garcia2001-03-161-1/+64 * Removed .oafinfo files -- they are obsolete. Moved pixmaps fromGediminas Paulauskas2001-03-151-0/+2 * create doc/devel/executive-summary/MakefileGediminas Paulauskas2001-03-152-2/+5 * Deleting some files that should not have been added in the first placeHector Garcia2001-03-142-59/+0 * Adding files to help translating evolution guide using a .po wayHector Garcia2001-03-14