qmgr: Implement IEnumBackgroundCopyFiles_Next.
[wine.git] / dlls / qmgr / file.c
blob60958f5b9b92ba837538bd08f3737975f0b3401f
1 /*
2 * Queue Manager (BITS) File
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 static void BackgroundCopyFileDestructor(BackgroundCopyFileImpl *This)
28 HeapFree(GetProcessHeap(), 0, This->info.LocalName);
29 HeapFree(GetProcessHeap(), 0, This->info.RemoteName);
30 HeapFree(GetProcessHeap(), 0, This);
33 static ULONG WINAPI BITS_IBackgroundCopyFile_AddRef(IBackgroundCopyFile* iface)
35 BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
36 return InterlockedIncrement(&This->ref);
39 static HRESULT WINAPI BITS_IBackgroundCopyFile_QueryInterface(
40 IBackgroundCopyFile* iface,
41 REFIID riid,
42 void **ppvObject)
44 BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
46 if (IsEqualGUID(riid, &IID_IUnknown)
47 || IsEqualGUID(riid, &IID_IBackgroundCopyFile))
49 *ppvObject = &This->lpVtbl;
50 BITS_IBackgroundCopyFile_AddRef(iface);
51 return S_OK;
54 *ppvObject = NULL;
55 return E_NOINTERFACE;
59 static ULONG WINAPI BITS_IBackgroundCopyFile_Release(
60 IBackgroundCopyFile* iface)
62 BackgroundCopyFileImpl *This = (BackgroundCopyFileImpl *) iface;
63 ULONG ref = InterlockedDecrement(&This->ref);
65 if (ref == 0)
66 BackgroundCopyFileDestructor(This);
68 return ref;
71 /*** IBackgroundCopyFile methods ***/
72 static HRESULT WINAPI BITS_IBackgroundCopyFile_GetRemoteName(
73 IBackgroundCopyFile* iface,
74 LPWSTR *pVal)
76 FIXME("Not implemented\n");
77 return E_NOTIMPL;
80 static HRESULT WINAPI BITS_IBackgroundCopyFile_GetLocalName(
81 IBackgroundCopyFile* iface,
82 LPWSTR *pVal)
84 FIXME("Not implemented\n");
85 return E_NOTIMPL;
88 static HRESULT WINAPI BITS_IBackgroundCopyFile_GetProgress(
89 IBackgroundCopyFile* iface,
90 BG_FILE_PROGRESS *pVal)
92 FIXME("Not implemented\n");
93 return E_NOTIMPL;
96 static const IBackgroundCopyFileVtbl BITS_IBackgroundCopyFile_Vtbl =
98 BITS_IBackgroundCopyFile_QueryInterface,
99 BITS_IBackgroundCopyFile_AddRef,
100 BITS_IBackgroundCopyFile_Release,
101 BITS_IBackgroundCopyFile_GetRemoteName,
102 BITS_IBackgroundCopyFile_GetLocalName,
103 BITS_IBackgroundCopyFile_GetProgress
106 HRESULT BackgroundCopyFileConstructor(LPCWSTR remoteName,
107 LPCWSTR localName, LPVOID *ppObj)
109 BackgroundCopyFileImpl *This;
110 int n;
112 TRACE("(%s,%s,%p)\n", debugstr_w(remoteName),
113 debugstr_w(localName), ppObj);
115 This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
116 if (!This)
117 return E_OUTOFMEMORY;
119 n = (lstrlenW(remoteName) + 1) * sizeof(WCHAR);
120 This->info.RemoteName = HeapAlloc(GetProcessHeap(), 0, n);
121 if (!This->info.RemoteName)
123 HeapFree(GetProcessHeap(), 0, This);
124 return E_OUTOFMEMORY;
126 memcpy(This->info.RemoteName, remoteName, n);
128 n = (lstrlenW(localName) + 1) * sizeof(WCHAR);
129 This->info.LocalName = HeapAlloc(GetProcessHeap(), 0, n);
130 if (!This->info.LocalName)
132 HeapFree(GetProcessHeap(), 0, This->info.RemoteName);
133 HeapFree(GetProcessHeap(), 0, This);
134 return E_OUTOFMEMORY;
136 memcpy(This->info.LocalName, localName, n);
138 This->lpVtbl = &BITS_IBackgroundCopyFile_Vtbl;
139 This->ref = 1;
141 *ppObj = &This->lpVtbl;
142 return S_OK;