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



On 03/10/2010 12:03 AM, vaibhav gurav wrote:
>
> Hi ,
> I am try to parse the multipart data (which comes from N/W) on your
> any url response .
> when the response is multipart I wanted to parse this with help of
> gmime parser and send each part to browser
> Main problem ::
> how to check data coming is multipart or not
> I am doing like this -
>       //initialize the gmime
>             g_mime_init(0);
>             g_mime_charset_map_init();
>             g_mime_iconv_init();

just an FYI, but g_mime_init() calls g_mime_charset_map_init() and
g_mime_iconv_init() for you, so you don't need to call them again.

>       //checking the data coming is multipart or not (void * ptr -
> response data  )
>                GMimeStream* stream =
> g_mime_stream_mem_new_with_buffer(static_cast<char*>(ptr),dataSize);
>                GMimeParser* parser =
> g_mime_parser_new_with_stream(stream);
>                GMimeObject* mimeObject =
> g_mime_parser_construct_part(parser);
>     //checking Gmime Object and and find out content type
>                 if (mineObject && GMIME_IS_MULTIPART(mimeObject))
>                     string m_mainResourceType =
> g_mime_object_get_content_type_parameter(mimeObject, "type");
> ----------------------------------------
>
> is it correct the above code .

yes, it looks correct.

> if yes then still I am facing one problem even though response is
> multipart(i.e. multipart/mixed) the out of
> GMIME_IS_MULTIPART(mimeObject) is getting null(i.e. fail ).



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