-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.h
320 lines (237 loc) · 7.16 KB
/
types.h
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
/*
* Copyright (C) 2008 Ali Shah <[email protected]>
*
* This file is part of the Qlix project on http://berlios.de
*
* This file may be used under the terms of the GNU General Public
* License version 2.0 as published by the Free Software Foundation
* and appearing in the file COPYING included in the packaging of
* this file.
*
* 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 version 2.0 for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* TODO Move CommandLineOpts to singleton pattern
*/
#ifndef __TYPES__
#define __TYPES__
#include <vector>
#include <string>
#include <libmtp.h>
using namespace std;
typedef vector<LIBMTP_error_t> MTPErrorVector;
typedef unsigned int count_t;
typedef unsigned int index_t;
typedef unsigned char ubyte;
enum MtpObjectType
{
MtpInvalid,
MtpTrack,
MtpShadowTrack,
MtpFile,
MtpFolder,
MtpAlbum,
MtpPlaylist
};
enum QlixProgressType
{
FreeSpaceUsage,
TransferAmount
};
struct CommandLineOptions
{
const bool AutoFixPlaylists;
const bool AutoFixAlbums;
const bool SimulateTransfers;
const bool DebugOutput;
CommandLineOptions(bool in_AutoFixPlaylists = false, bool in_AutoFixAlbums = false,
bool in_SimulateTransfers = false, bool in_DebugOutput = false) :
AutoFixPlaylists(in_AutoFixPlaylists),
AutoFixAlbums(in_AutoFixAlbums),
SimulateTransfers(in_SimulateTransfers),
DebugOutput(in_DebugOutput)
{ }
CommandLineOptions(const CommandLineOptions& in_opts) :
AutoFixPlaylists(in_opts.AutoFixPlaylists),
AutoFixAlbums(in_opts.AutoFixAlbums),
SimulateTransfers(in_opts.SimulateTransfers),
DebugOutput(in_opts.DebugOutput)
{ }
CommandLineOptions& operator = (const CommandLineOptions& in_opts)
{
(const_cast<bool&> (this->AutoFixPlaylists)) = in_opts.AutoFixPlaylists;
(const_cast<bool&> (this->AutoFixAlbums)) = in_opts.AutoFixAlbums;
(const_cast<bool&> (this->SimulateTransfers)) = in_opts.SimulateTransfers;
(const_cast<bool&> (this->DebugOutput)) = in_opts.DebugOutput;
return *this;
}
};
namespace MTP
{
//TODO this isn't very usefull if you have foreign characters
static LIBMTP_filetype_t StringToType(const std::string& in_type)
{
if (in_type == "UNKNOWN")
return LIBMTP_FILETYPE_UNKNOWN;
if (in_type == "WAV") return LIBMTP_FILETYPE_WAV;
if (in_type == "MP3")
return LIBMTP_FILETYPE_MP3;
if (in_type == "WMA")
return LIBMTP_FILETYPE_WMA;
if (in_type == "OGG")
return LIBMTP_FILETYPE_OGG;
if (in_type == "AUD")
return LIBMTP_FILETYPE_AUDIBLE;
if (in_type == "MP4")
return LIBMTP_FILETYPE_MP4;
if (in_type == "WMV")
return LIBMTP_FILETYPE_WMV;
if (in_type == "AVI" || in_type == "SVI")
return LIBMTP_FILETYPE_AVI;
if (in_type == "MPEG")
return LIBMTP_FILETYPE_MPEG;
if (in_type == "MPG")
return LIBMTP_FILETYPE_MPEG;
if (in_type == "ASF")
return LIBMTP_FILETYPE_ASF;
if (in_type == "QT")
return LIBMTP_FILETYPE_QT;
if (in_type == "JPEG" || in_type == "JPG")
return LIBMTP_FILETYPE_JPEG;
if (in_type == "JFIF")
return LIBMTP_FILETYPE_JFIF;
if (in_type == "BMP")
return LIBMTP_FILETYPE_BMP;
if (in_type == "GIF")
return LIBMTP_FILETYPE_GIF;
if (in_type == "PICT")
return LIBMTP_FILETYPE_PICT;
if (in_type == "PNG")
return LIBMTP_FILETYPE_PNG;
if (in_type == "EXE")
return LIBMTP_FILETYPE_WINEXEC;
if (in_type == "TXT")
return LIBMTP_FILETYPE_TEXT;
if (in_type == "HTML" || in_type == "HTM")
return LIBMTP_FILETYPE_HTML;
if (in_type == "AAC")
return LIBMTP_FILETYPE_AAC;
if (in_type == "FLAC")
return LIBMTP_FILETYPE_FLAC;
if (in_type == "MP2")
return LIBMTP_FILETYPE_MP2;
if (in_type == "M4A")
return LIBMTP_FILETYPE_M4A;
if (in_type == "XML")
return LIBMTP_FILETYPE_XML;
if (in_type == "XLS")
return LIBMTP_FILETYPE_XLS;
if (in_type == "PPT")
return LIBMTP_FILETYPE_PPT;
if (in_type == "MHT")
return LIBMTP_FILETYPE_MHT;
if (in_type == "JP2")
return LIBMTP_FILETYPE_JP2;
if (in_type == "JPX")
return LIBMTP_FILETYPE_JPX;
return LIBMTP_FILETYPE_UNKNOWN; //default
}
static std::string TypeToString (LIBMTP_filetype_t in_type)
{
switch (in_type)
{
case LIBMTP_FILETYPE_WAV:
return "Wav";
case LIBMTP_FILETYPE_MP3:
return "Mp3";
case LIBMTP_FILETYPE_WMA:
return "Wma";
case LIBMTP_FILETYPE_OGG:
return "Ogg";
case LIBMTP_FILETYPE_AUDIBLE:
return "Aud";
case LIBMTP_FILETYPE_MP4:
return "Mp4";
case LIBMTP_FILETYPE_UNDEF_AUDIO:
return "Undef Audio";
case LIBMTP_FILETYPE_WMV:
return "Wmv";
case LIBMTP_FILETYPE_AVI:
return "Avi";
case LIBMTP_FILETYPE_MPEG:
return "Mpeg";
case LIBMTP_FILETYPE_ASF:
return "Asf";
case LIBMTP_FILETYPE_QT:
return "Qt";
case LIBMTP_FILETYPE_UNDEF_VIDEO:
return "Undef Video";
case LIBMTP_FILETYPE_JPEG:
return "Jpeg";
case LIBMTP_FILETYPE_JFIF:
return "Jfif";
case LIBMTP_FILETYPE_TIFF:
return "Tiff";
case LIBMTP_FILETYPE_BMP:
return "Bmp";
case LIBMTP_FILETYPE_GIF:
return "Gif";
case LIBMTP_FILETYPE_PICT:
return "Pict";
case LIBMTP_FILETYPE_PNG:
return "Png";
case LIBMTP_FILETYPE_VCALENDAR1:
return "VCalendar1";
case LIBMTP_FILETYPE_VCALENDAR2:
return "VCalendar2";
case LIBMTP_FILETYPE_VCARD2:
return "VCard2";
case LIBMTP_FILETYPE_VCARD3:
return "VCard3";
case LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT:
return "Windows Image";
case LIBMTP_FILETYPE_WINEXEC:
return "Exe";
case LIBMTP_FILETYPE_TEXT:
return "Txt";
case LIBMTP_FILETYPE_HTML:
return "Html";
case LIBMTP_FILETYPE_FIRMWARE:
return "IMG- Firmware";
case LIBMTP_FILETYPE_AAC:
return "Aac";
case LIBMTP_FILETYPE_MEDIACARD:
return "MediaCard";
case LIBMTP_FILETYPE_FLAC:
return "Flac";
case LIBMTP_FILETYPE_MP2:
return "Mp2";
case LIBMTP_FILETYPE_M4A:
return "M4a";
case LIBMTP_FILETYPE_DOC:
return "Doc";
case LIBMTP_FILETYPE_XML:
return "Xml";
case LIBMTP_FILETYPE_XLS:
return "Xls";
case LIBMTP_FILETYPE_PPT:
return "Ppt";
case LIBMTP_FILETYPE_MHT:
return "Mht";
case LIBMTP_FILETYPE_JP2:
return "Jp2";
case LIBMTP_FILETYPE_JPX:
return "Jpx";
case LIBMTP_FILETYPE_UNKNOWN:
return "Unknown";
default:
return "Unknown";
}
}
}
#endif