Kaydet (Commit) 68ffb332 authored tarafından Caolán McNamara's avatar Caolán McNamara

nothing propagates HAVE_CUPS_H so cups is always disabled

regression from 22f2e5f2

so, lets follow the same pattern as else where and fixup
ENABLE_CUPS to be TRUE when enabled and lets just link
against cups and not do the dlopen dance

Change-Id: I3cff1bd98a7474c403d7ff66183e76e26e407de8
üst c20ba023
...@@ -1219,6 +1219,26 @@ $(call gb_LinkTarget_add_libs,$(1),$(GTHREAD_LIBS)) ...@@ -1219,6 +1219,26 @@ $(call gb_LinkTarget_add_libs,$(1),$(GTHREAD_LIBS))
endef endef
ifeq ($(ENABLE_CUPS),TRUE)
define gb_LinkTarget__use_cups
$(call gb_LinkTarget_add_defs,$(1),\
-DENABLE_CUPS \
)
$(call gb_LinkTarget_add_libs,$(1),\
-lcups \
)
endef
else # ENABLE_CUPS
define gb_LinkTarget__use_cups
endef
endif # ENABLE_DBUS
ifeq ($(ENABLE_DBUS),TRUE) ifeq ($(ENABLE_DBUS),TRUE)
......
...@@ -4109,32 +4109,32 @@ if test "$enable_headless" = "yes"; then ...@@ -4109,32 +4109,32 @@ if test "$enable_headless" = "yes"; then
enable_gnome_vfs=no enable_gnome_vfs=no
fi fi
dnl ===================================================================
dnl check for cups support dnl check for cups support
dnl =================================================================== dnl ===================================================================
ENABLE_CUPS=""
if test "$enable_cups" = "no"; then if test "$enable_cups" = "no"; then
test_cups=no test_cups=no
ENABLE_CUPS="NO"
elif test "$enable_cups" = "yes"; then
if test $_os = iOS -o $_os = Android; then
AC_MSG_ERROR([CUPS makes no sense for $_os])
fi
ENABLE_CUPS="YES"
elif test $_os = iOS -o $_os = Android; then
ENABLE_CUPS=NO
else
ENABLE_CUPS="YES"
fi fi
AC_SUBST(ENABLE_CUPS)
AC_MSG_CHECKING([whether to enable CUPS support])
if test "$test_cups" = "yes"; then if test "$test_cups" = "yes"; then
ENABLE_CUPS="TRUE"
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([whether cups support is present]) AC_MSG_CHECKING([whether cups support is present])
AC_CHECK_LIB([cups], [cupsPrintFiles], [:]) AC_CHECK_LIB([cups], [cupsPrintFiles], [:])
AC_CHECK_HEADER(cups/cups.h, AC_DEFINE(HAVE_CUPS_H)) AC_CHECK_HEADER(cups/cups.h, AC_DEFINE(HAVE_CUPS_H))
if test "$ac_cv_lib_cups_cupsPrintFiles" != "yes" -a "$ac_cv_header_cups_cups_h" != "yes"; then if test "$ac_cv_lib_cups_cupsPrintFiles" != "yes" -a "$ac_cv_header_cups_cups_h" != "yes"; then
AC_MSG_ERROR([Could not find CUPS. Install libcupsys2-dev or cups???-devel.]) AC_MSG_ERROR([Could not find CUPS. Install libcupsys2-dev or cups-devel.])
fi fi
else
AC_MSG_RESULT([no])
fi fi
AC_SUBST(ENABLE_CUPS)
# fontconfig checks # fontconfig checks
if test "$test_fontconfig" = "yes"; then if test "$test_fontconfig" = "yes"; then
......
...@@ -498,12 +498,6 @@ $(eval $(call gb_Library_add_defs,vcl,\ ...@@ -498,12 +498,6 @@ $(eval $(call gb_Library_add_defs,vcl,\
) \ ) \
)) ))
ifeq ($(ENABLE_CUPS),YES)
$(eval $(call gb_Library_add_defs,vcl,\
-DENABLE_CUPS\
))
endif
ifeq ($(GUIBASE),unx) ifeq ($(GUIBASE),unx)
$(eval $(call gb_Library_add_defs,vcl,\ $(eval $(call gb_Library_add_defs,vcl,\
-DSAL_DLLPREFIX=\"$(gb_Library_SYSPRE)\" \ -DSAL_DLLPREFIX=\"$(gb_Library_SYSPRE)\" \
...@@ -515,15 +509,15 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ ...@@ -515,15 +509,15 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/unx/generic/plugadapt/salplug \ vcl/unx/generic/plugadapt/salplug \
vcl/unx/generic/printer/jobdata \ vcl/unx/generic/printer/jobdata \
vcl/unx/generic/printer/ppdparser \ vcl/unx/generic/printer/ppdparser \
$(if $(filter YES,$(ENABLE_CUPS)),\ $(if $(filter TRUE,$(ENABLE_CUPS)),\
vcl/unx/generic/printer/cupsmgr \ vcl/unx/generic/printer/cupsmgr \
vcl/unx/generic/printer/printerinfomanager \ vcl/unx/generic/printer/printerinfomanager, \
) \ else \
$(if $(filter NO,$(ENABLE_CUPS)),\
vcl/null/printerinfomanager \ vcl/null/printerinfomanager \
) \ ) \
)) ))
$(eval $(call gb_Library_use_externals,vcl,\ $(eval $(call gb_Library_use_externals,vcl,\
cups \
dbus \ dbus \
fontconfig \ fontconfig \
freetype \ freetype \
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
namespace psp namespace psp
{ {
class CUPSWrapper;
class PPDParser; class PPDParser;
struct FPtrHash struct FPtrHash
...@@ -48,7 +47,6 @@ struct FPtrHash ...@@ -48,7 +47,6 @@ struct FPtrHash
class CUPSManager : public PrinterInfoManager class CUPSManager : public PrinterInfoManager
{ {
CUPSWrapper* m_pCUPSWrapper;
boost::unordered_map< FILE*, rtl::OString, FPtrHash > m_aSpoolFiles; boost::unordered_map< FILE*, rtl::OString, FPtrHash > m_aSpoolFiles;
int m_nDests; int m_nDests;
void* m_pDests; void* m_pDests;
...@@ -66,13 +64,17 @@ class CUPSManager : public PrinterInfoManager ...@@ -66,13 +64,17 @@ class CUPSManager : public PrinterInfoManager
osl::Mutex m_aCUPSMutex; osl::Mutex m_aCUPSMutex;
oslThread m_aDestThread; oslThread m_aDestThread;
CUPSManager( CUPSWrapper* ); osl::Mutex m_aGetPPDMutex;
bool m_bPPDThreadRunning;
CUPSManager();
virtual ~CUPSManager(); virtual ~CUPSManager();
virtual void initialize(); virtual void initialize();
void getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner, int& rNumOptions, void** rOptions ) const; void getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner, int& rNumOptions, void** rOptions ) const;
void runDests(); void runDests();
OString threadedCupsGetPPD(const char* pPrinter);
public: public:
// public for stub // public for stub
static void runDestThread(void* pMgr); static void runDestThread(void* pMgr);
......
...@@ -44,106 +44,6 @@ ...@@ -44,106 +44,6 @@
#include <algorithm> #include <algorithm>
#define CUPS_LIB_NAME "libcups.so.2"
namespace psp
{
class CUPSWrapper
{
oslModule m_pLib;
osl::Mutex m_aGetPPDMutex;
bool m_bPPDThreadRunning;
int (*m_pcupsPrintFile)(const char*, const char*, const char*, int, cups_option_t*);
int (*m_pcupsGetDests)(cups_dest_t**);
void (*m_pcupsSetDests)(int,cups_dest_t*);
void (*m_pcupsFreeDests)(int,cups_dest_t*);
const char* (*m_pcupsGetPPD)(const char*);
int (*m_pcupsMarkOptions)(ppd_file_t*,int,cups_option_t*);
int (*m_pcupsAddOption)(const char*,const char*,int,cups_option_t**);
void (*m_pcupsFreeOptions)(int,cups_option_t*);
ppd_file_t* (*m_pppdOpenFile)(const char* pFile);
void (*m_pppdClose)(ppd_file_t*);
http_t* (*m_phttpConnectEncrypt)(const char*, int, http_encryption_t);
void (*m_phttpClose)(http_t*);
int (*m_pippPort)();
const char* (*m_pcupsServer)();
http_encryption_t (*m_pcupsEncryption)();
void (*m_pcupsSetPasswordCB)(const char*(cb)(const char*));
const char* (*m_pcupsUser)();
void (*m_pcupsSetUser)(const char*);
const char* (*m_pcupsGetOption)(const char*,int,cups_option_t*);
oslGenericFunction loadSymbol( const char* );
public:
CUPSWrapper();
~CUPSWrapper();
bool isValid();
int cupsGetDests(cups_dest_t** pDests)
{ return m_pcupsGetDests(pDests); }
void cupsSetDests( int nDests, cups_dest_t* pDests )
{ m_pcupsSetDests( nDests, pDests ); }
void cupsFreeDests(int nDests, cups_dest_t* pDests)
{ m_pcupsFreeDests(nDests, pDests); }
int cupsPrintFile( const char* pPrinter,
const char* pFileName,
const char* pTitle,
int nOptions,
cups_option_t* pOptions )
{ return m_pcupsPrintFile( pPrinter, pFileName, pTitle, nOptions, pOptions ); }
rtl::OString cupsGetPPD( const char* pPrinter );
int cupsMarkOptions(ppd_file_t* pPPD, int nOptions, cups_option_t* pOptions )
{ return m_pcupsMarkOptions(pPPD, nOptions, pOptions); }
int cupsAddOption( const char* pName, const char* pValue, int nOptions, cups_option_t** pOptions )
{ return m_pcupsAddOption( pName, pValue, nOptions, pOptions ); }
void cupsFreeOptions( int nOptions, cups_option_t* pOptions )
{ m_pcupsFreeOptions( nOptions, pOptions ); }
ppd_file_t* ppdOpenFile( const char* pFileName )
{ return m_pppdOpenFile( pFileName ); }
void ppdClose( ppd_file_t* pPPD )
{ m_pppdClose( pPPD ); }
http_t* httpConnectEncrypt(const char* host, int port, http_encryption_t crypt)
{ return m_phttpConnectEncrypt(host, port, crypt); }
void httpClose(http_t* server)
{ m_phttpClose(server); }
int ippPort()
{ return m_pippPort(); }
const char *cupsServer(void)
{ return m_pcupsServer(); }
http_encryption_t cupsEncryption()
{ return m_pcupsEncryption(); }
const char *cupsUser(void)
{ return m_pcupsUser(); }
void cupsSetPasswordCB(const char *(*cb)(const char *))
{ m_pcupsSetPasswordCB( cb ); }
void cupsSetUser(const char *user)
{ m_pcupsSetUser( user ); }
const char* cupsGetOption(const char* name, int num_options, cups_option_t* options)
{ return m_pcupsGetOption( name, num_options, options ); }
};
}
using namespace psp; using namespace psp;
using namespace osl; using namespace osl;
...@@ -154,120 +54,8 @@ using ::rtl::OStringToOUString; ...@@ -154,120 +54,8 @@ using ::rtl::OStringToOUString;
using ::rtl::OUStringHash; using ::rtl::OUStringHash;
using ::rtl::OString; using ::rtl::OString;
/*
* CUPSWrapper class
*/
oslGenericFunction CUPSWrapper::loadSymbol( const char* pSymbol )
{
OUString aSym( OUString::createFromAscii( pSymbol ) );
oslGenericFunction pSym = osl_getFunctionSymbol( m_pLib, aSym.pData );
#if OSL_DEBUG_LEVEL > 1
fprintf( stderr, "%s %s\n", pSymbol, pSym ? "found" : "not found" );
#endif
return pSym;
}
CUPSWrapper::CUPSWrapper()
: m_pLib( NULL ),
m_bPPDThreadRunning( false )
{
OUString aLib( CUPS_LIB_NAME );
m_pLib = osl_loadModule( aLib.pData, SAL_LOADMODULE_LAZY );
if( ! m_pLib )
{
aLib = OUString( SAL_MODULENAME( "cups" ) );
m_pLib = osl_loadModule( aLib.pData, SAL_LOADMODULE_LAZY );
}
if( ! m_pLib )
{
#if OSL_DEBUG_LEVEL > 1
fprintf( stderr, "no cups library found\n" );
#endif
return;
}
m_pcupsPrintFile = (int(*)(const char*,const char*,const char*,int,cups_option_t*))
loadSymbol( "cupsPrintFile" );
m_pcupsGetDests = (int(*)(cups_dest_t**))
loadSymbol( "cupsGetDests" );
m_pcupsSetDests = (void(*)(int,cups_dest_t*))
loadSymbol( "cupsSetDests" );
m_pcupsFreeDests = (void(*)(int,cups_dest_t*))
loadSymbol( "cupsFreeDests" );
m_pcupsGetPPD = (const char*(*)(const char*))
loadSymbol( "cupsGetPPD" );
m_pcupsMarkOptions = (int(*)(ppd_file_t*,int,cups_option_t*))
loadSymbol( "cupsMarkOptions" );
m_pcupsAddOption = (int(*)(const char*,const char*,int,cups_option_t**))
loadSymbol( "cupsAddOption" );
m_pcupsFreeOptions = (void(*)(int,cups_option_t*))
loadSymbol( "cupsFreeOptions" );
m_pppdOpenFile = (ppd_file_t*(*)(const char*))
loadSymbol( "ppdOpenFile" );
m_pppdClose = (void(*)(ppd_file_t*))
loadSymbol( "ppdClose" );
m_phttpConnectEncrypt = (http_t*(*)(const char*, int, http_encryption_t))
loadSymbol( "httpConnectEncrypt" );
m_phttpClose = (void(*)(http_t*))
loadSymbol( "httpClose" );
m_pippPort = (int(*)())
loadSymbol( "ippPort" );
m_pcupsServer = (const char*(*)())
loadSymbol( "cupsServer" );
m_pcupsEncryption = (http_encryption_t(*)())
loadSymbol( "cupsEncryption" );
m_pcupsUser = (const char*(*)())
loadSymbol( "cupsUser" );
m_pcupsSetPasswordCB = (void(*)(const char*(*)(const char*)))
loadSymbol( "cupsSetPasswordCB" );
m_pcupsSetUser = (void(*)(const char*))
loadSymbol( "cupsSetUser" );
m_pcupsGetOption = (const char*(*)(const char*,int,cups_option_t*))
loadSymbol( "cupsGetOption" );
if( ! (
m_pcupsPrintFile &&
m_pcupsGetDests &&
m_pcupsSetDests &&
m_pcupsFreeDests &&
m_pcupsGetPPD &&
m_pcupsMarkOptions &&
m_pcupsAddOption &&
m_pcupsServer &&
m_pcupsUser &&
m_pcupsSetPasswordCB &&
m_pcupsSetUser &&
m_pcupsFreeOptions &&
m_pppdOpenFile &&
m_pppdClose &&
m_phttpConnectEncrypt &&
m_phttpClose &&
m_pippPort &&
m_pcupsGetOption
) )
{
osl_unloadModule( m_pLib );
m_pLib = NULL;
}
}
CUPSWrapper::~CUPSWrapper()
{
if( m_pLib )
osl_unloadModule( m_pLib );
}
bool CUPSWrapper::isValid()
{
return m_pLib != NULL;
}
typedef const char*(*PPDFunction)(const char*);
struct GetPPDAttribs struct GetPPDAttribs
{ {
PPDFunction m_pFunction;
osl::Condition m_aCondition; osl::Condition m_aCondition;
OString m_aParameter; OString m_aParameter;
OString m_aResult; OString m_aResult;
...@@ -276,10 +64,9 @@ struct GetPPDAttribs ...@@ -276,10 +64,9 @@ struct GetPPDAttribs
bool* m_pResetRunning; bool* m_pResetRunning;
osl::Mutex* m_pSyncMutex; osl::Mutex* m_pSyncMutex;
GetPPDAttribs( PPDFunction pFn, const char * m_pParameter, GetPPDAttribs( const char * m_pParameter,
bool* pResetRunning, osl::Mutex* pSyncMutex ) bool* pResetRunning, osl::Mutex* pSyncMutex )
: m_pFunction( pFn ), : m_aParameter( m_pParameter ),
m_aParameter( m_pParameter ),
m_pResetRunning( pResetRunning ), m_pResetRunning( pResetRunning ),
m_pSyncMutex( pSyncMutex ) m_pSyncMutex( pSyncMutex )
{ {
...@@ -306,7 +93,7 @@ struct GetPPDAttribs ...@@ -306,7 +93,7 @@ struct GetPPDAttribs
{ {
// This CUPS method is not at all thread-safe we need // This CUPS method is not at all thread-safe we need
// to dup the pointer to a static buffer it returns ASAP // to dup the pointer to a static buffer it returns ASAP
OString aResult = m_pFunction( m_aParameter.getStr() ); OString aResult = cupsGetPPD(m_aParameter.getStr());
MutexGuard aGuard( *m_pSyncMutex ); MutexGuard aGuard( *m_pSyncMutex );
m_aResult = aResult; m_aResult = aResult;
m_aCondition.set(); m_aCondition.set();
...@@ -342,7 +129,7 @@ extern "C" { ...@@ -342,7 +129,7 @@ extern "C" {
} }
} }
OString CUPSWrapper::cupsGetPPD( const char* pPrinter ) OString CUPSManager::threadedCupsGetPPD( const char* pPrinter )
{ {
OString aResult; OString aResult;
...@@ -351,8 +138,7 @@ OString CUPSWrapper::cupsGetPPD( const char* pPrinter ) ...@@ -351,8 +138,7 @@ OString CUPSWrapper::cupsGetPPD( const char* pPrinter )
if( ! m_bPPDThreadRunning ) if( ! m_bPPDThreadRunning )
{ {
m_bPPDThreadRunning = true; m_bPPDThreadRunning = true;
GetPPDAttribs* pAttribs = new GetPPDAttribs( m_pcupsGetPPD, GetPPDAttribs* pAttribs = new GetPPDAttribs( pPrinter,
pPrinter,
&m_bPPDThreadRunning, &m_bPPDThreadRunning,
&m_aGetPPDMutex ); &m_aGetPPDMutex );
...@@ -388,17 +174,10 @@ static const char* setPasswordCallback( const char* pIn ) ...@@ -388,17 +174,10 @@ static const char* setPasswordCallback( const char* pIn )
CUPSManager* CUPSManager::tryLoadCUPS() CUPSManager* CUPSManager::tryLoadCUPS()
{ {
CUPSManager* pManager = NULL; CUPSManager* pManager = NULL;
static const char* pEnv = getenv( "SAL_DISABLE_CUPS" ); static const char* pEnv = getenv("SAL_DISABLE_CUPS");
if( ! pEnv || ! *pEnv ) if (!pEnv || !*pEnv)
{ pManager = new CUPSManager();
// try to load CUPS
CUPSWrapper* pWrapper = new CUPSWrapper();
if( pWrapper->isValid() )
pManager = new CUPSManager( pWrapper );
else
delete pWrapper;
}
return pManager; return pManager;
} }
...@@ -410,9 +189,8 @@ static void run_dest_thread_stub( void* pThis ) ...@@ -410,9 +189,8 @@ static void run_dest_thread_stub( void* pThis )
} }
} }
CUPSManager::CUPSManager( CUPSWrapper* pWrapper ) : CUPSManager::CUPSManager() :
PrinterInfoManager( CUPS ), PrinterInfoManager( CUPS ),
m_pCUPSWrapper( pWrapper ),
m_nDests( 0 ), m_nDests( 0 ),
m_pDests( NULL ), m_pDests( NULL ),
m_bNewDests( false ) m_bNewDests( false )
...@@ -430,9 +208,8 @@ CUPSManager::~CUPSManager() ...@@ -430,9 +208,8 @@ CUPSManager::~CUPSManager()
osl_destroyThread( m_aDestThread ); osl_destroyThread( m_aDestThread );
} }
if( m_nDests && m_pDests ) if (m_nDests && m_pDests)
m_pCUPSWrapper->cupsFreeDests( m_nDests, (cups_dest_t*)m_pDests ); cupsFreeDests( m_nDests, (cups_dest_t*)m_pDests );
delete m_pCUPSWrapper;
} }
void CUPSManager::runDestThread( void* pThis ) void CUPSManager::runDestThread( void* pThis )
...@@ -449,15 +226,15 @@ void CUPSManager::runDests() ...@@ -449,15 +226,15 @@ void CUPSManager::runDests()
// n#722902 - do a fast-failing check for cups working *at all* first // n#722902 - do a fast-failing check for cups working *at all* first
http_t* p_http; http_t* p_http;
if( (p_http=m_pCUPSWrapper->httpConnectEncrypt( if( (p_http=httpConnectEncrypt(
m_pCUPSWrapper->cupsServer(), cupsServer(),
m_pCUPSWrapper->ippPort(), ippPort(),
m_pCUPSWrapper->cupsEncryption())) != NULL ) cupsEncryption())) != NULL )
{ {
// neat, cups is up, clean up the canary // neat, cups is up, clean up the canary
m_pCUPSWrapper->httpClose(p_http); httpClose(p_http);
int nDests = m_pCUPSWrapper->cupsGetDests( &pDests ); int nDests = cupsGetDests( &pDests );
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
fprintf( stderr, "came out of cupsGetDests\n" ); fprintf( stderr, "came out of cupsGetDests\n" );
#endif #endif
...@@ -509,7 +286,7 @@ void CUPSManager::initialize() ...@@ -509,7 +286,7 @@ void CUPSManager::initialize()
// (#i65684#, #i65491#) // (#i65684#, #i65491#)
bool bUsePDF = false; bool bUsePDF = false;
cups_dest_t* pDest = ((cups_dest_t*)m_pDests); cups_dest_t* pDest = ((cups_dest_t*)m_pDests);
const char* pOpt = m_pCUPSWrapper->cupsGetOption( "printer-info", const char* pOpt = cupsGetOption( "printer-info",
pDest->num_options, pDest->num_options,
pDest->options ); pDest->options );
if( pOpt ) if( pOpt )
...@@ -610,7 +387,7 @@ void CUPSManager::initialize() ...@@ -610,7 +387,7 @@ void CUPSManager::initialize()
aRemovePrinters.pop_front(); aRemovePrinters.pop_front();
} }
m_pCUPSWrapper->cupsSetPasswordCB( setPasswordCallback ); cupsSetPasswordCB( setPasswordCallback );
} }
static void updatePrinterContextInfo( ppd_group_t* pPPDGroup, PPDContext& rContext ) static void updatePrinterContextInfo( ppd_group_t* pPPDGroup, PPDContext& rContext )
...@@ -682,7 +459,7 @@ const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter ) ...@@ -682,7 +459,7 @@ const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter )
if( dest_it != m_aCUPSDestMap.end() ) if( dest_it != m_aCUPSDestMap.end() )
{ {
cups_dest_t* pDest = ((cups_dest_t*)m_pDests) + dest_it->second; cups_dest_t* pDest = ((cups_dest_t*)m_pDests) + dest_it->second;
OString aPPDFile = m_pCUPSWrapper->cupsGetPPD( pDest->name ); OString aPPDFile = threadedCupsGetPPD( pDest->name );
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
fprintf( stderr, "PPD for %s is %s\n", OUStringToOString( aPrinter, osl_getThreadTextEncoding() ).getStr(), aPPDFile.getStr() ); fprintf( stderr, "PPD for %s is %s\n", OUStringToOString( aPrinter, osl_getThreadTextEncoding() ).getStr(), aPPDFile.getStr() );
#endif #endif
...@@ -691,7 +468,7 @@ const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter ) ...@@ -691,7 +468,7 @@ const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter )
rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
OUString aFileName( OStringToOUString( aPPDFile, aEncoding ) ); OUString aFileName( OStringToOUString( aPPDFile, aEncoding ) );
// update the printer info with context information // update the printer info with context information
ppd_file_t* pPPD = m_pCUPSWrapper->ppdOpenFile( aPPDFile.getStr() ); ppd_file_t* pPPD = ppdOpenFile( aPPDFile.getStr() );
if( pPPD ) if( pPPD )
{ {
// create the new parser // create the new parser
...@@ -699,7 +476,7 @@ const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter ) ...@@ -699,7 +476,7 @@ const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter )
pCUPSParser->m_aFile = rPrinter; pCUPSParser->m_aFile = rPrinter;
pNewParser = pCUPSParser; pNewParser = pCUPSParser;
/*int nConflicts =*/ m_pCUPSWrapper->cupsMarkOptions( pPPD, pDest->num_options, pDest->options ); /*int nConflicts =*/ cupsMarkOptions( pPPD, pDest->num_options, pDest->options );
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
fprintf( stderr, "processing the following options for printer %s (instance %s):\n", fprintf( stderr, "processing the following options for printer %s (instance %s):\n",
pDest->name, pDest->instance ); pDest->name, pDest->instance );
...@@ -723,7 +500,7 @@ const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter ) ...@@ -723,7 +500,7 @@ const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter )
rInfo.m_aContext = rContext; rInfo.m_aContext = rContext;
// clean up the mess // clean up the mess
m_pCUPSWrapper->ppdClose( pPPD ); ppdClose( pPPD );
} }
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
else else
...@@ -858,7 +635,7 @@ void CUPSManager::getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner ...@@ -858,7 +635,7 @@ void CUPSManager::getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner
{ {
OString aKey = OUStringToOString( pKey->getKey(), RTL_TEXTENCODING_ASCII_US ); OString aKey = OUStringToOString( pKey->getKey(), RTL_TEXTENCODING_ASCII_US );
OString aValue = OUStringToOString( pValue->m_aOption, RTL_TEXTENCODING_ASCII_US ); OString aValue = OUStringToOString( pValue->m_aOption, RTL_TEXTENCODING_ASCII_US );
rNumOptions = m_pCUPSWrapper->cupsAddOption( aKey.getStr(), aValue.getStr(), rNumOptions, (cups_option_t**)rOptions ); rNumOptions = cupsAddOption( aKey.getStr(), aValue.getStr(), rNumOptions, (cups_option_t**)rOptions );
} }
} }
} }
...@@ -866,11 +643,11 @@ void CUPSManager::getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner ...@@ -866,11 +643,11 @@ void CUPSManager::getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner
if( rJob.m_nPDFDevice > 0 && rJob.m_nCopies > 1 ) if( rJob.m_nPDFDevice > 0 && rJob.m_nCopies > 1 )
{ {
rtl::OString aVal( rtl::OString::valueOf( sal_Int32( rJob.m_nCopies ) ) ); rtl::OString aVal( rtl::OString::valueOf( sal_Int32( rJob.m_nCopies ) ) );
rNumOptions = m_pCUPSWrapper->cupsAddOption( "copies", aVal.getStr(), rNumOptions, (cups_option_t**)rOptions ); rNumOptions = cupsAddOption( "copies", aVal.getStr(), rNumOptions, (cups_option_t**)rOptions );
} }
if( ! bBanner ) if( ! bBanner )
{ {
rNumOptions = m_pCUPSWrapper->cupsAddOption( "job-sheets", "none", rNumOptions, (cups_option_t**)rOptions ); rNumOptions = cupsAddOption( "job-sheets", "none", rNumOptions, (cups_option_t**)rOptions );
} }
} }
...@@ -906,7 +683,7 @@ int CUPSManager::endSpool( const OUString& rPrintername, const OUString& rJobTit ...@@ -906,7 +683,7 @@ int CUPSManager::endSpool( const OUString& rPrintername, const OUString& rJobTit
getOptionsFromDocumentSetup( rDocumentJobData, bBanner, nNumOptions, (void**)&pOptions ); getOptionsFromDocumentSetup( rDocumentJobData, bBanner, nNumOptions, (void**)&pOptions );
cups_dest_t* pDest = ((cups_dest_t*)m_pDests) + dest_it->second; cups_dest_t* pDest = ((cups_dest_t*)m_pDests) + dest_it->second;
nJobID = m_pCUPSWrapper->cupsPrintFile( pDest->name, nJobID = cupsPrintFile( pDest->name,
it->second.getStr(), it->second.getStr(),
OUStringToOString( rJobTitle, aEnc ).getStr(), OUStringToOString( rJobTitle, aEnc ).getStr(),
nNumOptions, pOptions ); nNumOptions, pOptions );
...@@ -930,7 +707,7 @@ int CUPSManager::endSpool( const OUString& rPrintername, const OUString& rJobTit ...@@ -930,7 +707,7 @@ int CUPSManager::endSpool( const OUString& rPrintername, const OUString& rJobTit
unlink( it->second.getStr() ); unlink( it->second.getStr() );
m_aSpoolFiles.erase( pFile ); m_aSpoolFiles.erase( pFile );
if( pOptions ) if( pOptions )
m_pCUPSWrapper->cupsFreeOptions( nNumOptions, pOptions ); cupsFreeOptions( nNumOptions, pOptions );
} }
return nJobID; return nJobID;
...@@ -972,7 +749,7 @@ bool CUPSManager::checkPrintersChanged( bool bWait ) ...@@ -972,7 +749,7 @@ bool CUPSManager::checkPrintersChanged( bool bWait )
// there is no way to query CUPS whether the printer list has changed // there is no way to query CUPS whether the printer list has changed
// so get the dest list anew // so get the dest list anew
if( m_nDests && m_pDests ) if( m_nDests && m_pDests )
m_pCUPSWrapper->cupsFreeDests( m_nDests, (cups_dest_t*)m_pDests ); cupsFreeDests( m_nDests, (cups_dest_t*)m_pDests );
m_nDests = 0; m_nDests = 0;
m_pDests = NULL; m_pDests = NULL;
runDests(); runDests();
...@@ -1027,7 +804,7 @@ bool CUPSManager::setDefaultPrinter( const OUString& rName ) ...@@ -1027,7 +804,7 @@ bool CUPSManager::setDefaultPrinter( const OUString& rName )
for( int i = 0; i < m_nDests; i++ ) for( int i = 0; i < m_nDests; i++ )
pDests[i].is_default = 0; pDests[i].is_default = 0;
pDests[ nit->second ].is_default = 1; pDests[ nit->second ].is_default = 1;
m_pCUPSWrapper->cupsSetDests( m_nDests, (cups_dest_t*)m_pDests ); cupsSetDests( m_nDests, (cups_dest_t*)m_pDests );
m_aDefaultPrinter = rName; m_aDefaultPrinter = rName;
m_aCUPSMutex.release(); m_aCUPSMutex.release();
bSuccess = true; bSuccess = true;
...@@ -1072,11 +849,11 @@ bool CUPSManager::writePrinterConfig() ...@@ -1072,11 +849,11 @@ bool CUPSManager::writePrinterConfig()
{ {
OString aName = OUStringToOString( pKey->getKey(), aEncoding ); OString aName = OUStringToOString( pKey->getKey(), aEncoding );
OString aValue = OUStringToOString( pValue->m_aOption, aEncoding ); OString aValue = OUStringToOString( pValue->m_aOption, aEncoding );
nNewOptions = m_pCUPSWrapper->cupsAddOption( aName.getStr(), aValue.getStr(), nNewOptions, &pNewOptions ); nNewOptions = cupsAddOption( aName.getStr(), aValue.getStr(), nNewOptions, &pNewOptions );
} }
} }
// set PPD options on CUPS dest // set PPD options on CUPS dest
m_pCUPSWrapper->cupsFreeOptions( pDest->num_options, pDest->options ); cupsFreeOptions( pDest->num_options, pDest->options );
pDest->num_options = nNewOptions; pDest->num_options = nNewOptions;
pDest->options = pNewOptions; pDest->options = pNewOptions;
m_aCUPSMutex.release(); m_aCUPSMutex.release();
...@@ -1084,7 +861,7 @@ bool CUPSManager::writePrinterConfig() ...@@ -1084,7 +861,7 @@ bool CUPSManager::writePrinterConfig()
} }
if( bDestModified && m_aCUPSMutex.tryToAcquire() ) if( bDestModified && m_aCUPSMutex.tryToAcquire() )
{ {
m_pCUPSWrapper->cupsSetDests( m_nDests, (cups_dest_t*)m_pDests ); cupsSetDests( m_nDests, (cups_dest_t*)m_pDests );
m_aCUPSMutex.release(); m_aCUPSMutex.release();
} }
...@@ -1111,14 +888,14 @@ const char* CUPSManager::authenticateUser( const char* /*pIn*/ ) ...@@ -1111,14 +888,14 @@ const char* CUPSManager::authenticateUser( const char* /*pIn*/ )
{ {
osl::MutexGuard aGuard( m_aCUPSMutex ); osl::MutexGuard aGuard( m_aCUPSMutex );
OString aUser = m_pCUPSWrapper->cupsUser(); OString aUser = cupsUser();
OString aServer = m_pCUPSWrapper->cupsServer(); OString aServer = cupsServer();
OString aPassword; OString aPassword;
if( getpw( aServer, aUser, aPassword ) ) if( getpw( aServer, aUser, aPassword ) )
{ {
m_aPassword = aPassword; m_aPassword = aPassword;
m_aUser = aUser; m_aUser = aUser;
m_pCUPSWrapper->cupsSetUser( m_aUser.getStr() ); cupsSetUser( m_aUser.getStr() );
pRet = m_aPassword.getStr(); pRet = m_aPassword.getStr();
} }
} }
......
...@@ -655,7 +655,7 @@ const PPDParser* PPDParser::getParser( const String& rFile ) ...@@ -655,7 +655,7 @@ const PPDParser* PPDParser::getParser( const String& rFile )
PrinterInfoManager& rMgr = PrinterInfoManager::get(); PrinterInfoManager& rMgr = PrinterInfoManager::get();
if( rMgr.getType() == PrinterInfoManager::CUPS ) if( rMgr.getType() == PrinterInfoManager::CUPS )
{ {
#ifdef HAVE_CUPS_H #ifdef ENABLE_CUPS
pNewParser = const_cast<PPDParser*>(static_cast<CUPSManager&>(rMgr).createCUPSParser( aFile )); pNewParser = const_cast<PPDParser*>(static_cast<CUPSManager&>(rMgr).createCUPSParser( aFile ));
#endif #endif
} }
......
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