Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Private Attributes | Friends
nsPrintJobPipePS Class Reference

#include <nsPrintJobPS.h>

Inheritance diagram for nsPrintJobPipePS:
Inheritance graph
[legend]
Collaboration diagram for nsPrintJobPipePS:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~nsPrintJobPipePS ()
nsresult StartSubmission (FILE **aHandle)
 Launch the print command using popen(), then copy the print job data to the pipe.
nsresult FinishSubmission ()
 Finish a print job.
nsresult SetNumCopies (int aNumCopies)
 Set the number of copies for this print job.
virtual void SetJobTitle (const PRUnichar *aTitle)
 Set the print job title.

Protected Member Functions

nsresult Init (nsIDeviceContextSpecPS *)
 Initialize a print-to-pipe object.
void SetDestHandle (FILE *aHandle)
 Set the destination file handle.
FILEGetDestHandle ()
 Get the current value for the destination file handle.
void SetDestination (const char *aDest)
 Set a string representing the destination.
nsCStringGetDestination ()
 Get the string representing the destination.

Private Attributes

nsCString mPrinterName

Friends

class nsPrintJobFactoryPS

Detailed Description

Definition at line 149 of file nsPrintJobPS.h.


Constructor & Destructor Documentation

Definition at line 260 of file nsPrintJobPS.cpp.

Here is the call graph for this function:


Member Function Documentation

Finish a print job.

See nsIPrintJobPS.h and nsPrintJobPS.h for details.

Reimplemented from nsPrintJobFilePS.

Definition at line 328 of file nsPrintJobPS.cpp.

{
    NS_PRECONDITION(GetDestHandle(), "No destination file handle");
    NS_PRECONDITION(!GetDestination().IsEmpty(), "No destination");

    int presult = pclose(GetDestHandle());
    SetDestHandle(nsnull);
    if (!WIFEXITED(presult) || (EXIT_SUCCESS != WEXITSTATUS(presult)))
        return NS_ERROR_GFX_PRINTER_CMD_FAILURE;
    return NS_OK;
}

Here is the call graph for this function:

FILE* nsPrintJobFilePS::GetDestHandle ( ) [inline, protected, inherited]

Get the current value for the destination file handle.

Returns:
the current value for the destination file handle.

Definition at line 100 of file nsPrintJobPS.h.

{ return mDestHandle; }

Here is the caller graph for this function:

nsCString& nsPrintJobFilePS::GetDestination ( ) [inline, protected, inherited]

Get the string representing the destination.

Returns:
The current value of the destination string.

Definition at line 114 of file nsPrintJobPS.h.

{ return mDestination; }

Here is the caller graph for this function:

nsresult nsPrintJobPipePS::Init ( nsIDeviceContextSpecPS aSpec) [protected, virtual]

Initialize a print-to-pipe object.

See nsIPrintJobPS.h and nsPrintJobPS.h for details.

Reimplemented from nsPrintJobFilePS.

Definition at line 274 of file nsPrintJobPS.cpp.

{
    NS_PRECONDITION(aSpec, "argument must not be NULL");
#ifdef DEBUG
    PRBool toPrinter;
    aSpec->GetToPrinter(toPrinter);
    NS_PRECONDITION(toPrinter, "Wrong class for this print job");
#endif

    /* Print command. This is stored as the destination string. */
    const char *command;
    aSpec->GetCommand(&command);
    SetDestination(command);

    /* Printer name */
    const char *printerName;
    aSpec->GetPrinterName(&printerName);
    if (printerName) {
        const char *slash = strchr(printerName, '/');
        if (slash)
            printerName = slash + 1;
        if (0 != strcmp(printerName, "default"))
            mPrinterName = printerName;
    }
    return NS_OK;
}

Here is the call graph for this function:

void nsPrintJobFilePS::SetDestHandle ( FILE aHandle) [inline, protected, inherited]

Set the destination file handle.

Parameters:
aHandleNew value for the handle.

Definition at line 94 of file nsPrintJobPS.h.

Here is the caller graph for this function:

void nsPrintJobFilePS::SetDestination ( const char *  aDest) [inline, protected, inherited]

Set a string representing the destination.

For print-to-file this is the name of the destination file. Subclasses could store something else here.

Parameters:
aDestDestination filename.

Definition at line 108 of file nsPrintJobPS.h.

Here is the caller graph for this function:

virtual void nsIPrintJobPS::SetJobTitle ( const PRUnichar aTitle) [inline, virtual, inherited]

Set the print job title.

Some printing systems accept a job title which is displayed on a banner page, in a print queue listing, etc.

This must be called after Init() and before StartSubmission(). nsIPrintJobPS provides a stub implementation because most classes do not make use of this information.

Parameters:
aTitleThe job title.

Reimplemented in nsPrintJobCUPS.

Definition at line 92 of file nsIPrintJobPS.h.

{ }

Here is the caller graph for this function:

nsresult nsPrintJobFilePS::SetNumCopies ( int  aNumCopies) [inline, virtual, inherited]

Set the number of copies for this print job.

Some printing systems allow setting this out of band, instead of embedding it into the postscript.

Parameters:
aNumCopiesNumber of copies requested. Values <= 1 are interpreted as "do not specify a copy count to the printing system" when possible, or else as one copy.
Returns:
NS_ERROR_NOT_IMPLEMENTED if this print job class doesn't support the specific copy count requested.
NS_OK The print job class will request the specified number of copies when printing the job.

Implements nsIPrintJobPS.

Reimplemented in nsPrintJobCUPS.

Definition at line 83 of file nsPrintJobPS.h.

nsresult nsPrintJobPipePS::StartSubmission ( FILE **  aHandle) [virtual]

Launch the print command using popen(), then copy the print job data to the pipe.

See nsIPrintJobPS.h and nsPrintJobPS.h for details.

Reimplemented from nsPrintJobFilePS.

Definition at line 307 of file nsPrintJobPS.cpp.

{
    NS_PRECONDITION(aHandle, "aHandle is NULL");
    NS_PRECONDITION(!GetDestination().IsEmpty(), "No destination");
    NS_PRECONDITION(!GetDestHandle(), "Already have a destination handle");

    if (PR_SUCCESS != EnvLock())
        return NS_ERROR_OUT_OF_MEMORY;  // Couldn't allocate the object?
    if (!mPrinterName.IsEmpty())
        EnvSetPrinter(mPrinterName);

    FILE *destPipe = popen(GetDestination().get(), "w");
    EnvClear();
    if (!destPipe)
        return NS_ERROR_GFX_PRINTER_CMD_FAILURE;
    SetDestHandle(destPipe);
    *aHandle = destPipe;
    return NS_OK;
}

Here is the call graph for this function:


Friends And Related Function Documentation

friend class nsPrintJobFactoryPS [friend, inherited]

Definition at line 65 of file nsIPrintJobPS.h.


Member Data Documentation

Definition at line 160 of file nsPrintJobPS.h.


The documentation for this class was generated from the following files: