Re: [gmime-devel] Help Need parse Multipart data with help of GMIME



On 03/11/2010 05:44 AM, vaibhav gurav wrote:
Hi Jeffrey ,

Thanks for your quick reply .
I little bit found what is the problem,even though passing multipart data buffer Gmime object created is of content type is text/plain .
This I found out by
code snippet::
const GMimeContentType* gmimecontentType = g_mime_object_get_content_type(mimeObject);
        if(gmimecontentType)
        {
            string gmimeType = gmimecontentType->type ;
            string gmimesubcontentType = gmimecontentType->subtype ;
        }
----------
here I found value are gmimeType is text and gmimesubcontentType is plain

I am creating the GmimeObject to parse this curl buffer(i.e. end with /r/n)

Data buffer ::

In order for GMime to know that it's a multipart, it needs to have a Content-Type header which has a value of "multipart/<something>" as well as a "boundary" parameter which, in this case, should have a value of "abcd1234xwyz7890"

--abcd1234wxyz7890
Content-Type: text/vnd.wap.wml

Not sure why GMime is coming up with the Content-Type as being text/plain, perhaps the boundary marker confused it?


<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<template>
<do type="prev" name="sb" label="Go Back"><prev/></do>
<do type="accept" name="PostResults" label="PostResults">
<go href=""/></do>
</template>

<card id="C1" title="Gif Image">
<h3>Gif Image in WML page</h3>

<p> verify that the image is displayed below.<br/>
<img src=""true" href="http://testsuite.nokia-boston.com/content/MultipartMixed/MultipartMixed_images/web1.gif" class="ot-anchor">http://testsuite.nokia-boston.com/content/MultipartMixed/MultipartMixed_images/web1.gif" alt="Gif image"/><br/>

</p>
<p>
<anchor>
Post Results
<go href="">
</go>
</anchor>
</p>
</card>


</wml>

--abcd1234wxyz7890
Content-Type: image/gif
Content-Location: http://testsuite.nokia-boston.com/content/MultipartMixed/MultipartMixed_images/web1.gif

GIF89a

--------------------------------
- how I parse this buffer using gmime  ?
I am doing like this
code snippet::
            g_mime_init(0); //only one time
            g_mime_charset_map_init();
            g_mime_iconv_init();
//try to make GmimeObject so i can do parsing operation this
GMimeStream* stream = g_mime_stream_mem_new_with_buffer(static_cast<char*>(ptr),totalSize);
g_mime_stream_seek (stream, 0, GMIME_STREAM_SEEK_END);
g_mime_stream_write (stream, "\r\n", 1); //  as this curl buffer \r\n giving it uses line endings
g_mime_stream_reset (stream);   
GMimeParser* parser = g_mime_parser_new_with_stream(stream);
GMimeObject* mimeObject = g_mime_parser_construct_part(parser);
//checking the content type -Expected it must be mutipart/mixed(I pass above data buffer in this )
if(gmimecontentType)
        {
            string gmimeType = gmimecontentType->type ;
            string gmimesubcontentType = gmimecontentType->subtype ;
        }
//if is it mutipart
if (GMIME_IS_MULTIPART(mimeObject))
        {
        string multipartmainResourceType = g_mime_object_get_content_type_parameter(mimeObject, "type");
        }
Problem ::
1.I am following right way or any other way to make buffer of multipart data and parse this .
2.After passing mutipart buffer this must  true on
GMIME_IS_MULTIPART(..) ,but i am getting  false value .

The problem is that GMime needs the multipart headers as well, not just the multipart's content (which is all you are giving to it).

Hope that helps,

Jeff


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]