GMimeTnefWriter

GMimeTnefWriter — Write TNEF attributes to a stream

Functions

Types and Values

Description

Writers generate the signature, version, codepage, lengths and checksums. Message attributes precede attachments. MapiProperties ends the message attributes; AttachRenderData starts each attachment and Attachment ends its attributes. Do not write automatically generated header attributes.

Use g_mime_tnef_writer_open_property_writer() to obtain a GMimeTnefPropertyWriter. Property lists and streamed values use seekable temporary storage, allowing the final output to be forward-only. A custom factory can use files instead of the default block-backed memory. Embedded writers inherit the factory.

Close value streams, embedded writers and property writers before continuing their parent. Finally call g_mime_tnef_writer_close() and check its result. Finalizers never complete output: abandoning an unfinished child poisons its parent instead of silently publishing an incomplete attribute. The root output stream remains open and owned by its caller.

Functions

GMimeTnefTemporaryStreamFactory ()

GMimeStream *
(*GMimeTnefTemporaryStreamFactory) (gpointer user_data,
                                    GError **error);

Creates a new, empty, readable/writable, seekable stream at position zero. The writer owns it. Embedded writers inherit the configured factory.

Parameters

user_data

callback data.

[closure][nullable]

error

return location for an error

 

Returns

a temporary stream, or NULL on error.

[transfer full][nullable]


g_mime_tnef_writer_new ()

GMimeTnefWriter *
g_mime_tnef_writer_new (GMimeStream *stream,
                        int codepage,
                        guint16 legacy_key,
                        GError **error);

Creates a writer without writing any output. The stream is referenced, not closed. Unsupported codepages and UTF-16/UTF-32 are rejected. Call g_mime_tnef_writer_close() to complete output before unref.

Parameters

stream

the output stream

 

codepage

the 8-bit string codepage, usually 1252

 

legacy_key

the stream's legacy key, usually zero

 

error

return location for an error

 

Returns

a writer, or NULL on error.

[transfer full][nullable]


g_mime_tnef_writer_get_codepage ()

int
g_mime_tnef_writer_get_codepage (GMimeTnefWriter *writer);

Gets the output codepage.

Parameters

writer

a TNEF writer

 

Returns

the output codepage


g_mime_tnef_writer_get_legacy_key ()

guint16
g_mime_tnef_writer_get_legacy_key (GMimeTnefWriter *writer);

Gets the legacy key.

Parameters

writer

a TNEF writer

 

Returns

the legacy key


g_mime_tnef_writer_set_temporary_stream_factory ()

void
g_mime_tnef_writer_set_temporary_stream_factory
                               (GMimeTnefWriter *writer,
                                GMimeTnefTemporaryStreamFactory factory,
                                gpointer user_data,
                                GDestroyNotify destroy);

Configures temporary attribute storage. NULL restores block-backed memory streams. Each embedded writer retains the factory current when it is created, including ownership of the callback data.

Parameters

writer

a TNEF writer

 

factory

stream factory.

[scope notified][closure user_data][destroy destroy][nullable]

user_data

callback data.

[nullable]

destroy

callback-data destroy function.

[nullable]

g_mime_tnef_writer_write_attribute_int32 ()

gboolean
g_mime_tnef_writer_write_attribute_int32
                               (GMimeTnefWriter *writer,
                                GMimeTnefAttributeTag tag,
                                gint32 value,
                                GError **error);

Writes a Short, Word, Long or DWord attribute, checking 16-bit ranges.

Parameters

writer

a TNEF writer

 

tag

the attribute tag

 

value

the integer value

 

error

return location for an error

 

Returns

whether the operation succeeded


g_mime_tnef_writer_write_attribute_string ()

gboolean
g_mime_tnef_writer_write_attribute_string
                               (GMimeTnefWriter *writer,
                                GMimeTnefAttributeTag tag,
                                const char *value,
                                GError **error);

Writes a nul-terminated String, Text or message-class attribute using the selected codepage. Message classes require 1 to 254 printable ASCII characters.

Parameters

writer

a TNEF writer

 

tag

the attribute tag

 

value

a UTF-8 string

 

error

return location for an error

 

Returns

whether the operation succeeded


g_mime_tnef_writer_write_attribute_date_time ()

gboolean
g_mime_tnef_writer_write_attribute_date_time
                               (GMimeTnefWriter *writer,
                                GMimeTnefAttributeTag tag,
                                GDateTime *value,
                                GError **error);

Writes the seven legacy date fields, without converting their timezone.

Parameters

writer

a TNEF writer

 

tag

the date attribute tag

 

value

a date and time

 

error

return location for an error

 

Returns

whether the operation succeeded


g_mime_tnef_writer_write_attribute_bytes ()

gboolean
g_mime_tnef_writer_write_attribute_bytes
                               (GMimeTnefWriter *writer,
                                GMimeTnefAttributeTag tag,
                                const guint8 *buffer,
                                gsize length,
                                GError **error);

Writes an attribute's raw value, generating its level, length and checksum.

Parameters

writer

a TNEF writer

 

tag

the attribute tag

 

buffer

raw value bytes.

[array length=length][nullable]

length

byte count, no greater than G_MAXINT32

 

error

return location for an error

 

Returns

whether the operation succeeded


g_mime_tnef_writer_open_attribute_stream ()

GMimeStream *
g_mime_tnef_writer_open_attribute_stream
                               (GMimeTnefWriter *writer,
                                GMimeTnefAttributeTag tag,
                                GError **error);

Opens a write-only raw attribute stream backed by temporary storage. Explicitly close it before the next writer operation. Closing queues the completed attribute; the next operation writes its length and checksum.

Parameters

writer

a TNEF writer

 

tag

the attribute tag

 

error

return location for an error

 

Returns

the stream, or NULL on error.

[transfer full][nullable]


g_mime_tnef_writer_open_property_writer ()

GMimeTnefPropertyWriter *
g_mime_tnef_writer_open_property_writer
                               (GMimeTnefWriter *writer,
                                GMimeTnefAttributeTag tag,
                                GError **error);

Opens a property-list or recipient-table writer backed by temporary storage. Explicitly close it before advancing the attribute writer.

Parameters

writer

a TNEF writer

 

tag

MapiProperties, Attachment or RecipientTable

 

error

return location for an error

 

Returns

the property writer, or NULL on error.

[transfer full][nullable]


g_mime_tnef_writer_flush ()

gboolean
g_mime_tnef_writer_flush (GMimeTnefWriter *writer,
                          GError **error);

Writes the stream header and completed buffered attributes, then flushes the underlying stream. All child writers and streams must be closed first.

Parameters

writer

a TNEF writer

 

error

return location for an error

 

Returns

whether the operation succeeded


g_mime_tnef_writer_close ()

gboolean
g_mime_tnef_writer_close (GMimeTnefWriter *writer,
                          GError **error);

Completes output and flushes it. Does not close the caller's output stream. For an embedded writer, also completes the enclosing property value. Repeated successful closes are harmless; errors remain latched.

Parameters

writer

a TNEF writer

 

error

return location for an error

 

Returns

whether the writer completed successfully

Types and Values

GMimeTnefWriter

typedef struct _GMimeTnefWriter GMimeTnefWriter;

A forward-only TNEF writer. The header, version, codepage, attribute lengths and checksums are generated automatically. Message attributes precede attachments; MapiProperties and Attachment finish their respective property lists. Explicitly close child streams/property writers and then the writer to report completion errors. Finalization performs no I/O.