Hello,

How implement IPrintOemDriverUni::DrvWriteAbortBuf ? If you have any sample,
can you send it.

Please, Help me, I don't understand/find solution to abort document.

Benoit

Re: How implement DrvWriteAbortBuf ? by Serguei

Serguei
Wed Nov 19 11:42:10 CST 2003

> How implement IPrintOemDriverUni::DrvWriteAbortBuf ? If you have any
sample,
> can you send it.

I assume you've meant "use" and not "implement".

> Please, Help me, I don't understand/find solution to abort document.

The purpose of the rendering plug-in does not generally include the abortion
of the documents. You can hack around it if you want but it should rather be
done somewhere else, if at all. DrvWriteAbortBuf is to send commands to the
printer only _after_ the _user_ has terminated the print job. It cannot be
called at any other time.



Re: How implement DrvWriteAbortBuf ? by Benoit

Benoit
Thu Nov 20 05:52:46 CST 2003

I need to implement something to allow the user to abort a printing
document.
I have read in an old post the the DrvWriteAbortBuf is the good function to
do it. Is it right ?

> > How implement IPrintOemDriverUni::DrvWriteAbortBuf ? If you have any
> sample,
> > can you send it.
>
> I assume you've meant "use" and not "implement".
>
> > Please, Help me, I don't understand/find solution to abort document.
>
> The purpose of the rendering plug-in does not generally include the
abortion
> of the documents. You can hack around it if you want but it should rather
be
> done somewhere else, if at all. DrvWriteAbortBuf is to send commands to
the
> printer only _after_ the _user_ has terminated the print job. It cannot be
> called at any other time.
>
>



Re: How implement DrvWriteAbortBuf ? by Serguei

Serguei
Thu Nov 20 10:59:34 CST 2003

> I need to implement something to allow the user to abort a printing
> document.
> I have read in an old post the the DrvWriteAbortBuf is the good function
to
> do it. Is it right ?

DrvWriteAbortBuf only allows you to send data to the printer in case
document was aborted. I'm not sure what you want. If you want to send abort
command to printer after you discover that user has aborted the document,
then this is the right function to use. If you want to abort the document
yourself, then it is not.



Re: How implement DrvWriteAbortBuf ? by vipin

vipin
Thu Nov 20 09:14:21 CST 2003

If he wants to abort the job, use SetJob or SetPrinter
win32 apis.
vipin
>-----Original Message-----
>> I need to implement something to allow the user to
abort a printing
>> document.
>> I have read in an old post the the DrvWriteAbortBuf is
the good function
>to
>> do it. Is it right ?
>
>DrvWriteAbortBuf only allows you to send data to the
printer in case
>document was aborted. I'm not sure what you want. If you
want to send abort
>command to printer after you discover that user has
aborted the document,
>then this is the right function to use. If you want to
abort the document
>yourself, then it is not.
>
>
>.
>

Re: How implement DrvWriteAbortBuf ? by Benoit

Benoit
Thu Nov 20 10:29:56 CST 2003

> > I need to implement something to allow the user to abort a printing
> > document.
> > I have read in an old post the the DrvWriteAbortBuf is the good function
> to
> > do it. Is it right ?
> DrvWriteAbortBuf only allows you to send data to the printer in case
> document was aborted. I'm not sure what you want. If you want to send
abort
> command to printer after you discover that user has aborted the document,
> then this is the right function to use. If you want to abort the document
> yourself, then it is not.
>

This is the first case I need. My printer need a specific command to abort a
job. So I need to implement DrvWriteAbortBuf, but I don't understand hox can
I do it.

Thanks for your help.

Benoit (sorry for my poor english)



Re: How implement DrvWriteAbortBuf ? by Serguei

Serguei
Thu Nov 20 13:05:03 CST 2003

> This is the first case I need. My printer need a specific command to abort
a
> job. So I need to implement DrvWriteAbortBuf, but I don't understand hox
can
> I do it.

You do not implement it, you call it yourself. You only need to use it if
you are writing to spooler directly using DrvWriteSpoolBuf. You then check
if it fails, and if it does, you then can clean up with DrvWriteAbortBuf. If
you are not using DrvWriteSpoolBuf, then you should set up clean up data in
.gpd file, refer to DDK doc for details on .gpd format.



Re: How implement DrvWriteAbortBuf ? by Benoit

Benoit
Thu Nov 20 11:53:39 CST 2003

Thank for your help

> > This is the first case I need. My printer need a specific command to
abort
> a
> > job. So I need to implement DrvWriteAbortBuf, but I don't understand hox
> can
> > I do it.
>
> You do not implement it, you call it yourself. You only need to use it if
> you are writing to spooler directly using DrvWriteSpoolBuf. You then check
> if it fails, and if it does, you then can clean up with DrvWriteAbortBuf.
If
> you are not using DrvWriteSpoolBuf, then you should set up clean up data
in
> .gpd file, refer to DDK doc for details on .gpd format.

There's no GPD command to clean up the printing operation.
If I use it, and not implement it, where must I use it, and where can I send
the "<RAZ>" command to my printer.

Actually my driver works like this:
my GPD and my rendering plug-in send the data to the card printer.
The printer wait a card insertion. My language monitor ask each seconde if
the card as been printing.
All of this are OK. I just need to send <RAZ> to my printer. That's means
the user want to abort the document.

thanks
Benoit






Re: How implement DrvWriteAbortBuf ? by Serguei

Serguei
Thu Nov 20 16:23:10 CST 2003

> There's no GPD command to clean up the printing operation.
> If I use it, and not implement it, where must I use it, and where can I
send
> the "<RAZ>" command to my printer.

We don't use it, but I _think_ that data from CmdEndDoc will get sent to
printer regardless if it was cancelled or terminated normally. In any case,
OEMEndDoc hook will always be called. So if CmdEndDoc will not work for you,
just implement OEMEndDoc and do the following in it: first try to write end
of printing command with DrvWriteSpoolBuf, if that fails, it means that user
has aborted the doc and you have to send the abort command with
DrvWriteAbortBuf.



Re: How implement DrvWriteAbortBuf ? by Benoit

Benoit
Fri Nov 21 09:11:37 CST 2003

> > There's no GPD command to clean up the printing operation.
> > If I use it, and not implement it, where must I use it, and where can I
> send
> > the "<RAZ>" command to my printer.
>
> We don't use it, but I _think_ that data from CmdEndDoc will get sent to
> printer regardless if it was cancelled or terminated normally. In any
case,
> OEMEndDoc hook will always be called. So if CmdEndDoc will not work for
you,
> just implement OEMEndDoc and do the following in it: first try to write
end
> of printing command with DrvWriteSpoolBuf, if that fails, it means that
user
> has aborted the doc and you have to send the abort command with
> DrvWriteAbortBuf.

I have try your solution, but the problem is that CmdEndDoc and OEMEndDoc
are always called. So <RAZ> is always send to the printer, so my document is
always aborted.

Benoit





Re: How implement DrvWriteAbortBuf ? by Serguei

Serguei
Fri Nov 21 12:37:13 CST 2003

> I have try your solution, but the problem is that CmdEndDoc and OEMEndDoc
> are always called. So <RAZ> is always send to the printer, so my document
is
> always aborted.

That is why I have told you to use DrvWriteSpoolBuf first. Try calling it
with some command that does nothing for the printer in OEMEndDoc. If it
succeds, then your document was printed normally, if it fails, then you send
abort command with DrvWriteAbortBuf. You can also just call
DrvWriteAbortBuf, the data will only be sent if document was aborted, but
I'm not sure if it is legal to call it without DrvWriteSpoolBuf failing
first.



Re: How implement DrvWriteAbortBuf ? by Benoit

Benoit
Mon Nov 24 08:29:20 CST 2003

> That is why I have told you to use DrvWriteSpoolBuf first. Try calling it
> with some command that does nothing for the printer in OEMEndDoc. If it
> succeds, then your document was printed normally, if it fails, then you
send
> abort command with DrvWriteAbortBuf. You can also just call
> DrvWriteAbortBuf, the data will only be sent if document was aborted, but
> I'm not sure if it is legal to call it without DrvWriteSpoolBuf failing
> first.

I have try this, but it doesn't works.

BOOL APIENTRY OEMEndDoc( SURFOBJ *pso, FLONG fl )
{
PDEVOBJ pdevobj;
POEMPDEV poempdev;
HRESULT ret;

VERBOSE(DLLTEXT("OEMEndDoc() entry.\r\n"));

pdevobj = (PDEVOBJ)pso->dhpdev;
poempdev = (POEMPDEV)pdevobj->pdevOEM;

//
// turn around to call Unidrv
//

ret = pdevobj->pDrvProcs->DrvWriteSpoolBuf(pdevobj, "RAZ",3);
if( ret == E_FAIL )
ret = pdevobj->pDrvProcs->DrvWriteAbortBuf(pdevobj, "<RAZ>",5,30);


/*return (((PFN_DrvEndDoc)(poempdev->pfnUnidrv[UD_DrvEndDoc])) (
pso,
fl));
*/
return ret;
}



Re: How implement DrvWriteAbortBuf ? by Serguei

Serguei
Mon Nov 24 13:41:16 CST 2003

> I have try this, but it doesn't works.

I've just tried sticking it in one of our drivers and it works here, the
text is properly injected when job is cancelled. Except I have used
IPrintOemDriverUni interface instead of pDrvProcs of POEMPDEV. Can you try
it with IPrintOemDriverUni instead? pDrvProcs is not supposed to be used by
rendering plug-ins that have COM interface. Code is something like this:

BOOL APIENTRY XEndDoc (SURFOBJ *pso, FLONG fl)
{
...
IPrinterOemDriverUni *ipodu; <- get that from PublishDriverInterface
DWORD written;
HRESULT retval = ipodu->DrvWriteSpoolBuf (reinterpret_cast <DEVOBJ *>
(pso->dhpdev), "RAZ", 3, &written);
if (retval == E_FAIL)
{
retval = ipodu->DrvWriteAbortBuf (reinterpret_cast <DEVOBJ *>
(pso->dhpdev), "<RAZ>", 5, 30);
}
...
}



Re: How implement DrvWriteAbortBuf ? by Benoit

Benoit
Tue Nov 25 05:06:06 CST 2003

> I've just tried sticking it in one of our drivers and it works here, the
> text is properly injected when job is cancelled. Except I have used
> IPrintOemDriverUni interface instead of pDrvProcs of POEMPDEV. Can you try
> it with IPrintOemDriverUni instead? pDrvProcs is not supposed to be used
by
> rendering plug-ins that have COM interface. Code is something like this:
>
> BOOL APIENTRY XEndDoc (SURFOBJ *pso, FLONG fl)
> {
> ...
> IPrinterOemDriverUni *ipodu; <- get that from PublishDriverInterface
> DWORD written;
> HRESULT retval = ipodu->DrvWriteSpoolBuf (reinterpret_cast <DEVOBJ *>
> (pso->dhpdev), "RAZ", 3, &written);
> if (retval == E_FAIL)
> {
> retval = ipodu->DrvWriteAbortBuf (reinterpret_cast <DEVOBJ *>
> (pso->dhpdev), "<RAZ>", 5, 30);
> }
> ...
> }
>

I have try your code, but it doesn't build.
I have include <PRCOMOEM.H> in ddihook.cpp. Is it right ?
I have this error (for the line IPrintOemDriverUni *ipodu;):
dihook.cpp(701) : error C4700: local variable 'ipodu' used without having
been initialized
What do you mean with: "get that from PublishDriverIntercace"


This is my PublishDriverInterface in intrface.cpp:

----------------------------------------------------------------------------
------
HRESULT __stdcall IOemUni::PublishDriverInterface(IUnknown *pIUnknown)
{
VERBOSE(DLLTEXT("IOemUni::PublishDriverInterface() entry.\r\n"));

// Need to store pointer to Driver Helper functions, if we already
haven't.
if (this->m_pOEMHelp == NULL)
{
HRESULT hResult;

// Get Interface to Helper Functions.
hResult = pIUnknown->QueryInterface(IID_IPrintOemDriverUni,
(void** ) &(this->m_pOEMHelp));

if(!SUCCEEDED(hResult))
{
// Make sure that interface pointer reflects interface query
failure.
this->m_pOEMHelp = NULL;

return E_FAIL;
}
}

return S_OK;
}
----------------------------------------------------------------------------
------

and my IOemUni class declaration:

----------------------------------------------------------------------------
------
////////////////////////////////////////////////////////////////////////////
////
//
// IOemUni
//
// Interface for Unidrv OEM sample rendering module
//
class IOemUni : public IPrintOemUni
{
public:
public:
// *** IUnknown methods ***
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj);
STDMETHOD_(ULONG,AddRef) (THIS);
STDMETHOD_(ULONG,Release) (THIS);

// Method for publishing Driver interface.
STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown);

// Method for getting the implemented methods.
// Returns S_OK if the given method is implemneted.
// Returns S_FALSE if the given method is notimplemneted.
STDMETHOD(GetImplementedMethod)(THIS_ PSTR pMethodName);

// Method for OEM to specify DDI hook out
STDMETHOD(EnableDriver) (THIS_ DWORD DriverVersion,
DWORD cbSize,
PDRVENABLEDATA pded);

// Method to notify OEM plugin that it is no longer required
STDMETHOD(DisableDriver) (THIS);

// Method for OEM to contruct its own PDEV
STDMETHOD(EnablePDEV) (THIS_ PDEVOBJ pdevobj,
PWSTR pPrinterName,
ULONG cPatterns,
HSURF *phsurfPatterns,
ULONG cjGdiInfo,
GDIINFO *pGdiInfo,
ULONG cjDevInfo,
DEVINFO *pDevInfo,
DRVENABLEDATA *pded,
OUT PDEVOEM *pDevOem);

// Method for OEM to free any resource associated with its PDEV
STDMETHOD(DisablePDEV) (THIS_ PDEVOBJ pdevobj);

// Method for OEM to transfer from old PDEV to new PDEV
STDMETHOD(ResetPDEV) (THIS_ PDEVOBJ pdevobjOld,
PDEVOBJ pdevobjNew);

// Get OEM dll related information
STDMETHOD(GetInfo) (THIS_ DWORD dwMode,
PVOID pBuffer,
DWORD cbSize,
PDWORD pcbNeeded);

// OEMDriverDMS - UNIDRV only, return E_NOTIMPL on Pscript
STDMETHOD(DriverDMS)(THIS_ PVOID pDevObj,
PVOID pBuffer,
DWORD cbSize,
PDWORD pcbNeeded);

// OEMDevMode
STDMETHOD(DevMode) (THIS_ DWORD dwMode,
POEMDMPARAM pOemDMParam);

// OEMCommandCallback - UNIDRV only, return E_NOTIMPL on Pscript
STDMETHOD(CommandCallback)(THIS_ PDEVOBJ pdevobj,
DWORD dwCallbackID,
DWORD dwCount,
PDWORD pdwParams,
OUT INT *piResult);

// OEMImageProcessing - UNIDRV only, return E_NOTIMPL on Pscript
STDMETHOD(ImageProcessing)(THIS_ PDEVOBJ pdevobj,
PBYTE pSrcBitmap,
PBITMAPINFOHEADER pBitmapInfoHeader,
PBYTE pColorTable,
DWORD dwCallbackID,
PIPPARAMS pIPParams,
OUT PBYTE *ppbResult);

// OEMFilterGraphics - UNIDRV only, return E_NOTIMPL on Pscript
STDMETHOD(FilterGraphics) (THIS_ PDEVOBJ pdevobj,
PBYTE pBuf,
DWORD dwLen);
// OEMCompression - UNIDRV only, return E_NOTIMPL on Pscript
STDMETHOD(Compression)(THIS_ PDEVOBJ pdevobj,
PBYTE pInBuf,
PBYTE pOutBuf,
DWORD dwInLen,
DWORD dwOutLen,
OUT INT *piResult);

// OEMHalftone - UNIDRV only, return E_NOTIMPL on Pscript
STDMETHOD(HalftonePattern) (THIS_ PDEVOBJ pdevobj,
PBYTE pHTPattern,
DWORD dwHTPatternX,
DWORD dwHTPatternY,
DWORD dwHTNumPatterns,
DWORD dwCallbackID,
PBYTE pResource,
DWORD dwResourceSize);

// OEMMemoryUsage - UNIDRV only, return E_NOTIMPL on Pscript
STDMETHOD(MemoryUsage) (THIS_ PDEVOBJ pdevobj,
POEMMEMORYUSAGE pMemoryUsage);

// OEMTTYGetInfo - UNIDRV only, return E_NOTIMPL on Pscript
STDMETHOD(TTYGetInfo)(THIS_ PDEVOBJ pdevobj,
DWORD dwInfoIndex,
PVOID pOutputBuf,
DWORD dwSize,
DWORD *pcbcNeeded);

// OEMDownloadFontheader - UNIDRV only
STDMETHOD(DownloadFontHeader)(THIS_ PDEVOBJ pdevobj,
PUNIFONTOBJ pUFObj,
OUT DWORD *pdwResult);

// OEMDownloadCharGlyph - UNIDRV only
STDMETHOD(DownloadCharGlyph)(THIS_ PDEVOBJ pdevobj,
PUNIFONTOBJ pUFObj,
HGLYPH hGlyph,
PDWORD pdwWidth,
OUT DWORD *pdwResult);

// OEMTTDownloadMethod - UNIDRV only
STDMETHOD(TTDownloadMethod)(THIS_ PDEVOBJ pdevobj,
PUNIFONTOBJ pUFObj,
OUT DWORD *pdwResult);

// OEMOutputCharStr - UNIDRV only
STDMETHOD(OutputCharStr)(THIS_ PDEVOBJ pdevobj,
PUNIFONTOBJ pUFObj,
DWORD dwType,
DWORD dwCount,
PVOID pGlyph);

// OEMSendFontCmd - UNIDRV only
STDMETHOD(SendFontCmd)(THIS_ PDEVOBJ pdevobj,
PUNIFONTOBJ pUFObj,
PFINVOCATION pFInv);

// OEMTextOutAsBitmap - UNIDRV only
STDMETHOD(TextOutAsBitmap)(THIS_ SURFOBJ *pso,
STROBJ *pstro,
FONTOBJ *pfo,
CLIPOBJ *pco,
RECTL *prclExtra,
RECTL *prclOpaque,
BRUSHOBJ *pboFore,
BRUSHOBJ *pboOpaque,
POINTL *pptlOrg,
MIX mix);


IOemUni() { m_cRef = 1; m_pOEMHelp = NULL; };
~IOemUni();

protected:
LONG m_cRef;
IPrintOemDriverUni* m_pOEMHelp; //IPrintK8DriverUni* m_pOEMHelp; ////
};
----------------------------------------------------------------------------
------

Must I do something else ?

Thanks a lot for your help.



Re: How implement DrvWriteAbortBuf ? by Serguei

Serguei
Tue Nov 25 12:00:06 CST 2003

> I have try your code, but it doesn't build.
> I have include <PRCOMOEM.H> in ddihook.cpp. Is it right ?
> I have this error (for the line IPrintOemDriverUni *ipodu;):
> dihook.cpp(701) : error C4700: local variable 'ipodu' used without having
> been initialized
> What do you mean with: "get that from PublishDriverIntercace"

You get it from PublishDriverInterface already, you just call it m_pOEMHelp
instead of ipodu. You need to store it in your PDEV so you can acccess it
from EndDoc. Store it there during EnablePDEV.