Commit e502d4dd authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

ScheduleJob for 'file' ports.

parent 8f83234a
Makefile
libwinspool.drv.def
winspool.drv.dbg.c
winspool.res
/*
* 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."
}
......@@ -12,6 +12,8 @@ C_SRCS = \
info.c \
wspool.c
RC_SRCS = winspool.rc
SUBDIRS = tests
@MAKE_DLL_RULES@
......
......@@ -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));
......
/*
* 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"
......@@ -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;
......
/******************************************************************************
* 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment