@@ -1255,6 +1255,9 @@ void add_mimetype_attributes(char* cluster_name, ipp_t **merged_attributes)
1255
1255
p ; p = (remote_printer_t * )cupsArrayNext (remote_printers )) {
1256
1256
if (strcmp (cluster_name ,p -> queue_name ))
1257
1257
continue ;
1258
+ if (p -> status == STATUS_DISAPPEARED || p -> status == STATUS_UNCONFIRMED ||
1259
+ p -> status == STATUS_TO_BE_RELEASED )
1260
+ continue ;
1258
1261
if ((attr = ippFindAttribute (p -> prattrs ,attributes [attr_no ], IPP_TAG_MIMETYPE )) != NULL ) {
1259
1262
count = ippGetCount (attr );
1260
1263
for (i = 0 ; i < count ; i ++ ) {
@@ -1314,6 +1317,9 @@ void add_tagzero_attributes(char* cluster_name,ipp_t **merged_attributes)
1314
1317
p ; p = (remote_printer_t * )cupsArrayNext (remote_printers )) {
1315
1318
if (strcmp (cluster_name ,p -> queue_name ))
1316
1319
continue ;
1320
+ if (p -> status == STATUS_DISAPPEARED || p -> status == STATUS_UNCONFIRMED ||
1321
+ p -> status == STATUS_TO_BE_RELEASED )
1322
+ continue ;
1317
1323
if ((attr = ippFindAttribute (p -> prattrs ,attributes [attr_no ], IPP_TAG_ZERO )) != NULL ) {
1318
1324
count = ippGetCount (attr );
1319
1325
for (i = 0 ; i < count ; i ++ ) {
@@ -1375,6 +1381,9 @@ void add_keyword_attributes(char* cluster_name,ipp_t **merged_attributes)
1375
1381
p ; p = (remote_printer_t * )cupsArrayNext (remote_printers )) {
1376
1382
if (strcmp (cluster_name ,p -> queue_name ))
1377
1383
continue ;
1384
+ if (p -> status == STATUS_DISAPPEARED || p -> status == STATUS_UNCONFIRMED ||
1385
+ p -> status == STATUS_TO_BE_RELEASED )
1386
+ continue ;
1378
1387
if ((attr = ippFindAttribute (p -> prattrs ,attributes [attr_no ], IPP_TAG_KEYWORD )) != NULL ) {
1379
1388
count = ippGetCount (attr );
1380
1389
for (i = 0 ; i < count ; i ++ ) {
@@ -1431,6 +1440,9 @@ void add_enum_attributes(char* cluster_name,ipp_t **merged_attributes)
1431
1440
p ; p = (remote_printer_t * )cupsArrayNext (remote_printers )) {
1432
1441
if (strcmp (cluster_name ,p -> queue_name ))
1433
1442
continue ;
1443
+ if (p -> status == STATUS_DISAPPEARED || p -> status == STATUS_UNCONFIRMED ||
1444
+ p -> status == STATUS_TO_BE_RELEASED )
1445
+ continue ;
1434
1446
if ((attr = ippFindAttribute (p -> prattrs ,attributes [attr_no ], IPP_TAG_ENUM )) != NULL ) {
1435
1447
count = ippGetCount (attr );
1436
1448
for (i = 0 ; i < count ; i ++ ) {
@@ -1485,6 +1497,9 @@ void add_margin_attributes(char* cluster_name,ipp_t **merged_attributes)
1485
1497
p ; p = (remote_printer_t * )cupsArrayNext (remote_printers )) {
1486
1498
if (strcmp (cluster_name ,p -> queue_name ))
1487
1499
continue ;
1500
+ if (p -> status == STATUS_DISAPPEARED || p -> status == STATUS_UNCONFIRMED ||
1501
+ p -> status == STATUS_TO_BE_RELEASED )
1502
+ continue ;
1488
1503
if ((attr = ippFindAttribute (p -> prattrs ,attributes [attr_no ], IPP_TAG_INTEGER )) != NULL ) {
1489
1504
count = ippGetCount (attr );
1490
1505
for (i = 0 ; i < count ; i ++ ) {
@@ -1535,6 +1550,9 @@ void add_resolution_attributes(char* cluster_name, ipp_t **merged_attributes)
1535
1550
p ; p = (remote_printer_t * )cupsArrayNext (remote_printers )) {
1536
1551
if (strcmp (cluster_name ,p -> queue_name ))
1537
1552
continue ;
1553
+ if (p -> status == STATUS_DISAPPEARED || p -> status == STATUS_UNCONFIRMED ||
1554
+ p -> status == STATUS_TO_BE_RELEASED )
1555
+ continue ;
1538
1556
if ((attr = ippFindAttribute (p -> prattrs ,attributes [attr_no ], IPP_TAG_RESOLUTION )) != NULL ){
1539
1557
for (i = 0 , count = ippGetCount (attr ); i < count ; i ++ ) {
1540
1558
if ((res = ippResolutionToRes (attr , i )) != NULL &&
@@ -1590,6 +1608,9 @@ void add_mediasize_attributes(char* cluster_name, ipp_t **merged_attributes)
1590
1608
p ; p = (remote_printer_t * )cupsArrayNext (remote_printers )) {
1591
1609
if (strcmp (cluster_name ,p -> queue_name ))
1592
1610
continue ;
1611
+ if (p -> status == STATUS_DISAPPEARED || p -> status == STATUS_UNCONFIRMED ||
1612
+ p -> status == STATUS_TO_BE_RELEASED )
1613
+ continue ;
1593
1614
if ((attr = ippFindAttribute (p -> prattrs , attributes [attr_no ],
1594
1615
IPP_TAG_BEGIN_COLLECTION )) != NULL ) {
1595
1616
for (i = 0 , count = ippGetCount (attr ); i < count ; i ++ ) {
@@ -1682,6 +1703,9 @@ add_mediadatabase_attributes(char* cluster_name, ipp_t **merged_attributes)
1682
1703
p ; p = (remote_printer_t * )cupsArrayNext (remote_printers )) {
1683
1704
if (strcmp (cluster_name ,p -> queue_name ))
1684
1705
continue ;
1706
+ if (p -> status == STATUS_DISAPPEARED || p -> status == STATUS_UNCONFIRMED ||
1707
+ p -> status == STATUS_TO_BE_RELEASED )
1708
+ continue ;
1685
1709
if ((attr = ippFindAttribute (p -> prattrs ,attributes [attr_no ],
1686
1710
IPP_TAG_BEGIN_COLLECTION )) != NULL ){
1687
1711
for (i = 0 , count = ippGetCount (attr ); i < count ; i ++ ) {
@@ -1794,6 +1818,9 @@ void add_jobpresets_attribute(char* cluster_name, ipp_t ** merged_attributes)
1794
1818
p ; p = (remote_printer_t * )cupsArrayNext (remote_printers )) {
1795
1819
if (strcmp (cluster_name ,p -> queue_name ))
1796
1820
continue ;
1821
+ if (p -> status == STATUS_DISAPPEARED || p -> status == STATUS_UNCONFIRMED ||
1822
+ p -> status == STATUS_TO_BE_RELEASED )
1823
+ continue ;
1797
1824
if ((attr = ippFindAttribute (p -> prattrs , "job-presets-supported" ,
1798
1825
IPP_TAG_BEGIN_COLLECTION )) != NULL ) {
1799
1826
for (i = 0 , count = ippGetCount (attr ); i < count ; i ++ ) {
@@ -2447,6 +2474,9 @@ cups_array_t* get_cluster_sizes(char* cluster_name)
2447
2474
for (p = (remote_printer_t * )cupsArrayFirst (remote_printers );
2448
2475
p ; p = (remote_printer_t * )cupsArrayNext (remote_printers )) {
2449
2476
if (!strcmp (p -> queue_name ,cluster_name )) {
2477
+ if (p -> status == STATUS_DISAPPEARED || p -> status == STATUS_UNCONFIRMED ||
2478
+ p -> status == STATUS_TO_BE_RELEASED )
2479
+ continue ;
2450
2480
defattr = NULL ;
2451
2481
min_length = INT_MAX ;
2452
2482
min_width = INT_MAX ;
@@ -2539,6 +2569,9 @@ cups_array_t* generate_cluster_conflicts(char* cluster_name,
2539
2569
p = (remote_printer_t * )cupsArrayIndex (remote_printers , j );
2540
2570
if (strcmp (cluster_name ,p -> queue_name ))
2541
2571
continue ;
2572
+ if (p -> status == STATUS_DISAPPEARED || p -> status == STATUS_UNCONFIRMED ||
2573
+ p -> status == STATUS_TO_BE_RELEASED )
2574
+ continue ;
2542
2575
for (i = 0 ; i < no_of_ppd_keywords ; i ++ ) {
2543
2576
printer_first_options =
2544
2577
get_supported_options (p -> prattrs , ppd_keywords [i ]);
@@ -2589,15 +2622,18 @@ ipp_t* get_cluster_attributes(char* cluster_name)
2589
2622
{
2590
2623
remote_printer_t * p ;
2591
2624
ipp_t * merged_attributes = NULL ;
2592
- char printer_make_and_model [256 ], buffer [ 1024 * 30 ] ;
2625
+ char printer_make_and_model [256 ];
2593
2626
ipp_attribute_t * attr ;
2594
- int color_supported = 0 ,make_model_done = 0 ;
2595
-
2627
+ int color_supported = 0 ,make_model_done = 0 , i ;
2628
+ char valuebuffer [ 65536 ];
2596
2629
merged_attributes = ippNew ();
2597
2630
for (p = (remote_printer_t * )cupsArrayFirst (remote_printers );
2598
2631
p ; p = (remote_printer_t * )cupsArrayNext (remote_printers )) {
2599
2632
if (strcmp (cluster_name ,p -> queue_name ))
2600
2633
continue ;
2634
+ if (p -> status == STATUS_DISAPPEARED || p -> status == STATUS_UNCONFIRMED ||
2635
+ p -> status == STATUS_TO_BE_RELEASED )
2636
+ continue ;
2601
2637
if (!make_model_done ) {
2602
2638
strcpy (printer_make_and_model , "Cluster " );
2603
2639
strcat (printer_make_and_model , cluster_name );
@@ -2626,12 +2662,18 @@ ipp_t* get_cluster_attributes(char* cluster_name)
2626
2662
add_jobpresets_attribute (cluster_name , & merged_attributes );
2627
2663
attr = ippFirstAttribute (merged_attributes );
2628
2664
/* Printing merged attributes*/
2629
- debug_printf ("Merged attributes for the cluster %s" , cluster_name );
2630
- while (attr ) {
2631
- ippAttributeString (attr , buffer , sizeof (buffer ));
2632
- debug_printf ("%s,%s\n" , ippGetName (attr ), buffer );
2633
- attr = ippNextAttribute (merged_attributes );
2634
- }
2665
+ debug_printf ("Merged attributes for the cluster %s : \n" , cluster_name );
2666
+ while (attr ) {
2667
+ debug_printf (" Attr: %s\n" ,
2668
+ ippGetName (attr ));
2669
+ ippAttributeString (attr , valuebuffer , sizeof (valuebuffer ));
2670
+ debug_printf (" Value: %s\n" , valuebuffer );
2671
+ const char * kw ;
2672
+ for (i = 0 ; i < ippGetCount (attr ); i ++ )
2673
+ if ((kw = ippGetString (attr , i , NULL )) != NULL )
2674
+ debug_printf (" Keyword: %s\n" , kw );
2675
+ attr = ippNextAttribute (merged_attributes );
2676
+ }
2635
2677
return merged_attributes ;
2636
2678
}
2637
2679
@@ -2646,6 +2688,9 @@ int cluster_supports_given_attribute(char* cluster_name,ipp_tag_t tag,
2646
2688
p ; p = (remote_printer_t * )cupsArrayNext (remote_printers )) {
2647
2689
if (strcmp (cluster_name , p -> queue_name ))
2648
2690
continue ;
2691
+ if (p -> status == STATUS_DISAPPEARED || p -> status == STATUS_UNCONFIRMED ||
2692
+ p -> status == STATUS_TO_BE_RELEASED )
2693
+ continue ;
2649
2694
if ((attr = ippFindAttribute (p -> prattrs , attribute , tag )) != NULL &&
2650
2695
(count = ippGetCount (attr )) > 1 )
2651
2696
return 1 ;
@@ -2683,6 +2728,9 @@ void get_cluster_default_attributes(ipp_t** merged_attributes,
2683
2728
p ; p = (remote_printer_t * )cupsArrayNext (remote_printers )) {
2684
2729
if (strcmp (p -> queue_name , cluster_name ))
2685
2730
continue ;
2731
+ if (p -> status == STATUS_DISAPPEARED || p -> status == STATUS_UNCONFIRMED ||
2732
+ p -> status == STATUS_TO_BE_RELEASED )
2733
+ continue ;
2686
2734
if ((attr = ippFindAttribute (p -> prattrs , "pages-per-minute" ,
2687
2735
IPP_TAG_INTEGER )) != NULL ) {
2688
2736
pages_per_min = ippGetInteger (attr , 0 );
@@ -2808,7 +2856,6 @@ void get_cluster_default_attributes(ipp_t** merged_attributes,
2808
2856
2809
2857
if (attr && ippGetCount (attr ) > 0 ) {
2810
2858
* default_color = NULL ;
2811
- debug_printf ("ColorModel\n" );
2812
2859
for (i = 0 , count = ippGetCount (attr ); i < count ; i ++ ) {
2813
2860
keyword = ippGetString (attr , i , NULL );
2814
2861
if ((!strcasecmp (keyword , "black_1" ) ||
@@ -2939,7 +2986,7 @@ int supports_job_attributes_requested(const gchar* printer, int printer_index,
2939
2986
ipp_attribute_t * attr ,* attr1 ;
2940
2987
ipp_t * request , * response = NULL ;
2941
2988
const char * str ,* side ,* resource ;
2942
- cups_array_t * formats_supported , * job_sheet_supported ,
2989
+ cups_array_t * job_sheet_supported ,
2943
2990
* multiple_doc_supported ,* print_qualities ,
2944
2991
* media_type_supported ,* staplelocation_supported ,
2945
2992
* foldtype_supported ,* punchmedia_supported ,
@@ -2976,7 +3023,7 @@ int supports_job_attributes_requested(const gchar* printer, int printer_index,
2976
3023
attr = ippFirstAttribute (response );
2977
3024
2978
3025
/* Document Format */
2979
- if ((attr = ippFindAttribute (response , "document-format-detected" ,
3026
+ /* if ((attr = ippFindAttribute(response, "document-format-detected",
2980
3027
IPP_TAG_MIMETYPE)) != NULL &&
2981
3028
ippGetCount(attr) > 0) {
2982
3029
str = ippGetString(attr,0, NULL);
@@ -2987,7 +3034,7 @@ int supports_job_attributes_requested(const gchar* printer, int printer_index,
2987
3034
printer, str);
2988
3035
return 0;
2989
3036
}
2990
- }
3037
+ }*/
2991
3038
2992
3039
/* Job Sheets*/
2993
3040
if ((attr = ippFindAttribute (response , "job-sheets" ,
@@ -5851,8 +5898,12 @@ on_job_state (CupsNotifier *object,
5851
5898
num_of_printers = 0 ;
5852
5899
for (r = (remote_printer_t * )cupsArrayFirst (remote_printers );
5853
5900
r ; r = (remote_printer_t * )cupsArrayNext (remote_printers )) {
5854
- if (!strcmp (r -> queue_name , q -> queue_name ))
5855
- num_of_printers ++ ;
5901
+ if (!strcmp (r -> queue_name , q -> queue_name )){
5902
+ if (r -> status == STATUS_DISAPPEARED || r -> status == STATUS_UNCONFIRMED ||
5903
+ r -> status == STATUS_TO_BE_RELEASED )
5904
+ continue ;
5905
+ num_of_printers ++ ;
5906
+ }
5856
5907
}
5857
5908
5858
5909
/* If we are in a cluster, see whether the printer supports the
@@ -7129,7 +7180,7 @@ remove_printer_entry(remote_printer_t *p) {
7129
7180
}
7130
7181
7131
7182
gboolean update_cups_queues (gpointer unused ) {
7132
- remote_printer_t * p , * q , * r , * s ;
7183
+ remote_printer_t * p , * q , * r , * s , * master ;
7133
7184
http_t * http ;
7134
7185
char uri [HTTP_MAX_URI ], device_uri [HTTP_MAX_URI ], buf [1024 ],
7135
7186
line [1024 ];
@@ -7399,6 +7450,9 @@ gboolean update_cups_queues(gpointer unused) {
7399
7450
/* Do not create a queue for slaves */
7400
7451
if (p -> slave_of ) {
7401
7452
p -> status = STATUS_CONFIRMED ;
7453
+ master = p -> slave_of ;
7454
+ master -> status = STATUS_TO_BE_CREATED ;
7455
+ master -> timeout = time (NULL ) + TIMEOUT_IMMEDIATELY ;
7402
7456
if (p -> is_legacy ) {
7403
7457
p -> timeout = time (NULL ) + BrowseTimeout ;
7404
7458
debug_printf ("starting BrowseTimeout timer for %s (%ds)\n" ,
@@ -7606,8 +7660,12 @@ gboolean update_cups_queues(gpointer unused) {
7606
7660
num_cluster_printers = 0 ;
7607
7661
for (s = (remote_printer_t * )cupsArrayFirst (remote_printers );
7608
7662
s ; s = (remote_printer_t * )cupsArrayNext (remote_printers )){
7609
- if (!strcmp (s -> queue_name ,p -> queue_name ))
7610
- num_cluster_printers ++ ;
7663
+ if (!strcmp (s -> queue_name ,p -> queue_name )) {
7664
+ if (s -> status == STATUS_DISAPPEARED || s -> status == STATUS_UNCONFIRMED ||
7665
+ s -> status == STATUS_TO_BE_RELEASED )
7666
+ continue ;
7667
+ num_cluster_printers ++ ;
7668
+ }
7611
7669
}
7612
7670
7613
7671
if (num_cluster_printers == 1 ) {
@@ -7918,8 +7976,12 @@ gboolean update_cups_queues(gpointer unused) {
7918
7976
num_cluster_printers = 0 ;
7919
7977
for (s = (remote_printer_t * )cupsArrayFirst (remote_printers );
7920
7978
s ; s = (remote_printer_t * )cupsArrayNext (remote_printers )) {
7921
- if (!strcmp (s -> queue_name ,p -> queue_name ))
7922
- num_cluster_printers ++ ;
7979
+ if (!strcmp (s -> queue_name ,p -> queue_name )) {
7980
+ if (s -> status == STATUS_DISAPPEARED || s -> status == STATUS_UNCONFIRMED ||
7981
+ s -> status == STATUS_TO_BE_RELEASED )
7982
+ continue ;
7983
+ num_cluster_printers ++ ;
7984
+ }
7923
7985
}
7924
7986
if (num_cluster_printers == 1 ) {
7925
7987
printer_attributes = p -> prattrs ;
0 commit comments