~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kcontrol/kfontinst/dbus/FontInst.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef FONTINST_H
 
2
#define FONTINST_H
 
3
 
 
4
/*
 
5
 * KFontInst - KDE Font Installer
 
6
 *
 
7
 * Copyright 2003-2009 Craig Drummond <craig@kde.org>
 
8
 *
 
9
 * ----
 
10
 *
 
11
 * This program is free software; you can redistribute it and/or modify
 
12
 * it under the terms of the GNU General Public License as published by
 
13
 * the Free Software Foundation; either version 2 of the License, or
 
14
 * (at your option) any later version.
 
15
 *
 
16
 * This program is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
19
 * General Public License for more details.
 
20
 *
 
21
 * You should have received a copy of the GNU General Public License
 
22
 * along with this program; see the file COPYING.  If not, write to
 
23
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
24
 * Boston, MA 02110-1301, USA.
 
25
 */
 
26
 
 
27
#include <QtCore/QObject>
 
28
#include <QtCore/QStringList>
 
29
#include <QtCore/QSet>
 
30
#include <QtDBus/QtDBus>
 
31
#include <KDE/KJob>
 
32
#include "Family.h"
 
33
#include "Folder.h"
 
34
#include "FontinstIface.h"
 
35
#include "kfontinst_export.h"
 
36
 
 
37
#define FONTINST_PATH "/FontInst"
 
38
 
 
39
class QTimer;
 
40
 
 
41
namespace KFI
 
42
{
 
43
 
 
44
class KFONTINST_EXPORT FontInst : public QObject
 
45
{
 
46
    Q_OBJECT
 
47
    Q_CLASSINFO("D-Bus Interface", "org.kde.fontinst")
 
48
 
 
49
    public:
 
50
 
 
51
    enum EStatus
 
52
    {
 
53
        STATUS_OK=0,
 
54
        STATUS_SERVICE_DIED = KJob::UserDefinedError+500,
 
55
        STATUS_BITMAPS_DISABLED,
 
56
        STATUS_ALREADY_INSTALLED,
 
57
        STATUS_NOT_FONT_FILE,
 
58
        STATUS_PARTIAL_DELETE,
 
59
        STATUS_NO_SYS_CONNECTION
 
60
    };
 
61
    
 
62
    enum EFolder
 
63
    {
 
64
        FOLDER_SYS,
 
65
        FOLDER_USER,
 
66
 
 
67
        FOLDER_COUNT
 
68
    };
 
69
 
 
70
    enum
 
71
    {
 
72
        SYS_MASK=0x01,
 
73
        USR_MASK=0x02
 
74
    };
 
75
 
 
76
    static void registerTypes()
 
77
    {
 
78
        qDBusRegisterMetaType<Families>();
 
79
        qDBusRegisterMetaType<Family>();
 
80
        qDBusRegisterMetaType<Style>();
 
81
        qDBusRegisterMetaType<File>();
 
82
        qDBusRegisterMetaType<Style>();
 
83
        qDBusRegisterMetaType<QList< Families > >();
 
84
    }
 
85
 
 
86
    static bool isStarted(OrgKdeFontinstInterface *iface)
 
87
    {
 
88
        QDBusReply<QStringList> reply=iface->connection().interface()->registeredServiceNames();
 
89
        if(reply.isValid())
 
90
        {
 
91
            QStringList services(reply.value());
 
92
            QStringList::ConstIterator it(services.begin()),
 
93
                                       end(services.end());
 
94
            for(; it!=end; ++it)
 
95
                if((*it)==OrgKdeFontinstInterface::staticInterfaceName())
 
96
                    return true;
 
97
        }
 
98
        return false;
 
99
    } 
 
100
    
 
101
    FontInst();
 
102
    ~FontInst();
 
103
 
 
104
    public Q_SLOTS:
 
105
 
 
106
    Q_NOREPLY    void list(int folders, int pid);
 
107
    Q_NOREPLY    void stat(const QString &font, int folders, int pid);
 
108
    Q_NOREPLY    void install(const QString &file, bool createAfm, bool toSystem, int pid, bool checkConfig);
 
109
    Q_NOREPLY    void uninstall(const QString &family, quint32 style, bool fromSystem, int pid, bool checkConfig);
 
110
    Q_NOREPLY    void uninstall(const QString &name, bool fromSystem, int pid, bool checkConfig);
 
111
    Q_NOREPLY    void move(const QString &family, quint32 style, bool toSystem, int pid, bool checkConfig);
 
112
    Q_NOREPLY    void enable(const QString &family, quint32 style, bool inSystem, int pid, bool checkConfig);
 
113
    Q_NOREPLY    void disable(const QString &family, quint32 style, bool inSystem, int pid, bool checkConfig);
 
114
    Q_NOREPLY    void removeFile(const QString &family, quint32 style, const QString &file, bool fromSystem, int pid,
 
115
                                 bool checkConfig);
 
116
    Q_NOREPLY    void reconfigure(int pid);
 
117
    Q_SCRIPTABLE void saveDisabled();
 
118
 
 
119
    Q_SIGNALS:
 
120
    
 
121
    void fontList(int pid, const QList<KFI::Families> &families);
 
122
    void status(int pid, int status);
 
123
    void fontStat(int pid, const KFI::Family &font);
 
124
    void fontsAdded(const KFI::Families &families);
 
125
    void fontsRemoved(const KFI::Families &families);
 
126
 
 
127
    private Q_SLOTS:
 
128
 
 
129
    void connectionsTimeout();
 
130
    void fontListTimeout();
 
131
 
 
132
    private:
 
133
 
 
134
    void updateFontList(bool emitChanges=true);
 
135
    void toggle(bool enable, const QString &family, quint32 style, bool inSystem, int pid, bool checkConfig);
 
136
    void addModifedSysFolders(const Family &family);
 
137
    void checkConnections();
 
138
    bool findFontReal(const QString &family, const QString &style, EFolder folder,
 
139
                      FamilyCont::ConstIterator &fam, StyleCont::ConstIterator &st);
 
140
    bool findFont(const QString &font, EFolder folder,
 
141
                  FamilyCont::ConstIterator &fam, StyleCont::ConstIterator &st,
 
142
                  bool updateList=true);
 
143
    bool findFontReal(const QString &family, quint32 style, EFolder folder,
 
144
                      FamilyCont::ConstIterator &fam, StyleCont::ConstIterator &st);
 
145
    bool findFont(const QString &family, quint32 style, EFolder folder,
 
146
                  FamilyCont::ConstIterator &fam, StyleCont::ConstIterator &st,
 
147
                  bool updateList=true);
 
148
    int performAction(const QVariantMap &args);
 
149
 
 
150
    static void emergencySave(int sig);
 
151
 
 
152
    private:
 
153
 
 
154
    QTimer    *itsConnectionsTimer,
 
155
              *itsFontListTimer;
 
156
    QSet<int> itsConnections;
 
157
};
 
158
 
 
159
}
 
160
 
 
161
#endif