diff --git a/dlls/winspool/.cvsignore b/dlls/winspool/.cvsignore index 2fb969f7556..c1082a0fdfb 100644 --- a/dlls/winspool/.cvsignore +++ b/dlls/winspool/.cvsignore @@ -1,3 +1,4 @@ Makefile libwinspool.drv.def winspool.drv.dbg.c +winspool.res diff --git a/dlls/winspool/En.rc b/dlls/winspool/En.rc new file mode 100644 index 00000000000..8e0cd54e572 --- /dev/null +++ b/dlls/winspool/En.rc @@ -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." +} diff --git a/dlls/winspool/Makefile.in b/dlls/winspool/Makefile.in index 2a1b9fe4685..4faf9658cb8 100644 --- a/dlls/winspool/Makefile.in +++ b/dlls/winspool/Makefile.in @@ -12,6 +12,8 @@ C_SRCS = \ info.c \ wspool.c +RC_SRCS = winspool.rc + SUBDIRS = tests @MAKE_DLL_RULES@ diff --git a/dlls/winspool/info.c b/dlls/winspool/info.c index a1ba08425f9..b5fc3ba3ce7 100644 --- a/dlls/winspool/info.c +++ b/dlls/winspool/info.c @@ -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 printer_name, LPCWSTR filename) } } +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.@] * @@ -4815,6 +4899,10 @@ BOOL WINAPI ScheduleJob( HANDLE hPrinter, DWORD dwJobID ) { schedule_cups(pi5->pPortName + strlenW(CUPS_Port), job->filename); } + else if(!strncmpW(pi5->pPortName, FILE_Port, strlenW(FILE_Port))) + { + schedule_file(job->filename); + } else { FIXME("can't schedule to port %s\n", debugstr_w(pi5->pPortName)); diff --git a/dlls/winspool/winspool.rc b/dlls/winspool/winspool.rc new file mode 100644 index 00000000000..c5d1e441877 --- /dev/null +++ b/dlls/winspool/winspool.rc @@ -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" diff --git a/dlls/winspool/wspool.c b/dlls/winspool/wspool.c index c8eebcb0201..bf3b8cd8145 100644 --- a/dlls/winspool/wspool.c +++ b/dlls/winspool/wspool.c @@ -27,10 +27,11 @@ #include "winbase.h" #include "wingdi.h" #include "winspool.h" +#include "wspool.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(winspool); - +HINSTANCE WINSPOOL_hInstance = NULL; /****************************************************************************** * DllMain @@ -43,8 +44,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD reason, LPVOID lpReserved) switch (reason) { case DLL_PROCESS_ATTACH: { - extern void WINSPOOL_LoadSystemPrinters(void); - + WINSPOOL_hInstance = hInstance; DisableThreadLibraryCalls(hInstance); WINSPOOL_LoadSystemPrinters(); break; diff --git a/dlls/winspool/wspool.h b/dlls/winspool/wspool.h new file mode 100644 index 00000000000..83c611885f2 --- /dev/null +++ b/dlls/winspool/wspool.h @@ -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