@@ -205,8 +205,7 @@ struct Scanner::Private
205205 explicit InputSource (Private* p);
206206 const char * init (const sanecpp::option_set&);
207207 void writeCapabilitiesXml (std::ostream&) const ;
208- } * mpPlaten, *mpAdf;
209- bool mDuplex ;
208+ } * mpPlaten, *mpAdfSimplex, *mpAdfDuplex;
210209
211210 std::string mGrayScanModeName , mColorScanModeName ;
212211 mutable int mCurrentProfile ;
@@ -239,8 +238,8 @@ std::set<Scanner::Private*> Scanner::Private::sInstances;
239238Scanner::Private::Private (Scanner* p)
240239 : p(p)
241240 , mpPlaten(nullptr )
242- , mpAdf (nullptr )
243- , mDuplex( false )
241+ , mpAdfSimplex (nullptr )
242+ , mpAdfDuplex( nullptr )
244243 , mTemporaryAdfStatus(SANE_STATUS_GOOD )
245244 , mError(nullptr )
246245{
@@ -250,7 +249,8 @@ Scanner::Private::Private(Scanner* p)
250249Scanner::Private::~Private ()
251250{
252251 delete mpPlaten;
253- delete mpAdf;
252+ delete mpAdfSimplex;
253+ delete mpAdfDuplex;
254254 sInstances .erase (this );
255255}
256256
@@ -278,20 +278,16 @@ Scanner::Private::writeScannerCapabilitiesXml(std::ostream& os) const
278278 mpPlaten->writeCapabilitiesXml (os);
279279 os << " </scan:PlatenInputCaps>\r\n </scan:Platen>\r\n " ;
280280 }
281- if (mpAdf && ! mDuplex ) {
281+ if (mpAdfSimplex ) {
282282 os << " <scan:Adf>\r\n <scan:AdfSimplexInputCaps>\r\n " ;
283- mpAdf->writeCapabilitiesXml (os);
284- os << " </scan:AdfSimplexInputCaps>\r\n "
285- << " <scan:AdfOptions>\r\n "
286- << " <scan:AdfOption>DetectPaperLoaded</scan:AdfOption>\r\n "
287- << " </scan:AdfOptions>\r\n "
288- << " </scan:Adf>\r\n " ;
289- }
290- if (mpAdf && mDuplex ) {
291- os << " <scan:Adf>\r\n <scan:AdfDuplexInputCaps>\r\n " ;
292- mpAdf->writeCapabilitiesXml (os);
293- os << " </scan:AdfDuplexInputCaps>\r\n "
294- << " <scan:AdfOptions>\r\n "
283+ mpAdfSimplex->writeCapabilitiesXml (os);
284+ os << " </scan:AdfSimplexInputCaps>\r\n " ;
285+ if (mpAdfDuplex) {
286+ os << " <scan:AdfDuplexInputCaps>\r\n " ;
287+ mpAdfDuplex->writeCapabilitiesXml (os);
288+ os << " </scan:AdfDuplexInputCaps>\r\n " ;
289+ }
290+ os << " <scan:AdfOptions>\r\n "
295291 << " <scan:AdfOption>DetectPaperLoaded</scan:AdfOption>\r\n "
296292 << " </scan:AdfOptions>\r\n "
297293 << " </scan:Adf>\r\n " ;
@@ -565,20 +561,35 @@ Scanner::Private::init2(const OptionsFile& optionsfile)
565561 mMaxHeightPx300dpi = std::max (mMaxHeightPx300dpi , mpPlaten->mMaxHeight );
566562 }
567563 }
568- if (!adfName.empty ()) {
569- mInputSources .push_back (" Feeder" );
570- mDuplex = !adfDuplexName.empty ();
571- opt[SANE_NAME_SCAN_SOURCE ].set_string_value (adfName);
572- mpAdf = new Private::InputSource (this );
573- err = mpAdf->init (opt);
564+ if (!adfSimplexName.empty () || !adfDuplexName.empty ()) {
565+ mInputSources .push_back (" Feeder" );
566+ }
567+ if (!adfSimplexName.empty ()) {
568+ opt[SANE_NAME_SCAN_SOURCE ].set_string_value (adfSimplexName);
569+ mpAdfSimplex = new Private::InputSource (this );
570+ err = mpAdfSimplex->init (opt);
574571 if (!err) {
575- mpAdf ->mSupportedIntents = std::vector<std::string>({
572+ mpAdfSimplex ->mSupportedIntents = std::vector<std::string>({
576573 " TextAndGraphic" ,
577574 " Photo" ,
578575 });
579- maxBits = std::max (maxBits, mpAdf->mMaxBits );
580- mMaxWidthPx300dpi = std::max (mMaxWidthPx300dpi , mpAdf->mMaxWidth );
581- mMaxHeightPx300dpi = std::max (mMaxHeightPx300dpi , mpAdf->mMaxHeight );
576+ maxBits = std::max (maxBits, mpAdfSimplex->mMaxBits );
577+ mMaxWidthPx300dpi = std::max (mMaxWidthPx300dpi , mpAdfSimplex->mMaxWidth );
578+ mMaxHeightPx300dpi = std::max (mMaxHeightPx300dpi , mpAdfSimplex->mMaxHeight );
579+ }
580+ }
581+ if (!adfDuplexName.empty ()) {
582+ opt[SANE_NAME_SCAN_SOURCE ].set_string_value (adfDuplexName);
583+ mpAdfDuplex = new Private::InputSource (this );
584+ err = mpAdfDuplex->init (opt);
585+ if (!err) {
586+ mpAdfDuplex->mSupportedIntents = std::vector<std::string>({
587+ " TextAndGraphic" ,
588+ " Photo" ,
589+ });
590+ maxBits = std::max (maxBits, mpAdfDuplex->mMaxBits );
591+ mMaxWidthPx300dpi = std::max (mMaxWidthPx300dpi , mpAdfDuplex->mMaxWidth );
592+ mMaxHeightPx300dpi = std::max (mMaxHeightPx300dpi , mpAdfDuplex->mMaxHeight );
582593 }
583594 }
584595 if (maxBits == 16 ) {
@@ -799,9 +810,16 @@ Scanner::platenSupportedIntents() const
799810}
800811
801812std::vector<std::string>
802- Scanner::adfSupportedIntents () const
813+ Scanner::adfSimplexSupportedIntents () const
814+ {
815+ return p->mpAdfSimplex ? p->mpAdfSimplex ->mSupportedIntents : std::vector<std::string>();
816+ ;
817+ }
818+
819+ std::vector<std::string>
820+ Scanner::adfDuplexSupportedIntents () const
803821{
804- return p->mpAdf ? p->mpAdf ->mSupportedIntents : std::vector<std::string>();
822+ return p->mpAdfDuplex ? p->mpAdfDuplex ->mSupportedIntents : std::vector<std::string>();
805823 ;
806824}
807825
@@ -844,13 +862,13 @@ Scanner::hasPlaten() const
844862bool
845863Scanner::hasAdf () const
846864{
847- return p->mpAdf ;
865+ return p->mpAdfSimplex ;
848866}
849867
850868bool
851869Scanner::hasDuplexAdf () const
852870{
853- return p->mpAdf && p-> mDuplex ;
871+ return p->mpAdfDuplex ;
854872}
855873
856874std::string
@@ -860,9 +878,15 @@ Scanner::platenSourceName() const
860878}
861879
862880std::string
863- Scanner::adfSourceName () const
881+ Scanner::adfSimplexSourceName () const
882+ {
883+ return p->mpAdfSimplex ? p->mpAdfSimplex ->mSourceName : " " ;
884+ }
885+
886+ std::string
887+ Scanner::adfDuplexSourceName () const
864888{
865- return p->mpAdf ? p->mpAdf ->mSourceName : " " ;
889+ return p->mpAdfDuplex ? p->mpAdfDuplex ->mSourceName : " " ;
866890}
867891
868892std::string
@@ -963,7 +987,7 @@ Scanner::writeScannerStatusXml(std::ostream& os) const
963987 << p->statusString ()
964988 << " </pwg:State>\r\n " ;
965989
966- if (p->mpAdf )
990+ if (p->mpAdfSimplex || p-> mpAdfDuplex )
967991 os << " <scan:AdfState>" << p->temporaryAdfStatusString ()
968992 << " </scan:AdfState>\r\n " ;
969993
0 commit comments