ReactOS  0.4.14-dev-998-g623dd26
qmgr.h File Reference
#include "windef.h"
#include "bits.h"
#include "bits1_5.h"
#include "bits2_0.h"
#include "bits2_5.h"
#include "bits3_0.h"
#include <string.h>
#include "wine/list.h"
Include dependency graph for qmgr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  BackgroundCopyJobImpl
 
struct  BackgroundCopyFileImpl
 
struct  BackgroundCopyManagerImpl
 
struct  ClassFactoryImpl
 

Macros

#define COBJMACROS
 

Functions

HRESULT BackgroundCopyManagerConstructor (LPVOID *ppObj) DECLSPEC_HIDDEN
 
HRESULT BackgroundCopyJobConstructor (LPCWSTR displayName, BG_JOB_TYPE type, GUID *pJobId, BackgroundCopyJobImpl **job) DECLSPEC_HIDDEN
 
HRESULT enum_copy_job_create (BackgroundCopyManagerImpl *qmgr, IEnumBackgroundCopyJobs **enumjob) DECLSPEC_HIDDEN
 
HRESULT BackgroundCopyFileConstructor (BackgroundCopyJobImpl *owner, LPCWSTR remoteName, LPCWSTR localName, BackgroundCopyFileImpl **file) DECLSPEC_HIDDEN
 
HRESULT EnumBackgroundCopyFilesConstructor (BackgroundCopyJobImpl *, IEnumBackgroundCopyFiles **) DECLSPEC_HIDDEN
 
DWORD WINAPI fileTransfer (void *param) DECLSPEC_HIDDEN
 
void processJob (BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN
 
BOOL processFile (BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN
 
BOOL transitionJobState (BackgroundCopyJobImpl *job, BG_JOB_STATE from, BG_JOB_STATE to) DECLSPEC_HIDDEN
 
static WCHARstrdupW (const WCHAR *src)
 
static WCHARco_strdupW (const WCHAR *src)
 
static HRESULT return_strval (const WCHAR *str, WCHAR **ret)
 

Variables

HANDLE stop_event DECLSPEC_HIDDEN
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 25 of file qmgr.h.

Function Documentation

◆ BackgroundCopyFileConstructor()

HRESULT BackgroundCopyFileConstructor ( BackgroundCopyJobImpl owner,
LPCWSTR  remoteName,
LPCWSTR  localName,
BackgroundCopyFileImpl **  file 
)

Definition at line 162 of file file.c.

165 {
167 
168  TRACE("(%s, %s, %p)\n", debugstr_w(remoteName), debugstr_w(localName), file);
169 
170  This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
171  if (!This)
172  return E_OUTOFMEMORY;
173 
174  This->info.RemoteName = strdupW(remoteName);
175  if (!This->info.RemoteName)
176  {
178  return E_OUTOFMEMORY;
179  }
180 
181  This->info.LocalName = strdupW(localName);
182  if (!This->info.LocalName)
183  {
184  HeapFree(GetProcessHeap(), 0, This->info.RemoteName);
186  return E_OUTOFMEMORY;
187  }
188 
189  This->IBackgroundCopyFile2_iface.lpVtbl = &BackgroundCopyFile2Vtbl;
190  This->ref = 1;
191 
192  This->fileProgress.BytesTotal = BG_SIZE_UNKNOWN;
193  This->fileProgress.BytesTransferred = 0;
194  This->fileProgress.Completed = FALSE;
195  This->owner = owner;
196  This->read_size = 0;
197  This->tempFileName[0] = 0;
198  IBackgroundCopyJob3_AddRef(&owner->IBackgroundCopyJob3_iface);
199 
200  *file = This;
201  return S_OK;
202 }
IBackgroundCopyJob3 IBackgroundCopyJob3_iface
Definition: qmgr.h:38
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const IBackgroundCopyFile2Vtbl BackgroundCopyFile2Vtbl
Definition: file.c:150
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define S_OK
Definition: intsafe.h:59
#define HeapFree(x, y, z)
Definition: compat.h:402
Definition: fci.c:126

Referenced by BackgroundCopyJob_AddFileSet().

◆ BackgroundCopyJobConstructor()

HRESULT BackgroundCopyJobConstructor ( LPCWSTR  displayName,
BG_JOB_TYPE  type,
GUID pJobId,
BackgroundCopyJobImpl **  job 
)

Definition at line 1197 of file job.c.

1198 {
1199  HRESULT hr;
1201 
1202  TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, job);
1203 
1204  This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
1205  if (!This)
1206  return E_OUTOFMEMORY;
1207 
1208  This->IBackgroundCopyJob3_iface.lpVtbl = &BackgroundCopyJob3Vtbl;
1209  This->IBackgroundCopyJobHttpOptions_iface.lpVtbl = &http_options_vtbl;
1211  This->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": BackgroundCopyJobImpl.cs");
1212 
1213  This->ref = 1;
1214  This->type = type;
1215 
1216  This->displayName = strdupW(displayName);
1217  if (!This->displayName)
1218  {
1219  This->cs.DebugInfo->Spare[0] = 0;
1221  HeapFree(GetProcessHeap(), 0, This);
1222  return E_OUTOFMEMORY;
1223  }
1224 
1225  hr = CoCreateGuid(&This->jobId);
1226  if (FAILED(hr))
1227  {
1228  This->cs.DebugInfo->Spare[0] = 0;
1230  HeapFree(GetProcessHeap(), 0, This->displayName);
1231  HeapFree(GetProcessHeap(), 0, This);
1232  return hr;
1233  }
1234  *job_id = This->jobId;
1235 
1236  list_init(&This->files);
1237  This->jobProgress.BytesTotal = 0;
1238  This->jobProgress.BytesTransferred = 0;
1239  This->jobProgress.FilesTotal = 0;
1240  This->jobProgress.FilesTransferred = 0;
1241 
1242  This->state = BG_JOB_STATE_SUSPENDED;
1243  This->description = NULL;
1244  This->notify_flags = BG_NOTIFY_JOB_ERROR | BG_NOTIFY_JOB_TRANSFERRED;
1245  This->callback = NULL;
1246  This->callback2 = FALSE;
1247 
1248  This->error.context = 0;
1249  This->error.code = S_OK;
1250  This->error.file = NULL;
1251 
1252  memset(&This->http_options, 0, sizeof(This->http_options));
1253 
1254  This->wait = CreateEventW(NULL, FALSE, FALSE, NULL);
1255  This->cancel = CreateEventW(NULL, FALSE, FALSE, NULL);
1256  This->done = CreateEventW(NULL, FALSE, FALSE, NULL);
1257 
1258  *job = This;
1259 
1260  TRACE("created job %s:%p\n", debugstr_guid(&This->jobId), This);
1261 
1262  return S_OK;
1263 }
static HANDLE job
Definition: process.c:77
#define DWORD_PTR
Definition: treelist.c:76
HRESULT hr
Definition: shlfolder.c:183
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
char displayName[]
Definition: tftpd.cpp:35
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
static const IBackgroundCopyJob3Vtbl BackgroundCopyJob3Vtbl
Definition: job.c:981
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
LONG HRESULT
Definition: typedefs.h:78
HRESULT WINAPI CoCreateGuid(GUID *pguid)
Definition: compobj.c:2206
static const IBackgroundCopyJobHttpOptionsVtbl http_options_vtbl
Definition: job.c:1182
#define S_OK
Definition: intsafe.h:59
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
#define memset(x, y, z)
Definition: compat.h:39
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by BackgroundCopyManager_CreateJob().

◆ BackgroundCopyManagerConstructor()

HRESULT BackgroundCopyManagerConstructor ( LPVOID ppObj)

Definition at line 141 of file qmgr.c.

142 {
143  TRACE("(%p)\n", ppObj);
144  *ppObj = &globalMgr;
145  return S_OK;
146 }
BackgroundCopyManagerImpl globalMgr
Definition: qmgr.c:26
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

Referenced by BITS_IClassFactory_CreateInstance().

◆ co_strdupW()

static WCHAR* co_strdupW ( const WCHAR src)
inlinestatic

Definition at line 125 of file qmgr.h.

126 {
127  WCHAR *dst = CoTaskMemAlloc((lstrlenW(src) + 1) * sizeof(WCHAR));
128  if (dst) lstrcpyW(dst, src);
129  return dst;
130 }
#define lstrlenW
Definition: compat.h:415
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum src
Definition: glext.h:6340
#define lstrcpyW
Definition: compat.h:414
GLenum GLenum dst
Definition: glext.h:6340
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404

◆ enum_copy_job_create()

HRESULT enum_copy_job_create ( BackgroundCopyManagerImpl qmgr,
IEnumBackgroundCopyJobs **  enumjob 
)

Definition at line 179 of file enum_jobs.c.

180 {
183  ULONG i;
184 
185  TRACE("%p, %p)\n", qmgr, enumjob);
186 
187  This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
188  if (!This)
189  return E_OUTOFMEMORY;
190  This->IEnumBackgroundCopyJobs_iface.lpVtbl = &EnumBackgroundCopyJobsVtbl;
191  This->ref = 1;
192 
193  /* Create array of jobs */
194  This->indexJobs = 0;
195 
196  EnterCriticalSection(&qmgr->cs);
197  This->numJobs = list_count(&qmgr->jobs);
198 
199  if (0 < This->numJobs)
200  {
201  This->jobs = HeapAlloc(GetProcessHeap(), 0,
202  This->numJobs * sizeof *This->jobs);
203  if (!This->jobs)
204  {
205  LeaveCriticalSection(&qmgr->cs);
207  return E_OUTOFMEMORY;
208  }
209  }
210  else
211  This->jobs = NULL;
212 
213  i = 0;
214  LIST_FOR_EACH_ENTRY(job, &qmgr->jobs, BackgroundCopyJobImpl, entryFromQmgr)
215  {
216  IBackgroundCopyJob3_AddRef(&job->IBackgroundCopyJob3_iface);
217  This->jobs[i++] = &job->IBackgroundCopyJob3_iface;
218  }
219  LeaveCriticalSection(&qmgr->cs);
220 
221  *enumjob = &This->IEnumBackgroundCopyJobs_iface;
222  return S_OK;
223 }
static HANDLE job
Definition: process.c:77
CRITICAL_SECTION cs
Definition: qmgr.h:89
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
__WINE_SERVER_LIST_INLINE unsigned int list_count(const struct list *list)
Definition: list.h:155
smooth NULL
Definition: ftsmooth.c:416
struct list jobs
Definition: qmgr.h:91
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define S_OK
Definition: intsafe.h:59
static const IEnumBackgroundCopyJobsVtbl EnumBackgroundCopyJobsVtbl
Definition: enum_jobs.c:167
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by BackgroundCopyManager_EnumJobs().

◆ EnumBackgroundCopyFilesConstructor()

HRESULT EnumBackgroundCopyFilesConstructor ( BackgroundCopyJobImpl ,
IEnumBackgroundCopyFiles **   
)

Definition at line 183 of file enum_files.c.

184 {
187  ULONG i;
188 
189  TRACE("%p, %p)\n", job, enum_files);
190 
191  This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
192  if (!This)
193  return E_OUTOFMEMORY;
194 
195  This->IEnumBackgroundCopyFiles_iface.lpVtbl = &EnumBackgroundCopyFilesVtbl;
196  This->ref = 1;
197 
198  /* Create array of files */
199  This->indexFiles = 0;
201  This->numFiles = list_count(&job->files);
202  This->files = NULL;
203  if (This->numFiles > 0)
204  {
205  This->files = HeapAlloc(GetProcessHeap(), 0,
206  This->numFiles * sizeof This->files[0]);
207  if (!This->files)
208  {
211  return E_OUTOFMEMORY;
212  }
213  }
214 
215  i = 0;
216  LIST_FOR_EACH_ENTRY(file, &job->files, BackgroundCopyFileImpl, entryFromJob)
217  {
218  IBackgroundCopyFile2_AddRef(&file->IBackgroundCopyFile2_iface);
219  This->files[i] = &file->IBackgroundCopyFile2_iface;
220  ++i;
221  }
223 
224  *enum_files = &This->IEnumBackgroundCopyFiles_iface;
225  return S_OK;
226 }
static HANDLE job
Definition: process.c:77
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static const IEnumBackgroundCopyFilesVtbl EnumBackgroundCopyFilesVtbl
Definition: enum_files.c:171
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
__WINE_SERVER_LIST_INLINE unsigned int list_count(const struct list *list)
Definition: list.h:155
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
const char file[]
Definition: icontest.c:11
#define S_OK
Definition: intsafe.h:59
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define HeapFree(x, y, z)
Definition: compat.h:402
Definition: fci.c:126

Referenced by BackgroundCopyJob_EnumFiles().

◆ fileTransfer()

DWORD WINAPI fileTransfer ( void param)

Definition at line 148 of file qmgr.c.

149 {
151  HANDLE events[2];
152 
153  events[0] = stop_event;
154  events[1] = qmgr->jobEvent;
155 
156  for (;;)
157  {
158  BackgroundCopyJobImpl *job, *jobCur;
159  BOOL haveJob = FALSE;
160 
161  /* Check if it's the stop_event */
163  {
164  LIST_FOR_EACH_ENTRY_SAFE(job, jobCur, &qmgr->jobs, BackgroundCopyJobImpl, entryFromQmgr)
165  {
166  list_remove(&job->entryFromQmgr);
167  IBackgroundCopyJob3_Release(&job->IBackgroundCopyJob3_iface);
168  }
169  return 0;
170  }
171 
172  /* Note that other threads may add files to the job list, but only
173  this thread ever deletes them so we don't need to worry about jobs
174  magically disappearing from the list. */
175  EnterCriticalSection(&qmgr->cs);
176 
177  LIST_FOR_EACH_ENTRY_SAFE(job, jobCur, &qmgr->jobs, BackgroundCopyJobImpl, entryFromQmgr)
178  {
179  if (job->state == BG_JOB_STATE_ACKNOWLEDGED || job->state == BG_JOB_STATE_CANCELLED)
180  {
181  list_remove(&job->entryFromQmgr);
182  IBackgroundCopyJob3_Release(&job->IBackgroundCopyJob3_iface);
183  }
184  else if (job->state == BG_JOB_STATE_QUEUED)
185  {
186  haveJob = TRUE;
187  break;
188  }
189  else if (job->state == BG_JOB_STATE_CONNECTING
190  || job->state == BG_JOB_STATE_TRANSFERRING)
191  {
192  ERR("Invalid state for job %p: %d\n", job, job->state);
193  }
194  }
195 
196  if (!haveJob)
197  ResetEvent(qmgr->jobEvent);
198 
199  LeaveCriticalSection(&qmgr->cs);
200 
201  if (haveJob)
202  processJob(job);
203  }
204 }
static HANDLE job
Definition: process.c:77
#define TRUE
Definition: types.h:120
BackgroundCopyManagerImpl globalMgr
Definition: qmgr.c:26
CRITICAL_SECTION cs
Definition: qmgr.h:89
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
Definition: synch.c:151
HANDLE stop_event
Definition: nfs41_daemon.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
struct list jobs
Definition: qmgr.h:91
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define WAIT_OBJECT_0
Definition: winbase.h:387
void processJob(BackgroundCopyJobImpl *job)
Definition: job.c:1265
#define ERR(fmt,...)
Definition: debug.h:109
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
HANDLE events[2]
Definition: event.c:4
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define INFINITE
Definition: serial.h:102

Referenced by ServiceMain().

◆ processFile()

BOOL processFile ( BackgroundCopyFileImpl file,
BackgroundCopyJobImpl job 
)

Definition at line 477 of file file.c.

478 {
479  static const WCHAR prefix[] = {'B','I','T', 0};
480  WCHAR tmpDir[MAX_PATH], tmpName[MAX_PATH];
482  URL_COMPONENTSW uc;
483  BOOL ret;
484 
485  if (!GetTempPathW(MAX_PATH, tmpDir))
486  {
487  ERR("Couldn't create temp file name: %d\n", GetLastError());
488  /* Guessing on what state this should give us */
489  transitionJobState(job, BG_JOB_STATE_QUEUED, BG_JOB_STATE_TRANSIENT_ERROR);
490  return FALSE;
491  }
492 
493  if (!GetTempFileNameW(tmpDir, prefix, 0, tmpName))
494  {
495  ERR("Couldn't create temp file: %d\n", GetLastError());
496  /* Guessing on what state this should give us */
497  transitionJobState(job, BG_JOB_STATE_QUEUED, BG_JOB_STATE_TRANSIENT_ERROR);
498  return FALSE;
499  }
500 
502  file->fileProgress.BytesTotal = BG_SIZE_UNKNOWN;
503  file->fileProgress.BytesTransferred = 0;
504  file->fileProgress.Completed = FALSE;
506 
507  TRACE("Transferring: %s -> %s -> %s\n",
508  debugstr_w(file->info.RemoteName),
509  debugstr_w(tmpName),
510  debugstr_w(file->info.LocalName));
511 
512  uc.dwStructSize = sizeof(uc);
513  uc.nScheme = 0;
514  uc.lpszScheme = NULL;
515  uc.dwSchemeLength = 0;
516  uc.lpszUserName = NULL;
517  uc.dwUserNameLength = 0;
518  uc.lpszPassword = NULL;
519  uc.dwPasswordLength = 0;
520  uc.lpszHostName = host;
522  uc.nPort = 0;
523  uc.lpszUrlPath = NULL;
524  uc.dwUrlPathLength = ~0u;
525  uc.lpszExtraInfo = NULL;
526  uc.dwExtraInfoLength = 0;
527  ret = WinHttpCrackUrl(file->info.RemoteName, 0, 0, &uc);
528  if (!ret)
529  {
530  TRACE("WinHttpCrackUrl failed, trying local file copy\n");
531  if (!transfer_file_local(file, tmpName)) WARN("local transfer failed\n");
532  }
533  else if (!transfer_file_http(file, &uc, tmpName)) WARN("HTTP transfer failed\n");
534 
535  if (transitionJobState(job, BG_JOB_STATE_CONNECTING, BG_JOB_STATE_QUEUED) ||
536  transitionJobState(job, BG_JOB_STATE_TRANSFERRING, BG_JOB_STATE_QUEUED))
537  {
538  lstrcpyW(file->tempFileName, tmpName);
539 
541  file->fileProgress.Completed = TRUE;
542  job->jobProgress.FilesTransferred++;
544 
545  return TRUE;
546  }
547  else
548  {
549  DeleteFileW(tmpName);
550  return FALSE;
551  }
552 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
static HANDLE job
Definition: process.c:77
#define TRUE
Definition: types.h:120
BOOL transitionJobState(BackgroundCopyJobImpl *job, BG_JOB_STATE from, BG_JOB_STATE to)
Definition: job.c:30
DWORD dwStructSize
Definition: wininet.h:211
#define WARN(fmt,...)
Definition: debug.h:111
char * host
Definition: whois.c:55
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD dwUserNameLength
Definition: wininet.h:219
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
LPWSTR lpszHostName
Definition: wininet.h:215
LPWSTR lpszExtraInfo
Definition: wininet.h:224
DWORD dwSchemeLength
Definition: wininet.h:213
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079
INTERNET_PORT nPort
Definition: wininet.h:217
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI WinHttpCrackUrl(LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONENTSW uc)
Definition: url.c:179
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL transfer_file_local(BackgroundCopyFileImpl *file, const WCHAR *tmpname)
Definition: file.c:453
LPWSTR lpszScheme
Definition: wininet.h:212
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL transfer_file_http(BackgroundCopyFileImpl *file, URL_COMPONENTSW *uc, const WCHAR *tmpfile)
Definition: file.c:367
INTERNET_SCHEME nScheme
Definition: wininet.h:214
#define MAX_PATH
Definition: compat.h:26
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
Definition: filename.c:84
DWORD dwPasswordLength
Definition: wininet.h:221
DWORD dwHostNameLength
Definition: wininet.h:216
int ret
LPWSTR lpszUserName
Definition: wininet.h:218
LPWSTR lpszUrlPath
Definition: wininet.h:222
DWORD dwUrlPathLength
Definition: wininet.h:223
#define ERR(fmt,...)
Definition: debug.h:109
#define lstrcpyW
Definition: compat.h:414
#define ARRAY_SIZE(a)
Definition: main.h:24
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
LPWSTR lpszPassword
Definition: wininet.h:220
DWORD dwExtraInfoLength
Definition: wininet.h:225
Definition: fci.c:126

Referenced by processJob().

◆ processJob()

void processJob ( BackgroundCopyJobImpl job)

Definition at line 1265 of file job.c.

1266 {
1267  for (;;)
1268  {
1270  BOOL done = TRUE;
1271 
1272  EnterCriticalSection(&job->cs);
1273  LIST_FOR_EACH_ENTRY(file, &job->files, BackgroundCopyFileImpl, entryFromJob)
1274  if (!file->fileProgress.Completed)
1275  {
1276  done = FALSE;
1277  break;
1278  }
1279  LeaveCriticalSection(&job->cs);
1280  if (done)
1281  {
1282  transitionJobState(job, BG_JOB_STATE_QUEUED, BG_JOB_STATE_TRANSFERRED);
1283  return;
1284  }
1285 
1286  if (!processFile(file, job))
1287  return;
1288  }
1289 }
static HANDLE job
Definition: process.c:77
#define TRUE
Definition: types.h:120
BOOL transitionJobState(BackgroundCopyJobImpl *job, BG_JOB_STATE from, BG_JOB_STATE to)
Definition: job.c:30
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
unsigned int BOOL
Definition: ntddk_ex.h:94
const char file[]
Definition: icontest.c:11
BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job)
Definition: file.c:477
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
Definition: fci.c:126

Referenced by fileTransfer().

◆ return_strval()

static HRESULT return_strval ( const WCHAR str,
WCHAR **  ret 
)
inlinestatic

Definition at line 132 of file qmgr.h.

133 {
134  int len;
135 
136  if (!ret) return E_INVALIDARG;
137 
138  len = lstrlenW(str);
139  *ret = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
140  if (!*ret) return E_OUTOFMEMORY;
141  lstrcpyW(*ret, str);
142  return S_OK;
143 }
#define lstrlenW
Definition: compat.h:415
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
const WCHAR * str
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
#define lstrcpyW
Definition: compat.h:414
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404

Referenced by BackgroundCopyFile_GetLocalName(), BackgroundCopyFile_GetRemoteName(), BackgroundCopyJob_GetDescription(), and BackgroundCopyJob_GetDisplayName().

◆ strdupW()

static WCHAR* strdupW ( const WCHAR src)
inlinestatic

Definition at line 118 of file qmgr.h.

119 {
120  WCHAR *dst = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(src) + 1) * sizeof(WCHAR));
121  if (dst) lstrcpyW(dst, src);
122  return dst;
123 }
#define lstrlenW
Definition: compat.h:415
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum src
Definition: glext.h:6340
#define lstrcpyW
Definition: compat.h:414
GLenum GLenum dst
Definition: glext.h:6340

◆ transitionJobState()

BOOL transitionJobState ( BackgroundCopyJobImpl job,
BG_JOB_STATE  from,
BG_JOB_STATE  to 
)

Definition at line 30 of file job.c.

31 {
32  BOOL ret = FALSE;
33 
35  if (job->state == from)
36  {
37  job->state = to;
38  ret = TRUE;
39  }
41  return ret;
42 }
static HANDLE job
Definition: process.c:77
#define TRUE
Definition: types.h:120
BackgroundCopyManagerImpl globalMgr
Definition: qmgr.c:26
CRITICAL_SECTION cs
Definition: qmgr.h:89
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
unsigned int BOOL
Definition: ntddk_ex.h:94
int ret
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
CardRegion * from
Definition: spigame.cpp:19

Referenced by processFile(), processJob(), progress_callback_http(), transfer_file_http(), transfer_file_local(), and wait_for_completion().

Variable Documentation

◆ DECLSPEC_HIDDEN

Definition at line 100 of file qmgr.h.