summaryrefslogtreecommitdiffstats
path: root/kcontrol/kfontinst/kfontinst/XConfig.h
blob: 127b243fada485d53ce5d64f149773578f8fedd8 (plain)
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
#ifndef __X_CONFIG_H__
#define __X_CONFIG_H__

////////////////////////////////////////////////////////////////////////////////
//
// Class Name    : KFI::CXConfig
// Author        : Craig Drummond
// Project       : K Font Installer
// Creation Date : 05/05/2001
// Version       : $Revision$ $Date$
//
////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//
////////////////////////////////////////////////////////////////////////////////
// (C) Craig Drummond, 2001, 2002, 2003, 2004
///////////////////////////////////////////////////////////////////////////////

#include "Misc.h"
#include <tqptrlist.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <time.h>

namespace KFI
{

class CFontEngine;

class CXConfig
{
    public:

    struct TPath
    {
        enum EType
        {
            DIR,
            FONT_SERVER,
            FONT_CONFIG
        };

        TPath(const TQString &d, bool u=false, EType t=DIR, bool o=true)
           : dir(DIR==t ? Misc::dirSyntax(d) : d), unscaled(u), orig(o), type(t) {}

        static EType getType(const TQString &d);

        TQString dir;
        bool    unscaled,
                orig;          // Was dir in file when read?
        EType   type;
    };

    enum EType
    {
        XFS,
        X11
    };

    public:

    CXConfig(EType type, const TQString &file);

    static bool configureDir(const TQString &dir);

    bool  ok()                       { return itsOk; }
    bool  writable()                 { return itsWritable; }
    bool  readConfig();
    bool  writeConfig();
    bool  madeChanges();
    void  addPath(const TQString &dir, bool unscaled=false);
    bool  inPath(TPath::EType type);
    bool  xfsInPath()                { return inPath(TPath::FONT_SERVER); }
    bool  fcInPath()                 { return inPath(TPath::FONT_CONFIG); }
    void  refreshPaths()             { refreshPaths(XFS==itsType); }
    void  restart();
    EType getType()                  { return itsType; }

    static void refreshPaths(bool xfs);

    private:

    bool processX11(bool read);
    bool processXfs(bool read);

    TPath * findPath(const TQString &dir);

    private:

    EType           itsType;
    TQPtrList<TPath> itsPaths;
    TQString         itsFileName,
                    itsInsertPos;
    bool            itsOk,
                    itsWritable;
    time_t          itsTime;
};

}

#endif