Commit f18d1563 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

inetcomm: COM cleanup for the IMimeMessage iface.

parent 431e77be
...@@ -1428,15 +1428,19 @@ typedef struct body_t ...@@ -1428,15 +1428,19 @@ typedef struct body_t
typedef struct MimeMessage typedef struct MimeMessage
{ {
const IMimeMessageVtbl *lpVtbl; IMimeMessage IMimeMessage_iface;
LONG ref;
LONG refs;
IStream *stream; IStream *stream;
struct list body_tree; struct list body_tree;
DWORD next_index; DWORD next_index;
} MimeMessage; } MimeMessage;
static inline MimeMessage *impl_from_IMimeMessage(IMimeMessage *iface)
{
return CONTAINING_RECORD(iface, MimeMessage, IMimeMessage_iface);
}
static HRESULT WINAPI MimeMessage_QueryInterface(IMimeMessage *iface, REFIID riid, void **ppv) static HRESULT WINAPI MimeMessage_QueryInterface(IMimeMessage *iface, REFIID riid, void **ppv)
{ {
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv); TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
...@@ -1459,9 +1463,12 @@ static HRESULT WINAPI MimeMessage_QueryInterface(IMimeMessage *iface, REFIID rii ...@@ -1459,9 +1463,12 @@ static HRESULT WINAPI MimeMessage_QueryInterface(IMimeMessage *iface, REFIID rii
static ULONG WINAPI MimeMessage_AddRef(IMimeMessage *iface) static ULONG WINAPI MimeMessage_AddRef(IMimeMessage *iface)
{ {
MimeMessage *This = (MimeMessage *)iface; MimeMessage *This = impl_from_IMimeMessage(iface);
TRACE("(%p)->()\n", iface); ULONG ref = InterlockedIncrement(&This->ref);
return InterlockedIncrement(&This->refs);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
} }
static void empty_body_list(struct list *list) static void empty_body_list(struct list *list)
...@@ -1478,13 +1485,12 @@ static void empty_body_list(struct list *list) ...@@ -1478,13 +1485,12 @@ static void empty_body_list(struct list *list)
static ULONG WINAPI MimeMessage_Release(IMimeMessage *iface) static ULONG WINAPI MimeMessage_Release(IMimeMessage *iface)
{ {
MimeMessage *This = (MimeMessage *)iface; MimeMessage *This = impl_from_IMimeMessage(iface);
ULONG refs; ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->()\n", iface); TRACE("(%p) ref=%d\n", This, ref);
refs = InterlockedDecrement(&This->refs); if (!ref)
if (!refs)
{ {
empty_body_list(&This->body_tree); empty_body_list(&This->body_tree);
...@@ -1492,7 +1498,7 @@ static ULONG WINAPI MimeMessage_Release(IMimeMessage *iface) ...@@ -1492,7 +1498,7 @@ static ULONG WINAPI MimeMessage_Release(IMimeMessage *iface)
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return refs; return ref;
} }
/*** IPersist methods ***/ /*** IPersist methods ***/
...@@ -1674,11 +1680,9 @@ static body_t *create_sub_body(MimeMessage *msg, IStream *pStm, BODYOFFSETS *off ...@@ -1674,11 +1680,9 @@ static body_t *create_sub_body(MimeMessage *msg, IStream *pStm, BODYOFFSETS *off
return body; return body;
} }
static HRESULT WINAPI MimeMessage_Load( static HRESULT WINAPI MimeMessage_Load(IMimeMessage *iface, IStream *pStm)
IMimeMessage *iface,
LPSTREAM pStm)
{ {
MimeMessage *This = (MimeMessage *)iface; MimeMessage *This = impl_from_IMimeMessage(iface);
body_t *root_body; body_t *root_body;
BODYOFFSETS offsets; BODYOFFSETS offsets;
ULARGE_INTEGER cur; ULARGE_INTEGER cur;
...@@ -1734,12 +1738,11 @@ static HRESULT WINAPI MimeMessage_InitNew( ...@@ -1734,12 +1738,11 @@ static HRESULT WINAPI MimeMessage_InitNew(
} }
/*** IMimeMessageTree methods ***/ /*** IMimeMessageTree methods ***/
static HRESULT WINAPI MimeMessage_GetMessageSource( static HRESULT WINAPI MimeMessage_GetMessageSource(IMimeMessage *iface, IStream **ppStream,
IMimeMessage *iface,
IStream **ppStream,
DWORD dwFlags) DWORD dwFlags)
{ {
MimeMessage *This = (MimeMessage *)iface; MimeMessage *This = impl_from_IMimeMessage(iface);
FIXME("(%p)->(%p, 0x%x)\n", iface, ppStream, dwFlags); FIXME("(%p)->(%p, 0x%x)\n", iface, ppStream, dwFlags);
IStream_AddRef(This->stream); IStream_AddRef(This->stream);
...@@ -1822,13 +1825,10 @@ static HRESULT find_body(struct list *list, HBODY hbody, body_t **body) ...@@ -1822,13 +1825,10 @@ static HRESULT find_body(struct list *list, HBODY hbody, body_t **body)
return S_FALSE; return S_FALSE;
} }
static HRESULT WINAPI MimeMessage_BindToObject( static HRESULT WINAPI MimeMessage_BindToObject(IMimeMessage *iface, const HBODY hBody, REFIID riid,
IMimeMessage *iface,
const HBODY hBody,
REFIID riid,
void **ppvObject) void **ppvObject)
{ {
MimeMessage *This = (MimeMessage *)iface; MimeMessage *This = impl_from_IMimeMessage(iface);
HRESULT hr; HRESULT hr;
body_t *body; body_t *body;
...@@ -1933,13 +1933,10 @@ static HRESULT WINAPI MimeMessage_InsertBody( ...@@ -1933,13 +1933,10 @@ static HRESULT WINAPI MimeMessage_InsertBody(
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI MimeMessage_GetBody( static HRESULT WINAPI MimeMessage_GetBody(IMimeMessage *iface, BODYLOCATION location, HBODY hPivot,
IMimeMessage *iface, HBODY *phBody)
BODYLOCATION location,
HBODY hPivot,
LPHBODY phBody)
{ {
MimeMessage *This = (MimeMessage *)iface; MimeMessage *This = impl_from_IMimeMessage(iface);
body_t *body; body_t *body;
HRESULT hr; HRESULT hr;
...@@ -1981,14 +1978,11 @@ static void count_children(body_t *body, boolean recurse, ULONG *count) ...@@ -1981,14 +1978,11 @@ static void count_children(body_t *body, boolean recurse, ULONG *count)
} }
} }
static HRESULT WINAPI MimeMessage_CountBodies( static HRESULT WINAPI MimeMessage_CountBodies(IMimeMessage *iface, HBODY hParent, boolean fRecurse,
IMimeMessage *iface,
HBODY hParent,
boolean fRecurse,
ULONG *pcBodies) ULONG *pcBodies)
{ {
HRESULT hr; HRESULT hr;
MimeMessage *This = (MimeMessage *)iface; MimeMessage *This = impl_from_IMimeMessage(iface);
body_t *body; body_t *body;
TRACE("(%p)->(%p, %s, %p)\n", iface, hParent, fRecurse ? "TRUE" : "FALSE", pcBodies); TRACE("(%p)->(%p, %s, %p)\n", iface, hParent, fRecurse ? "TRUE" : "FALSE", pcBodies);
...@@ -2044,12 +2038,9 @@ static HRESULT WINAPI MimeMessage_FindFirst( ...@@ -2044,12 +2038,9 @@ static HRESULT WINAPI MimeMessage_FindFirst(
return find_next( iface, NULL, pFindBody, phBody ); return find_next( iface, NULL, pFindBody, phBody );
} }
static HRESULT WINAPI MimeMessage_FindNext( static HRESULT WINAPI MimeMessage_FindNext(IMimeMessage *iface, FINDBODY *pFindBody, HBODY *phBody)
IMimeMessage *iface,
LPFINDBODY pFindBody,
LPHBODY phBody)
{ {
MimeMessage *This = (MimeMessage *)iface; MimeMessage *This = impl_from_IMimeMessage(iface);
body_t *body; body_t *body;
HRESULT hr; HRESULT hr;
...@@ -2561,13 +2552,13 @@ HRESULT MimeMessage_create(IUnknown *outer, void **obj) ...@@ -2561,13 +2552,13 @@ HRESULT MimeMessage_create(IUnknown *outer, void **obj)
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This)); This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
if (!This) return E_OUTOFMEMORY; if (!This) return E_OUTOFMEMORY;
This->lpVtbl = &MimeMessageVtbl; This->IMimeMessage_iface.lpVtbl = &MimeMessageVtbl;
This->refs = 1; This->ref = 1;
This->stream = NULL; This->stream = NULL;
list_init(&This->body_tree); list_init(&This->body_tree);
This->next_index = 1; This->next_index = 1;
*obj = &This->lpVtbl; *obj = &This->IMimeMessage_iface;
return S_OK; return S_OK;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment