| 1652 | // lifetime is controlled by refcounts (see defer.h) |
| 1653 | |
| 1654 | CDeferredCommand::CDeferredCommand(__inout CCmdQueue *pQ, __in_opt LPUNKNOWN pUnk, __inout HRESULT *phr, |
| 1655 | __in LPUNKNOWN pUnkExecutor, REFTIME time, __in GUID *iid, long dispidMethod, |
| 1656 | short wFlags, long nArgs, __in_ecount(nArgs) VARIANT *pDispParams, |
| 1657 | __out VARIANT *pvarResult, __out short *puArgErr, BOOL bStream) |
| 1658 | : CUnknown(NAME("DeferredCommand"), pUnk) |
| 1659 | , m_pQueue(pQ) |
| 1660 | , m_pUnk(pUnkExecutor) |
| 1661 | , m_iid(iid) |
| 1662 | , m_dispidMethod(dispidMethod) |
| 1663 | , m_wFlags(wFlags) |
| 1664 | , m_DispParams(nArgs, pDispParams, phr) |
| 1665 | , m_pvarResult(pvarResult) |
| 1666 | , m_bStream(bStream) |
| 1667 | , m_hrResult(E_ABORT) |
| 1668 | |
| 1669 | { |
| 1670 | // convert REFTIME to REFERENCE_TIME |
| 1671 | COARefTime convertor(time); |
| 1672 | m_time = convertor; |
| 1673 | |
| 1674 | // no check of time validity - it's ok to queue a command that's |
| 1675 | // already late |
| 1676 | |
| 1677 | // check iid is supportable on pUnk by QueryInterface for it |
| 1678 | IUnknown *pInterface; |
| 1679 | HRESULT hr = m_pUnk->QueryInterface(GetIID(), (void **)&pInterface); |
| 1680 | if (FAILED(hr)) |
| 1681 | { |
| 1682 | *phr = hr; |
| 1683 | return; |
| 1684 | } |
| 1685 | pInterface->Release(); |
| 1686 | |
| 1687 | // !!! check dispidMethod and param/return types using typelib |
| 1688 | ITypeInfo *pti; |
| 1689 | hr = m_Dispatch.GetTypeInfo(*iid, 0, 0, &pti); |
| 1690 | if (FAILED(hr)) |
| 1691 | { |
| 1692 | *phr = hr; |
| 1693 | return; |
| 1694 | } |
| 1695 | // !!! some sort of ITypeInfo validity check here |
| 1696 | pti->Release(); |
| 1697 | |
| 1698 | // Fix up the dispid for put and get |
| 1699 | if (wFlags == DISPATCH_PROPERTYPUT) |
| 1700 | { |
| 1701 | m_DispParams.cNamedArgs = 1; |
| 1702 | m_DispId = DISPID_PROPERTYPUT; |
| 1703 | m_DispParams.rgdispidNamedArgs = &m_DispId; |
| 1704 | } |
| 1705 | |
| 1706 | // all checks ok - add to queue |
| 1707 | hr = pQ->Insert(this); |
| 1708 | if (FAILED(hr)) |
| 1709 | { |
| 1710 | *phr = hr; |
| 1711 | } |
nothing calls this directly
no test coverage detected