disallow disabling cups

which means that there is only one option left in
"add a printer" in spadmin, that to add a pdf so remove
the intermediate page

Change-Id: I5f19b526b5da9307bec77c731f305280b0ebecc3
This commit is contained in:
Caolán McNamara
2014-03-20 15:51:06 +00:00
parent a475c6963e
commit aa4e31ab27
13 changed files with 13 additions and 238 deletions

View File

@@ -112,8 +112,6 @@ protected:
bool m_bUseJobPatch;
OUString m_aSystemDefaultPaper;
bool m_bDisableCUPS;
PrinterInfoManager( Type eType = Default );
virtual void initialize();
@@ -195,21 +193,12 @@ public:
// returns true on success
virtual bool endSpool( const OUString& rPrinterName, const OUString& rJobTitle, FILE* pFile, const JobData& rDocumentJobData, bool bBanner, const OUString &rFaxNumber );
// for spadmin: whether adding or removing a printer is possible
virtual bool addOrRemovePossible() const;
bool getUseIncludeFeature() const { return m_bUseIncludeFeature; }
bool getUseJobPatch() const { return m_bUseJobPatch; }
// check whether a printer's feature string contains a subfeature
bool checkFeatureToken( const OUString& rPrinterName, const char* pToken ) const;
// set m_bDisableCUPS and update printer config
void setCUPSDisabled( bool );
// gets m_bDisableCUPS, initialized from printer config
bool isCUPSDisabled() const;
virtual ~PrinterInfoManager();
};

View File

@@ -46,41 +46,6 @@ APTabPage::APTabPage( AddPrinterDialog* pParent, const ResId& rResId )
{
}
APChooseDevicePage::APChooseDevicePage( AddPrinterDialog* pParent ) :
APTabPage( pParent, PaResId( RID_ADDP_PAGE_CHOOSEDEV ) ),
m_aPrinterBtn( this, PaResId( RID_ADDP_CHDEV_BTN_PRINTER ) ),
m_aPDFBtn( this, PaResId( RID_ADDP_CHDEV_BTN_PDF ) ),
m_aOverTxt( this, PaResId( RID_ADDP_CHDEV_TXT_OVER ) )
{
FreeResource();
m_aPrinterBtn.Check( true );
m_aPDFBtn.Check( false );
if( ! PrinterInfoManager::get().addOrRemovePossible() )
{
m_aPrinterBtn.Check( false );
m_aPrinterBtn.Enable( false );
}
}
APChooseDevicePage::~APChooseDevicePage()
{
}
bool APChooseDevicePage::check()
{
return true;
}
void APChooseDevicePage::fill( PrinterInfo& rInfo )
{
if( m_aPDFBtn.IsChecked() )
{
rInfo.m_aFeatures = "pdf=";
}
else
rInfo.m_aFeatures = "";
}
APChooseDriverPage::APChooseDriverPage( AddPrinterDialog* pParent )
: APTabPage( pParent, PaResId( RID_ADDP_PAGE_CHOOSEDRIVER ) ),
m_aDriverTxt( this, PaResId( RID_ADDP_CHDRV_TXT_DRIVER ) ),
@@ -489,7 +454,6 @@ AddPrinterDialog::AddPrinterDialog( Window* pParent )
m_aLine( this, PaResId( RID_ADDP_LINE ) ),
m_aTitleImage( this, PaResId( RID_ADDP_CTRL_TITLE ) ),
m_pCurrentPage( NULL ),
m_pChooseDevicePage( NULL ),
m_pCommandPage( NULL ),
m_pChooseDriverPage( NULL ),
m_pNamePage( NULL ),
@@ -499,7 +463,8 @@ AddPrinterDialog::AddPrinterDialog( Window* pParent )
m_pPdfCommandPage( NULL )
{
FreeResource();
m_pCurrentPage = m_pChooseDevicePage = new APChooseDevicePage( this );
m_pCurrentPage = m_pPdfDriverPage = new APPdfDriverPage( this );
m_pCurrentPage->Show( true );
m_aFinishPB.Enable( false );
m_aPrevPB.Enable( false );
@@ -516,7 +481,6 @@ AddPrinterDialog::AddPrinterDialog( Window* pParent )
AddPrinterDialog::~AddPrinterDialog()
{
delete m_pChooseDevicePage;
delete m_pChooseDriverPage;
delete m_pNamePage;
delete m_pCommandPage;
@@ -544,24 +508,7 @@ void AddPrinterDialog::DataChanged( const DataChangedEvent& rEv )
void AddPrinterDialog::advance()
{
m_pCurrentPage->Show( false );
if( m_pCurrentPage == m_pChooseDevicePage )
{
if( m_pChooseDevicePage->isPrinter() )
{
if( ! m_pChooseDriverPage )
m_pChooseDriverPage = new APChooseDriverPage( this );
m_pCurrentPage = m_pChooseDriverPage;
m_aPrevPB.Enable( true );
}
else if( m_pChooseDevicePage->isPDF() )
{
if( ! m_pPdfDriverPage )
m_pPdfDriverPage = new APPdfDriverPage( this );
m_pCurrentPage = m_pPdfDriverPage;
m_aPrevPB.Enable( true );
}
}
else if( m_pCurrentPage == m_pChooseDriverPage )
if( m_pCurrentPage == m_pChooseDriverPage )
{
if( ! m_pCommandPage )
m_pCommandPage = new APCommandPage( this, DeviceKind::Printer );
@@ -591,6 +538,7 @@ void AddPrinterDialog::advance()
m_pPdfCommandPage = new APCommandPage( this, DeviceKind::Pdf );
m_pCurrentPage = m_pPdfCommandPage;
}
m_aPrevPB.Enable( true );
}
else if( m_pCurrentPage == m_pPdfSelectDriverPage )
{
@@ -614,12 +562,7 @@ void AddPrinterDialog::advance()
void AddPrinterDialog::back()
{
m_pCurrentPage->Show( false );
if( m_pCurrentPage == m_pChooseDriverPage )
{
m_pCurrentPage = m_pChooseDevicePage;
m_aPrevPB.Enable( false );
}
else if( m_pCurrentPage == m_pNamePage )
if( m_pCurrentPage == m_pNamePage )
{
m_pCurrentPage = m_pCommandPage;
m_aNextPB.Enable( true );
@@ -628,11 +571,6 @@ void AddPrinterDialog::back()
{
m_pCurrentPage = m_pChooseDriverPage;
}
else if( m_pCurrentPage == m_pPdfDriverPage )
{
m_pCurrentPage = m_pChooseDevicePage;
m_aPrevPB.Enable( false );
}
else if( m_pCurrentPage == m_pPdfSelectDriverPage )
{
m_pCurrentPage = m_pPdfDriverPage;
@@ -659,17 +597,9 @@ void AddPrinterDialog::addPrinter()
{
PrinterInfo aInfo( rManager.getPrinterInfo( m_aPrinter.m_aPrinterName ) );
aInfo.m_aCommand = m_aPrinter.m_aCommand;
if( m_pChooseDevicePage->isPrinter() )
{
if( m_pNamePage->isDefault() )
rManager.setDefaultPrinter( m_aPrinter.m_aPrinterName );
}
else if( m_pChooseDevicePage->isPDF() )
{
OUString aPdf( "pdf=" );
aPdf += m_pPdfCommandPage->getPdfDir();
aInfo.m_aFeatures = aPdf;
}
OUString aPdf( "pdf=" );
aPdf += m_pPdfCommandPage->getPdfDir();
aInfo.m_aFeatures = aPdf;
rManager.changePrinterInfo( m_aPrinter.m_aPrinterName, aInfo );
}
}

View File

@@ -53,16 +53,12 @@ public:
class APChooseDevicePage : public APTabPage
{
RadioButton m_aPrinterBtn;
RadioButton m_aPDFBtn;
FixedText m_aOverTxt;
public:
APChooseDevicePage( AddPrinterDialog* pParent );
~APChooseDevicePage();
bool isPrinter() { return m_aPrinterBtn.IsChecked(); }
bool isPDF() { return m_aPDFBtn.IsChecked(); }
virtual bool check();
virtual void fill( ::psp::PrinterInfo& rInfo );
};
@@ -180,7 +176,6 @@ class AddPrinterDialog : public ModalDialog
APTabPage* m_pCurrentPage;
APChooseDevicePage* m_pChooseDevicePage;
APCommandPage* m_pCommandPage;
APChooseDriverPage* m_pChooseDriverPage;
APNamePage* m_pNamePage;

View File

@@ -221,7 +221,7 @@ RTSCommandPage::RTSCommandPage( RTSDialog* pParent ) :
{
// configuring as printer is only sensible in default print system
PrinterInfoManager& rMgr( PrinterInfoManager::get() );
if( rMgr.getType() == PrinterInfoManager::Default || rMgr.isCUPSDisabled() )
if( rMgr.getType() == PrinterInfoManager::Default )
m_nPrinterEntry = m_aConfigureBox.InsertEntry( OUString( PaResId( RID_RTS_CMD_STR_CONFIGURE_PRINTER ) ) );
else
m_nPrinterEntry = ~0;

View File

@@ -84,8 +84,6 @@ PADialog::PADialog( Window* pParent, sal_Bool /*bAdmin*/ ) :
m_aCommand( this, PaResId( RID_PA_TXT_COMMAND_STRING ) ),
m_aCommentTxt( this, PaResId( RID_PA_TXT_COMMENT ) ),
m_aComment( this, PaResId( RID_PA_TXT_COMMENT_STRING ) ),
m_aCUPSFL( this, PaResId( RID_PA_FL_CUPSUSAGE ) ),
m_aCUPSCB( this, PaResId( RID_PA_CB_CUPSUSAGE ) ),
m_aSepButtonFL( this, PaResId( RID_PA_FL_SEPBUTTON ) ),
m_aAddPB( this, PaResId( RID_PA_BTN_ADD ) ),
m_aCancelButton( this, PaResId( RID_PA_BTN_CANCEL ) ),
@@ -108,7 +106,6 @@ void PADialog::Init()
{
// #i79787# initially ensure printer discovery has ended
m_rPIManager.checkPrintersChanged( true );
m_aCUPSCB.Check( m_rPIManager.isCUPSDisabled() );
UpdateDevice();
UpdateText();
@@ -124,7 +121,6 @@ void PADialog::Init()
m_aTestPagePB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) );
m_aAddPB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) );
m_aDevicesLB.setDelPressedLink( LINK( this, PADialog, DelPressedHdl ) );
m_aCUPSCB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) );
// at this point no actual changes will be written
// but the write will have checked whether any writeable config exists
@@ -135,7 +131,6 @@ void PADialog::Init()
m_aConfPB.Enable( false );
m_aRenamePB.Enable( false );
m_aStdPB.Enable( false );
m_aCUPSCB.Enable( false );
ErrorBox aBox( GetParent(), WB_OK | WB_DEF_OK, OUString( PaResId( RID_ERR_NOWRITE ) ) );
aBox.Execute();
}
@@ -204,12 +199,6 @@ IMPL_LINK( PADialog, ClickBtnHdl, PushButton*, pButton )
PrintTestPage();
else if( pButton == &m_aAddPB )
AddDevice();
else if( static_cast<Button*>(pButton) == &m_aCUPSCB )
{
m_rPIManager.setCUPSDisabled( m_aCUPSCB.IsChecked() );
UpdateDevice();
UpdateText();
}
return 0;
}

View File

@@ -43,8 +43,6 @@
#define RID_PA_STR_RENAME 21
#define RID_PA_FL_SEPBUTTON 22
#define RID_PA_FL_CUPSUSAGE 23
#define RID_PA_CB_CUPSUSAGE 23
#define RID_PPDIMPORT_DLG 1004
#define RID_PPDIMP_BTN_OK 1
@@ -106,11 +104,6 @@
#define RID_ADDP_CTRL_TITLE 6
#define RID_ADDP_STR_TITLE 127
#define RID_ADDP_PAGE_CHOOSEDEV 2001
#define RID_ADDP_CHDEV_TXT_OVER 1
#define RID_ADDP_CHDEV_BTN_PRINTER 2
#define RID_ADDP_CHDEV_BTN_PDF 3
#define RID_ADDP_PAGE_CHOOSEDRIVER 2002
#define RID_ADDP_CHDRV_TXT_DRIVER 1
#define RID_ADDP_CHDRV_BOX_DRIVER 2

View File

@@ -53,9 +53,6 @@ namespace padmin {
FixedText m_aCommentTxt;
FixedText m_aComment;
FixedLine m_aCUPSFL;
CheckBox m_aCUPSCB;
FixedLine m_aSepButtonFL;
PushButton m_aAddPB;
CancelButton m_aCancelButton;

View File

@@ -28,20 +28,6 @@ ModalDialog RID_PADIALOG
Moveable = TRUE ;
Closeable = TRUE ;
FixedLine RID_PA_FL_CUPSUSAGE
{
Pos = MAP_APPFONT( 6, 145 );
Size = MAP_APPFONT( 248, 8 );
Text [ en-US ] = "CUPS support";
};
CheckBox RID_PA_CB_CUPSUSAGE
{
HelpID = "padmin:CheckBox:RID_PADIALOG:RID_PA_CB_CUPSUSAGE";
Pos = MAP_APPFONT( 12, 158 );
Size = MAP_APPFONT( 168, 8 );
Text [ en-US ] = "Disable CUPS Support";
};
FixedLine RID_PA_FL_SEPBUTTON
{
Pos = MAP_APPFONT( 0, 176 );
@@ -154,7 +140,7 @@ ModalDialog RID_PADIALOG
HelpID = "padmin:PushButton:RID_PADIALOG:RID_PA_BTN_ADD";
Pos = MAP_APPFONT( 5, 181 );
Size = MAP_APPFONT( 70, 12 );
Text [ en-US ] = "New Printer...";
Text [ en-US ] = "New PDF Converter...";
};
String RID_PA_STR_DEFPRT
@@ -506,38 +492,6 @@ TabPage RID_ADDP_PAGE_CHOOSEDRIVER
};
};
TabPage RID_ADDP_PAGE_CHOOSEDEV
{
HelpID = "padmin:TabPage:RID_ADDP_PAGE_CHOOSEDEV";
Hide = TRUE;
Pos = MAP_APPFONT( 0, 30 );
Size = MAP_APPFONT( 240, 110 );
String RID_ADDP_STR_TITLE
{
Text [ en-US ] = "Choose a device type";
};
FixedText RID_ADDP_CHDEV_TXT_OVER
{
Pos = MAP_APPFONT( 40, 25 );
Size = MAP_APPFONT( 180, 8 );
Text [ en-US ] = "Do you want to";
};
RadioButton RID_ADDP_CHDEV_BTN_PRINTER
{
HelpID = "padmin:RadioButton:RID_ADDP_PAGE_CHOOSEDEV:RID_ADDP_CHDEV_BTN_PRINTER";
Pos = MAP_APPFONT ( 40, 40 );
Size = MAP_APPFONT( 180, 10 );
Text [ en-US ] = "Add a ~printer";
};
RadioButton RID_ADDP_CHDEV_BTN_PDF
{
HelpID = "padmin:RadioButton:RID_ADDP_PAGE_CHOOSEDEV:RID_ADDP_CHDEV_BTN_PDF";
Pos = MAP_APPFONT ( 40, 50 );
Size = MAP_APPFONT( 180, 10 );
Text [ en-US ] = "Connect a P~DF converter";
};
};
TabPage RID_ADDP_PAGE_NAME
{
HelpID = "padmin:TabPage:RID_ADDP_PAGE_NAME";

View File

@@ -96,7 +96,7 @@ RTSDialog::RTSDialog( const PrinterInfo& rJobData, const OUString& rPrinter, boo
m_pTabControl->RemovePage(m_pTabControl->GetPageId("other"));
m_pTabControl->RemovePage(m_pTabControl->GetPageId("command"));
}
else if( m_aJobData.m_aDriverName.startsWith("CUPS:") && ! PrinterInfoManager::get().isCUPSDisabled() )
else if (m_aJobData.m_aDriverName.startsWith("CUPS:"))
{
// command page makes no sense for CUPS printers
m_pTabControl->RemovePage(m_pTabControl->GetPageId("command"));

View File

@@ -92,8 +92,6 @@ public:
virtual bool removePrinter( const OUString& rPrinterName, bool bCheckOnly = false );
virtual bool writePrinterConfig();
virtual bool setDefaultPrinter( const OUString& rPrinterName );
virtual bool addOrRemovePossible() const;
};
} // namespace psp

View File

@@ -46,11 +46,6 @@ PrinterInfoManager::PrinterInfoManager( Type eType ) :
m_bUseIncludeFeature( false ),
m_bUseJobPatch( true ),
m_aSystemDefaultPaper( "A4" ),
#ifdef LIBO_HEADLESS
m_bDisableCUPS( true )
#else
m_bDisableCUPS( false )
#endif
{
// initSystemDefaultPaper();
}
@@ -70,16 +65,6 @@ void PrinterInfoManager::initialize()
// ???
}
bool PrinterInfoManager::isCUPSDisabled() const
{
return m_bDisableCUPS;
}
void PrinterInfoManager::setCUPSDisabled( bool /* bDisable */ )
{
// cups is already disabled in config so do nothing
}
void PrinterInfoManager::listPrinters( ::std::list< OUString >& rList ) const
{
rList.clear();
@@ -117,11 +102,6 @@ bool PrinterInfoManager::setDefaultPrinter( const OUString& /* rPrinterName */ )
return false;
}
bool PrinterInfoManager::addOrRemovePossible() const
{
return false;
}
void PrinterInfoManager::getSystemPrintCommands( std::list< OUString >& /* rCommands */ )
{

View File

@@ -256,9 +256,6 @@ void CUPSManager::initialize()
if( ! (m_nDests && m_pDests ) )
return;
if( isCUPSDisabled() )
return;
// check for CUPS server(?) > 1.2
// since there is no API to query, check for options that were
// introduced in dests with 1.2
@@ -424,7 +421,7 @@ const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter )
if( m_aCUPSMutex.tryToAcquire() )
{
if( m_nDests && m_pDests && ! isCUPSDisabled() )
if (m_nDests && m_pDests)
{
boost::unordered_map< OUString, int, OUStringHash >::iterator dest_it =
m_aCUPSDestMap.find( aPrinter );
@@ -830,11 +827,6 @@ bool CUPSManager::writePrinterConfig()
return PrinterInfoManager::writePrinterConfig();
}
bool CUPSManager::addOrRemovePossible() const
{
return (m_nDests && m_pDests && ! isCUPSDisabled())? false : PrinterInfoManager::addOrRemovePossible();
}
const char* CUPSManager::authenticateUser( const char* /*pIn*/ )
{
const char* pRet = NULL;

View File

@@ -117,16 +117,13 @@ PrinterInfoManager::PrinterInfoManager( Type eType ) :
m_eType( eType ),
m_bUseIncludeFeature( false ),
m_bUseJobPatch( true ),
m_aSystemDefaultPaper( "A4" ),
m_bDisableCUPS( false )
m_aSystemDefaultPaper( "A4" )
{
if( eType == Default )
m_pQueueInfo = new SystemQueueInfo();
initSystemDefaultPaper();
}
PrinterInfoManager::~PrinterInfoManager()
{
delete m_pQueueInfo;
@@ -135,26 +132,6 @@ PrinterInfoManager::~PrinterInfoManager()
#endif
}
bool PrinterInfoManager::isCUPSDisabled() const
{
return m_bDisableCUPS;
}
void PrinterInfoManager::setCUPSDisabled( bool bDisable )
{
m_bDisableCUPS = bDisable;
writePrinterConfig();
// actually we know the printers changed
// however this triggers reinitialization the right way
checkPrintersChanged( true );
}
void PrinterInfoManager::initSystemDefaultPaper()
{
m_aSystemDefaultPaper = OStringToOUString(
@@ -231,7 +208,6 @@ void PrinterInfoManager::initialize()
// need a parser for the PPDContext. generic printer should do.
m_aGlobalDefaults.m_pParser = PPDParser::getParser( OUString( "SGENPRT" ) );
m_aGlobalDefaults.m_aContext.setParser( m_aGlobalDefaults.m_pParser );
m_bDisableCUPS = false;
if( ! m_aGlobalDefaults.m_pParser )
{
@@ -291,15 +267,6 @@ void PrinterInfoManager::initialize()
if (!aValue.isEmpty())
m_aGlobalDefaults.m_nPDFDevice = aValue.toInt32();
aValue = aConfig.ReadKey( "DisableCUPS" );
if (!aValue.isEmpty())
{
if (aValue.equals("1") || aValue.equalsIgnoreAsciiCase("true"))
m_bDisableCUPS = true;
else
m_bDisableCUPS = false;
}
// get the PPDContext of global JobData
for( int nKey = 0; nKey < aConfig.GetKeyCount(); ++nKey )
{
@@ -656,7 +623,6 @@ bool PrinterInfoManager::writePrinterConfig()
Config* pGlobal = files.begin()->second;
pGlobal->SetGroup( GLOBAL_DEFAULTS_GROUP );
pGlobal->WriteKey( "DisableCUPS", m_bDisableCUPS ? "true" : "false" );
::boost::unordered_map< OUString, Printer, OUStringHash >::iterator it;
for( it = m_aPrinters.begin(); it != m_aPrinters.end(); ++it )
@@ -900,14 +866,6 @@ bool PrinterInfoManager::setDefaultPrinter( const OUString& rPrinterName )
return bSuccess;
}
bool PrinterInfoManager::addOrRemovePossible() const
{
return true;
}
void PrinterInfoManager::getSystemPrintCommands( std::list< OUString >& rCommands )
{
if( m_pQueueInfo && m_pQueueInfo->hasChanged() )