/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ #include #include "camel-mime-message.h" #include "camel-multipart.h" #include "camel-stream.h" #include "camel-stream-fs.h" #include "camel-data-wrapper.h" #include "camel.h" int main (int argc, char**argv) { CamelMimeMessage *message; CamelMultipart *multipart; CamelMimePart *body_part; CamelMimePart *attachment_part; CamelStream *attachment_stream; CamelStream *stream; CamelException *ex = camel_exception_new (); gtk_init (&argc, &argv); camel_init (); if (argc < 2) { attachment_stream = NULL; } else { if (argc == 2) { attachment_stream = camel_stream_fs_new_with_name (argv[1], O_RDONLY, 0, ex); if (attachment_stream == NULL) { fprintf (stderr, "Cannot open `%s': %s\n", argv[1], camel_exception_get_description (ex)); return 1; } } else { fprintf (stderr, "Usage: %s []\n", argv[0]); return 1; } } message = camel_mime_message_new (); camel_mime_part_set_description (CAMEL_MIME_PART (message), "a test"); camel_medium_add_header (CAMEL_MEDIUM (message), "X-test1", "the value of a test"); camel_medium_add_header (CAMEL_MEDIUM (message), "X-test2", "the value of another test"); /*camel_mime_part_add_content_language (CAMEL_MIME_PART (message), g_string_new ("es-ca"));*/ camel_mime_message_set_date (message, CAMEL_MESSAGE_DATE_CURRENT, 0); camel_mime_message_set_subject (message, g_strdup ("A test message")); camel_mime_message_set_reply_to (message, g_strdup ("toto@toto.com")); camel_mime_message_set_from (message, g_strdup ("Bertrand.Guiheneuf@aful.org")); camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_TO, "Franck DeChamps", "franck.dechamps@alseve.fr"); camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_TO, NULL, "mc@alseve.fr"); camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_TO, "Richo", "richard.lengagne@inria.fr"); camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_CC, "Frank", "Francois.fleuret@inria.fr"); camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_CC, NULL, "maury@justmagic.com"); camel_mime_message_add_recipient (message, CAMEL_RECIPIENT_TYPE_BCC, "Bertie", "Bertrand.Guiheneuf@aful.org"); multipart = camel_multipart_new (); body_part = camel_mime_part_new (); camel_mime_part_set_content (CAMEL_MIME_PART (body_part), "This is a test.\nThis is only a test.\n", strlen("This is a test.\nThis is only a test.\n"), "text/plain"); camel_multipart_add_part (multipart, body_part); if (attachment_stream == NULL) { attachment_part = NULL; } else { CamelDataWrapper *attachment_wrapper; /*CamelDataWrapper *stream_wrapper; stream_wrapper = camel_stream_data_wrapper_new (attachment_stream); attachment_part = camel_mime_body_part_new (); camel_mime_part_set_encoding (CAMEL_MIME_PART (attachment_part), CAMEL_MIME_PART_ENCODING_BASE64); camel_medium_set_content_object (CAMEL_MEDIUM (attachment_part), stream_wrapper); camel_multipart_add_part (multipart, attachment_part); gtk_object_unref (GTK_OBJECT (stream_wrapper));*/ attachment_wrapper = camel_data_wrapper_new (); camel_data_wrapper_construct_from_stream (attachment_wrapper, attachment_stream); attachment_part = camel_mime_part_new (); camel_mime_part_set_encoding (CAMEL_MIME_PART (attachment_part), CAMEL_MIME_PART_ENCODING_BASE64); camel_medium_set_content_object (CAMEL_MEDIUM (attachment_part), attachment_wrapper); camel_multipart_add_part (multipart, attachment_part); } camel_medium_set_content_object (CAMEL_MEDIUM (message), CAMEL_DATA_WRAPPER (multipart)); stream = camel_stream_fs_new_with_name ("mail1.test", O_WRONLY|O_TRUNC|O_CREAT, 0600, ex); if (!stream) { printf ("Could not open output file: %s\n", camel_exception_get_description (ex)); exit(2); } camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream, ex); camel_stream_flush (stream, ex); gtk_object_unref (GTK_OBJECT (stream)); if (camel_exception_is_set (ex)) { printf ("Oops. Failed. %s\n", camel_exception_get_description (ex)); exit (1); } gtk_object_unref (GTK_OBJECT (message)); gtk_object_unref (GTK_OBJECT (multipart)); gtk_object_unref (GTK_OBJECT (body_part)); if (attachment_part != NULL) gtk_object_unref (GTK_OBJECT (attachment_part)); printf ("Test1 finished\n"); return 1; } option> FreeBSD GNOME current development ports (https://github.com/freebsd/freebsd-ports-gnome)
aboutsummaryrefslogtreecommitdiffstats
Commit message (Expand)AuthorAgeFilesLines
* fix script to work with /bin/sholiver2014-06-131-0/+17
* STAGEifyoliver2014-06-122-19/+5
* - Update to 13.1jadawin2014-06-122-8/+6
* - Added libtool to USES for audio/wildmidibar2014-06-122-1/+2
* Reset the 99 ports still listed under sylvio@marino2014-06-121-1/+1
* - Un-breakriggs2014-06-123-48/+79
* Support LIBS like LDFLAGS.tijl2014-06-1110-28/+20
* - Update to 1.1.2olivierd2014-06-113-7/+6
* Fix compilation on i386 when OPTIMIZED_CFLAGS option is off.tijl2014-06-101-0/+1
* Remove all the bootstrap files (.bs) from the plists.mat2014-06-102-2/+0
* Fix build with gcc from base, it doesn't undertand -Wno-tautological-constan...antoine2014-06-101-1/+4
* - Stagifyriggs2014-06-102-4/+8
* Update libdvbpsi to 1.2.0bapt2014-06-094-19/+43
* Fix typo.vanilla2014-06-091-1/+1
* Stagify.vanilla2014-06-092-2/+16
* Stagify.vanilla2014-06-091-4/+3
* 1: Stagify.vanilla2014-06-092-169/+5
* 1: Stagify.vanilla2014-06-091-6/+7
* Stagify, bump version for pkg-plist changed.vanilla2014-06-092-14/+8
* Stagify.vanilla2014-06-092-6/+6
* - New upstream release (dated 2011-05-02)riggs2014-06-093-19/+27
* Remove all space characters from Makefile assignments.olgeni2014-06-092-2/+2
* Remove indefinite articles from COMMENT where I'm maintainer.olgeni2014-06-082-2/+2
* - Stagifyriggs2014-06-081-6/+5
* Update to 1.8.2 .nox2014-06-082-3/+3
* - Stagifyriggs2014-06-071-3/+4
* - Add CONFLICTS to mplayer to prevent install conflict with mplayer2 [1]riggs2014-06-073-8/+22
* - New upstream release 1.0.1riggs2014-06-075-29/+191
* Update to 0.9.9.10feld2014-06-063-804/+850
* - Convert USE_BZIP2 to USESamdmi32014-06-061-3/+2
* Update to 0.9.9.11feld2014-06-053-930/+942
* - Stagifyriggs2014-06-052-9/+9
* Update to 1.3.1madpilot2014-06-042-4/+4
* Complete overhaul:naddy2014-06-041-14/+16
* Fix pkg-plist when NLS option is off.tijl2014-06-031-122/+122
* - Remove libproxy dependency. I cannot find any references to it.tijl2014-06-039-314/+421
* Remove expired port:rene2014-06-024-63/+0
* - USE_(BZIP2|XZ) -> USES= tar:(bzip2|xz)ohauer2014-06-011-2/+1
* - Update graphics/sdl_gfx to version 2.0.25mva2014-06-011-1/+1
* Mark a few unfetchable ports as BROKENantoine2014-06-011-0/+2
* - Update to version 10.1mva2014-06-012-4/+3
* multimedia/gtk-recordmydesktop: support stagerm2014-06-013-10/+4
* Fix LEGAL/LICENSE* for multimedia/vtkmpeg2encode.riggs2014-06-012-22/+17
* - Fix various distinfo errorsak2014-06-011-1/+0
* Back to poolcs2014-05-311-1/+1
* - Convert USE_BZIP2 to USESamdmi32014-05-312-7/+3
* - Stagify.nox2014-05-311-2/+1
* Stagify.kwm2014-05-312-9/+10
* Stagify.nox2014-05-312-7/+6
* Stagify.nox2014-05-311-1/+0
* Stage support.kevlo2014-05-301-3/+1
* - Update to 13.1 RC1jadawin2014-05-304-12/+56
* - Add LICENSEsunpoet2014-05-302-24/+11
* No need to try and patch the docs Makefile,jpaetzel2014-05-301-9/+0
* Commit correct patch.kwm2014-05-301-25/+20
* Fix compile on ppc.kwm2014-05-301-0/+25
* - Update from 1.3 to 1.4danilo2014-05-281-0/+1
* Fix after scons.mk changesbapt2014-05-281-3/+2
* - Switch to USES=libtool, drop .la filesamdmi32014-05-272-14/+17
* Revert update which should not have happenbapt2014-05-272-7/+12
* Convert vlc to USES=libtoolbapt2014-05-274-6/+7
* Fix build with new luabapt2014-05-271-1/+1
* UIDs:riggs2014-05-275-81/+24
* Replace lang/lua with the new lang/lua51bapt2014-05-263-16/+10
* Update openjpeg to 2.1.0.kwm2014-05-267-10/+11
* Fixbapt2014-05-261-1/+1
* Convert to USES=monobapt2014-05-261-6/+2
* Convert to USES=monobapt2014-05-261-7/+3
* - Convert gmake,xz,bzip to USESmiwi2014-05-267-11/+7
* Multiple ports: reset maintainerseadler2014-05-263-3/+3
* Switch Opus to USES=libtool.naddy2014-05-264-3/+4
* Add staging support.olgeni2014-05-231-4/+2
* Update to 1.2.13jpaetzel2014-05-234-6/+11
* Update to 1.8.1 .nox2014-05-232-3/+3
* - Stage supportmiwi2014-05-222-191/+2
* - Stage supportmiwi2014-05-222-16/+2
* - Stage supportmiwi2014-05-222-168/+2
* - Update to 0.9.7swills2014-05-224-41/+47
* - Use PORTSCOUT to ignore 1.41 (older than current version)jadawin2014-05-21