~ubuntu-branches/ubuntu/karmic/kid3/karmic

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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
/**
 * \file scriptinterface.h
 * D-Bus script adaptor.
 *
 * \b Project: Kid3
 * \author Urs Fleisch
 * \date 20 Dec 2007
 *
 * Copyright (C) 2007-2008  Urs Fleisch
 *
 * This file is part of Kid3.
 *
 * Kid3 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.
 *
 * Kid3 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, see <http://www.gnu.org/licenses/>.
 */

#ifndef SCRIPTINTERFACE_H
#define SCRIPTINTERFACE_H

#include "config.h"
#include <qstringlist.h>
/** The base class depends on the Qt version and is a D-Bus adaptor. */
#ifdef HAVE_QTDBUS
#include <QDBusAbstractAdaptor>
typedef QDBusAbstractAdaptor ScriptInterfaceBaseClass;
#else
#include <qobject.h>
typedef QObject ScriptInterfaceBaseClass;
#endif

class Kid3App;

/**
 * Adaptor class for interface net.sourceforge.Kid3
 * Create net.sourceforge.Kid3.xml with:
 * qdbuscpp2xml scriptinterface.h >net.sourceforge.Kid3.xml
 */
class ScriptInterface: public ScriptInterfaceBaseClass
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "net.sourceforge.Kid3")
public:
	/**
	 * Constructor.
	 *
	 * @param parent parent application object
	 */
	ScriptInterface(Kid3App* parent);

	/**
	 * Destructor.
	 */
	virtual ~ScriptInterface();

public slots:
	/**
	 * Open file or directory.
	 *
	 * @param path path to file or directory
	 *
	 * @return true if ok.
	 */
	bool openDirectory(const QString& path);

	/**
	 * Save all modified files.
	 *
	 * @return true if ok,
	 *         else the error message is available using getErrorMessage().
	 */
	bool save();

	/**
	 * Get a detailed error message provided by some methods.
	 * @return detailed error message.
	 */
	QString getErrorMessage() const;

	/**
	 * Revert changes in the selected files.
	 */
	void revert();

	/**
	 * Import tags from a file.
	 *
	 * @param tagMask tag bit (1 for tag 1, 2 for tag 2)
	 * @param path    path of file
	 * @param fmtIdx  index of format
	 *
	 * @return true if ok.
	 */
	bool importFromFile(int tagMask, const QString& path, int fmtIdx);

	/**
	 * Download album cover art into the picture frame of the selected files.
	 *
	 * @param url           URL of picture file or album art resource
	 * @param allFilesInDir true to add the image to all files in the directory
	 */
	void downloadAlbumArt(const QString& url, bool allFilesInDir);

	/**
	 * Export tags to a file.
	 *
	 * @param tagMask tag bit (1 for tag 1, 2 for tag 2)
	 * @param path    path of file
	 * @param fmtIdx  index of format
	 *
	 * @return true if ok.
	 */
	bool exportToFile(int tagMask, const QString& path, int fmtIdx);

	/**
	 * Create a playlist.
	 *
	 * @return true if ok.
	 */
  bool createPlaylist();

	/**
	 * Quit the application.
	 * Omitted Q_NOREPLY because the Qt 3 moc chokes on it. 
	 */
	void quit();

	/**
	 * Select all files.
	 */
	void selectAll();

	/**
	 * Deselect all files.
	 */
	void deselectAll();

	/**
	 * Select the first file.
	 *
	 * @return true if there is a first file.
	 */
	bool firstFile();

	/**
	 * Select the previous file.
	 *
	 * @return true if there is a previous file.
	 */
	bool previousFile();

	/**
	 * Select the next file.
	 *
	 * @return true if there is a next file.
	 */
	bool nextFile();

	/**
	 * Expand or collapse the current file item if it is a directory.
	 * A file list item is a directory if getFileName() returns a name with
	 * '/' as the last character.
	 *
	 * @return true if current file item is a directory.
	 */
	bool expandDirectory();

	/**
	 * Apply the file name format.
	 */
	void applyFilenameFormat();

	/**
	 * Apply the tag format.
	 */
	void applyTagFormat();

	/**
	 * Set the directory name from the tags.
	 *
	 * @param tagMask tag mask (bit 0 for tag 1, bit 1 for tag 2)
	 * @param format  directory name format
	 * @param create  true to create, false to rename
	 *
	 * @return true if ok,
	 *         else the error message is available using getErrorMessage().
	 */
	bool setDirNameFromTag(int tagMask, const QString& format, bool create);

	/**
	 * Set subsequent track numbers in the selected files.
	 *
	 * @param tagMask      tag mask (bit 0 for tag 1, bit 1 for tag 2)
	 * @param firstTrackNr number to use for first file
	 */
	void numberTracks(int tagMask, int firstTrackNr);

	/**
	 * Filter the files.
	 *
	 * @param expression filter expression
	 */
	void filter(const QString& expression);

	/**
	 * Convert ID3v2.3 tags to ID3v2.4.
	 */
	void convertToId3v24();

	/**
	 * Convert ID3v2.4 tags to ID3v2.3.
	 */
	void convertToId3v23();

	/**
	 * Get path of directory.
	 *
	 * @return absolute path of directory.
	 */
	QString getDirectoryName();

	/**
	 * Get name of current file.
	 *
	 * @return absolute file name, ends with "/" if it is a directory.
	 */
	QString getFileName();

	/**
	 * Set name of selected file.
	 * The file will be renamed when the directory is saved.
	 *
	 * @param name file name.
	 */
	void setFileName(const QString& name);

	/**
	 * Set format to use when setting the filename from the tags.
	 *
	 * @param format file name format
	 * @see setFileNameFromTag()
	 */
	void setFileNameFormat(const QString& format);

	/**
	 * Set the file names of the selected files from the tags.
	 *
	 * @param tagMask tag bit (1 for tag 1, 2 for tag 2)
	 * @see setFileNameFormat()
	 */
	void setFileNameFromTag(int tagMask);

	/**
	 * Get value of frame.
	 * To get binary data like a picture, the name of a file to write can be
	 * added after the @a name, e.g. "Picture:/path/to/file".
	 *
	 * @param tagMask tag bit (1 for tag 1, 2 for tag 2)
	 * @param name    name of frame (e.g. "artist")
	 */
	QString getFrame(int tagMask, const QString& name);

	/**
	 * Set value of frame.
	 * For tag 2 (@a tagMask 2), if no frame with @a name exists, a new frame
	 * is added, if @a value is empty, the frame is deleted.
	 * To add binary data like a picture, a file can be added after the
	 * @a name, e.g. "Picture:/path/to/file".
	 *
	 * @param tagMask tag bit (1 for tag 1, 2 for tag 2)
	 * @param name    name of frame (e.g. "artist")
	 * @param value   value of frame
	 */
	bool setFrame(int tagMask, const QString& name, const QString& value);

	/**
	 * Get all frames of a tag.
	 *
	 * @param tagMask tag bit (1 for tag 1, 2 for tag 2)
	 *
	 * @return list with alternating frame names and values.
	 */
	QStringList getTag(int tagMask);

	/**
	 * Get technical information about file.
	 * Properties are Format, Bitrate, Samplerate, Channels, Duration,
	 * Channel Mode, VBR, Tag 1, Tag 2.
	 * Properties which are not available are omitted.
	 *
	 * @return list with alternating property names and values.
	 */
	QStringList getInformation();

	/**
	 * Set tag from file name.
	 *
	 * @param tagMask tag bit (1 for tag 1, 2 for tag 2)
	 */
	void setTagFromFileName(int tagMask);

	/**
	 * Set tag from other tag.
	 *
	 * @param tagMask tag bit (1 for tag 1, 2 for tag 2)
	 */
	void setTagFromOtherTag(int tagMask);

	/**
	 * Copy tag.
	 *
	 * @param tagMask tag bit (1 for tag 1, 2 for tag 2)
	 */
	void copyTag(int tagMask);

	/**
	 * Paste tag.
	 *
	 * @param tagMask tag bit (1 for tag 1, 2 for tag 2)
	 */
	void pasteTag(int tagMask);

	/**
	 * Remove tag.
	 *
	 * @param tagMask tag bit (1 for tag 1, 2 for tag 2)
	 */
	void removeTag(int tagMask);

	/**
	 * Hide or show tag in GUI.
	 *
	 * @param tagMask tag bit (1 for tag 1, 2 for tag 2)
	 * @param hide    true to hide tag
	 */
	void hideTag(int tagMask, bool hide);

	/**
	 * Reparse the configuration.
	 * Automated configuration changes are possible by modifying
	 * the configuration file and then reparsing the configuration.
	 */
	void reparseConfiguration();

private:
	Kid3App* m_app;
	QString m_errorMsg;
};

#endif // SCRIPTINTERFACE_H