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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/***************************************************************************
* CT Host Header *
* -------------------------------------------------------------------- *
* Copyright (C) 1999, Gary Meyer <gary@meyer.net> *
* -------------------------------------------------------------------- *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef CTHOST_H
#define CTHOST_H
// Do not introduce any TQt or KDE dependencies into the "CT"-prefixed classes.
// I want to be able to reuse these classes with another GUI toolkit. -GM 11/99
#include <vector>
#include <string>
#include <tqstring.h> // Whatever
class CTCron;
struct passwd;
/**
* The host machine, or computer (encapsulation of crontab files on the
* host).
*
* If the user is the root user, the cron vector will have a member for
* each user of the host plus one for the system crontab.
*
* If the user is a non-root user, there will be only one member in the
* cron vector.
*/
class CTHost
{
public:
/**
* Constructs the user(s), scheduled tasks, and environment variables
* from crontab files.
*/
CTHost();
/**
* Destroys the user(s), scheduled tasks, and environment variable
* objects. Does not make any changes to the crontab files. Any unapplied
* changes are consequently "cancelled."
*/
~CTHost();
/**
* Apply changes.
*/
void apply();
/**
* Cancel changes.
*/
void cancel();
/**
* Indicates whether or not dirty.
*/
bool dirty();
/**
* Indicates whether or not the user is the root user.
*/
bool root() const;
/**
* Indicates an error has occured.
*/
bool isError() { return !error.isEmpty(); }
/**
* Error message
*/
TQString errorMessage() { TQString r = error; error = TQString(); return r; }
/**
* User(s).
*
* If the user is the root user, the cron vector will have a member for
* each user of the host plus one for the system crontab.
*
* If the user is a non-root user, there will be only one member in the
* cron vector.
*/
std::vector<CTCron*> cron;
private:
/**
* Copy construction not allowed.
*/
CTHost(const CTHost& source);
/**
* Assignment not allowed
*/
void operator = (const CTHost& source);
/**
* Factory create a cron table. Appends to the end of cron.
*/
CTCron* createCTCron(bool _syscron = false, std::string _login = "");
CTCron* createCTCron(const struct passwd *);
TQString error;
};
typedef std::vector<CTCron*>::iterator CTCronIterator;
#endif // CTHOST_H
|