~ubuntu-branches/ubuntu/raring/hplip/raring

« back to all changes in this revision

Viewing changes to prnt/hpijs/hpijs.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2009-12-14 20:08:44 UTC
  • mfrom: (2.1.118 lucid)
  • Revision ID: james.westby@ubuntu.com-20091214200844-z8qhqwgppbu3t7ze
Tags: 3.9.10-4
KBSD patch from KiBi (Closes: #560796)

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
}
72
72
#endif
73
73
 
 
74
void setLogLevel(UXServices *pSS)
 
75
{
 
76
    FILE    *fp;
 
77
    char    str[258];
 
78
    char    *p;
 
79
    fp = fopen ("/etc/cups/cupsd.conf", "r");
 
80
    if (fp == NULL)
 
81
        return;
 
82
    while (!feof (fp))
 
83
    {
 
84
        if (!fgets (str, 256, fp))
 
85
        {
 
86
            break;
 
87
        }
 
88
        if ((p = strstr (str, "hpLogLevel")))
 
89
        {
 
90
            p += strlen ("hpLogLevel") + 1;
 
91
            pSS->m_iLogLevel = atoi (p);
 
92
            break;
 
93
        }
 
94
    }
 
95
    fclose (fp);
 
96
 
 
97
    if (pSS->m_iLogLevel & SAVE_PCL_FILE)
 
98
    {
 
99
        char    szFileName[32];
 
100
        sprintf (szFileName, "/tmp/hpijs_%d.out", getpid());
 
101
        pSS->outfp = fopen (szFileName, "w");
 
102
        if (pSS->outfp)
 
103
        {
 
104
            chmod (szFileName, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 
105
        }
 
106
    }
 
107
}
 
108
 
74
109
/* Set Print Context. */
75
110
int hpijs_set_context(UXServices *pSS)
76
111
{
218
253
                // call dbus here
219
254
                const char    *user_name = " ";
220
255
                const char    *title     = " ";
 
256
                const char *device_uri = getenv ("DEVICE_URI");
 
257
                const char *printer = getenv ("PRINTER");
221
258
                int     job_id = 0;
222
 
                SendDbusMessage (getenv ("DEVICE_URI"), getenv("PRINTER"),
 
259
 
 
260
                if (device_uri == NULL)
 
261
                    device_uri = "";
 
262
                if (printer == NULL)
 
263
                    printer = "";
 
264
 
 
265
                SendDbusMessage (device_uri, printer,
223
266
                                 EVENT_PRINT_FAILED_MISSING_PLUGIN,
224
267
                                 user_name, job_id, title);
225
268
                BUG("unable to set device=%s, err=%d\n", svalue, r);
458
501
   }
459
502
   else if (!strcmp (key, "ColorSpace"))
460
503
   {
461
 
      return snprintf(value_buf, value_size, pSS->ph.cs);
 
504
      return snprintf(value_buf, value_size, "%s", pSS->ph.cs);
462
505
   }
463
506
   else if (!strcmp (key, "PageImageFormat"))
464
507
   {
512
555
   int status = EXIT_FAILURE;
513
556
   int ret, n, i, kn=0, width, k_width;
514
557
 
 
558
   openlog("hpijs", LOG_PID,  LOG_DAEMON);
 
559
 
515
560
   if (argc > 1)
516
561
   {
517
562
      const char *arg = argv[1];
546
591
      goto BUGOUT;
547
592
   }
548
593
 
 
594
   setLogLevel(pSS);
 
595
 
549
596
#ifdef CAPTURE
550
597
   if ((pSS->InitScript("/tmp/capout", TRUE)) != NO_ERROR)
551
598
      BUG("unable to init capture");
588
635
                        case WARN_LOW_INK_YELLOW:
589
636
                        case WARN_LOW_INK_MULTIPLE_PENS:
590
637
                        {
591
 
                           BUG ("STATE: marker-supply-low-warning\n");
 
638
                           BUG ("STATE: +marker-supply-low-warning\n");
592
639
                           break;
593
640
                        }
594
641
                        default:
595
 
                           BUG ("STATE: -marker-supply-low-warning");
 
642
                           BUG ("STATE: -marker-supply-low-warning\n");
596
643
                }
597
644
    }
598
645