Пример #1
0
static int
pop_create_attribute (struct _pop3_message *mpm)
{
  int status;
  mu_attribute_t attribute;
  
  status = mu_attribute_create (&attribute, mpm);
  if (status)
    return status;

  mu_attribute_set_get_flags (attribute, pop_get_attribute, mpm);
  mu_attribute_set_set_flags (attribute, pop_set_attribute, mpm);
  mu_attribute_set_unset_flags (attribute, pop_unset_attribute, mpm);
  mu_message_set_attribute (mpm->message, attribute, mpm);
  return 0;
}
Пример #2
0
static int
new_message (mu_mailbox_t mailbox, mbox_message_t mum, mu_message_t *pmsg)
{
  int status;
  mu_message_t msg;

  /* Get an empty message struct.  */
  status = mu_message_create (&msg, mum);
  if (status != 0)
    return status;

  /* Set the header.  */
  {
    mu_header_t header = NULL;
    status = mu_header_create (&header, NULL, 0, msg);
    if (status != 0)
      {
	mu_message_destroy (&msg, mum);
	return status;
      }
    mu_header_set_fill (header, mbox_header_fill, msg);
    mu_message_set_header (msg, header, mum);
  }

  /* Set the attribute.  */
  {
    mu_attribute_t attribute;
    status = mu_attribute_create (&attribute, msg);
    if (status != 0)
      {
	mu_message_destroy (&msg, mum);
	return status;
      }
    mu_attribute_set_get_flags (attribute, mbox_get_attr_flags, msg);
    mu_attribute_set_set_flags (attribute, mbox_set_attr_flags, msg);
    mu_attribute_set_unset_flags (attribute, mbox_unset_attr_flags, msg);
    mu_message_set_attribute (msg, attribute, mum);
  }

  /* Prepare the body.  */
  {
    mu_body_t body = NULL;
    mu_stream_t stream = NULL;
    if ((status = mu_body_create (&body, msg)) != 0
	|| (status = mu_stream_create (&stream,
				       mailbox->flags | MU_STREAM_SEEKABLE,
				       body)) != 0)
      {
	mu_body_destroy (&body, msg);
	mu_stream_destroy (&stream, body);
	mu_message_destroy (&msg, mum);
	return status;
      }
    mu_stream_set_read (stream, mbox_body_read, body);
    mu_stream_set_readline (stream, mbox_body_readline, body);
    mu_stream_set_get_transport2 (stream, mbox_get_body_transport, body);
    mu_stream_set_size (stream, mbox_stream_size, body);
    mu_body_set_stream (body, stream, msg);
    mu_body_set_size (body, mbox_body_size, msg);
    mu_body_set_lines (body, mbox_body_lines, msg);
    mu_message_set_body (msg, body, mum);
  }

  /* Set the envelope.  */
  {
    mu_envelope_t envelope= NULL;
    status = mu_envelope_create (&envelope, msg);
    if (status != 0)
      {
	mu_message_destroy (&msg, mum);
	return status;
      }
    mu_envelope_set_sender (envelope, mbox_envelope_sender, msg);
    mu_envelope_set_date (envelope, mbox_envelope_date, msg);
    mu_message_set_envelope (msg, envelope, mum);
  }

  /* Set the UID.  */
  mu_message_set_uid (msg, mbox_message_uid, mum);
  mu_message_set_qid (msg, mbox_message_qid, mum);
  
  /* Attach the message to the mailbox mbox data.  */
  mum->message = msg;
  mu_message_set_mailbox (msg, mailbox, mum);

  *pmsg = msg;
  
  return 0;
}