зеркало из https://github.com/mozilla/pjs.git
r=mkaply, sr=blizzard (platform specific), a=mkaply OS/2 only - refresh printer list before dialog comes up
This commit is contained in:
Родитель
49c48515e4
Коммит
66d51ebb5b
|
@ -398,6 +398,8 @@ NS_IMETHODIMP nsPrinterEnumeratorOS2::EnumeratePrinters(PRUint32* aCount, PRUnic
|
||||||
*aResult = nsnull;
|
*aResult = nsnull;
|
||||||
else
|
else
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
|
nsDeviceContextSpecOS2::PrnDlg.RefreshPrintQueue();
|
||||||
|
|
||||||
nsresult rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
|
nsresult rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
@ -674,6 +676,61 @@ PRINTDLG::~PRINTDLG ()
|
||||||
delete mPQBuf [cnt];
|
delete mPQBuf [cnt];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRINTDLG::RefreshPrintQueue ()
|
||||||
|
{
|
||||||
|
ULONG newQueueCount = 0;
|
||||||
|
ULONG TotalQueues = 0;
|
||||||
|
ULONG MemNeeded = 0;
|
||||||
|
mDefaultQueue = 0;
|
||||||
|
SPLERR rc;
|
||||||
|
|
||||||
|
rc = ::SplEnumQueue (NULL, 3, NULL, 0, &newQueueCount, &TotalQueues, &MemNeeded, NULL);
|
||||||
|
PRQINFO3* pPQI3Buf = (PRQINFO3*) malloc (MemNeeded);
|
||||||
|
rc = ::SplEnumQueue (NULL, 3, pPQI3Buf, MemNeeded, &newQueueCount, &TotalQueues, &MemNeeded, NULL);
|
||||||
|
|
||||||
|
if (newQueueCount > MAX_PRINT_QUEUES)
|
||||||
|
newQueueCount = MAX_PRINT_QUEUES;
|
||||||
|
|
||||||
|
PRTQUEUE* tmpBuf[MAX_PRINT_QUEUES];
|
||||||
|
|
||||||
|
for (ULONG cnt = 0 ; cnt < newQueueCount ; cnt++)
|
||||||
|
{
|
||||||
|
if (pPQI3Buf [cnt].fsType & PRQ3_TYPE_APPDEFAULT)
|
||||||
|
mDefaultQueue = cnt;
|
||||||
|
|
||||||
|
BOOL found = FALSE;
|
||||||
|
for (ULONG j = 0 ; j < mQueueCount && !found; j++)
|
||||||
|
{
|
||||||
|
//Compare printer from requeried list with what's already in Mozilla's printer list(mPQBuf)
|
||||||
|
//If printer is already there, use current properties; otherwise create a new printer in list
|
||||||
|
if (mPQBuf[j] != 0) {
|
||||||
|
if ((strcmp(pPQI3Buf[cnt].pszPrinters, mPQBuf[j]->PrinterName()) == 0) &&
|
||||||
|
(strcmp(pPQI3Buf[cnt].pszDriverName, mPQBuf[j]->PQI3().pszDriverName) == 0)) {
|
||||||
|
found = TRUE;
|
||||||
|
tmpBuf[cnt] = mPQBuf[j];
|
||||||
|
mPQBuf[j] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
tmpBuf[cnt] = new PRTQUEUE (&pPQI3Buf[cnt]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i < newQueueCount; i++) {
|
||||||
|
if (mPQBuf[i] != 0)
|
||||||
|
delete(mPQBuf[i]);
|
||||||
|
mPQBuf[i] = tmpBuf[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mQueueCount > newQueueCount)
|
||||||
|
for (int i = newQueueCount; i < mQueueCount; i++)
|
||||||
|
if (mPQBuf[i] != 0)
|
||||||
|
delete(mPQBuf[i]);
|
||||||
|
|
||||||
|
mQueueCount = newQueueCount;
|
||||||
|
free (pPQI3Buf);
|
||||||
|
}
|
||||||
|
|
||||||
int PRINTDLG::GetIndex (int numPrinter)
|
int PRINTDLG::GetIndex (int numPrinter)
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
|
|
|
@ -79,6 +79,7 @@ class PRINTDLG
|
||||||
public:
|
public:
|
||||||
PRINTDLG ();
|
PRINTDLG ();
|
||||||
~PRINTDLG ();
|
~PRINTDLG ();
|
||||||
|
RefreshPrintQueue();
|
||||||
int GetNumPrinters ();
|
int GetNumPrinters ();
|
||||||
int GetDefaultPrinter ();
|
int GetDefaultPrinter ();
|
||||||
void GetPrinter (int numPrinter, char** printerName);
|
void GetPrinter (int numPrinter, char** printerName);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче