1 #include <oyranos.h>
2 #include <oyranos_icc.h>
3 #include <oyranos_devices.h>
4 #include <oyProfiles_s.h>
5 #include <oyObject_s.h>
6
get_device(const char * printer_name)7 oyConfig_s * get_device(const char * printer_name)
8 {
9 oyConfig_s * device = 0;
10 oyOptions_s * options = 0;
11
12 oyOptions_SetFromText( &options, "//" OY_TYPE_STD "/config/command",
13 "properties", OY_CREATE_NEW );
14 oyOptions_SetFromText( &options,
15 "//"OY_TYPE_STD"/config/icc_profile.x_color_region_target",
16 "yes", OY_CREATE_NEW );
17
18 oyDeviceGet( OY_TYPE_STD, "PRINTER", printer_name,
19 options, &device );
20
21 oyOptions_Release(&options);
22
23 return device;
24 }
25
kmIsPrinterCmOff(const char * printer_name)26 int kmIsPrinterCmOff(const char * printer_name)
27 {
28 int state = 0;
29 oyConfig_s * device = 0;
30 const char* str = 0;
31
32 // Disable CM if invalid
33 if(printer_name == NULL)
34 return 1;
35
36 device = get_device(printer_name);
37
38 if (error)
39 state = 1;
40 else {
41 str = oyConfig_FindString(device, "CM_State", 0);
42 if (!strcmp(str, "Disabled"))
43 state = 1;
44 }
45
46 return state;
47 }
48
kmGetPrinterProfile(const char * printer_name)49 const char * kmGetPrinterProfile(const char* printer_name)
50 {
51 int state = 0;
52 oyConfig_s * device = 0;
53 oyProfile_s * profile = 0;
54 const char* profile_filepath = 0;
55
56 if(printer_name == NULL)
57 return 0;
58
59 device = get_device(printer_name);
60
61 if (device != NULL)
62 profile_filepath = oyGetDeviceProfile( device, options, profile );
63
64 return profile_filepath;
65 }
66