push 014043c4937c940c54cd1214c96e33a3b3c8cf7d
[wine/hacks.git] / dlls / qmgr / qmgr.c
blobfdfd30cfb792028ebe13681a120d3357f7eecca2
1 /*
2 * Queue Manager (BITS) core functions
4 * Copyright 2007 Google (Roy Shea)
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.
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.
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
21 #include "qmgr.h"
22 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
26 /* Destructor for instances of background copy manager */
27 static void BackgroundCopyManagerDestructor(BackgroundCopyManagerImpl *This)
29 BackgroundCopyJobImpl *job;
30 TRACE("%p\n", This);
32 LIST_FOR_EACH_ENTRY(job, &This->jobs, BackgroundCopyJobImpl, entryFromQmgr)
33 job->lpVtbl->Release((IBackgroundCopyJob *) job);
35 HeapFree(GetProcessHeap(), 0, This);
38 /* Add a reference to the iface pointer */
39 static ULONG WINAPI BITS_IBackgroundCopyManager_AddRef(
40 IBackgroundCopyManager* iface)
42 BackgroundCopyManagerImpl * This = (BackgroundCopyManagerImpl *)iface;
43 ULONG ref;
45 TRACE("\n");
47 ref = InterlockedIncrement(&This->ref);
48 return ref;
51 /* Attempt to provide a new interface to interact with iface */
52 static HRESULT WINAPI BITS_IBackgroundCopyManager_QueryInterface(
53 IBackgroundCopyManager* iface,
54 REFIID riid,
55 LPVOID *ppvObject)
57 BackgroundCopyManagerImpl * This = (BackgroundCopyManagerImpl *)iface;
59 TRACE("IID: %s\n", debugstr_guid(riid));
61 if (IsEqualGUID(riid, &IID_IUnknown) ||
62 IsEqualGUID(riid, &IID_IBackgroundCopyManager))
64 *ppvObject = &This->lpVtbl;
65 BITS_IBackgroundCopyManager_AddRef(iface);
66 return S_OK;
69 *ppvObject = NULL;
70 return E_NOINTERFACE;
73 /* Release an interface to iface */
74 static ULONG WINAPI BITS_IBackgroundCopyManager_Release(
75 IBackgroundCopyManager* iface)
77 BackgroundCopyManagerImpl * This = (BackgroundCopyManagerImpl *)iface;
78 ULONG ref;
80 TRACE("\n");
82 ref = InterlockedDecrement(&This->ref);
83 if (ref == 0)
85 BackgroundCopyManagerDestructor(This);
87 return ref;
90 /*** IBackgroundCopyManager interface methods ***/
92 static HRESULT WINAPI BITS_IBackgroundCopyManager_CreateJob(
93 IBackgroundCopyManager* iface,
94 LPCWSTR DisplayName,
95 BG_JOB_TYPE Type,
96 GUID *pJobId,
97 IBackgroundCopyJob **ppJob)
99 BackgroundCopyManagerImpl * This = (BackgroundCopyManagerImpl *) iface;
100 BackgroundCopyJobImpl *job;
101 HRESULT hres;
102 TRACE("\n");
104 hres = BackgroundCopyJobConstructor(DisplayName, Type, pJobId,
105 (LPVOID *) ppJob);
106 if (FAILED(hres))
107 return hres;
109 /* Add a reference to the job to job list */
110 IBackgroundCopyJob_AddRef(*ppJob);
111 job = (BackgroundCopyJobImpl *) *ppJob;
112 list_add_head(&This->jobs, &job->entryFromQmgr);
113 return S_OK;
116 static HRESULT WINAPI BITS_IBackgroundCopyManager_GetJob(
117 IBackgroundCopyManager* iface,
118 REFGUID jobID,
119 IBackgroundCopyJob **ppJob)
121 FIXME("Not implemented\n");
122 return E_NOTIMPL;
125 static HRESULT WINAPI BITS_IBackgroundCopyManager_EnumJobs(
126 IBackgroundCopyManager* iface,
127 DWORD dwFlags,
128 IEnumBackgroundCopyJobs **ppEnum)
130 TRACE("\n");
131 return EnumBackgroundCopyJobsConstructor((LPVOID *) ppEnum, iface);
134 static HRESULT WINAPI BITS_IBackgroundCopyManager_GetErrorDescription(
135 IBackgroundCopyManager* iface,
136 HRESULT hResult,
137 DWORD LanguageId,
138 LPWSTR *pErrorDescription)
140 FIXME("Not implemented\n");
141 return E_NOTIMPL;
145 static const IBackgroundCopyManagerVtbl BITS_IBackgroundCopyManager_Vtbl =
147 BITS_IBackgroundCopyManager_QueryInterface,
148 BITS_IBackgroundCopyManager_AddRef,
149 BITS_IBackgroundCopyManager_Release,
150 BITS_IBackgroundCopyManager_CreateJob,
151 BITS_IBackgroundCopyManager_GetJob,
152 BITS_IBackgroundCopyManager_EnumJobs,
153 BITS_IBackgroundCopyManager_GetErrorDescription
156 /* Constructor for instances of background copy manager */
157 HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj)
159 BackgroundCopyManagerImpl *This;
161 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
163 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
164 if (!This)
166 return E_OUTOFMEMORY;
169 This->lpVtbl = &BITS_IBackgroundCopyManager_Vtbl;
170 This->ref = 1;
171 list_init(&This->jobs);
173 *ppObj = &This->lpVtbl;
174 return S_OK;