winspool: file scheduler
Huw D M Davies
h.davies1 at physics.ox.ac.uk
Tue Jul 12 04:18:26 CDT 2005
Huw Davies <huw at codeweavers.com>
ScheduleJob for 'file' ports.
Index: dlls/winspool/.cvsignore
===================================================================
RCS file: /home/wine/wine/dlls/winspool/.cvsignore,v
retrieving revision 1.10
diff -u -p -r1.10 .cvsignore
--- dlls/winspool/.cvsignore 7 May 2005 12:39:52 -0000 1.10
+++ dlls/winspool/.cvsignore 12 Jul 2005 09:04:23 -0000
@@ -1,3 +1,4 @@
Makefile
libwinspool.drv.def
winspool.drv.dbg.c
+winspool.res
Index: dlls/winspool/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/winspool/Makefile.in,v
retrieving revision 1.30
diff -u -p -r1.30 Makefile.in
--- dlls/winspool/Makefile.in 6 Jul 2005 15:44:15 -0000 1.30
+++ dlls/winspool/Makefile.in 12 Jul 2005 09:04:23 -0000
@@ -12,6 +12,8 @@ C_SRCS = \
info.c \
wspool.c
+RC_SRCS = winspool.rc
+
SUBDIRS = tests
@MAKE_DLL_RULES@
Index: dlls/winspool/info.c
===================================================================
RCS file: /home/wine/wine/dlls/winspool/info.c,v
retrieving revision 1.114
diff -u -p -r1.114 info.c
--- dlls/winspool/info.c 11 Jul 2005 13:21:48 -0000 1.114
+++ dlls/winspool/info.c 12 Jul 2005 09:04:23 -0000
@@ -56,6 +56,8 @@
#include "heap.h"
#include "winnls.h"
+#include "wspool.h"
+
WINE_DEFAULT_DEBUG_CHANNEL(winspool);
static CRITICAL_SECTION printer_handles_cs;
@@ -4772,6 +4774,88 @@ static BOOL schedule_cups(LPCWSTR printe
}
}
+INT_PTR CALLBACK file_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ LPWSTR filename;
+
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ SetWindowLongPtrW(hwnd, DWLP_USER, lparam);
+ return TRUE;
+
+ case WM_COMMAND:
+ if(HIWORD(wparam) == BN_CLICKED)
+ {
+ if(LOWORD(wparam) == IDOK)
+ {
+ HANDLE hf;
+ DWORD len = SendDlgItemMessageW(hwnd, 201, WM_GETTEXTLENGTH, 0, 0);
+ LPWSTR *output;
+
+ filename = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
+ GetDlgItemTextW(hwnd, EDITBOX, filename, len + 1);
+
+ if(GetFileAttributesW(filename) != INVALID_FILE_ATTRIBUTES)
+ {
+ WCHAR caption[200], message[200];
+ int mb_ret;
+
+ LoadStringW(WINSPOOL_hInstance, IDS_CAPTION, caption, sizeof(caption) / sizeof(WCHAR));
+ LoadStringW(WINSPOOL_hInstance, IDS_FILE_EXISTS, message, sizeof(message) / sizeof(WCHAR));
+ mb_ret = MessageBoxW(hwnd, message, caption, MB_OKCANCEL | MB_ICONEXCLAMATION);
+ if(mb_ret == IDCANCEL)
+ {
+ HeapFree(GetProcessHeap(), 0, filename);
+ return TRUE;
+ }
+ }
+ hf = CreateFileW(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ if(hf == INVALID_HANDLE_VALUE)
+ {
+ WCHAR caption[200], message[200];
+
+ LoadStringW(WINSPOOL_hInstance, IDS_CAPTION, caption, sizeof(caption) / sizeof(WCHAR));
+ LoadStringW(WINSPOOL_hInstance, IDS_CANNOT_OPEN, message, sizeof(message) / sizeof(WCHAR));
+ MessageBoxW(hwnd, message, caption, MB_OK | MB_ICONEXCLAMATION);
+ HeapFree(GetProcessHeap(), 0, filename);
+ return TRUE;
+ }
+ CloseHandle(hf);
+ DeleteFileW(filename);
+ output = (LPWSTR *)GetWindowLongPtrW(hwnd, DWLP_USER);
+ *output = filename;
+ EndDialog(hwnd, IDOK);
+ return TRUE;
+ }
+ if(LOWORD(wparam) == IDCANCEL)
+ {
+ EndDialog(hwnd, IDCANCEL);
+ return TRUE;
+ }
+ }
+ return FALSE;
+ }
+ return FALSE;
+}
+
+/*****************************************************************************
+ * schedule_file
+ */
+static BOOL schedule_file(LPCWSTR filename)
+{
+ LPWSTR output = NULL;
+
+ if(DialogBoxParamW(WINSPOOL_hInstance, MAKEINTRESOURCEW(FILENAME_DIALOG), GetForegroundWindow(),
+ file_dlg_proc, (LPARAM)&output) == IDOK)
+ {
+ TRACE("copy to %s\n", debugstr_w(output));
+ CopyFileW(filename, output, FALSE);
+ HeapFree(GetProcessHeap(), 0, output);
+ return TRUE;
+ }
+ return FALSE;
+}
/*****************************************************************************
* ScheduleJob [WINSPOOL.@]
*
@@ -4814,6 +4898,10 @@ BOOL WINAPI ScheduleJob( HANDLE hPrinter
else if(!strncmpW(pi5->pPortName, CUPS_Port, strlenW(CUPS_Port)))
{
schedule_cups(pi5->pPortName + strlenW(CUPS_Port), job->filename);
+ }
+ else if(!strncmpW(pi5->pPortName, FILE_Port, strlenW(FILE_Port)))
+ {
+ schedule_file(job->filename);
}
else
{
Index: dlls/winspool/wspool.c
===================================================================
RCS file: /home/wine/wine/dlls/winspool/wspool.c,v
retrieving revision 1.12
diff -u -p -r1.12 wspool.c
--- dlls/winspool/wspool.c 13 Dec 2004 21:19:01 -0000 1.12
+++ dlls/winspool/wspool.c 12 Jul 2005 09:04:23 -0000
@@ -30,7 +30,7 @@
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(winspool);
-
+HINSTANCE WINSPOOL_hInstance = NULL;
/******************************************************************************
* DllMain
@@ -43,8 +43,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance,
switch (reason)
{
case DLL_PROCESS_ATTACH: {
- extern void WINSPOOL_LoadSystemPrinters(void);
-
+ WINSPOOL_hInstance = hInstance;
DisableThreadLibraryCalls(hInstance);
WINSPOOL_LoadSystemPrinters();
break;
--- /dev/null 2004-02-23 21:02:56.000000000 +0000
+++ dlls/winspool/winspool.rc 2005-07-11 17:56:20.000000000 +0100
@@ -0,0 +1,26 @@
+/*
+ * Top level resource file for winspool
+ *
+ * Copyright 2005 Huw Davies
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "wspool.h"
+
+#include "En.rc"
--- /dev/null 2004-02-23 21:02:56.000000000 +0000
+++ dlls/winspool/En.rc 2005-07-11 17:57:49.000000000 +0100
@@ -0,0 +1,39 @@
+/*
+ * English resources for winspool
+ *
+ * Copyright 2005 Huw Davies
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
+
+FILENAME_DIALOG DIALOG LOADONCALL MOVEABLE DISCARDABLE 6, 18, 245, 47
+STYLE DS_CONTEXTHELP | DS_MODALFRAME | DS_SETFONT | DS_SETFOREGROUND | WS_POPUPWINDOW | WS_VISIBLE | WS_CAPTION
+CAPTION "Print to File"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ LTEXT "&Output File Name:", -1, 7, 13, 194, 13, WS_VISIBLE
+ EDITTEXT EDITBOX, 6, 28, 174, 12, WS_VISIBLE | ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK", IDOK, 199, 10, 40, 14, WS_VISIBLE
+ PUSHBUTTON "Cancel", IDCANCEL, 199, 27, 40, 14, WS_VISIBLE
+END
+
+STRINGTABLE DISCARDABLE
+{
+ IDS_CAPTION "Local Port"
+ IDS_FILE_EXISTS "The output file already exists. Click OK to overwrite."
+ IDS_CANNOT_OPEN "Unable to create the output file."
+}
--- /dev/null 2004-02-23 21:02:56.000000000 +0000
+++ dlls/winspool/wspool.h 2005-07-11 17:56:02.000000000 +0100
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * winspool internal include file
+ *
+ *
+ * Copyright 2005 Huw Davies
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+extern HINSTANCE WINSPOOL_hInstance;
+
+extern void WINSPOOL_LoadSystemPrinters(void);
+
+#define IDS_CAPTION 10
+#define IDS_FILE_EXISTS 11
+#define IDS_CANNOT_OPEN 12
+
+#define FILENAME_DIALOG 100
+#define EDITBOX 201
More information about the wine-patches
mailing list