Ejemplo n.º 1
0
static inline int message_mime_unref(struct mailprivacy * privacy,
                                     struct message_ref_elt * ref_elt)
{
    int count;

    message_unref(ref_elt);

#ifdef LIBETPAN_REENTRANT
    pthread_mutex_lock(&ref_elt->lock);
#endif
    ref_elt->mime_ref_count --;

    if (ref_elt->mime_ref_count == 0)
        mailprivacy_msg_flush(privacy, ref_elt->msg);

    count = ref_elt->mime_ref_count;

#ifdef LIBETPAN_REENTRANT
    pthread_mutex_unlock(&ref_elt->lock);
#endif

    return count;
}
Ejemplo n.º 2
0
int mailprivacy_get_mime(struct mailprivacy * privacy,
    int check_privacy, int reencode,
    char * content, size_t content_len,
    struct mailmime ** result_mime)
{
  struct mailmime * mime;
  mailmessage * msg;
  int r;
  int res;

#if 0
  int check_privacy;
  
  check_privacy = (privacy != NULL);
#endif
  
  /*
    use message data driver, get bodystructure and
    convert all the data part in MAILMIME_SINGLE to files.
  */
  
  msg = data_message_init(content, content_len);
  if (msg == NULL) {
    res = MAIL_ERROR_MEMORY;
    goto err;
  }
  
#if 0
  if (msg->mime == NULL) {
    if (check_privacy) {
      r = mailprivacy_msg_get_bodystructure(privacy, msg, &mime);
    }
    else {
      /*
        don't use etpan_msg_get_bodystructure because it is not useful
        and to avoid loops due to security part
      */
      r = mailmessage_get_bodystructure(msg, &mime);
    }
  }
  else {
    mime = msg->mime;
  }
#endif

  if (check_privacy)
    r = mailprivacy_msg_get_bodystructure(privacy, msg, &mime);
  else
    r = mailmessage_get_bodystructure(msg, &mime);
  if (r != MAIL_NO_ERROR) {
    res = r;
    goto free_msg;
  }

  /*
    should be done so that the MIME structure need not to be unregistered.
  */
  mailprivacy_recursive_unregister_mime(privacy, mime);

  r = recursive_replace_single_parts(privacy, mime, reencode);
  if (r != MAIL_NO_ERROR) {
    res = r;
    goto clear_mime;
  }
  
  data_message_detach_mime(msg);
#if 0
  if (check_privacy)
    mailprivacy_msg_flush(privacy, msg);
  else
    mailmessage_flush(msg);
#endif
  mailprivacy_msg_flush(privacy, msg);
  mailmessage_free(msg);
  
  * result_mime = mime;
  
  return MAIL_NO_ERROR;
  
 clear_mime:
  mailprivacy_mime_clear(mime);
  mailprivacy_msg_flush(privacy, msg);
 free_msg:
  mailmessage_free(msg);
 err:
  return res;
}