winhelp: Update Polish translation.
[wine] / dlls / qmgr / qmgr.c
1 /*
2  * Queue Manager (BITS) core functions
3  *
4  * Copyright 2007 Google (Roy Shea)
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "qmgr.h"
22 #include "wine/debug.h"
23
24 WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
25
26 /* Destructor for instances of background copy manager */
27 static void BackgroundCopyManagerDestructor(BackgroundCopyManagerImpl *This)
28 {
29     TRACE("%p\n", This);
30     HeapFree(GetProcessHeap(), 0, This);
31 }
32
33 /* Add a reference to the iface pointer */
34 static ULONG WINAPI BITS_IBackgroundCopyManager_AddRef(
35         IBackgroundCopyManager* iface)
36 {
37     BackgroundCopyManagerImpl * This = (BackgroundCopyManagerImpl *)iface;
38     ULONG ref;
39
40     TRACE("\n");
41
42     ref = InterlockedIncrement(&This->ref);
43     return ref;
44 }
45
46 /* Attempt to provide a new interface to interact with iface */
47 static HRESULT WINAPI BITS_IBackgroundCopyManager_QueryInterface(
48         IBackgroundCopyManager* iface,
49         REFIID riid,
50         LPVOID *ppvObject)
51 {
52     BackgroundCopyManagerImpl * This = (BackgroundCopyManagerImpl *)iface;
53
54     TRACE("IID: %s\n", debugstr_guid(riid));
55
56     if (IsEqualGUID(riid, &IID_IUnknown) ||
57             IsEqualGUID(riid, &IID_IBackgroundCopyManager))
58     {
59         *ppvObject = &This->lpVtbl;
60         BITS_IBackgroundCopyManager_AddRef(iface);
61         return S_OK;
62     }
63
64     *ppvObject = NULL;
65     return E_NOINTERFACE;
66 }
67
68 /* Release an interface to iface */
69 static ULONG WINAPI BITS_IBackgroundCopyManager_Release(
70         IBackgroundCopyManager* iface)
71 {
72     BackgroundCopyManagerImpl * This = (BackgroundCopyManagerImpl *)iface;
73     ULONG ref;
74
75     TRACE("\n");
76
77     ref = InterlockedDecrement(&This->ref);
78     if (ref == 0)
79     {
80         BackgroundCopyManagerDestructor(This);
81     }
82     return ref;
83 }
84
85 /*** IBackgroundCopyManager interface methods ***/
86
87 static HRESULT WINAPI BITS_IBackgroundCopyManager_CreateJob(
88         IBackgroundCopyManager* iface,
89         LPCWSTR DisplayName,
90         BG_JOB_TYPE Type,
91         GUID *pJobId,
92         IBackgroundCopyJob **ppJob)
93 {
94     FIXME("Not implemented\n");
95     return E_NOTIMPL;
96 }
97
98 static HRESULT WINAPI BITS_IBackgroundCopyManager_GetJob(
99         IBackgroundCopyManager* iface,
100         REFGUID jobID,
101         IBackgroundCopyJob **ppJob)
102 {
103     FIXME("Not implemented\n");
104     return E_NOTIMPL;
105 }
106
107 static HRESULT WINAPI BITS_IBackgroundCopyManager_EnumJobs(
108         IBackgroundCopyManager* iface,
109         DWORD dwFlags,
110         IEnumBackgroundCopyJobs **ppEnum)
111 {
112     FIXME("Not implemented\n");
113     return E_NOTIMPL;
114 }
115
116 static HRESULT WINAPI BITS_IBackgroundCopyManager_GetErrorDescription(
117         IBackgroundCopyManager* iface,
118         HRESULT hResult,
119         DWORD LanguageId,
120         LPWSTR *pErrorDescription)
121 {
122     FIXME("Not implemented\n");
123     return E_NOTIMPL;
124 }
125
126
127 static const IBackgroundCopyManagerVtbl BITS_IBackgroundCopyManager_Vtbl =
128 {
129     BITS_IBackgroundCopyManager_QueryInterface,
130     BITS_IBackgroundCopyManager_AddRef,
131     BITS_IBackgroundCopyManager_Release,
132     BITS_IBackgroundCopyManager_CreateJob,
133     BITS_IBackgroundCopyManager_GetJob,
134     BITS_IBackgroundCopyManager_EnumJobs,
135     BITS_IBackgroundCopyManager_GetErrorDescription
136 };
137
138 /* Constructor for instances of background copy manager */
139 HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj)
140 {
141     BackgroundCopyManagerImpl *This;
142
143     TRACE("(%p,%p)\n", pUnkOuter, ppObj);
144
145     This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
146     if (!This)
147     {
148         return E_OUTOFMEMORY;
149     }
150
151     This->lpVtbl = &BITS_IBackgroundCopyManager_Vtbl;
152     This->ref = 1;
153
154     *ppObj = &This->lpVtbl;
155     return S_OK;
156 }