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
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
;
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
;
47 ref
= InterlockedIncrement(&This
->ref
);
51 /* Attempt to provide a new interface to interact with iface */
52 static HRESULT WINAPI
BITS_IBackgroundCopyManager_QueryInterface(
53 IBackgroundCopyManager
* iface
,
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
);
73 /* Release an interface to iface */
74 static ULONG WINAPI
BITS_IBackgroundCopyManager_Release(
75 IBackgroundCopyManager
* iface
)
77 BackgroundCopyManagerImpl
* This
= (BackgroundCopyManagerImpl
*)iface
;
82 ref
= InterlockedDecrement(&This
->ref
);
85 BackgroundCopyManagerDestructor(This
);
90 /*** IBackgroundCopyManager interface methods ***/
92 static HRESULT WINAPI
BITS_IBackgroundCopyManager_CreateJob(
93 IBackgroundCopyManager
* iface
,
97 IBackgroundCopyJob
**ppJob
)
99 BackgroundCopyManagerImpl
* This
= (BackgroundCopyManagerImpl
*) iface
;
100 BackgroundCopyJobImpl
*job
;
104 hres
= BackgroundCopyJobConstructor(DisplayName
, Type
, pJobId
,
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
);
116 static HRESULT WINAPI
BITS_IBackgroundCopyManager_GetJob(
117 IBackgroundCopyManager
* iface
,
119 IBackgroundCopyJob
**ppJob
)
121 FIXME("Not implemented\n");
125 static HRESULT WINAPI
BITS_IBackgroundCopyManager_EnumJobs(
126 IBackgroundCopyManager
* iface
,
128 IEnumBackgroundCopyJobs
**ppEnum
)
131 return EnumBackgroundCopyJobsConstructor((LPVOID
*) ppEnum
, iface
);
134 static HRESULT WINAPI
BITS_IBackgroundCopyManager_GetErrorDescription(
135 IBackgroundCopyManager
* iface
,
138 LPWSTR
*pErrorDescription
)
140 FIXME("Not implemented\n");
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
));
166 return E_OUTOFMEMORY
;
169 This
->lpVtbl
= &BITS_IBackgroundCopyManager_Vtbl
;
171 list_init(&This
->jobs
);
173 *ppObj
= &This
->lpVtbl
;