update for camelstream changes
svn path=/trunk/; revision=2926
This commit is contained in:
@ -17,9 +17,8 @@ main (int argc, char**argv)
|
||||
CamelMimePart *body_part;
|
||||
CamelMimePart *attachment_part;
|
||||
CamelStream *attachment_stream;
|
||||
|
||||
/* FILE *output_file; */
|
||||
CamelStream *stream;
|
||||
CamelException *ex = camel_exception_new ();
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
camel_init ();
|
||||
@ -28,10 +27,11 @@ main (int argc, char**argv)
|
||||
attachment_stream = NULL;
|
||||
} else {
|
||||
if (argc == 2) {
|
||||
attachment_stream = camel_stream_fs_new_with_name (argv[1], O_RDONLY, 0);
|
||||
attachment_stream = camel_stream_fs_new_with_name (argv[1], O_RDONLY, 0, ex);
|
||||
if (attachment_stream == NULL) {
|
||||
fprintf (stderr, "Cannot open `%s'\n",
|
||||
argv[1]);
|
||||
fprintf (stderr, "Cannot open `%s': %s\n",
|
||||
argv[1],
|
||||
camel_exception_get_description (ex));
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
@ -106,16 +106,22 @@ main (int argc, char**argv)
|
||||
|
||||
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);
|
||||
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");
|
||||
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);
|
||||
camel_stream_close (stream);
|
||||
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));
|
||||
|
||||
@ -40,7 +40,7 @@ dump_message_content(CamelDataWrapper *object)
|
||||
left = 0;
|
||||
|
||||
if (stream) {
|
||||
while ( (len = camel_stream_read(stream, buffer+left, sizeof(buffer)-left)) > 0) {
|
||||
while ( (len = camel_stream_read(stream, buffer+left, sizeof(buffer)-left, NULL)) > 0) {
|
||||
fwrite(buffer, len, 1, stdout);
|
||||
}
|
||||
printf("\n");
|
||||
@ -95,7 +95,7 @@ main (int argc, char**argv)
|
||||
message = camel_mime_message_new ();
|
||||
|
||||
|
||||
input_stream = camel_stream_fs_new_with_name ("mail.test", O_RDONLY, 0);
|
||||
input_stream = camel_stream_fs_new_with_name ("mail.test", O_RDONLY, 0, NULL);
|
||||
if (!input_stream) {
|
||||
perror ("could not open input file\n");
|
||||
printf ("You must create the file mail.test before running this test\n");
|
||||
@ -110,12 +110,11 @@ main (int argc, char**argv)
|
||||
|
||||
dump_message_content(CAMEL_DATA_WRAPPER (message));
|
||||
|
||||
camel_stream_close (input_stream);
|
||||
gtk_object_unref (GTK_OBJECT (input_stream));
|
||||
|
||||
output_stream = camel_stream_fs_new_with_name ("mail2.test", O_WRONLY|O_CREAT|O_TRUNC, 0600);
|
||||
camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), output_stream);
|
||||
camel_stream_close (output_stream);
|
||||
output_stream = camel_stream_fs_new_with_name ("mail2.test", O_WRONLY|O_CREAT|O_TRUNC, 0600, NULL);
|
||||
camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), output_stream, NULL);
|
||||
camel_stream_flush (output_stream, NULL);
|
||||
gtk_object_unref (GTK_OBJECT (output_stream));
|
||||
|
||||
//gtk_object_unref (GTK_OBJECT (message));
|
||||
|
||||
@ -12,6 +12,7 @@ main (int argc, char**argv)
|
||||
{
|
||||
CamelMimeMessage *message;
|
||||
CamelStream *input_stream;
|
||||
CamelException *ex = camel_exception_new ();
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
camel_init ();
|
||||
@ -19,7 +20,7 @@ main (int argc, char**argv)
|
||||
message = camel_mime_message_new ();
|
||||
|
||||
|
||||
input_stream = camel_stream_fs_new_with_name ("mail.test", O_RDONLY, 0);
|
||||
input_stream = camel_stream_fs_new_with_name ("mail.test", O_RDONLY, 0, ex);
|
||||
if (!input_stream) {
|
||||
perror ("could not open input file\n");
|
||||
printf ("You must create the file mail.test before running this test\n");
|
||||
|
||||
Reference in New Issue
Block a user