| 329 | */ |
| 330 | |
| 331 | CFStringRef /* O - Default printer name */ |
| 332 | _cupsAppleCopyDefaultPrinter(void) |
| 333 | { |
| 334 | # if _CUPS_LOCATION_DEFAULTS |
| 335 | CFStringRef network; /* Network location */ |
| 336 | CFArrayRef locations; /* Location array */ |
| 337 | CFStringRef locprinter; /* Current printer */ |
| 338 | |
| 339 | |
| 340 | /* |
| 341 | * Use location-based defaults only if "use last printer" is selected in the |
| 342 | * system preferences... |
| 343 | */ |
| 344 | |
| 345 | if (!_cupsAppleGetUseLastPrinter()) |
| 346 | { |
| 347 | DEBUG_puts("1_cupsAppleCopyDefaultPrinter: Not using last printer as " |
| 348 | "default."); |
| 349 | return (NULL); |
| 350 | } |
| 351 | |
| 352 | /* |
| 353 | * Get the current location... |
| 354 | */ |
| 355 | |
| 356 | if ((network = appleCopyNetwork()) == NULL) |
| 357 | { |
| 358 | DEBUG_puts("1_cupsAppleCopyDefaultPrinter: Unable to get current " |
| 359 | "network."); |
| 360 | return (NULL); |
| 361 | } |
| 362 | |
| 363 | /* |
| 364 | * Lookup the network in the preferences... |
| 365 | */ |
| 366 | |
| 367 | if ((locations = appleCopyLocations()) == NULL) |
| 368 | { |
| 369 | /* |
| 370 | * Missing or bad location array, so no location-based default... |
| 371 | */ |
| 372 | |
| 373 | DEBUG_puts("1_cupsAppleCopyDefaultPrinter: Missing or bad last used " |
| 374 | "printer array."); |
| 375 | |
| 376 | CFRelease(network); |
| 377 | |
| 378 | return (NULL); |
| 379 | } |
| 380 | |
| 381 | DEBUG_printf(("1_cupsAppleCopyDefaultPrinter: Got locations, %d entries.", |
| 382 | (int)CFArrayGetCount(locations))); |
| 383 | |
| 384 | if ((locprinter = appleGetPrinter(locations, network, NULL)) != NULL) |
| 385 | CFRetain(locprinter); |
| 386 | |
| 387 | CFRelease(network); |
| 388 | CFRelease(locations); |
no test coverage detected