Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
b329a2ef
Commit
b329a2ef
authored
Mar 13, 2008
by
Dan Hipschman
Committed by
Alexandre Julliard
Mar 14, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qmgr: Implement local file background "downloads."
parent
374fea0a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
134 additions
and
6 deletions
+134
-6
file.c
dlls/qmgr/file.c
+88
-0
job.c
dlls/qmgr/job.c
+27
-0
qmgr.c
dlls/qmgr/qmgr.c
+1
-6
qmgr.h
dlls/qmgr/qmgr.h
+18
-0
No files found.
dlls/qmgr/file.c
View file @
b329a2ef
...
...
@@ -170,3 +170,91 @@ HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
*
ppObj
=
&
This
->
lpVtbl
;
return
S_OK
;
}
static
DWORD
CALLBACK
copyProgressCallback
(
LARGE_INTEGER
totalSize
,
LARGE_INTEGER
totalTransferred
,
LARGE_INTEGER
streamSize
,
LARGE_INTEGER
streamTransferred
,
DWORD
streamNum
,
DWORD
reason
,
HANDLE
srcFile
,
HANDLE
dstFile
,
LPVOID
obj
)
{
BackgroundCopyFileImpl
*
file
=
(
BackgroundCopyFileImpl
*
)
obj
;
BackgroundCopyJobImpl
*
job
=
file
->
owner
;
ULONG64
diff
;
EnterCriticalSection
(
&
job
->
cs
);
diff
=
(
file
->
fileProgress
.
BytesTotal
==
BG_SIZE_UNKNOWN
?
totalTransferred
.
QuadPart
:
totalTransferred
.
QuadPart
-
file
->
fileProgress
.
BytesTransferred
);
file
->
fileProgress
.
BytesTotal
=
totalSize
.
QuadPart
;
file
->
fileProgress
.
BytesTransferred
=
totalTransferred
.
QuadPart
;
job
->
jobProgress
.
BytesTransferred
+=
diff
;
LeaveCriticalSection
(
&
job
->
cs
);
return
(
job
->
state
==
BG_JOB_STATE_TRANSFERRING
?
PROGRESS_CONTINUE
:
PROGRESS_CANCEL
);
}
BOOL
processFile
(
BackgroundCopyFileImpl
*
file
,
BackgroundCopyJobImpl
*
job
)
{
static
WCHAR
prefix
[]
=
{
'B'
,
'I'
,
'T'
,
0
};
WCHAR
tmpDir
[
MAX_PATH
];
WCHAR
tmpName
[
MAX_PATH
];
if
(
!
GetTempPathW
(
MAX_PATH
,
tmpDir
))
{
ERR
(
"Couldn't create temp file name: %d
\n
"
,
GetLastError
());
/* Guessing on what state this should give us */
transitionJobState
(
job
,
BG_JOB_STATE_QUEUED
,
BG_JOB_STATE_TRANSIENT_ERROR
);
return
FALSE
;
}
if
(
!
GetTempFileNameW
(
tmpDir
,
prefix
,
0
,
tmpName
))
{
ERR
(
"Couldn't create temp file: %d
\n
"
,
GetLastError
());
/* Guessing on what state this should give us */
transitionJobState
(
job
,
BG_JOB_STATE_QUEUED
,
BG_JOB_STATE_TRANSIENT_ERROR
);
return
FALSE
;
}
EnterCriticalSection
(
&
job
->
cs
);
file
->
fileProgress
.
BytesTotal
=
BG_SIZE_UNKNOWN
;
file
->
fileProgress
.
BytesTransferred
=
0
;
file
->
fileProgress
.
Completed
=
FALSE
;
LeaveCriticalSection
(
&
job
->
cs
);
TRACE
(
"Transferring: %s -> %s -> %s
\n
"
,
debugstr_w
(
file
->
info
.
RemoteName
),
debugstr_w
(
tmpName
),
debugstr_w
(
file
->
info
.
LocalName
));
transitionJobState
(
job
,
BG_JOB_STATE_QUEUED
,
BG_JOB_STATE_TRANSFERRING
);
if
(
!
CopyFileExW
(
file
->
info
.
RemoteName
,
tmpName
,
copyProgressCallback
,
file
,
NULL
,
0
))
{
ERR
(
"Local file copy failed: error %d
\n
"
,
GetLastError
());
transitionJobState
(
job
,
BG_JOB_STATE_TRANSFERRING
,
BG_JOB_STATE_ERROR
);
return
FALSE
;
}
if
(
transitionJobState
(
job
,
BG_JOB_STATE_TRANSFERRING
,
BG_JOB_STATE_QUEUED
))
{
lstrcpyW
(
file
->
tempFileName
,
tmpName
);
EnterCriticalSection
(
&
job
->
cs
);
file
->
fileProgress
.
Completed
=
TRUE
;
job
->
jobProgress
.
FilesTransferred
++
;
LeaveCriticalSection
(
&
job
->
cs
);
return
TRUE
;
}
else
{
DeleteFileW
(
tmpName
);
return
FALSE
;
}
}
dlls/qmgr/job.c
View file @
b329a2ef
...
...
@@ -98,6 +98,7 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_AddFile(
file
=
(
BackgroundCopyFileImpl
*
)
pFile
;
EnterCriticalSection
(
&
This
->
cs
);
list_add_head
(
&
This
->
files
,
&
file
->
entryFromJob
);
This
->
jobProgress
.
BytesTotal
=
BG_SIZE_UNKNOWN
;
++
This
->
jobProgress
.
FilesTotal
;
LeaveCriticalSection
(
&
This
->
cs
);
...
...
@@ -485,3 +486,29 @@ HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
*
ppObj
=
&
This
->
lpVtbl
;
return
S_OK
;
}
void
processJob
(
BackgroundCopyJobImpl
*
job
)
{
for
(;;)
{
BackgroundCopyFileImpl
*
file
;
BOOL
done
=
TRUE
;
EnterCriticalSection
(
&
job
->
cs
);
LIST_FOR_EACH_ENTRY
(
file
,
&
job
->
files
,
BackgroundCopyFileImpl
,
entryFromJob
)
if
(
!
file
->
fileProgress
.
Completed
)
{
done
=
FALSE
;
break
;
}
LeaveCriticalSection
(
&
job
->
cs
);
if
(
done
)
{
transitionJobState
(
job
,
BG_JOB_STATE_QUEUED
,
BG_JOB_STATE_TRANSFERRED
);
return
;
}
if
(
!
processFile
(
file
,
job
))
return
;
}
}
dlls/qmgr/qmgr.c
View file @
b329a2ef
...
...
@@ -189,11 +189,6 @@ DWORD WINAPI fileTransfer(void *param)
LeaveCriticalSection
(
&
qmgr
->
cs
);
if
(
haveJob
)
{
FIXME
(
"Actually process job %p; setting error state
\n
"
,
job
);
EnterCriticalSection
(
&
qmgr
->
cs
);
job
->
state
=
BG_JOB_STATE_ERROR
;
LeaveCriticalSection
(
&
qmgr
->
cs
);
}
processJob
(
job
);
}
}
dlls/qmgr/qmgr.h
View file @
b329a2ef
...
...
@@ -73,6 +73,7 @@ typedef struct
LONG
ref
;
BG_FILE_INFO
info
;
BG_FILE_PROGRESS
fileProgress
;
WCHAR
tempFileName
[
MAX_PATH
];
struct
list
entryFromJob
;
BackgroundCopyJobImpl
*
owner
;
}
BackgroundCopyFileImpl
;
...
...
@@ -107,6 +108,8 @@ HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
HRESULT
EnumBackgroundCopyFilesConstructor
(
LPVOID
*
ppObj
,
IBackgroundCopyJob
*
copyJob
);
DWORD
WINAPI
fileTransfer
(
void
*
param
);
void
processJob
(
BackgroundCopyJobImpl
*
job
);
BOOL
processFile
(
BackgroundCopyFileImpl
*
file
,
BackgroundCopyJobImpl
*
job
);
/* Little helper functions */
static
inline
char
*
...
...
@@ -117,4 +120,19 @@ qmgr_strdup(const char *s)
return
d
?
memcpy
(
d
,
s
,
n
)
:
NULL
;
}
static
inline
BOOL
transitionJobState
(
BackgroundCopyJobImpl
*
job
,
BG_JOB_STATE
fromState
,
BG_JOB_STATE
toState
)
{
BOOL
rv
=
FALSE
;
EnterCriticalSection
(
&
globalMgr
.
cs
);
if
(
job
->
state
==
fromState
)
{
job
->
state
=
toState
;
rv
=
TRUE
;
}
LeaveCriticalSection
(
&
globalMgr
.
cs
);
return
rv
;
}
#endif
/* __QMGR_H__ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment