コード例 #1
0
ファイル: message-gen.c プロジェクト: karfai/portfolio
static void add_part(GSList** stack, GMimeObject* p)
{
    GMimeObject* top_part = GMIME_OBJECT((*stack)->data);

    if ( GMIME_IS_MESSAGE(top_part) ) {
        GMimeMessage* m = GMIME_MESSAGE(top_part);
        GMimeObject*  msg_part = g_mime_message_get_mime_part(m);
        GMimeObject*  add_part = p;
        if ( msg_part ) {
            add_part = add_part_to_existing(msg_part, p);
        }
        
        g_mime_message_set_mime_part(m, add_part);
    } else {
        (*stack)->data = add_part_to_existing(top_part, p);
    }    
}
コード例 #2
0
ファイル: removeattach.c プロジェクト: hager/removeattach
int remove_part(GMimeObject *parent, GMimeObject *part) {
  int attachment = is_attachment(part);

  if (attachment && GMIME_IS_MULTIPART(parent)) {
    g_mime_multipart_remove((GMimeMultipart*)parent, part);
    return 1;
  }
  else if (attachment && GMIME_IS_MESSAGE(parent)) { // I'm not sure if this could ever occur or even makes sense.
    GMimePart *new_part;
    new_part = g_mime_part_new_with_type("text", "plain");
    g_mime_part_set_content_object(new_part,
				   g_mime_data_wrapper_new_with_stream(g_mime_stream_mem_new_with_buffer("Attachment Removed.", 19),
								       GMIME_CONTENT_ENCODING_DEFAULT));
    g_mime_message_set_mime_part((GMimeMessage*)parent, (GMimeObject*)new_part);
    g_object_unref(part);
  }
  else if (GMIME_IS_MESSAGE_PART(part)) {
    remove_message(g_mime_message_part_get_message((GMimeMessagePart*)part));
  }

  return 0;
}