File: kmdevices.cpp

package info (click to toggle)
cups-filters 1.28.17-3%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,096 kB
  • sloc: ansic: 54,489; cpp: 7,023; sh: 1,911; makefile: 963; xml: 127; perl: 73; php: 28; python: 8
file content (65 lines) | stat: -rw-r--r-- 1,439 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <oyranos.h>
#include <oyranos_icc.h>
#include <oyranos_devices.h>
#include <oyProfiles_s.h>
#include <oyObject_s.h>

oyConfig_s * get_device(const char * printer_name)
{
  oyConfig_s * device = 0;
  oyOptions_s * options = 0;

  oyOptions_SetFromText( &options, "//" OY_TYPE_STD "/config/command",
                         "properties", OY_CREATE_NEW );
  oyOptions_SetFromText( &options,
                   "//"OY_TYPE_STD"/config/icc_profile.x_color_region_target",
                         "yes", OY_CREATE_NEW );

  oyDeviceGet( OY_TYPE_STD, "PRINTER", printer_name,
               options, &device );
  
  oyOptions_Release(&options);

  return device;
}

int kmIsPrinterCmOff(const char * printer_name)
{
  int state = 0;
  oyConfig_s * device = 0;
  const char* str = 0;

  // Disable CM if invalid
  if(printer_name == NULL)
    return 1;

  device = get_device(printer_name);

  if (error) 
    state = 1;
  else {
    str = oyConfig_FindString(device, "CM_State", 0);   
    if (!strcmp(str, "Disabled"))
      state = 1;
  }

  return state;
}

const char * kmGetPrinterProfile(const char* printer_name)
{
  int state = 0;
  oyConfig_s * device = 0;
  oyProfile_s * profile = 0;
  const char* profile_filepath = 0;

  if(printer_name == NULL)
    return 0;

  device = get_device(printer_name);

  if (device != NULL)
    profile_filepath = oyGetDeviceProfile( device, options, profile );

  return profile_filepath;
}