qmgr.h 4.57 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*
 * Queue Manager definitions
 *
 * Copyright 2007 Google (Roy Shea)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#ifndef __QMGR_H__
#define __QMGR_H__

#include "windef.h"
#define COBJMACROS
26
#include "bits.h"
27
#include "bits1_5.h"
28 29
#include "bits2_0.h"
#include "bits2_5.h"
30
#include "bits3_0.h"
31

32
#include <string.h>
33
#include "wine/list.h"
34
#include "wine/unicode.h"
35

36 37 38
/* Background copy job vtbl and related data */
typedef struct
{
39
    IBackgroundCopyJob3 IBackgroundCopyJob3_iface;
40
    IBackgroundCopyJobHttpOptions IBackgroundCopyJobHttpOptions_iface;
41
    LONG ref;
42
    LPWSTR displayName;
43
    LPWSTR description;
44 45
    BG_JOB_TYPE type;
    GUID jobId;
46 47
    struct list files;
    BG_JOB_PROGRESS jobProgress;
48
    BG_JOB_STATE state;
49
    ULONG notify_flags;
50 51
    IBackgroundCopyCallback2 *callback;
    BOOL callback2; /* IBackgroundCopyCallback2 is supported in addition to IBackgroundCopyCallback */
52 53
    /* Protects file list, and progress */
    CRITICAL_SECTION cs;
54
    struct list entryFromQmgr;
55
    struct
56 57 58
    {
        WCHAR              *headers;
        ULONG               flags;
59
        BG_AUTH_CREDENTIALS creds[BG_AUTH_TARGET_PROXY][BG_AUTH_SCHEME_PASSPORT];
60 61
    } http_options;
    struct
62 63 64 65 66
    {
        BG_ERROR_CONTEXT      context;
        HRESULT               code;
        IBackgroundCopyFile2 *file;
    } error;
67 68 69
    HANDLE wait;
    HANDLE cancel;
    HANDLE done;
70 71
} BackgroundCopyJobImpl;

72 73 74
/* Background copy file vtbl and related data */
typedef struct
{
75
    IBackgroundCopyFile2 IBackgroundCopyFile2_iface;
76 77
    LONG ref;
    BG_FILE_INFO info;
78
    BG_FILE_PROGRESS fileProgress;
79
    WCHAR tempFileName[MAX_PATH];
80
    struct list entryFromJob;
81
    BackgroundCopyJobImpl *owner;
82
    DWORD read_size;
83 84
} BackgroundCopyFileImpl;

85 86 87
/* Background copy manager vtbl and related data */
typedef struct
{
88
    IBackgroundCopyManager IBackgroundCopyManager_iface;
89
    /* Protects job list, job states, and jobEvent  */
90
    CRITICAL_SECTION cs;
91
    HANDLE jobEvent;
92
    struct list jobs;
93 94
} BackgroundCopyManagerImpl;

95 96
typedef struct
{
97
    IClassFactory IClassFactory_iface;
98 99
} ClassFactoryImpl;

100 101 102
extern HANDLE stop_event DECLSPEC_HIDDEN;
extern ClassFactoryImpl BITS_ClassFactory DECLSPEC_HIDDEN;
extern BackgroundCopyManagerImpl globalMgr DECLSPEC_HIDDEN;
103

104
HRESULT BackgroundCopyManagerConstructor(LPVOID *ppObj) DECLSPEC_HIDDEN;
105
HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
106
                                     GUID *pJobId, BackgroundCopyJobImpl **job) DECLSPEC_HIDDEN;
107 108
HRESULT enum_copy_job_create(BackgroundCopyManagerImpl *qmgr,
        IEnumBackgroundCopyJobs **enumjob) DECLSPEC_HIDDEN;
109 110
HRESULT BackgroundCopyFileConstructor(BackgroundCopyJobImpl *owner,
                                      LPCWSTR remoteName, LPCWSTR localName,
111
                                      BackgroundCopyFileImpl **file) DECLSPEC_HIDDEN;
112
HRESULT EnumBackgroundCopyFilesConstructor(BackgroundCopyJobImpl*, IEnumBackgroundCopyFiles**) DECLSPEC_HIDDEN;
113 114 115
DWORD WINAPI fileTransfer(void *param) DECLSPEC_HIDDEN;
void processJob(BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN;
BOOL processFile(BackgroundCopyFileImpl *file, BackgroundCopyJobImpl *job) DECLSPEC_HIDDEN;
116
BOOL transitionJobState(BackgroundCopyJobImpl *job, BG_JOB_STATE from, BG_JOB_STATE to) DECLSPEC_HIDDEN;
117

118
/* Little helper functions */
119 120 121 122 123 124 125 126 127 128 129 130 131 132
static inline WCHAR *strdupW(const WCHAR *src)
{
    WCHAR *dst = HeapAlloc(GetProcessHeap(), 0, (strlenW(src) + 1) * sizeof(WCHAR));
    if (dst) strcpyW(dst, src);
    return dst;
}

static inline WCHAR *co_strdupW(const WCHAR *src)
{
    WCHAR *dst = CoTaskMemAlloc((strlenW(src) + 1) * sizeof(WCHAR));
    if (dst) strcpyW(dst, src);
    return dst;
}

133 134 135 136 137 138 139 140 141 142 143 144 145
static inline HRESULT return_strval(const WCHAR *str, WCHAR **ret)
{
    int len;

    if (!ret) return E_INVALIDARG;

    len = strlenW(str);
    *ret = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
    if (!*ret) return E_OUTOFMEMORY;
    strcpyW(*ret, str);
    return S_OK;
}

146
#endif /* __QMGR_H__ */