displayattributemgr.c 4.19 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/*
 *  ITfDisplayAttributeMgr implementation
 *
 *  Copyright 2010 CodeWeavers, Aric Stewart
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#define COBJMACROS

#include "wine/debug.h"
#include "winbase.h"
#include "winreg.h"
#include "shlwapi.h"

#include "msctf.h"
#include "msctf_internal.h"

WINE_DEFAULT_DEBUG_CHANNEL(msctf);

typedef struct tagDisplayAttributeMgr {
34
    ITfDisplayAttributeMgr ITfDisplayAttributeMgr_iface;
35 36 37 38 39

    LONG refCount;

} DisplayAttributeMgr;

40 41 42 43 44
static inline DisplayAttributeMgr *impl_from_ITfDisplayAttributeMgr(ITfDisplayAttributeMgr *iface)
{
    return CONTAINING_RECORD(iface, DisplayAttributeMgr, ITfDisplayAttributeMgr_iface);
}

45 46 47 48 49 50 51 52 53
static void DisplayAttributeMgr_Destructor(DisplayAttributeMgr *This)
{
    TRACE("destroying %p\n", This);

    HeapFree(GetProcessHeap(),0,This);
}

static HRESULT WINAPI DisplayAttributeMgr_QueryInterface(ITfDisplayAttributeMgr *iface, REFIID iid, LPVOID *ppvOut)
{
54
    DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
    *ppvOut = NULL;

    if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfDisplayAttributeMgr))
    {
        *ppvOut = This;
    }

    if (*ppvOut)
    {
        IUnknown_AddRef(iface);
        return S_OK;
    }

    WARN("unsupported interface: %s\n", debugstr_guid(iid));
    return E_NOINTERFACE;
}

static ULONG WINAPI DisplayAttributeMgr_AddRef(ITfDisplayAttributeMgr *iface)
{
74
    DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
75 76 77 78 79
    return InterlockedIncrement(&This->refCount);
}

static ULONG WINAPI DisplayAttributeMgr_Release(ITfDisplayAttributeMgr *iface)
{
80
    DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
81 82 83 84 85 86 87 88 89 90 91 92 93 94
    ULONG ret;

    ret = InterlockedDecrement(&This->refCount);
    if (ret == 0)
        DisplayAttributeMgr_Destructor(This);
    return ret;
}

/*****************************************************
 * ITfDisplayAttributeMgr functions
 *****************************************************/

static HRESULT WINAPI DisplayAttributeMgr_OnUpdateInfo(ITfDisplayAttributeMgr *iface)
{
95
    DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
96 97 98 99 100 101 102

    FIXME("STUB:(%p)\n",This);
    return E_NOTIMPL;
}

static HRESULT WINAPI DisplayAttributeMgr_EnumDisplayAttributeInfo(ITfDisplayAttributeMgr *iface, IEnumTfDisplayAttributeInfo **ppEnum)
{
103
    DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
104 105 106 107 108 109 110

    FIXME("STUB:(%p)\n",This);
    return E_NOTIMPL;
}

static HRESULT WINAPI DisplayAttributeMgr_GetDisplayAttributeInfo(ITfDisplayAttributeMgr *iface, REFGUID guid, ITfDisplayAttributeInfo **ppInfo, CLSID *pclsidOwner)
{
111
    DisplayAttributeMgr *This = impl_from_ITfDisplayAttributeMgr(iface);
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137

    FIXME("STUB:(%p)\n",This);
    return E_NOTIMPL;
}

static const ITfDisplayAttributeMgrVtbl DisplayAttributeMgr_DisplayAttributeMgrVtbl =
{
    DisplayAttributeMgr_QueryInterface,
    DisplayAttributeMgr_AddRef,
    DisplayAttributeMgr_Release,

    DisplayAttributeMgr_OnUpdateInfo,
    DisplayAttributeMgr_EnumDisplayAttributeInfo,
    DisplayAttributeMgr_GetDisplayAttributeInfo
};

HRESULT DisplayAttributeMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
{
    DisplayAttributeMgr *This;
    if (pUnkOuter)
        return CLASS_E_NOAGGREGATION;

    This = HeapAlloc(GetProcessHeap(),0,sizeof(DisplayAttributeMgr));
    if (This == NULL)
        return E_OUTOFMEMORY;

138
    This->ITfDisplayAttributeMgr_iface.lpVtbl = &DisplayAttributeMgr_DisplayAttributeMgrVtbl;
139 140 141 142 143 144
    This->refCount = 1;

    TRACE("returning %p\n", This);
    *ppOut = (IUnknown *)This;
    return S_OK;
}