568
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: current mode is '%s'\n",resolution);
570
stp_eprintf(v,"current mode is '%s'\n",resolution);
575
const canon_modeuse_t* select_media_modes(stp_vars_t *v, const canon_paper_t* media_type,const canon_modeuselist_t* mlist){
576
const canon_modeuse_t* muse = NULL;
578
for(i=0;i<mlist->count;i++){
579
if(!strcmp(media_type->name,mlist->modeuses[i].name)){
580
muse = &mlist->modeuses[i];
581
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: mode searching: assigned media '%s'\n",mlist->name);
583
stp_eprintf(v,"mode searching: assigned media '%s'\n",mlist->name);
590
int compare_mode_valid(stp_vars_t *v,const canon_mode_t* mode,const canon_modeuse_t* muse, const canon_modeuselist_t* mlist){
593
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: mode searching: assigned mode-media '%s'\n",mlist->name);
595
stp_eprintf(v,"mode searching: assigned mode-media '%s'\n",mlist->name);
596
while (muse->mode_name_list[i]!=NULL){
597
if(!strcmp(mode->name,muse->mode_name_list[i])){
606
const canon_mode_t* suitable_mode_monochrome(stp_vars_t *v,const canon_modeuse_t* muse,const canon_cap_t *caps,int quality,const char *duplex_mode) {
607
const canon_mode_t* mode=NULL;
612
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Entered suitable_mode_monochrome\n");
614
while ((muse->mode_name_list[i]!=NULL) && (modefound != 1)){
615
for(j=0;j<caps->modelist->count;j++){
616
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
617
if ( (muse->use_flags & INKSET_BLACK_MODEREPL) ) {
618
/* only look at modes with MODE_FLAG_BLACK if INKSET_BLACK_MODEREPL is in force */
619
if ( (caps->modelist->modes[j].quality >= quality) && (caps->modelist->modes[j].flags & MODE_FLAG_BLACK) ){
620
/* keep setting the mode until lowest matching quality is found */
621
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
622
/* duplex check -- rare for monochrome, cannot remember any such case */
623
mode = &caps->modelist->modes[j];
627
break; /* go to next mode in muse list */
629
else { /* no special replacement modes for black inkset */
630
if ( (caps->modelist->modes[j].quality >= quality) ){
631
/* keep setting the mode until lowest matching quality is found */
632
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
633
/* duplex check -- rare for monochrome, cannot remember any such case */
634
mode = &caps->modelist->modes[j];
638
break; /* go to next mode in muse list */
647
const canon_mode_t* find_first_matching_mode_monochrome(stp_vars_t *v,const canon_modeuse_t* muse,const canon_cap_t *caps,const char *duplex_mode) {
648
const canon_mode_t* mode=NULL;
649
/* only look at modes with MODE_FLAG_BLACK if INKSET_BLACK_MODEREPL is in force */
654
while ( (muse->mode_name_list[i]!=NULL) && (modefound != 1) ) {
655
/* pick first mode with MODE_FLAG_BLACK */
656
for(j=0;j<caps->modelist->count;j++){
657
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
658
/* only look at modes with MODE_FLAG_BLACK if INKSET_BLACK_MODEREPL is in force */
659
if ( (caps->modelist->modes[j].flags & MODE_FLAG_BLACK) ) {
660
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
661
/* duplex check -- rare for monochrome, cannot remember any such case */
662
mode = &caps->modelist->modes[j];
666
break; /* go to next mode in muse list */
674
const canon_mode_t* find_first_matching_mode(stp_vars_t *v,const canon_modeuse_t* muse,const canon_cap_t *caps,const char *duplex_mode) {
675
const canon_mode_t* mode=NULL;
680
while ( (muse->mode_name_list[i]!=NULL) && (modefound != 1) ) {
681
for(j=0;j<caps->modelist->count;j++){
682
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
683
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
684
/* duplex check -- rare for monochrome, cannot remember any such case */
685
mode = &caps->modelist->modes[j];
687
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (find_first_matching_mode): picked mode without inkset limitation (%s)\n",mode->name);
689
break; /* go to next mode in muse list */
697
const canon_mode_t* suitable_mode_color(stp_vars_t *v,const canon_modeuse_t* muse,const canon_cap_t *caps,int quality,const char *duplex_mode) {
698
const canon_mode_t* mode=NULL;
703
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Entered suitable_mode_color\n");
705
while ((muse->mode_name_list[i]!=NULL) && (modefound != 1)){
706
for(j=0;j<caps->modelist->count;j++){
707
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
708
if ( (muse->use_flags & INKSET_COLOR_MODEREPL) ) {
709
/* only look at modes with MODE_FLAG_COLOR if INKSET_COLOR_MODEREPL is in force */
710
if ( (caps->modelist->modes[j].quality >= quality) && (caps->modelist->modes[j].flags & MODE_FLAG_COLOR) ) {
711
/* keep setting the mode until lowest matching quality is found */
712
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
714
mode = &caps->modelist->modes[j];
715
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (suitable_mode_color): picked mode with special replacement inkset (%s)\n",mode->name);
719
break; /* go to next mode in muse list */
721
else { /* no special replacement modes for color inkset */
722
if ( (caps->modelist->modes[j].quality >= quality) ){
723
/* keep setting the mode until lowest matching quality is found */
724
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
726
mode = &caps->modelist->modes[j];
727
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (suitable_mode_color): picked mode without any special replacement inkset (%s)\n",mode->name);
731
break; /* go to next mode in muse list */
740
const canon_mode_t* find_first_matching_mode_color(stp_vars_t *v,const canon_modeuse_t* muse,const canon_cap_t *caps,const char *duplex_mode) {
741
const canon_mode_t* mode=NULL;
742
/* only look at modes with MODE_FLAG_COLOR if INKSET_COLOR_MODEREPL is in force */
747
while ( (muse->mode_name_list[i]!=NULL) && (modefound != 1) ) {
748
/* pick first mode with MODE_FLAG_COLOR */
749
for(j=0;j<caps->modelist->count;j++){
750
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
751
/* only look at modes with MODE_FLAG_COLOR if INKSET_COLOR_MODEREPL is in force */
752
if ( (caps->modelist->modes[j].flags & MODE_FLAG_COLOR) ) {
753
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
755
mode = &caps->modelist->modes[j];
756
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (find_first_matching_mode_color): picked first mode with special replacement inkset (%s)\n",mode->name);
760
break; /* go to next mode in muse list */
768
const canon_mode_t* suitable_mode_photo(stp_vars_t *v,const canon_modeuse_t* muse,const canon_cap_t *caps,int quality,const char *duplex_mode) {
769
const canon_mode_t* mode=NULL;
774
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Entered suitable_mode_photo\n");
776
while ((muse->mode_name_list[i]!=NULL) && (modefound != 1)){
777
for(j=0;j<caps->modelist->count;j++){
778
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
779
if ( (muse->use_flags & INKSET_PHOTO_MODEREPL) ) {
780
/* only look at modes with MODE_FLAG_PHOTO if INKSET_PHOTO_MODEREPL is in force */
781
if ( (caps->modelist->modes[j].quality >= quality) && (caps->modelist->modes[j].flags & MODE_FLAG_PHOTO) ) {
782
/* keep setting the mode until lowest matching quality is found */
783
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
785
mode = &caps->modelist->modes[j];
789
break; /* go to next mode in muse list */
791
else { /* if no special replacement modes for photo inkset */
792
if ( (caps->modelist->modes[j].quality >= quality) ){
793
/* keep setting the mode until lowest matching quality is found */
794
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
796
mode = &caps->modelist->modes[j];
800
break; /* go to next mode in muse list */
809
const canon_mode_t* find_first_matching_mode_photo(stp_vars_t *v,const canon_modeuse_t* muse,const canon_cap_t *caps,const char *duplex_mode) {
810
const canon_mode_t* mode=NULL;
811
/* only look at modes with MODE_FLAG_PHOTO if INKSET_PHOTO_MODEREPL is in force */
816
while ( (muse->mode_name_list[i]!=NULL) && (modefound != 1) ) {
817
/* pick first mode with MODE_FLAG_PHOTO */
818
for(j=0;j<caps->modelist->count;j++){
819
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
820
/* only look at modes with MODE_FLAG_PHOTO if INKSET_PHOTO_MODEREPL is in force */
821
if ( (caps->modelist->modes[j].flags & MODE_FLAG_PHOTO) ) {
822
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
824
mode = &caps->modelist->modes[j];
828
break; /* go to next mode in muse list */
836
const canon_mode_t* suitable_mode_general(stp_vars_t *v,const canon_modeuse_t* muse,const canon_cap_t *caps,int quality,const char *duplex_mode) {
837
const canon_mode_t* mode=NULL;
842
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Entered suitable_mode_general\n");
844
while ((muse->mode_name_list[i]!=NULL) && (modefound != 1)){
845
for(j=0;j<caps->modelist->count;j++){
846
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
847
if ( (caps->modelist->modes[j].quality >= quality) ) {
848
/* keep setting the mode until lowest matching quality is found */
849
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
851
mode = &caps->modelist->modes[j];
855
break; /* go to next mode in muse list */
863
const char* find_ink_type(stp_vars_t *v,const canon_mode_t* mode,const char *printing_mode) {
865
const char *ink_type = stp_get_string_parameter(v, "InkType");
867
/* if InkType does not match that of mode, change InkType to match it */
868
/* choose highest color as default, as there is only one option for Black */
869
/* if InkType does not match that of mode, change InkType to match it */
870
/* choose highest color as default, as there is only one option for Black */
871
if (printing_mode && !strcmp(printing_mode,"BW")) {
872
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType changed to %u (%s)\n",CANON_INK_K, "Gray");
873
stp_set_string_parameter(v, "InkType", "Gray");
874
ink_type = stp_get_string_parameter(v, "InkType");
877
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType of mode %s is currently set as %s\n",mode->name,ink_type);
878
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
879
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
880
if ( !(strcmp(ink_type,canon_inktypes[i].name))) {
882
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType match found %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
883
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
884
ink_type = stp_get_string_parameter(v, "InkType");
889
/* if no match found choose first available inkset */
891
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
892
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
893
if ((!ink_type) || (strcmp(ink_type,canon_inktypes[i].name))) { /* if InkType does not match selected mode ink type*/
894
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): No match found---InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
895
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
896
ink_type = stp_get_string_parameter(v, "InkType");
897
inkfound=1; /* set */
907
/* function checks printmode (specified by resolution) */
908
/* and substitutes a mode if needed. NULL is returned for now */
909
const canon_mode_t* canon_check_current_mode(stp_vars_t *v){
911
const char* input_slot = stp_get_string_parameter(v, "InputSlot");
912
const char *quality = stp_get_string_parameter(v, "Quality");
914
const char *resolution = stp_get_string_parameter(v, "Resolution");
915
const char *ink_set = stp_get_string_parameter(v, "InkSet");
916
const char *duplex_mode = stp_get_string_parameter(v, "Duplex");
917
const char *ink_type = stp_get_string_parameter(v, "InkType");
918
const char *printing_mode = stp_get_string_parameter(v, "PrintingMode");
919
const canon_cap_t * caps = canon_get_model_capabilities(v);
920
const canon_mode_t* mode = NULL;
921
const canon_modeuselist_t* mlist = caps->modeuselist;
922
const canon_modeuse_t* muse = NULL;
923
const canon_paper_t* media_type = get_media_type(caps,stp_get_string_parameter(v, "MediaType"));
925
int modecheck, quality, modefound;
930
stp_dprintf(STP_DBG_CANON, v,"Entered canon_check_current_mode: got PrintingMode %s\n",printing_mode);
932
stp_eprintf(v,"entered canon_check_current_mode: got PrintingMode %s\n",printing_mode);
934
/* Logic: priority of options
935
1. Media --- always present for final selection.
936
2. InkSet (cartridge selection) --- optional as only some printers offer this.
937
3. PrintingMode --- for printers which have K-only monochrome modes can choose BW.
938
4. Duplex --- for printers that have special duplex modes need to skip non-duplex modes.
939
5. InkType --- suggestion only, since modes are tied to ink types in most Canon printers.
940
6. Quality --- suggestion, based on initially-selected mode.
941
7. Mode --- once chosen, InkType is selected based on quality, inkset, printing mode.
946
INKSET_BLACK_SUPPORT: media type supports black-only cartridge
947
INKSET_COLOR_SUPPORT: media type supports color-only cartridge
948
INKSET_BLACK_MODEREPL: media type has special modes for black-only cartridge
949
INKSET_COLOR_MODEREPL: media type has special modes for black-only cartridge
950
INKSET_PHOTO_SUPPORT: media type supports special photo cartridge
951
DUPLEX_MODEREPL: media type has (a) special mode(s) for duplex
953
MODE_FLAG_BLACK: mode can be used for supporting black-only cartridge
954
MODE_FLAG_COLOR: mode can be used for supporting color-only cartridge
955
MODE_FLAG_PHOTO: mode can be used for supporting photo cartridge
956
MODE_FLAG_NOPDUPLEX: mode cannot be used for duplex, must be skipped
960
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: check_current_mode --- (Initial) Resolution already known: '%s'\n",resolution);
962
stp_eprintf(v,"check_current_mode --- (Initial) Resolution already known: '%s'\n",resolution);
963
for(i=0;i<caps->modelist->count;i++){
964
if(!strcmp(resolution,caps->modelist->modes[i].name)){
965
mode = &caps->modelist->modes[i];
971
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: check_current_mode --- (Initial) Resolution not yet known \n");
973
stp_eprintf(v,"check_current_mode --- (Initial) Resolution not yet known \n");
977
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: (Initial) InkSet value (high priority): '%s'\n",ink_set);
979
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: (Initial) InkSet value is NULL\n");
982
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: (Initial) InkType value (low priority): '%s'\n",ink_type);
984
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: (Initial) InkType value is NULL\n");
986
/* beginning of mode replacement code */
987
if (media_type && resolution && mode) {
988
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: check_current_mode --- Resolution, Media, Mode all known \n");
990
stp_eprintf(v,"check_current_mode --- Resolution, Media, Mode all known \n");
991
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: media type selected: '%s'\n",media_type->name);
993
stp_eprintf(v,"media type selected: '%s'\n",media_type->name);
994
stp_dprintf(STP_DBG_CANON, v,"DEBUG: (Inital) Gutenprint: mode initally active: '%s'\n",mode->name);
996
stp_eprintf(v,"(Inital) mode initially active: '%s'\n",mode->name);
998
/* scroll through modeuse list to find media */
999
muse = select_media_modes(v,media_type,mlist);
1001
/* now scroll through to find if the mode is in the modeuses list */
1002
modecheck=compare_mode_valid(v,mode,muse,mlist);
1004
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: modecheck value: '%i'\n",modecheck);
1006
stp_eprintf(v,"modecheck value: '%i'\n",modecheck);
1008
/* if we did not find a valid mode, need to replace it */
1011
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (check_current_mode): no suitable mode exists, need to find a mode\n");
1012
quality = mode->quality;
1014
if (ink_set && !strcmp(ink_set,"Black")) {
1015
stp_set_string_parameter(v, "PrintingMode","BW");
1016
printing_mode = stp_get_string_parameter(v, "PrintingMode");
1017
if (!(mode->ink_types & CANON_INK_K)) {
1019
loop through modes in muse list searching for a matching inktype, comparing quality
1021
mode=suitable_mode_monochrome(v,muse,caps,quality,duplex_mode);
1027
if (modefound == 0) { /* still did not find a mode: pick first one for that media matching the InkSet limitation */
1028
if ( (muse->use_flags & INKSET_BLACK_MODEREPL) ) {
1029
mode=find_first_matching_mode_monochrome(v,muse,caps,duplex_mode);
1031
else { /* no special replacement modes for black inkset */
1032
mode=find_first_matching_mode(v,muse,caps,duplex_mode);
1040
/* set InkType for the mode found */
1041
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1042
if (mode->ink_types & canon_inktypes[i].ink_type) {
1043
if (strcmp(ink_type,canon_inktypes[i].name)) { /* if InkType does not match selected mode ink type*/
1044
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Black): InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1045
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1046
ink_type = stp_get_string_parameter(v, "InkType");
1054
/* matched expected K inkset, but need to check if Duplex matches, and if not, get a new mode with right inkset */
1055
mode=suitable_mode_monochrome(v,muse,caps,quality,duplex_mode);
1061
if (modefound == 0) { /* still did not find a mode: pick first one for that media matching the InkSet limitation */
1062
if ( (muse->use_flags & INKSET_BLACK_MODEREPL) ) {
1063
mode=find_first_matching_mode_monochrome(v,muse,caps,duplex_mode);
1065
else { /* no special replacement modes for black inkset */
1066
mode=find_first_matching_mode(v,muse,caps,duplex_mode);
1070
ink_type=find_ink_type(v,mode,printing_mode);
1072
/* if InkType does not match that of mode, change InkType to match it */
1073
/* choose highest color as default, as there is only one option for Black */
1074
/* if InkType does not match that of mode, change InkType to match it */
1075
/* choose highest color as default, as there is only one option for Black */
1076
if (printing_mode && !strcmp(printing_mode,"BW")) {
1077
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType changed to %u (%s)\n",CANON_INK_K, "Gray");
1078
stp_set_string_parameter(v, "InkType", "Gray");
1079
ink_type = stp_get_string_parameter(v, "InkType");
1082
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType of mode %s is currently set as %s\n",mode->name,ink_type);
1083
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1084
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1085
if ( !(strcmp(ink_type,canon_inktypes[i].name))) {
1087
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType match found %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1088
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1089
ink_type = stp_get_string_parameter(v, "InkType");
1094
/* if no match found choose first available inkset */
1096
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1097
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1098
if ((!ink_type) || (strcmp(ink_type,canon_inktypes[i].name))) { /* if InkType does not match selected mode ink type*/
1099
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): No match found---InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1100
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1101
ink_type = stp_get_string_parameter(v, "InkType");
1102
inkfound=1; /* set */
1112
/* set InkType for the mode found */
1113
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1114
if (mode->ink_types & canon_inktypes[i].ink_type) {
1115
if (strcmp(ink_type,canon_inktypes[i].name)) { /* if InkType does not match selected mode ink type*/
1116
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Black): InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1117
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1118
ink_type = stp_get_string_parameter(v, "InkType");
1126
} /* End of Black Inkset */
1127
/*-------------------------------------------------------------------------------------------------*/
1129
/* Added limitation: "Color" for BJC corresponds to "Both" on other types */
1130
else if ( (ink_set && !strcmp(ink_set,"Color")) && (caps->features & CANON_CAP_T) ) {
1131
stp_set_string_parameter(v, "PrintingMode","Color");
1132
printing_mode = stp_get_string_parameter(v, "PrintingMode");
1133
if (!(mode->ink_types & CANON_INK_CMY)) {
1134
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): inkset incorrect for Color cartridge---need new mode\n");
1136
loop through modes in muse list searching for a matching inktype, comparing quality
1138
mode=suitable_mode_color(v,muse,caps,quality,duplex_mode);
1144
if (modefound == 0) { /* still did not find a mode: pick first one for that media */
1145
if ( (muse->use_flags & INKSET_COLOR_MODEREPL) ) {
1146
mode=find_first_matching_mode_color(v,muse,caps,duplex_mode);
1147
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): Decided on first matching mode for color inkset (%s)\n",mode->name);
1149
else { /* no special replacement modes for color inkset */
1150
mode=find_first_matching_mode(v,muse,caps,duplex_mode);
1151
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): Decided on first matching mode with no special replacement modes for color inkset (%s)\n",mode->name);
1159
ink_type=find_ink_type(v,mode,printing_mode);
1161
/* if InkType does not match that of mode, change InkType to match it */
1162
/* choose highest color as default, as there is only one option for Black */
1163
/* if InkType does not match that of mode, change InkType to match it */
1164
/* choose highest color as default, as there is only one option for Black */
1165
if (printing_mode && !strcmp(printing_mode,"BW")) {
1166
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType changed to %u (%s)\n",CANON_INK_K, "Gray");
1167
stp_set_string_parameter(v, "InkType", "Gray");
1168
ink_type = stp_get_string_parameter(v, "InkType");
1171
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType of mode %s is currently set as %s\n",mode->name,ink_type);
1172
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1173
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1174
if ( !(strcmp(ink_type,canon_inktypes[i].name))) {
1176
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType match found %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1177
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1178
ink_type = stp_get_string_parameter(v, "InkType");
1183
/* if no match found choose first available inkset */
1185
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1186
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1187
if ((!ink_type) || (strcmp(ink_type,canon_inktypes[i].name))) { /* if InkType does not match selected mode ink type*/
1188
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): No match found---InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1189
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1190
ink_type = stp_get_string_parameter(v, "InkType");
1191
inkfound=1; /* set */
1200
/* set InkType for the mode found */
1201
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1202
if (mode->ink_types & canon_inktypes[i].ink_type) {
1203
if (strcmp(ink_type,canon_inktypes[i].name)) { /* if InkType does not match selected mode ink type*/
1204
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1205
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1206
ink_type = stp_get_string_parameter(v, "InkType");
1216
/* matched expected RGB inkset, but need to check if Duplex matches, and if not, get a new mode with right inkset */
1217
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): inkset OK but need to check other parameters\n");
1218
mode=suitable_mode_color(v,muse,caps,quality,duplex_mode);
1224
if (modefound == 0) { /* still did not find a mode: pick first one for that media */
1225
if ( (muse->use_flags & INKSET_COLOR_MODEREPL) ) {
1226
mode=find_first_matching_mode_color(v,muse,caps,duplex_mode);
1227
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): Decided on first matching mode for color inkset (%s)\n",mode->name);
1229
else { /* no special replacement modes for color inkset */
1230
mode=find_first_matching_mode(v,muse,caps,duplex_mode);
1231
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): Decided on first matching mode with no special replacement modes for color inkset (%s)\n",mode->name);
1239
ink_type=find_ink_type(v,mode,printing_mode);
1241
/* if InkType does not match that of mode, change InkType to match it */
1242
/* choose highest color as default, as there is only one option for Black */
1243
/* if InkType does not match that of mode, change InkType to match it */
1244
/* choose highest color as default, as there is only one option for Black */
1245
if (printing_mode && !strcmp(printing_mode,"BW")) {
1246
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType changed to %u (%s)\n",CANON_INK_K, "Gray");
1247
stp_set_string_parameter(v, "InkType", "Gray");
1248
ink_type = stp_get_string_parameter(v, "InkType");
1251
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType of mode %s is currently set as %s\n",mode->name,ink_type);
1252
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1253
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1254
if ( !(strcmp(ink_type,canon_inktypes[i].name))) {
1256
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType match found %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1257
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1258
ink_type = stp_get_string_parameter(v, "InkType");
1263
/* if no match found choose first available inkset */
1265
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1266
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1267
if ((!ink_type) || (strcmp(ink_type,canon_inktypes[i].name))) { /* if InkType does not match selected mode ink type*/
1268
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): No match found---InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1269
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1270
ink_type = stp_get_string_parameter(v, "InkType");
1271
inkfound=1; /* set */
1280
/* set InkType for the mode found */
1281
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1282
if (mode->ink_types & canon_inktypes[i].ink_type) {
1283
if (strcmp(ink_type,canon_inktypes[i].name)) { /* if InkType does not match selected mode ink type*/
1284
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1285
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1286
ink_type = stp_get_string_parameter(v, "InkType");
1294
} /* end of Color InkSet */
1295
/*-------------------------------------------------------------------------------------------------*/
1296
/* Photo cartridge selection: only use modes that support it */
1297
else if (ink_set && !strcmp(ink_set,"Photo")) {
1298
/* Photo cartridge printing does not seem to have any monochrome option */
1299
stp_set_string_parameter(v, "PrintingMode","Color");
1300
printing_mode = stp_get_string_parameter(v, "PrintingMode");
1301
/* need to match photo cartridge mode flag */
1302
if (!(mode->flags & MODE_FLAG_PHOTO)) {
1304
loop through modes in muse list searching for a matching inkset, comparing quality
1306
mode=suitable_mode_photo(v,muse,caps,quality,duplex_mode);
1312
if (modefound == 0) { /* still did not find a mode: pick first one for that media */
1313
if ( (muse->use_flags & INKSET_PHOTO_MODEREPL) ) {
1314
mode=find_first_matching_mode_photo(v,muse,caps,duplex_mode);
1316
else { /* no special replacement modes for photo inkset */
1317
mode=find_first_matching_mode(v,muse,caps,duplex_mode);
1325
ink_type=find_ink_type(v,mode,printing_mode);
1327
/* if InkType does not match that of mode, change InkType to match it */
1328
/* choose highest color as default, as there is only one option for Black */
1329
/* if InkType does not match that of mode, change InkType to match it */
1330
/* choose highest color as default, as there is only one option for Black */
1331
if (printing_mode && !strcmp(printing_mode,"BW")) {
1332
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType changed to %u (%s)\n",CANON_INK_K, "Gray");
1333
stp_set_string_parameter(v, "InkType", "Gray");
1334
ink_type = stp_get_string_parameter(v, "InkType");
1337
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType of mode %s is currently set as %s\n",mode->name,ink_type);
1338
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1339
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1340
if ( !(strcmp(ink_type,canon_inktypes[i].name))) {
1342
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType match found %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1343
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1344
ink_type = stp_get_string_parameter(v, "InkType");
1349
/* if no match found choose first available inkset */
1351
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1352
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1353
if ((!ink_type) || (strcmp(ink_type,canon_inktypes[i].name))) { /* if InkType does not match selected mode ink type*/
1354
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): No match found---InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1355
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1356
ink_type = stp_get_string_parameter(v, "InkType");
1357
inkfound=1; /* set */
1366
/* set InkType for the mode found */
1367
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1368
if (mode->ink_types & canon_inktypes[i].ink_type) {
1369
if (strcmp(ink_type,canon_inktypes[i].name)) { /* if InkType does not match selected mode ink type*/
1370
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1371
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1372
ink_type = stp_get_string_parameter(v, "InkType");
1382
/* matched expected inkset, but need to check if Duplex matches, and if not, get a new mode with right inkset */
1383
mode=suitable_mode_photo(v,muse,caps,quality,duplex_mode);
1389
if (modefound == 0) { /* still did not find a mode: pick first one for that media */
1390
if ( (muse->use_flags & INKSET_PHOTO_MODEREPL) ) {
1391
mode=find_first_matching_mode_photo(v,muse,caps,duplex_mode);
1393
else { /* no special replacement modes for photo inkset */
1394
mode=find_first_matching_mode(v,muse,caps,duplex_mode);
1402
ink_type=find_ink_type(v,mode,printing_mode);
1404
/* if InkType does not match that of mode, change InkType to match it */
1405
/* choose highest color as default, as there is only one option for Black */
1406
/* if InkType does not match that of mode, change InkType to match it */
1407
/* choose highest color as default, as there is only one option for Black */
1408
if (printing_mode && !strcmp(printing_mode,"BW")) {
1409
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType changed to %u (%s)\n",CANON_INK_K, "Gray");
1410
stp_set_string_parameter(v, "InkType", "Gray");
1411
ink_type = stp_get_string_parameter(v, "InkType");
1414
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType of mode %s is currently set as %s\n",mode->name,ink_type);
1415
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1416
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1417
if ( !(strcmp(ink_type,canon_inktypes[i].name))) {
1419
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType match found %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1420
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1421
ink_type = stp_get_string_parameter(v, "InkType");
1426
/* if no match found choose first available inkset */
1428
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1429
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1430
if ((!ink_type) || (strcmp(ink_type,canon_inktypes[i].name))) { /* if InkType does not match selected mode ink type*/
1431
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): No match found---InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1432
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1433
ink_type = stp_get_string_parameter(v, "InkType");
1434
inkfound=1; /* set */
1443
/* set InkType for the mode found */
1444
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1445
if (mode->ink_types & canon_inktypes[i].ink_type) {
1446
if (strcmp(ink_type,canon_inktypes[i].name)) { /* if InkType does not match selected mode ink type*/
1447
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1448
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1449
ink_type = stp_get_string_parameter(v, "InkType");
1458
} /* end of Photo Inkset */
1459
/*-------------------------------------------------------------------------------------------------*/
1460
/* no restrictions for InkSet "Both" (non-BJC) or "Color" (BJC) or if no InkSet set yet --- do not worry about InkSet at all */
1462
if (printing_mode && !strcmp(printing_mode,"Color")) {
1463
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both) PrintingMode Color\n");
1464
/* must skip K-only inksets if they exist: they only exist if the option "BW" is also declared but we cannot check if an option exists or not */
1465
/*if ( (duplex_mode) || (mode->flags & MODE_FLAG_NODUPLEX) ) {*/
1467
quality = mode->quality;
1469
while ( (muse->mode_name_list[i]!=NULL) && (modefound != 1) ) {
1470
for(j=0;j<caps->modelist->count;j++){
1471
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
1472
if ( (caps->modelist->modes[j].quality >= quality) ) {
1473
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
1475
if (caps->modelist->modes[j].ink_types > CANON_INK_K) {
1476
mode = &caps->modelist->modes[j];
1481
break; /* go to next mode in muse list */
1488
else if (printing_mode && !strcmp(printing_mode,"BW")) {
1489
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both) PrintingMode BW\n");
1490
/* need to find K-only inksets: they must exist since we declared the printer to have this capability! */
1491
/*if ( (duplex_mode) || (mode->flags & MODE_FLAG_NODUPLEX) ) {*/
1493
quality = mode->quality;
1495
while ( (muse->mode_name_list[i]!=NULL) && (modefound != 1) ) {
1496
for(j=0;j<caps->modelist->count;j++){
1497
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
1498
if ( (caps->modelist->modes[j].quality >= quality) ) {
1499
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
1501
if (caps->modelist->modes[j].ink_types & CANON_INK_K) { /* AND means support for CANON_IN_K is included */
1502
mode = &caps->modelist->modes[j];
1507
break; /* go to next mode in muse list */
1514
else { /* no restriction from PrintingMode if not set yet */
1515
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both) PrintingMode not set yet\n");
1516
/* if mode is not a matching duplex mode, need to find a new one */
1517
/*if ( (duplex_mode) || (mode->flags & MODE_FLAG_NODUPLEX) ) {*/
1519
quality = mode->quality;
1521
while ( (muse->mode_name_list[i]!=NULL) && (modefound != 1) ) {
1522
for(j=0;j<caps->modelist->count;j++){
1523
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
1524
if ( (caps->modelist->modes[j].quality >= quality) ) {
1525
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
1527
mode = &caps->modelist->modes[j];
1531
break; /* go to next mode in muse list */
1538
/* if no mode was found yet, repeat with no restrictions --- since some media may not allow PrintingMode to be what was selected */
1539
/*if ( (duplex_mode) || (mode->flags & MODE_FLAG_NODUPLEX) ) {*/
1542
quality = mode->quality;
1543
while ( (muse->mode_name_list[i]!=NULL) && (modefound != 1) ) {
1544
for(j=0;j<caps->modelist->count;j++){
1545
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
1546
if ( (caps->modelist->modes[j].quality >= quality) ) {
1547
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
1549
mode = &caps->modelist->modes[j];
1551
/* set PrintingMode to whatever the mode is capable of */
1552
if (caps->modelist->modes[j].ink_types > CANON_INK_K) {
1553
stp_set_string_parameter(v,"PrintingMode","Color");
1554
printing_mode = stp_get_string_parameter(v, "PrintingMode");
1555
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both) PrintingMode set to Color\n");
1557
stp_set_string_parameter(v,"PrintingMode","BW");
1558
printing_mode = stp_get_string_parameter(v, "PrintingMode");
1559
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both) PrintingMode set to BW\n");
1563
break; /* go to next mode in muse list */
1570
ink_type=find_ink_type(v,mode,printing_mode);
1572
/* if InkType does not match that of mode, change InkType to match it */
1573
/* choose highest color as default, as there is only one option for Black */
1574
/* if InkType does not match that of mode, change InkType to match it */
1575
/* choose highest color as default, as there is only one option for Black */
1576
if (printing_mode && !strcmp(printing_mode,"BW")) {
1577
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType changed to %u (%s)\n",CANON_INK_K, "Gray");
1578
stp_set_string_parameter(v, "InkType", "Gray");
1579
ink_type = stp_get_string_parameter(v, "InkType");
1582
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType of mode %s is currently set as %s\n",mode->name,ink_type);
1583
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1584
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1585
if ( !(strcmp(ink_type,canon_inktypes[i].name))) {
1587
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType match found %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1588
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1589
ink_type = stp_get_string_parameter(v, "InkType");
1594
/* if no match found choose first available inkset */
1596
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1597
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1598
if ((!ink_type) || (strcmp(ink_type,canon_inktypes[i].name))) { /* if InkType does not match selected mode ink type*/
1599
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): No match found---InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1600
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1601
ink_type = stp_get_string_parameter(v, "InkType");
1602
inkfound=1; /* set */
1611
/* end of cartridge option block */
1613
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: mode searching: replaced mode with: '%s'\n",mode->name);
1615
stp_eprintf(v,"mode searching: replaced mode with: '%s'\n",mode->name);
1618
/* set InkType for the mode decided upon */
1619
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1620
if (mode->ink_types & canon_inktypes[i].ink_type) {
1621
if (strcmp(ink_type,canon_inktypes[i].name)) {
1622
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (Mode found): InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1623
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1624
ink_type = stp_get_string_parameter(v, "InkType");
1632
}/* added one here */
1633
else { /* we did find the mode in the list for media, so it should take precedence over other settings, as it is more specific. */
1635
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (check_current_mode): mode exists, need to check for consistency (%s)\n",mode->name);
1636
quality = mode->quality;
1638
if (ink_set && !strcmp(ink_set,"Black")) {
1639
stp_set_string_parameter(v, "PrintingMode","BW");
1640
printing_mode = stp_get_string_parameter(v, "PrintingMode");
1641
if (!(mode->ink_types & CANON_INK_K)) {
1643
loop through modes in muse list searching for a matching inktype, comparing quality
1645
mode=suitable_mode_monochrome(v,muse,caps,quality,duplex_mode);
1651
if (modefound == 0) { /* still did not find a mode: pick first one for that media */
1652
if ( (muse->use_flags & INKSET_BLACK_MODEREPL) ) {
1653
mode=find_first_matching_mode_monochrome(v,muse,caps,duplex_mode);
1655
else { /* no special replacement modes for black inkset */
1656
mode=find_first_matching_mode(v,muse,caps,duplex_mode);
1664
ink_type=find_ink_type(v,mode,printing_mode);
1666
/* if InkType does not match that of mode, change InkType to match it */
1667
/* choose highest color as default, as there is only one option for Black */
1668
/* if InkType does not match that of mode, change InkType to match it */
1669
/* choose highest color as default, as there is only one option for Black */
1670
if (printing_mode && !strcmp(printing_mode,"BW")) {
1671
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType changed to %u (%s)\n",CANON_INK_K, "Gray");
1672
stp_set_string_parameter(v, "InkType", "Gray");
1673
ink_type = stp_get_string_parameter(v, "InkType");
1676
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType of mode %s is currently set as %s\n",mode->name,ink_type);
1677
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1678
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1679
if ( !(strcmp(ink_type,canon_inktypes[i].name))) {
1681
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType match found %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1682
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1683
ink_type = stp_get_string_parameter(v, "InkType");
1688
/* if no match found choose first available inkset */
1690
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1691
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1692
if ((!ink_type) || (strcmp(ink_type,canon_inktypes[i].name))) { /* if InkType does not match selected mode ink type*/
1693
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): No match found---InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1694
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1695
ink_type = stp_get_string_parameter(v, "InkType");
1696
inkfound=1; /* set */
1705
/* set InkType for the mode found */
1706
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1707
if (mode->ink_types & canon_inktypes[i].ink_type) {
1708
if (strcmp(ink_type,canon_inktypes[i].name)) { /* if InkType does not match selected mode ink type*/
1709
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Black): InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1710
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1711
ink_type = stp_get_string_parameter(v, "InkType");
1721
/* matched expected K inkset, but need to check if Duplex matches, and if not, get a new mode with right inkset */
1722
mode=suitable_mode_monochrome(v,muse,caps,quality,duplex_mode);
1728
if (modefound == 0) { /* still did not find a mode: pick first one for that media */
1729
if ( (muse->use_flags & INKSET_BLACK_MODEREPL) ) {
1730
mode=find_first_matching_mode_monochrome(v,muse,caps,duplex_mode);
1732
else { /* no special replacement modes for black inkset */
1733
mode=find_first_matching_mode(v,muse,caps,duplex_mode);
1741
ink_type=find_ink_type(v,mode,printing_mode);
1743
/* if InkType does not match that of mode, change InkType to match it */
1744
/* choose highest color as default, as there is only one option for Black */
1745
/* if InkType does not match that of mode, change InkType to match it */
1746
/* choose highest color as default, as there is only one option for Black */
1747
if (printing_mode && !strcmp(printing_mode,"BW")) {
1748
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType changed to %u (%s)\n",CANON_INK_K, "Gray");
1749
stp_set_string_parameter(v, "InkType", "Gray");
1750
ink_type = stp_get_string_parameter(v, "InkType");
1753
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType of mode %s is currently set as %s\n",mode->name,ink_type);
1754
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1755
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1756
if ( !(strcmp(ink_type,canon_inktypes[i].name))) {
1758
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType match found %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1759
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1760
ink_type = stp_get_string_parameter(v, "InkType");
1765
/* if no match found choose first available inkset */
1767
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1768
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1769
if ((!ink_type) || (strcmp(ink_type,canon_inktypes[i].name))) { /* if InkType does not match selected mode ink type*/
1770
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): No match found---InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1771
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1772
ink_type = stp_get_string_parameter(v, "InkType");
1773
inkfound=1; /* set */
1782
/* set InkType for the mode found */
1783
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1784
if (mode->ink_types & canon_inktypes[i].ink_type) {
1785
if (strcmp(ink_type,canon_inktypes[i].name)) { /* if InkType does not match selected mode ink type*/
1786
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Black): InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1787
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1788
ink_type = stp_get_string_parameter(v, "InkType");
1796
} /* End of Black Inkset */
1797
/*-------------------------------------------------------------------------------------------------*/
1799
else if ( (ink_set && !strcmp(ink_set,"Color")) && (caps->features & CANON_CAP_T) ) {
1800
stp_set_string_parameter(v, "PrintingMode","Color");
1801
printing_mode = stp_get_string_parameter(v, "PrintingMode");
1802
if (!(mode->ink_types & CANON_INK_CMY)) { /* Color InkSet */
1803
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): inkset incorrect for Color cartridge---need new mode\n");
1805
loop through modes in muse list searching for a matching inktype, comparing quality
1807
mode=suitable_mode_color(v,muse,caps,quality,duplex_mode);
1814
if (modefound == 0) { /* still did not find a mode: pick first one for that media */
1815
if ( (muse->use_flags & INKSET_COLOR_MODEREPL) ) {
1816
mode=find_first_matching_mode_monochrome(v,muse,caps,duplex_mode);
1817
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): Decided on first matching mode for color inkset (%s)\n",mode->name);
1819
else { /* no special replacement modes for color inkset */
1820
mode=find_first_matching_mode(v,muse,caps,duplex_mode);
1821
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): Decided on first matching mode with no special replacement modes for color inkset (%s)\n",mode->name);
1829
ink_type=find_ink_type(v,mode,printing_mode);
1831
/* if InkType does not match that of mode, change InkType to match it */
1832
/* choose highest color as default, as there is only one option for Black */
1833
/* if InkType does not match that of mode, change InkType to match it */
1834
/* choose highest color as default, as there is only one option for Black */
1835
if (printing_mode && !strcmp(printing_mode,"BW")) {
1836
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType changed to %u (%s)\n",CANON_INK_K, "Gray");
1837
stp_set_string_parameter(v, "InkType", "Gray");
1838
ink_type = stp_get_string_parameter(v, "InkType");
1841
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType of mode %s is currently set as %s\n",mode->name,ink_type);
1842
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1843
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1844
if ( !(strcmp(ink_type,canon_inktypes[i].name))) {
1846
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType match found %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1847
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1848
ink_type = stp_get_string_parameter(v, "InkType");
1853
/* if no match found choose first available inkset */
1855
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1856
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1857
if ((!ink_type) || (strcmp(ink_type,canon_inktypes[i].name))) { /* if InkType does not match selected mode ink type*/
1858
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): No match found---InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1859
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1860
ink_type = stp_get_string_parameter(v, "InkType");
1861
inkfound=1; /* set */
1870
/* set InkType for the mode found */
1871
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1872
if (mode->ink_types & canon_inktypes[i].ink_type) {
1873
if (strcmp(ink_type,canon_inktypes[i].name)) { /* if InkType does not match selected mode ink type*/
1874
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1875
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1876
ink_type = stp_get_string_parameter(v, "InkType");
1886
/* matched expected RGB inkset, but need to check if Duplex matches, and if not, get a new mode with right inkset */
1887
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): inkset OK but need to check other parameters\n");
1888
mode=suitable_mode_color(v,muse,caps,quality,duplex_mode); /* something wrong here!!! */
1889
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): returned mode for color inkset: %s\n",mode->name);
1895
if (modefound == 0) { /* still did not find a mode: pick first one for that media */
1896
if ( (muse->use_flags & INKSET_COLOR_MODEREPL) ) {
1897
mode=find_first_matching_mode_monochrome(v,muse,caps,duplex_mode);
1898
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): Decided on first matching mode for color inkset (%s)\n",mode->name);
1900
else { /* no special replacement modes for color inkset */
1901
mode=find_first_matching_mode(v,muse,caps,duplex_mode);
1902
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): Decided on first matching mode with no special replacement modes for color inkset (%s)\n",mode->name);
1910
ink_type=find_ink_type(v,mode,printing_mode);
1912
/* if InkType does not match that of mode, change InkType to match it */
1913
/* choose highest color as default, as there is only one option for Black */
1914
/* if InkType does not match that of mode, change InkType to match it */
1915
/* choose highest color as default, as there is only one option for Black */
1916
if (printing_mode && !strcmp(printing_mode,"BW")) {
1917
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType changed to %u (%s)\n",CANON_INK_K, "Gray");
1918
stp_set_string_parameter(v, "InkType", "Gray");
1919
ink_type = stp_get_string_parameter(v, "InkType");
1922
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType of mode %s is currently set as %s\n",mode->name,ink_type);
1923
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1924
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1925
if ( !(strcmp(ink_type,canon_inktypes[i].name))) {
1927
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType match found %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1928
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1929
ink_type = stp_get_string_parameter(v, "InkType");
1934
/* if no match found choose first available inkset */
1936
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1937
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
1938
if ((!ink_type) || (strcmp(ink_type,canon_inktypes[i].name))) { /* if InkType does not match selected mode ink type*/
1939
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): No match found---InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1940
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1941
ink_type = stp_get_string_parameter(v, "InkType");
1942
inkfound=1; /* set */
1951
/* set InkType for the mode found */
1952
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
1953
if (mode->ink_types & canon_inktypes[i].ink_type) {
1954
if (strcmp(ink_type,canon_inktypes[i].name)) { /* if InkType does not match selected mode ink type*/
1955
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
1956
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
1957
ink_type = stp_get_string_parameter(v, "InkType");
1965
} /* End of Color Inkset */
1966
/*-------------------------------------------------------------------------------------------------*/
1967
/* Photo cartridge selection: only use modes that support it */
1968
else if (ink_set && !strcmp(ink_set,"Photo")) {
1969
/* Photo cartridge printing does not seem to have any monochrome option */
1970
stp_set_string_parameter(v, "PrintingMode","Color");
1971
printing_mode = stp_get_string_parameter(v, "PrintingMode");
1972
/* need to match photo cartridge mode flag */
1973
if (!(mode->flags & MODE_FLAG_PHOTO)) {
1975
loop through modes in muse list searching for a matching inkset, comparing quality
1977
mode=suitable_mode_photo(v,muse,caps,quality,duplex_mode);
1983
if (modefound == 0) { /* still did not find a mode: pick first one for that media */
1984
if ( (muse->use_flags & INKSET_PHOTO_MODEREPL) ) {
1985
mode=find_first_matching_mode_photo(v,muse,caps,duplex_mode);
1987
else { /* no special replacement modes for photo inkset */
1988
mode=find_first_matching_mode(v,muse,caps,duplex_mode);
1996
ink_type=find_ink_type(v,mode,printing_mode);
1998
/* if InkType does not match that of mode, change InkType to match it */
1999
/* choose highest color as default, as there is only one option for Black */
2000
/* if InkType does not match that of mode, change InkType to match it */
2001
/* choose highest color as default, as there is only one option for Black */
2002
if (printing_mode && !strcmp(printing_mode,"BW")) {
2003
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType changed to %u (%s)\n",CANON_INK_K, "Gray");
2004
stp_set_string_parameter(v, "InkType", "Gray");
2005
ink_type = stp_get_string_parameter(v, "InkType");
2008
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType of mode %s is currently set as %s\n",mode->name,ink_type);
2009
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
2010
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
2011
if ( !(strcmp(ink_type,canon_inktypes[i].name))) {
2013
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType match found %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
2014
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
2015
ink_type = stp_get_string_parameter(v, "InkType");
2020
/* if no match found choose first available inkset */
2022
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
2023
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
2024
if ((!ink_type) || (strcmp(ink_type,canon_inktypes[i].name))) { /* if InkType does not match selected mode ink type*/
2025
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): No match found---InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
2026
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
2027
ink_type = stp_get_string_parameter(v, "InkType");
2028
inkfound=1; /* set */
2037
/* set InkType for the mode found */
2038
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
2039
if (mode->ink_types & canon_inktypes[i].ink_type) {
2040
if (strcmp(ink_type,canon_inktypes[i].name)) { /* if InkType does not match selected mode ink type*/
2041
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
2042
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
2043
ink_type = stp_get_string_parameter(v, "InkType");
2053
/* matched expected inkset, but need to check if Duplex matches, and if not, get a new mode with right inkset */
2054
mode=suitable_mode_photo(v,muse,caps,quality,duplex_mode);
2060
if (modefound == 0) { /* still did not find a mode: pick first one for that media */
2061
if ( (muse->use_flags & INKSET_PHOTO_MODEREPL) ) {
2062
mode=find_first_matching_mode_photo(v,muse,caps,duplex_mode);
2064
else { /* no special replacement modes for photo inkset */
2065
mode=find_first_matching_mode(v,muse,caps,duplex_mode);
2073
ink_type=find_ink_type(v,mode,printing_mode);
2075
/* if InkType does not match that of mode, change InkType to match it */
2076
/* choose highest color as default, as there is only one option for Black */
2077
/* if InkType does not match that of mode, change InkType to match it */
2078
/* choose highest color as default, as there is only one option for Black */
2079
if (printing_mode && !strcmp(printing_mode,"BW")) {
2080
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType changed to %u (%s)\n",CANON_INK_K, "Gray");
2081
stp_set_string_parameter(v, "InkType", "Gray");
2082
ink_type = stp_get_string_parameter(v, "InkType");
2085
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType of mode %s is currently set as %s\n",mode->name,ink_type);
2086
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
2087
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
2088
if ( !(strcmp(ink_type,canon_inktypes[i].name))) {
2090
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType match found %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
2091
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
2092
ink_type = stp_get_string_parameter(v, "InkType");
2097
/* if no match found choose first available inkset */
2099
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
2100
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
2101
if ((!ink_type) || (strcmp(ink_type,canon_inktypes[i].name))) { /* if InkType does not match selected mode ink type*/
2102
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): No match found---InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
2103
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
2104
ink_type = stp_get_string_parameter(v, "InkType");
2105
inkfound=1; /* set */
2114
/* set InkType for the mode found */
2115
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
2116
if (mode->ink_types & canon_inktypes[i].ink_type) {
2117
if (strcmp(ink_type,canon_inktypes[i].name)) { /* if InkType does not match selected mode ink type*/
2118
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Color): InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
2119
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
2120
ink_type = stp_get_string_parameter(v, "InkType");
2128
} /* end of Photo Inkset */
2129
/*-------------------------------------------------------------------------------------------------*/
2130
/* no restrictions for InkSet "Both" (non-BJC) or "Color" (BJC) or if no InkSet set yet */
2132
if (printing_mode && !strcmp(printing_mode,"Color")) {
2133
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both) PrintingMode Color\n");
2134
/* must skip K-only inksets if they exist: they only exist if the option "BW" is also declared but we cannot check if an option exists or not */
2135
/*if ( (duplex_mode) || (mode->flags & MODE_FLAG_NODUPLEX) ) {*/
2137
quality = mode->quality;
2139
while ( (muse->mode_name_list[i]!=NULL) && (modefound != 1) ) {
2140
for(j=0;j<caps->modelist->count;j++){
2141
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
2142
if ( (caps->modelist->modes[j].quality >= quality) ) {
2143
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
2145
if (caps->modelist->modes[j].ink_types > CANON_INK_K) {
2146
if (!strcmp(mode->name,caps->modelist->modes[j].name)) {
2147
mode = &caps->modelist->modes[j];
2148
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both) Color: Decided on mode (%s)\n",mode->name);
2154
break; /* go to next mode in muse list */
2161
else if (printing_mode && !strcmp(printing_mode,"BW")) {
2162
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both) PrintingMode BW\n");
2163
/* need to find K-only inksets: they must exist since we declared the printer to have this capability! */
2164
/*if ( (duplex_mode) || (mode->flags & MODE_FLAG_NODUPLEX) ) {*/
2166
quality = mode->quality;
2168
while ( (muse->mode_name_list[i]!=NULL) && (modefound != 1) ) {
2169
for(j=0;j<caps->modelist->count;j++){
2170
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
2171
if ( (caps->modelist->modes[j].quality >= quality) ) {
2172
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
2174
if (caps->modelist->modes[j].ink_types & CANON_INK_K) { /* AND means CANON_INK_K is included in the support */
2175
if (!strcmp(mode->name,caps->modelist->modes[j].name)) {
2176
mode = &caps->modelist->modes[j];
2177
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both) BW: Decided on mode (%s)\n",mode->name);
2183
break; /* go to next mode in muse list */
2190
else { /* no restriction from PrintingMode if not set yet */
2191
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both) PrintingMode not set yet\n");
2192
/* if mode is not a matching duplex mode, need to find a new one */
2193
/*if ( (duplex_mode) || (mode->flags & MODE_FLAG_NODUPLEX) ) {*/
2195
quality = mode->quality;
2197
while ( (muse->mode_name_list[i]!=NULL) && (modefound != 1) ) {
2198
for(j=0;j<caps->modelist->count;j++){
2199
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
2200
if ( (caps->modelist->modes[j].quality >= quality) ) {
2201
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
2203
if (!strcmp(mode->name,caps->modelist->modes[j].name)) {
2204
mode = &caps->modelist->modes[j];
2205
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both) PrintingMode not set yet: Decided on first matching mode with quality match (%s)\n",mode->name);
2210
break; /* go to next mode in muse list */
2217
/* if no mode was found yet, repeat with no restrictions --- since some media may not allow PrintingMode to be what was selected */
2218
/*if ( (duplex_mode) || (mode->flags & MODE_FLAG_NODUPLEX) ) {*/
2221
quality = mode->quality;
2222
while ( (muse->mode_name_list[i]!=NULL) && (modefound != 1) ) {
2223
for(j=0;j<caps->modelist->count;j++){
2224
if(!strcmp(muse->mode_name_list[i],caps->modelist->modes[j].name)){/* find right place in canon-modes list */
2225
if ( (caps->modelist->modes[j].quality >= quality) ) {
2226
if ( !(duplex_mode) || !(muse->use_flags & DUPLEX_SUPPORT) || !(caps->modelist->modes[j].flags & MODE_FLAG_NODUPLEX) ) {
2228
mode = &caps->modelist->modes[j];
2229
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both) No mode previously found---catch-all: Decided on first matching mode (%s)\n",mode->name);
2231
/* set PrintingMode to whatever the mode is capable of */
2232
if (caps->modelist->modes[j].ink_types > CANON_INK_K){
2233
stp_set_string_parameter(v,"PrintingMode","Color");
2234
printing_mode = stp_get_string_parameter(v, "PrintingMode");
2235
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both) PrintingMode set to Color\n");
2237
stp_set_string_parameter(v,"PrintingMode","BW");
2238
printing_mode = stp_get_string_parameter(v, "PrintingMode");
2239
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both) PrintingMode set to BW\n");
2243
break; /* go to next mode in muse list */
2250
ink_type=find_ink_type(v,mode,printing_mode);
2252
/* if InkType does not match that of mode, change InkType to match it */
2253
/* choose highest color as default, as there is only one option for Black */
2254
/* if InkType does not match that of mode, change InkType to match it */
2255
/* choose highest color as default, as there is only one option for Black */
2256
if (printing_mode && !strcmp(printing_mode,"BW")) {
2257
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType changed to %u (%s)\n",CANON_INK_K, "Gray");
2258
stp_set_string_parameter(v, "InkType", "Gray");
2259
ink_type = stp_get_string_parameter(v, "InkType");
2262
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType of mode %s is currently set as %s\n",mode->name,ink_type);
2263
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
2264
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
2265
if ( !(strcmp(ink_type,canon_inktypes[i].name))) {
2267
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): InkType match found %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
2268
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
2269
ink_type = stp_get_string_parameter(v, "InkType");
2274
/* if no match found choose first available inkset */
2276
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
2277
if (mode->ink_types & canon_inktypes[i].ink_type) { /* a mode can have several ink_types: must compare with ink_type if set */
2278
if ((!ink_type) || (strcmp(ink_type,canon_inktypes[i].name))) { /* if InkType does not match selected mode ink type*/
2279
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint (InkSet:Both): No match found---InkType changed to %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
2280
stp_set_string_parameter(v, "InkType", canon_inktypes[i].name);
2281
ink_type = stp_get_string_parameter(v, "InkType");
2282
inkfound=1; /* set */
2293
/* end of mode replacement code */
2297
if(quality && strcmp(quality, "None") == 0)
2298
quality = "Standard";
2300
if(quality && !strcmp(quality,"Standard")){
2301
return &caps->modelist->modes[caps->modelist->default_mode];
2306
/* only some modes can print to cd */
2307
if(input_slot && !strcmp(input_slot,"CD") && !(mode->flags & MODE_FLAG_CD)){
2308
for(i=0;i<caps->modelist->count;i++){
2309
if(caps->modelist->modes[i].flags & MODE_FLAG_CD){
2310
mode = &caps->modelist->modes[i];
2319
stp_set_string_parameter(v, "Resolution",mode->text); /* check_current_mode checks resolution! */
2320
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: check_current_mode --- updated Resolution: '%s'\n",mode->name);
2324
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: check_current_mode --- Final returned mode: '%s'\n",mode->name);
2326
stp_eprintf(v,"check_current_mode --- Final returned mode: '%s'\n",mode->name);
2329
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: check_current_mode --- Final returned mode is NULL \n");
2331
stp_eprintf(v,"check_current_mode --- Final returned mode is NULL \n");
2334
/* set PrintingMode in case of Inkset precedence */
2335
if (mode) { /* final mode takes precedence */
2336
if (mode->ink_types == CANON_INK_K)
2337
stp_set_string_parameter(v, "PrintingMode", "BW");
2339
stp_set_string_parameter(v, "PrintingMode", "Color");
2341
else if (ink_type) { /* mode not yet known, but InkType known. InkSet should have been handled together with InkType above */
2342
if (!strcmp(ink_type,"Gray"))
2343
stp_set_string_parameter(v, "PrintingMode", "BW");
2345
stp_set_string_parameter(v, "PrintingMode", "Color");
2349
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: Final PrintingMode %s\n",printing_mode);
2350
else /* should not happen */
2351
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: Final PrintingMode is NULL\n");
2354
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: Final InkSet value (high priority): '%s'\n",ink_set);
2356
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: Final InkSet value is NULL\n");
2359
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: Final InkType value (low priority): '%s'\n",ink_type);
2361
stp_dprintf(STP_DBG_CANON, v,"DEBUG: Gutenprint: Final InkType value is NULL\n");
518
2366
/* function returns the best ink_type for the current mode */
519
2367
static unsigned int
520
2368
canon_printhead_colors(const stp_vars_t*v)
523
2371
const canon_mode_t* mode;
2372
const canon_cap_t * caps = canon_get_model_capabilities(v);
524
2373
const char *print_mode = stp_get_string_parameter(v, "PrintingMode");
525
2374
const char *ink_type = stp_get_string_parameter(v, "InkType");
526
if(print_mode && strcmp(print_mode, "BW") == 0)
530
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
531
if(ink_type && !strcmp(canon_inktypes[i].name,ink_type))
532
return canon_inktypes[i].ink_type;
2375
const char *ink_set = stp_get_string_parameter(v, "InkSet");
2377
stp_dprintf(STP_DBG_CANON, v,"Entered canon_printhead_colors: got PrintingMode %s\n",print_mode);
2379
stp_eprintf(v,"entered canon_printhead_colors: got PrintingMode %s\n",print_mode);
2381
/* if a mode is available, use it. Else mode is NULL */
2383
stp_eprintf(v,"Calling get_current_parameter from canon_printhead_colors");
535
2384
mode = canon_get_current_mode(v);
536
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
537
if(mode->ink_types & canon_inktypes[i].ink_type)
538
return canon_inktypes[i].ink_type;
2386
/* get the printing mode again */
2387
print_mode = stp_get_string_parameter(v, "PrintingMode");
2389
/* if the printing mode was already selected as BW, accept it */
2390
if(print_mode && !strcmp(print_mode, "BW") && !(caps->features & CANON_CAP_NOBLACK) ){ /* workaround in case BW is a default */
2391
stp_dprintf(STP_DBG_CANON, v,"(canon_printhead_colors[BW]) Found InkType %u (CANON_INK_K)\n",CANON_INK_K);
2392
stp_dprintf(STP_DBG_CANON, v,"(canon_printhead_colors[BW]) NOBLACK? %lu\n",(caps->features & CANON_CAP_NOBLACK));
2394
stp_eprintf(v,"(canon_printhead_colors[BW]) Found InkType %u (CANON_INK_K)\n",CANON_INK_K);
2395
stp_eprintf(v,"(canon_printhead_colors[BW]) NOBLACK? %lu\n",(caps->features & CANON_CAP_NOBLACK));
2399
/* alternatively, if the cartridge selection is in force, and black cartride is selected, accept it */
2400
if(ink_set && !strcmp(ink_set, "Black")){
2401
stp_dprintf(STP_DBG_CANON, v,"(canon_printhead_colors[BW]) Found InkSet black selection\n");
2403
stp_eprintf(v,"(canon_printhead_colors[BW]) Found InkSet black selection\n");
2407
/* originaly finds selected InkType of form: CANON_INK_<inks> */
2408
/* but this is incorrect, since it does not check media or mode */
2409
/* change: deal with mode set and mode not set cases */
2411
/* if mode was already set, then return the ink types for only that mode */
2414
/* if an inktype selected check what it is */
2416
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
2417
if (mode->ink_types & canon_inktypes[i].ink_type) {
2418
stp_dprintf(STP_DBG_CANON, v,"(canon_printhead_colors[inktype]) Found InkType %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
2420
stp_eprintf(v,"(canon_printhead_colors[inktype]) Found InkType %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
2421
return canon_inktypes[i].ink_type;
2426
/* find the matching inks for the mode: chooses the first one found for a mode! */
2427
/* ink types are arranged in decreasing order so those with more meta inks are discovered first */
2428
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
2429
if(mode->ink_types & canon_inktypes[i].ink_type) {
2430
stp_dprintf(STP_DBG_CANON, v,"(canon_printhead_colors[mode]) Found InkType %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
2432
stp_eprintf(v,"(canon_printhead_colors[mode]) Found InkType %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
2433
return canon_inktypes[i].ink_type;
2438
else { /* mode not yet set */
2439
/* if an inktype selected check what it is */
2441
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
2442
if(ink_type && !strcmp(canon_inktypes[i].name,ink_type)) {
2443
stp_dprintf(STP_DBG_CANON, v,"(canon_printhead_colors[inktype]) Found InkType %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
2445
stp_eprintf(v,"(canon_printhead_colors[inktype]) Found InkType %i(%s)\n",canon_inktypes[i].ink_type,canon_inktypes[i].name);
2446
return canon_inktypes[i].ink_type;
2450
else { /* no ink type selected yet */
2452
stp_eprintf(v,"canon_printhead_colors: no mode and no inktype: we have to choose the highest one to return\n");
2453
/* loop through all modes, and return the highest inktype found */
2454
for(i=0;i<sizeof(canon_inktypes)/sizeof(canon_inktypes[0]);i++){
2455
for(j=0;j<caps->modelist->count;j++){
2456
if(caps->modelist->modes[j].ink_types & canon_inktypes[i].ink_type){
2457
stp_dprintf(STP_DBG_CANON, v," highest inktype found --- %s(%s)\n",canon_inktypes[i].name,canon_inktypes[i].text);
2459
stp_eprintf(v,"highest inktype found --- %s(%s)\n",canon_inktypes[i].name,canon_inktypes[i].text);
2460
return canon_inktypes[i].ink_type;
2468
/* originally as fallback choose CANON_INK_K */
2469
/* However, some Canon printers do not have monochrome mode at all, only color meta ink modes, like iP6000 series */
2471
stp_dprintf(STP_DBG_CANON, v,"(canon_printhead_colors[fall-through]) Returning InkType %i(CANON_INK_K)\n",CANON_INK_K);
2473
stp_eprintf(v,"(canon_printhead_colors[fall-through]) Found InkType %i(CANON_INK_K)\n",CANON_INK_K);
2476
/* new fallback: loop through ink type in reverse order, picking first one found, which if CANON_INK_K is supported will be that, else the lowest amount of color */
2477
for(i=((sizeof(canon_inktypes)/sizeof(canon_inktypes[0]))-1);i>=0;i--){
2478
for(j=0;j<caps->modelist->count;j++){
2479
if(caps->modelist->modes[j].ink_types & canon_inktypes[i].ink_type){
2480
stp_dprintf(STP_DBG_CANON, v," lowest inktype found --- %s(%s)\n",canon_inktypes[i].name,canon_inktypes[i].text);
2482
stp_eprintf(v,"lowest inktype found --- %s(%s)\n",canon_inktypes[i].name,canon_inktypes[i].text);
2483
return canon_inktypes[i].ink_type;
2488
/* if fails until here, return something reasonable in most situations */
543
2493
static unsigned char