blob: 18b601b9c7349c67b151c68492a6c25cff780737 (
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
/*
*
* $Id: k3bexternalbinmanager.h 619556 2007-01-03 17:38:12Z trueg $
* Copyright (C) 2003 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.
*/
#ifndef K3B_EXTERNAL_BIN_MANAGER_H
#define K3B_EXTERNAL_BIN_MANAGER_H
#include <tqmap.h>
#include <tqobject.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqptrlist.h>
#include "k3b_export.h"
#include "k3bversion.h"
class TDEConfig;
class TDEProcess;
class K3bExternalProgram;
/**
* A K3bExternalBin represents an installed version of a program.
* All K3bExternalBin objects are managed by K3bExternalPrograms.
*
* A bin may have certain features that are represented by a string.
*/
class LIBK3B_EXPORT K3bExternalBin
{
public:
K3bExternalBin( K3bExternalProgram* );
virtual ~K3bExternalBin() {}
K3bVersion version;
TQString path;
TQString copyright;
const TQString& name() const;
bool isEmpty() const;
const TQStringList& userParameters() const;
const TQStringList& features() const { return m_features; }
bool hasFeature( const TQString& ) const;
void addFeature( const TQString& );
K3bExternalProgram* program() const { return m_program; }
private:
TQStringList m_features;
K3bExternalProgram* m_program;
};
/**
* This is the main class that represents a program
* It's scan method has to be reimplemented for every program
* It manages a list of K3bExternalBin-objects that each represent
* one installed version of the program.
*/
class LIBK3B_EXPORT K3bExternalProgram
{
public:
K3bExternalProgram( const TQString& name );
virtual ~K3bExternalProgram();
const K3bExternalBin* defaultBin() const { return m_bins.getFirst(); }
const K3bExternalBin* mostRecentBin() const;
void addUserParameter( const TQString& );
void setUserParameters( const TQStringList& list ) { m_userParameters = list; }
const TQStringList& userParameters() const { return m_userParameters; }
const TQString& name() const { return m_name; }
void addBin( K3bExternalBin* );
void clear() { m_bins.clear(); }
void setDefault( const K3bExternalBin* );
void setDefault( const TQString& path );
const TQPtrList<K3bExternalBin>& bins() const { return m_bins; }
/**
* this scans for the program in the given path,
* adds the found bin object to the list and returnes true.
* if nothing could be found false is returned.
*/
virtual bool scan( const TQString& ) {return false;}//= 0;
/**
* reimplement this if it does not make sense to have the user be able
* to specify additional parameters
*/
virtual bool supportsUserParameters() const { return true; }
private:
TQString m_name;
TQStringList m_userParameters;
TQPtrList<K3bExternalBin> m_bins;
};
class LIBK3B_EXPORT K3bExternalBinManager : public TQObject
{
Q_OBJECT
public:
K3bExternalBinManager( TQObject* parent = 0, const char* name = 0 );
~K3bExternalBinManager();
void search();
/**
* read config and add changes to current map.
* Takes care of setting the config group
*/
bool readConfig( TDEConfig* );
/**
* Takes care of setting the config group
*/
bool saveConfig( TDEConfig* );
bool foundBin( const TQString& name );
const TQString& binPath( const TQString& name );
const K3bExternalBin* binObject( const TQString& name );
const K3bExternalBin* mostRecentBinObject( const TQString& name );
K3bExternalProgram* program( const TQString& ) const;
const TQMap<TQString, K3bExternalProgram*>& programs() const { return m_programs; }
/** always extends the default searchpath */
void setSearchPath( const TQStringList& );
void addSearchPath( const TQString& );
void loadDefaultSearchPath();
const TQStringList& searchPath() const { return m_searchPath; }
void addProgram( K3bExternalProgram* );
void clear();
private:
TQMap<TQString, K3bExternalProgram*> m_programs;
TQStringList m_searchPath;
static TQString m_noPath; // used for binPath() to return const string
TQString m_gatheredOutput;
};
#endif
|