CamelDataWrapper
3
CAMEL Library

# CamelDataWrapper

## Synopsis

    struct              CamelDataWrapper;
    CamelDataWrapper*   camel_data_wrapper_new              (void);
    ssize_t             camel_data_wrapper_write_to_stream  (CamelDataWrapper *data_wrapper,
                                                             CamelStream *stream);
    ssize_t             camel_data_wrapper_decode_to_stream (CamelDataWrapper *data_wrapper,
                                                             CamelStream *stream);
    void                camel_data_wrapper_set_mime_type    (CamelDataWrapper *data_wrapper,
                                                             const char *mime_type);
    char*               camel_data_wrapper_get_mime_type    (CamelDataWrapper *data_wrapper);
    CamelContentType*   camel_data_wrapper_get_mime_type_field
                                                            (CamelDataWrapper *data_wrapper);
    void                camel_data_wrapper_set_mime_type_field
                                                            (CamelDataWrapper *data_wrapper,
                                                             CamelContentType *mime_type);
    int                 camel_data_wrapper_construct_from_stream
                                                            (CamelDataWrapper *data_wrapper,
                                                             CamelStream *stream);
    gboolean            camel_data_wrapper_is_offline       (CamelDataWrapper *data_wrapper);

## Description

## Details

### struct CamelDataWrapper

    struct CamelDataWrapper {
    	CamelObject parent_object;
    	struct _CamelDataWrapperPrivate *priv;

    	CamelTransferEncoding encoding;

    	CamelContentType *mime_type;
    	CamelStream *stream;

    	unsigned int offline:1;
    };

### camel_data_wrapper_new ()

    CamelDataWrapper*   camel_data_wrapper_new              (void);

Create a new CamelDataWrapper object.

Returns :

  a new CamelDataWrapper object

### camel_data_wrapper_write_to_stream ()

    ssize_t             camel_data_wrapper_write_to_stream  (CamelDataWrapper *data_wrapper,
                                                             CamelStream *stream);

Writes the content of `data_wrapper` to `stream` in a machine-independent format appropriate for the data. It should be possible to construct an equivalent data wrapper object later by passing this stream to camel_data_wrapper_construct_from_stream.

`data_wrapper` :

  a CamelDataWrapper object

`stream` :

  a CamelStream for output

Returns :

  the number of bytes written, or `-1` on fail

### camel_data_wrapper_decode_to_stream ()

    ssize_t             camel_data_wrapper_decode_to_stream (CamelDataWrapper *data_wrapper,
                                                             CamelStream *stream);

Writes the decoded data content to `stream`.

`data_wrapper` :

  a CamelDataWrapper object

`stream` :

  a CamelStream for decoded data to be written to

Returns :

  the number of bytes written, or `-1` on fail

### camel_data_wrapper_set_mime_type ()

    void                camel_data_wrapper_set_mime_type    (CamelDataWrapper *data_wrapper,
                                                             const char *mime_type);

This sets the data wrapper's MIME type.

It might fail, but you won't know. It will allow you to set Content-Type parameters on the data wrapper, which are meaningless. You should not be allowed to change the MIME type of a data wrapper that contains data, or at least, if you do, it should invalidate the data.

`data_wrapper` :

  a CamelDataWrapper object

`mime_type` :

  a MIME type

### camel_data_wrapper_get_mime_type ()

    char*               camel_data_wrapper_get_mime_type    (CamelDataWrapper *data_wrapper);

`data_wrapper` :

  a CamelDataWrapper object

Returns :

  the MIME type which must be freed by the caller

### camel_data_wrapper_get_mime_type_field ()

    CamelContentType*   camel_data_wrapper_get_mime_type_field
                                                            (CamelDataWrapper *data_wrapper);

`data_wrapper` :

  a CamelDataWrapper object

Returns :

  the parsed form of the data wrapper's MIME type

### camel_data_wrapper_set_mime_type_field ()

    void                camel_data_wrapper_set_mime_type_field
                                                            (CamelDataWrapper *data_wrapper,
                                                             CamelContentType *mime_type);

This sets the data wrapper's MIME type. It suffers from the same flaws as camel_data_wrapper_set_mime_type.

`data_wrapper` :

  a CamelDataWrapper object

`mime_type` :

  a CamelContentType

### camel_data_wrapper_construct_from_stream ()

    int                 camel_data_wrapper_construct_from_stream
                                                            (CamelDataWrapper *data_wrapper,
                                                             CamelStream *stream);

Constructs the content of `data_wrapper` from the supplied `stream`.

`data_wrapper` :

  a CamelDataWrapper object

`stream` :

  an input CamelStream

Returns :

  `0` on success or `-1` on fail

### camel_data_wrapper_is_offline ()

    gboolean            camel_data_wrapper_is_offline       (CamelDataWrapper *data_wrapper);

`data_wrapper` :

  a CamelDataWrapper object

Returns :

  whether `data_wrapper` is "offline" (data stored remotely) or not. Some optional code paths may choose to not operate on offline data.