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
129
130
131
132
133
134
135
|
/*
*
* $Id: sourceheader,v 1.3 2005/01/19 13:03:46 trueg Exp $
* Copyright (C) 2005 Sebastian Trueg <[email protected]>
*
* This file is part of the K3b project.
* Copyright (C) 1998-2007 Sebastian Trueg <[email protected]>
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#include <config.h>
#include "kfile_k3bprojectfileplugin.h"
#include "kostore/koStore.h"
#include "kostore/koStoreDevice.h"
#include <k3bdoc.h>
#include <kgenericfactory.h>
#include <textstream.h>
#include <tqdom.h>
#include <tqfile.h>
K_EXPORT_COMPONENT_FACTORY(kfile_k3b, KGenericFactory<K3bProjectFilePlugin>("kfile_k3b"))
K3bProjectFilePlugin::K3bProjectFilePlugin( TQObject *parent, const char *name,
const TQStringList &args)
: KFilePlugin(parent, name, args)
{
KFileMimeTypeInfo* info = addMimeTypeInfo( "application/x-k3b" );
KFileMimeTypeInfo::GroupInfo* group = addGroupInfo( info, "General", i18n("General") );
addItemInfo( group, "documenttype", i18n("Document Type"), TQVariant::String );
}
bool K3bProjectFilePlugin::readInfo( KFileMetaInfo& info, uint /*what*/)
{
if( !info.url().isLocalFile() ) {
kdDebug() << "(K3bProjectFilePluginInfo) no local file." << endl;
return false;
}
// open the file
bool success = false;
TQDomDocument xmlDoc;
// try opening a store
KoStore* store = KoStore::createStore( info.url().path(), KoStore::Read );
if( store && !store->bad() && store->open( "maindata.xml" ) ) {
TQIODevice* dev = store->device();
dev->open( IO_ReadOnly );
if( xmlDoc.setContent( dev ) )
success = true;
dev->close();
store->close();
}
else
kdDebug() << "(K3bProjectFilePluginInfo) failed to open the store." << endl;
if( success ) {
// check the documents DOCTYPE
K3bDoc::DocType type = K3bDoc::AUDIO;
if( xmlDoc.doctype().name() == "k3b_audio_project" )
type = K3bDoc::AUDIO;
else if( xmlDoc.doctype().name() == "k3b_data_project" )
type = K3bDoc::DATA;
else if( xmlDoc.doctype().name() == "k3b_vcd_project" )
type = K3bDoc::VCD;
else if( xmlDoc.doctype().name() == "k3b_mixed_project" )
type = K3bDoc::MIXED;
else if( xmlDoc.doctype().name() == "k3b_movix_project" )
type = K3bDoc::MOVIX;
else if( xmlDoc.doctype().name() == "k3b_movixdvd_project" )
type = K3bDoc::MOVIX_DVD;
else if( xmlDoc.doctype().name() == "k3b_dvd_project" )
type = K3bDoc::DVD;
else if( xmlDoc.doctype().name() == "k3b_video_dvd_project" )
type = K3bDoc::VIDEODVD;
else {
kdDebug() << "(K3bDoc) unknown doc type: " << xmlDoc.doctype().name() << endl;
success = false;
}
TQString stringType;
switch( type ) {
case K3bDoc::AUDIO:
stringType = i18n("Audio CD");
break;
case K3bDoc::DATA:
stringType = i18n("Data CD");
break;
case K3bDoc::MIXED:
stringType = i18n("Mixed Mode CD");
break;
case K3bDoc::VCD:
stringType = i18n("Video CD");
break;
case K3bDoc::MOVIX:
stringType = i18n("eMovix CD");
break;
case K3bDoc::MOVIX_DVD:
stringType = i18n("eMovix DVD");
break;
case K3bDoc::DVD:
stringType = i18n("Data DVD");
break;
case K3bDoc::VIDEODVD:
stringType = i18n("Video DVD");
break;
}
// and finally display it!
KFileMetaInfoGroup group = appendGroup(info, "General");
appendItem( group, "documenttype", stringType );
}
delete store;
return success;
}
#include "kfile_k3bprojectfileplugin.moc"
|