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
119
120
121
122
123
124
125
126
127
128
|
/* This file is part of the KDE project
* Copyright (C) 2002 Rolf Magnus <ramagnus@kde.org>
*
* 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 version 2.
*
* 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; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#include "kfile_desktop.h"
#include <kurl.h>
#include <klocale.h>
#include <kgenericfactory.h>
#include <kdebug.h>
#include <kdesktopfile.h>
#include <kmimetype.h>
typedef KGenericFactory<KDotDesktopPlugin> DotDesktopFactory;
K_EXPORT_COMPONENT_FACTORY(kfile_desktop, DotDesktopFactory("kfile_desktop"))
KDotDesktopPlugin::KDotDesktopPlugin(TQObject *parent, const char *name,
const TQStringList &preferredItems)
: KFilePlugin(parent, name, preferredItems)
{
kdDebug(7034) << ".desktop plugin\n";
KFileMimeTypeInfo* info;
KFileMimeTypeInfo::GroupInfo* group;
KFileMimeTypeInfo::ItemInfo* item;
info = addMimeTypeInfo("application/x-desktop");
group = addGroupInfo(info, "General", i18n("General"));
item = addItemInfo(group, "Name", i18n("Name"), TQVariant::String);
setHint(item, KFileMimeTypeInfo::Name);
item = addItemInfo(group, "Comment", i18n("Comment"), TQVariant::String);
setHint(item, KFileMimeTypeInfo::Description);
addItemInfo(group, "Type", i18n("Type"), TQVariant::String);
addItemInfo(group, "Device", i18n("Device"), TQVariant::String);
addItemInfo(group, "Mount Point", i18n("Mount Point"), TQVariant::String);
addItemInfo(group, "File System", i18n("File System"), TQVariant::String);
addItemInfo(group, "Writable", i18n("Writable"), TQVariant::Bool);
addItemInfo(group, "File Type", i18n("File Type"), TQVariant::String);
addItemInfo(group, "Service Type", i18n("Service Type"), TQVariant::String);
addItemInfo(group, "Preferred Items", i18n("Preferred Items"), TQVariant::String);
addItemInfo(group, "Link To", i18n("Link To"), TQVariant::String);
}
bool KDotDesktopPlugin::readInfo( KFileMetaInfo& info, uint )
{
if ( info.path().isEmpty() ) // remote file
return false;
KDesktopFile file(info.path(), true);
TQString s;
KFileMetaInfoGroup group = appendGroup(info, "General");
s = file.readName();
if (!s.isEmpty()) appendItem(group, "Name", s);
s = file.readComment();
if (!s.isEmpty()) appendItem(group, "Comment", s);
TQString type = file.readType();
if (type == "FSDevice")
{
appendItem(group, "Type", i18n("Device"));
s = file.readDevice();
if (!s.isEmpty()) appendItem(group, "Device", s);
s = file.readEntry("MountPoint");
if (!s.isEmpty()) appendItem(group, "Mount Point", s);
s = i18n(file.readEntry("FSType").local8Bit());
if (!s.isEmpty()) appendItem(group, "File System", s);
appendItem(group, "Writable",
TQVariant(!file.readBoolEntry("ReadOnly", true), 42));
}
else if (type == "Service")
{
appendItem(group, "Type", i18n("Service"));
s = file.readEntry("MimeType");
if (!s.isEmpty())
{
KMimeType::Ptr mt = KMimeType::mimeType(s);
appendItem(group, "File Type", mt->comment());
}
TQString sType = file.readEntry("ServiceTypes");
appendItem(group, "Service Type", sType);
if (sType == "KFilePlugin")
{
TQStringList preferred = file.readListEntry("PreferredItems");
appendItem(group, "Preferred Items", preferred);
}
}
else if (type == "Link")
{
TQString url = file.readPathEntry("URL");
appendItem(group, "Link To", url);
}
return true;
}
#include "kfile_desktop.moc"
|