aboutsummaryrefslogtreecommitdiffstats
path: root/src/native/addrbook/msoutlook/com/MsOutlookAddrBookClientClassFactory.cxx
blob: 97d58562dae737f098230eaa818ee5055a3babce (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
#include "MsOutlookAddrBookClientClassFactory.h"

#include "MsOutlookAddrBookClient.h"

/**
 * Instanciates a new MsOutlookAddrBookClientClassFactory.
 */
MsOutlookAddrBookClientClassFactory::MsOutlookAddrBookClientClassFactory():
    ClassFactory(CLSID_MsOutlookAddrBookClient),
    _msOutlookAddrBookClient(NULL)
{
}

/**
 * Deletest this instance of MsOutlookAddrBookClientClassFactory.
 */
MsOutlookAddrBookClientClassFactory::~MsOutlookAddrBookClientClassFactory()
{
    if (_msOutlookAddrBookClient)
        _msOutlookAddrBookClient->Release();
}

/**
 * Creates a new instance of a MsOutlookAddrBookClient.
 *
 * @param outer A pointer used if the object is being created as part of an
 * aggregate,
 * @param iid The identifier of the interface requested.
 * @param obj A pointer use to return an object implemented the interface
 * requested.
 *
 * @return S_OK if the corresponding interface has been found. Any other error
 * otherwise.
 */
STDMETHODIMP
MsOutlookAddrBookClientClassFactory::CreateInstance
    (LPUNKNOWN outer, REFIID iid, PVOID *obj)
{
    HRESULT hr;

    if(outer)
    {
        *obj = NULL;
        hr = CLASS_E_NOAGGREGATION;
    }
    else
    {
        if(_msOutlookAddrBookClient)
        {
            _msOutlookAddrBookClient->Release();
        }
        _msOutlookAddrBookClient = NULL;
        _msOutlookAddrBookClient = new MsOutlookAddrBookClient();
        hr = _msOutlookAddrBookClient->QueryInterface(iid, obj);
    }
    return hr;
}