HEAD: someone (maybe me) had introduced buggy pathname stripping in
[wvapps.git] / wvprint / queue.h
blob5f074a67576d3d1ef3a8f2bbe6f0e1c54c5f78a6
1 /* -*- Mode: C++ -*-
3 * Worldvisions Weaver Software:
4 * Copyright (C) 1997-2003 Net Integration Technologies, Inc.
6 * This is the PrintQueue class for handling various queue functions
7 * under WvPrint.
8 * It is now just a simple data model and is no longer a stream because
9 * CUPS is taking care of the rest.
11 #ifndef __QUEUE_H
12 #define __QUEUE_H
14 /* $Id: queue.h,v 1.20 2002/04/18 17:53:30 pphaneuf Exp $ */
16 #include <cups/cups.h>
18 #include <wvistreamlist.h>
19 #include <wvhashtable.h>
20 #include <uniconf.h>
21 #include <wvlog.h>
22 #include <wvcallback.h>
23 #include <wvfdstream.h>
24 #include "job.h"
26 class WvBaseCUPSManager;
27 class PrintQueueIterator;
29 class PrintQueue {
30 protected:
31 const UniConf cfg;
32 WvLog& log;
33 PrintQueue(WvStringParm _name, const UniConf _cfg, WvLog& _log, bool _is_alias = false);
34 public:
35 virtual ~PrintQueue();
36 /* Here are the truly public members, as opposed to the "had to
37 * make them public so that something worked" public members. */
38 /* FIXME: Some of these should be virtual. Picking which one is
39 * left as an exercise to the reader. */
40 const WvString name;
42 void enable(void);
43 void disable(void);
45 static PrintQueue* new_queue(WvStringParm name, const UniConf cfg,
46 WvLog& log);
47 static PrintQueue* new_alias(WvStringParm name, const UniConf cfg,
48 WvLog& log);
50 void set_cups_manager(WvBaseCUPSManager *_cups)
51 { cups = _cups; }
53 virtual bool cancel(int id, WvStringParm agent = "root");
54 unsigned int get_active_id() const;
55 size_t job_count() const;
56 bool job_exists(WvStringParm queuename, int job_num);
57 void reconfig(void);
58 void set_default(void);
60 static WvString ipp_state_to_string(ipp_pstate_t state);
61 WvString get_state(void);
63 /*
64 * Modifies printjob list in such a way that it increases the effective
65 * priority of job_id to be 'top'. It will be the next spooled job in that
66 * queue
68 bool increase_priority(unsigned int job_id);
71 * Return the current job list.
73 PrintJobList& get_jobs();
75 bool get_is_alias(void)
76 { return is_alias; }
78 private:
79 /* this list is the cached version of the object returned by get_jobs() */
80 PrintJobList jobs;
81 time_t refresh_interval;
82 time_t last_refreshed;
83 bool configured;
84 WvBaseCUPSManager *cups;
85 bool is_alias;
88 class PrintQueueName
90 public:
91 const WvString name;
92 const bool alias;
93 const bool netprint;
94 PrintQueue* queue;
96 PrintQueueName(WvStringParm _name, PrintQueue* _queue, bool _alias = false,
97 bool _netprint = false)
98 : name(_name), alias(_alias), netprint(_netprint), queue(_queue) {}
101 DeclareWvDict(PrintQueueName, WvString, name);
103 #endif