1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002-2011 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
10 //
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 //
25
26 // The backtrace functions contain modified code from libYaMa, (c) Venkatesha Murthy G.
27 // You can check libYaMa at http://personal.pavanashree.org/libyama/
28
29 #include <tags/FileTags.h>
30
31 #include <wx/filename.h> // Needed for wxFileName
32 #include <wx/log.h> // Needed for wxLogNull
33
34 #ifdef HAVE_CONFIG_H
35 #include "config.h" // Needed for a number of defines
36 #endif
37
38 #include <wx/stdpaths.h> // Do_not_auto_remove
39 #include <common/StringFunctions.h>
40 #include <common/ClientVersion.h>
41 #include <common/MD5Sum.h>
42 #include <common/Path.h>
43 #include "Logger.h"
44 #include "BitVector.h" // Needed for BitVector
45
46 #include "OtherFunctions.h" // Interface declarations
47
48 #include <map>
49
50 #ifdef __WXBASE__
51 #include <cerrno>
52 #else
53 #include <wx/utils.h>
54 #endif
55
56
57
58
59 // Formats a filesize in bytes to make it suitable for displaying
CastItoXBytes(uint64 count)60 wxString CastItoXBytes( uint64 count )
61 {
62
63 if (count < 1024)
64 return CFormat(wxT("%u ")) % count + wxPLURAL("byte", "bytes", count) ;
65 else if (count < 1048576)
66 return CFormat(wxT("%u ")) % (count >> 10) + _("kB") ;
67 else if (count < 1073741824)
68 return CFormat(wxT("%.2f ")) % ((float)(uint32)count/1048576) + _("MB") ;
69 else if (count < 1099511627776LL)
70 return CFormat(wxT("%.3f ")) % ((float)((uint32)(count/1024))/1048576) + _("GB") ;
71 else
72 return CFormat(wxT("%.3f ")) % ((float)count/1099511627776LL) + _("TB") ;
73 }
74
75
CastItoIShort(uint64 count)76 wxString CastItoIShort(uint64 count)
77 {
78
79 if (count < 1000)
80 return CFormat(wxT("%u")) % count;
81 else if (count < 1000000)
82 return CFormat(wxT("%.0f")) % ((float)(uint32)count/1000) + _("k") ;
83 else if (count < 1000000000)
84 return CFormat(wxT("%.2f")) % ((float)(uint32)count/1000000) + _("M") ;
85 else if (count < 1000000000000LL)
86 return CFormat(wxT("%.2f")) % ((float)((uint32)(count/1000))/1000000) + _("G") ;
87 else
88 return CFormat(wxT("%.2f")) % ((float)count/1000000000000LL) + _("T");
89 }
90
91
CastItoSpeed(uint32 bytes)92 wxString CastItoSpeed(uint32 bytes)
93 {
94 if (bytes < 1024)
95 return CFormat(wxT("%u ")) % bytes + wxPLURAL("byte/sec", "bytes/sec", bytes);
96 else if (bytes < 1048576)
97 return CFormat(wxT("%.2f ")) % (bytes / 1024.0) + _("kB/s");
98 else
99 return CFormat(wxT("%.2f ")) % (bytes / 1048576.0) + _("MB/s");
100 }
101
102
103 // Make a time value in seconds suitable for displaying
CastSecondsToHM(uint32 count,uint16 msecs)104 wxString CastSecondsToHM(uint32 count, uint16 msecs)
105 {
106 if (count < 60) {
107 if (!msecs) {
108 return CFormat(wxT("%02u %s")) % count % _("secs");
109 } else {
110 return CFormat(wxT("%.3f %s"))
111 % (count + ((float)msecs/1000)) % _("secs");
112 }
113 } else if (count < 3600) {
114 return CFormat(wxT("%u:%02u %s"))
115 % (count/60) % (count % 60) % _("mins");
116 } else if (count < 86400) {
117 return CFormat(wxT("%u:%02u %s"))
118 % (count/3600) % ((count % 3600)/60) % _("hours");
119 } else {
120 return CFormat(wxT("%u %s %02u:%02u %s"))
121 % (count/86400) % _("Days")
122 % ((count % 86400)/3600) % ((count % 3600)/60) % _("hours");
123 }
124 }
125
126
127 // Examines a filename and determines the filetype
GetFiletype(const CPath & filename)128 FileType GetFiletype(const CPath& filename)
129 {
130 // FIXME: WTF do we have two such functions in the first place?
131 switch (GetED2KFileTypeID(filename)) {
132 case ED2KFT_AUDIO: return ftAudio;
133 case ED2KFT_VIDEO: return ftVideo;
134 case ED2KFT_IMAGE: return ftPicture;
135 case ED2KFT_PROGRAM: return ftProgram;
136 case ED2KFT_DOCUMENT: return ftText;
137 case ED2KFT_ARCHIVE: return ftArchive;
138 case ED2KFT_CDIMAGE: return ftCDImage;
139 default: return ftAny;
140 }
141 }
142
143
144 // Returns the (translated) description assosiated with a FileType
GetFiletypeDesc(FileType type,bool translated)145 wxString GetFiletypeDesc(FileType type, bool translated)
146 {
147 switch ( type ) {
148 case ftVideo:
149 if (translated) {
150 return _("Videos");
151 } else {
152 return wxT("Videos");
153 }
154 break;
155 case ftAudio:
156 if (translated) {
157 return _("Audio");
158 } else {
159 return wxT("Audio");
160 }
161 break;
162 case ftArchive:
163 if (translated) {
164 return _("Archives");
165 } else {
166 return wxT("Archives");
167 }
168 break;
169 case ftCDImage:
170 if (translated) {
171 return _("CD-Images");
172 } else {
173 return wxT("CD-Images");
174 }
175 break;
176 case ftPicture:
177 if (translated) {
178 return _("Pictures");
179 } else {
180 return wxT("Pictures");
181 }
182 break;
183 case ftText:
184 if (translated) {
185 return _("Texts");
186 } else {
187 return wxT("Texts");
188 }
189 break;
190 case ftProgram:
191 if (translated) {
192 return _("Programs");
193 } else {
194 return wxT("Programs");
195 }
196 break;
197 default:
198 if (translated) {
199 return _("Any");
200 } else {
201 return wxT("Any");
202 }
203 break;
204 }
205 }
206
207 // Returns the Typename, examining the extention of the given filename
208
GetFiletypeByName(const CPath & filename,bool translated)209 wxString GetFiletypeByName(const CPath& filename, bool translated)
210 {
211 return GetFiletypeDesc(GetFiletype(filename), translated);
212 }
213
214
215 // Return the text associated with a rating of a file
GetRateString(uint16 rate)216 wxString GetRateString(uint16 rate)
217 {
218 switch ( rate ) {
219 case 0: return _("Not rated");
220 case 1: return _("Invalid / Corrupt / Fake");
221 case 2: return _("Poor");
222 case 3: return _("Fair");
223 case 4: return _("Good");
224 case 5: return _("Excellent");
225 default: return _("Not rated");
226 }
227 }
228
229
230 /**
231 * Return the size in bytes of the given size-type
232 *
233 * @param type The type (as an int) where: 0 = Byte, 1 = KB, 2 = MB, 3 = GB
234 *
235 * @return The amount of Bytes the provided size-type represents
236 *
237 * Values over GB aren't handled since the amount of Bytes 1TB represents
238 * is over the uint32 capacity
239 */
GetTypeSize(uint8 type)240 uint32 GetTypeSize(uint8 type)
241 {
242 enum {Bytes, KB, MB, GB};
243 int size;
244
245 switch(type) {
246 case Bytes: size = 1; break;
247 case KB: size = 1024; break;
248 case MB: size = 1048576; break;
249 case GB: size = 1073741824; break;
250 default: size = -1; break;
251 }
252 return size;
253 }
254
255
256 // Base16 chars for encode an decode functions
257 static wxChar base16Chars[17] = wxT("0123456789ABCDEF");
258 static wxChar base32Chars[33] = wxT("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");
259 #define BASE16_LOOKUP_MAX 23
260 static wxChar base16Lookup[BASE16_LOOKUP_MAX][2] = {
261 { wxT('0'), 0x0 },
262 { wxT('1'), 0x1 },
263 { wxT('2'), 0x2 },
264 { wxT('3'), 0x3 },
265 { wxT('4'), 0x4 },
266 { wxT('5'), 0x5 },
267 { wxT('6'), 0x6 },
268 { wxT('7'), 0x7 },
269 { wxT('8'), 0x8 },
270 { wxT('9'), 0x9 },
271 { wxT(':'), 0x9 },
272 { wxT(';'), 0x9 },
273 { wxT('<'), 0x9 },
274 { wxT('='), 0x9 },
275 { wxT('>'), 0x9 },
276 { wxT('?'), 0x9 },
277 { wxT('@'), 0x9 },
278 { wxT('A'), 0xA },
279 { wxT('B'), 0xB },
280 { wxT('C'), 0xC },
281 { wxT('D'), 0xD },
282 { wxT('E'), 0xE },
283 { wxT('F'), 0xF }
284 };
285
286
287 // Returns a BASE16 encoded byte array
288 //
289 // [In]
290 // buffer: Pointer to byte array
291 // bufLen: Lenght of buffer array
292 //
293 // [Return]
294 // wxString object with BASE16 encoded byte array
EncodeBase16(const unsigned char * buffer,unsigned int bufLen)295 wxString EncodeBase16(const unsigned char* buffer, unsigned int bufLen)
296 {
297 wxString Base16Buff;
298
299 for(unsigned int i = 0; i < bufLen; ++i) {
300 Base16Buff += base16Chars[buffer[i] >> 4];
301 Base16Buff += base16Chars[buffer[i] & 0xf];
302 }
303
304 return Base16Buff;
305 }
306
307
308 // Decodes a BASE16 string into a byte array
309 //
310 // [In]
311 // base16Buffer: String containing BASE16
312 // base16BufLen: Lenght BASE16 coded string's length
313 //
314 // [Out]
315 // buffer: byte array containing decoded string
DecodeBase16(const wxString & base16Buffer,unsigned int base16BufLen,byte * buffer)316 unsigned int DecodeBase16(const wxString &base16Buffer, unsigned int base16BufLen, byte *buffer)
317 {
318 if (base16BufLen & 1) {
319 return 0;
320 }
321 unsigned int ret = base16BufLen >> 1;
322 memset( buffer, 0, ret);
323 for(unsigned int i = 0; i < base16BufLen; ++i) {
324 int lookup = toupper(base16Buffer[i]) - wxT('0');
325 // Check to make sure that the given word falls inside a valid range
326 byte word = (lookup < 0 || lookup >= BASE16_LOOKUP_MAX) ?
327 0xFF : base16Lookup[lookup][1];
328 unsigned idx = i >> 1;
329 buffer[idx] = (i & 1) ? // odd or even?
330 (buffer[idx] | word) : (word << 4);
331 }
332
333 return ret;
334 }
335
336
337 // Returns a BASE32 encoded byte array
338 //
339 // [In]
340 // buffer: Pointer to byte array
341 // bufLen: Lenght of buffer array
342 //
343 // [Return]
344 // wxString object with BASE32 encoded byte array
EncodeBase32(const unsigned char * buffer,unsigned int bufLen)345 wxString EncodeBase32(const unsigned char* buffer, unsigned int bufLen)
346 {
347 wxString Base32Buff;
348 unsigned int i, index;
349 unsigned char word;
350
351 for(i = 0, index = 0; i < bufLen;) {
352 // Is the current word going to span a byte boundary?
353 if (index > 3) {
354 word = (buffer[i] & (0xFF >> index));
355 index = (index + 5) % 8;
356 word <<= index;
357 if (i < bufLen - 1) {
358 word |= buffer[i + 1] >> (8 - index);
359 }
360 ++i;
361 } else {
362 word = (buffer[i] >> (8 - (index + 5))) & 0x1F;
363 index = (index + 5) % 8;
364 if (index == 0) {
365 ++i;
366 }
367 }
368 Base32Buff += (char) base32Chars[word];
369 }
370
371 return Base32Buff;
372 }
373
374
375 // Decodes a BASE32 string into a byte array
376 //
377 // [In]
378 // base32Buffer: String containing BASE32
379 // base32BufLen: Lenght BASE32 coded string's length
380 //
381 // [Out]
382 // buffer: byte array containing decoded string
383 // [Return]
384 // nDecodeLen:
DecodeBase32(const wxString & base32Buffer,unsigned int base32BufLen,unsigned char * buffer)385 unsigned int DecodeBase32(const wxString &base32Buffer, unsigned int base32BufLen, unsigned char *buffer)
386 {
387 size_t nInputLen = base32Buffer.Length();
388 uint32 nDecodeLen = (nInputLen * 5) / 8;
389 if ((nInputLen * 5) % 8 > 0) {
390 ++nDecodeLen;
391 }
392 if (base32BufLen == 0) {
393 return nDecodeLen;
394 }
395 if (nDecodeLen > base32BufLen) {
396 return 0;
397 }
398
399 uint32 nBits = 0;
400 int nCount = 0;
401 for (size_t i = 0; i < nInputLen; ++i)
402 {
403 if (base32Buffer[i] >= wxT('A') && base32Buffer[i] <= wxT('Z')) {
404 nBits |= ( base32Buffer[i] - wxT('A') );
405 }
406 else if (base32Buffer[i] >= wxT('a') && base32Buffer[i] <= wxT('z')) {
407 nBits |= ( base32Buffer[i] - wxT('a') );
408 }
409 else if (base32Buffer[i] >= wxT('2') && base32Buffer[i] <= wxT('7')) {
410 nBits |= ( base32Buffer[i] - wxT('2') + 26 );
411 } else {
412 return 0;
413 }
414 nCount += 5;
415 if (nCount >= 8)
416 {
417 *buffer++ = (byte)( nBits >> (nCount - 8) );
418 nCount -= 8;
419 }
420 nBits <<= 5;
421 }
422
423 return nDecodeLen;
424 }
425
426
427 /*
428 * base64.c
429 *
430 * Base64 encoding/decoding command line filter
431 *
432 * Copyright (c) 2002-2011 Matthias Gaertner
433 * Adapted to use wxWidgets by
434 * Copyright (c) 2005-2011 Marcelo Roberto Jimenez ( phoenix@amule.org )
435 *
436 */
437 static const wxString to_b64(
438 /* 0000000000111111111122222222223333333333444444444455555555556666 */
439 /* 0123456789012345678901234567890123456789012345678901234567890123 */
440 wxT("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"));
441
442
443 /* Option variables */
444 static bool g_fUseCRLF = false;
445 static unsigned int g_nCharsPerLine = 72;
446 static wxString strHeaderLine;
447
448
EncodeBase64(const char * pbBufferIn,unsigned int bufLen)449 wxString EncodeBase64(const char *pbBufferIn, unsigned int bufLen)
450 {
451 wxString pbBufferOut;
452 wxString strHeader;
453
454 if( !strHeaderLine.IsEmpty() ) {
455 strHeader = wxT("-----BEGIN ") + strHeaderLine + wxT("-----");
456 if( g_fUseCRLF ) {
457 strHeader += wxT("\r");
458 }
459 strHeader += wxT("\n");
460 }
461
462 unsigned long nDiv = ((unsigned long)bufLen) / 3;
463 unsigned long nRem = ((unsigned long)bufLen) % 3;
464 unsigned int NewLineSize = g_fUseCRLF ? 2 : 1;
465
466 // Allocate enough space in the output buffer to speed up things
467 pbBufferOut.Alloc(
468 strHeader.Len() * 2 + // header/footer
469 (bufLen * 4) / 3 + 1 + // Number of codes
470 nDiv * NewLineSize + // Number of new lines
471 (nRem ? 1 : 0) * NewLineSize ); // Last line
472 pbBufferOut = strHeader;
473
474 unsigned long nChars = 0;
475 const unsigned char *pIn = (unsigned char*)pbBufferIn;
476 while( nDiv > 0 ) {
477 pbBufferOut += to_b64[ (pIn[0] >> 2) & 0x3f];
478 pbBufferOut += to_b64[((pIn[0] << 4) & 0x30) | ((pIn[1] >> 4) & 0xf)];
479 pbBufferOut += to_b64[((pIn[1] << 2) & 0x3c) | ((pIn[2] >> 6) & 0x3)];
480 pbBufferOut += to_b64[ pIn[2] & 0x3f];
481 pIn += 3;
482 nDiv--;
483 nChars += 4;
484 if( nChars >= g_nCharsPerLine && g_nCharsPerLine != 0 ) {
485 nChars = 0;
486 if( g_fUseCRLF ) {
487 pbBufferOut += wxT("\r");
488 }
489 pbBufferOut += wxT("\n");
490 }
491 }
492 switch( nRem ) {
493 case 2:
494 pbBufferOut += to_b64[ (pIn[0] >> 2) & 0x3f];
495 pbBufferOut += to_b64[((pIn[0] << 4) & 0x30) | ((pIn[1] >> 4) & 0xf)];
496 pbBufferOut += to_b64[ (pIn[1] << 2) & 0x3c];
497 pbBufferOut += wxT("=");
498 nChars += 4;
499 if( nChars >= g_nCharsPerLine && g_nCharsPerLine != 0 ) {
500 nChars = 0;
501 if( g_fUseCRLF ) {
502 pbBufferOut += wxT("\r");
503 }
504 pbBufferOut += wxT("\n");
505 }
506 break;
507 case 1:
508 pbBufferOut += to_b64[ (pIn[0] >> 2) & 0x3f];
509 pbBufferOut += to_b64[ (pIn[0] << 4) & 0x30];
510 pbBufferOut += wxT("=");
511 pbBufferOut += wxT("=");
512 nChars += 4;
513 if( nChars >= g_nCharsPerLine && g_nCharsPerLine != 0 ) {
514 nChars = 0;
515 if( g_fUseCRLF ) {
516 pbBufferOut += wxT("\r");
517 }
518 pbBufferOut += wxT("\n");
519 }
520 break;
521 }
522
523 if( nRem > 0 ) {
524 if( nChars > 0 ) {
525 if( g_fUseCRLF ) {
526 pbBufferOut += wxT("\r");
527 }
528 pbBufferOut += wxT("\n");
529 }
530 }
531
532 if( !strHeaderLine.IsEmpty() ) {
533 pbBufferOut = wxT("-----END ") + strHeaderLine + wxT("-----");
534 if( g_fUseCRLF ) {
535 pbBufferOut += wxT("\r");
536 }
537 pbBufferOut += wxT("\n");
538 }
539
540 return pbBufferOut;
541 }
542
543
DecodeBase64(const wxString & base64Buffer,unsigned int base64BufLen,unsigned char * buffer)544 unsigned int DecodeBase64(const wxString &base64Buffer, unsigned int base64BufLen, unsigned char *buffer)
545 {
546 int z = 0; // 0 Normal, 1 skip MIME separator (---) to end of line
547 unsigned int nData = 0;
548 unsigned int i = 0;
549
550 if (base64BufLen == 0) {
551 *buffer = 0;
552 nData = 1;
553 }
554
555 for(unsigned int j = 0; j < base64BufLen; ++j) {
556 wxChar c = base64Buffer[j];
557 wxChar bits = wxT('z');
558 if( z > 0 ) {
559 if(c == wxT('\n')) {
560 z = 0;
561 }
562 }
563 else if(c >= wxT('A') && c <= wxT('Z')) {
564 bits = c - wxT('A');
565 }
566 else if(c >= wxT('a') && c <= wxT('z')) {
567 bits = c - wxT('a') + (wxChar)26;
568 }
569 else if(c >= wxT('0') && c <= wxT('9')) {
570 bits = c - wxT('0') + (wxChar)52;
571 }
572 else if(c == wxT('+')) {
573 bits = (wxChar)62;
574 }
575 else if(c == wxT('/')) {
576 bits = (wxChar)63;
577 }
578 else if(c == wxT('-')) {
579 z = 1;
580 }
581 else if(c == wxT('=')) {
582 break;
583 } else {
584 bits = wxT('y');
585 }
586
587 // Skips anything that was not recognized
588 // as a base64 valid char ('y' or 'z')
589 if (bits < (wxChar)64) {
590 switch (nData++) {
591 case 0:
592 buffer[i+0] = (bits << 2) & 0xfc;
593 break;
594 case 1:
595 buffer[i+0] |= (bits >> 4) & 0x03;
596 buffer[i+1] = (bits << 4) & 0xf0;
597 break;
598 case 2:
599 buffer[i+1] |= (bits >> 2) & 0x0f;
600 buffer[i+2] = (bits << 6) & 0xc0;
601 break;
602 case 3:
603 buffer[i+2] |= bits & 0x3f;
604 break;
605 }
606 if (nData == 4) {
607 nData = 0;
608 i += 3;
609 }
610 }
611 }
612 if (nData == 1) {
613 // Syntax error or buffer was empty
614 *buffer = 0;
615 nData = 0;
616 i = 0;
617 } else {
618 buffer[i+nData] = 0;
619 }
620
621 return i + nData;
622 }
623
624
625 // Returns the text assosiated with a category type
GetCatTitle(AllCategoryFilter cat)626 wxString GetCatTitle(AllCategoryFilter cat)
627 {
628 switch (cat) {
629 case acfAll: return _("all");
630 case acfAllOthers: return _("all others");
631 case acfIncomplete: return _("Incomplete");
632 case acfCompleted: return _("Completed");
633 case acfWaiting: return _("Waiting");
634 case acfDownloading: return _("Downloading");
635 case acfErroneous: return _("Erroneous");
636 case acfPaused: return _("Paused");
637 case acfStopped: return _("Stopped");
638 case acfVideo: return _("Video");
639 case acfAudio: return _("Audio");
640 case acfArchive: return _("Archive");
641 case acfCDImages: return _("CD-Images");
642 case acfPictures: return _("Pictures");
643 case acfText: return _("Text");
644 case acfActive: return _("Active");
645 default: return wxT("?");
646 }
647 }
648
649
650 typedef std::map<wxString, EED2KFileTypeClass> SED2KFileTypeMap;
651 typedef SED2KFileTypeMap::value_type SED2KFileTypeMapElement;
652 static SED2KFileTypeMap ED2KFileTypesMap;
653
654
655 class CED2KFileTypes{
656 public:
CED2KFileTypes()657 CED2KFileTypes()
658 {
659 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".669"), ED2KFT_AUDIO)); // 8 channel tracker module
660 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".aac"), ED2KFT_AUDIO)); // Advanced Audio Coding File
661 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ac3"), ED2KFT_AUDIO)); // Audio Codec 3 File
662 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".aif"), ED2KFT_AUDIO)); // Audio Interchange File Format
663 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".aifc"), ED2KFT_AUDIO)); // Audio Interchange File Format
664 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".aiff"), ED2KFT_AUDIO)); // Audio Interchange File Format
665 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".amf"), ED2KFT_AUDIO)); // DSMI Advanced Module Format
666 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".amr"), ED2KFT_AUDIO)); // Adaptive Multi-Rate Codec File
667 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ams"), ED2KFT_AUDIO)); // Extreme Tracker Module
668 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ape"), ED2KFT_AUDIO)); // Monkey's Audio Lossless Audio File
669 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".au"), ED2KFT_AUDIO)); // Audio File (Sun, Unix)
670 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".aud"), ED2KFT_AUDIO)); // General Audio File
671 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".audio"), ED2KFT_AUDIO)); // General Audio File
672 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".cda"), ED2KFT_AUDIO)); // CD Audio Track
673 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".dbm"), ED2KFT_AUDIO));
674 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".dmf"), ED2KFT_AUDIO)); // Delusion Digital Music File
675 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".dsm"), ED2KFT_AUDIO)); // Digital Sound Module
676 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".dts"), ED2KFT_AUDIO)); // DTS Encoded Audio File
677 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".far"), ED2KFT_AUDIO)); // Farandole Composer Module
678 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".flac"), ED2KFT_AUDIO)); // Free Lossless Audio Codec File
679 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".it"), ED2KFT_AUDIO)); // Impulse Tracker Module
680 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".m1a"), ED2KFT_AUDIO)); // MPEG-1 Audio File
681 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".m2a"), ED2KFT_AUDIO)); // MPEG-2 Audio File
682 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".m4a"), ED2KFT_AUDIO)); // MPEG-4 Audio File
683 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mdl"), ED2KFT_AUDIO)); // DigiTrakker Module
684 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".med"), ED2KFT_AUDIO)); // Amiga MED Sound File
685 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mid"), ED2KFT_AUDIO)); // MIDI File
686 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".midi"), ED2KFT_AUDIO)); // MIDI File
687 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mka"), ED2KFT_AUDIO)); // Matroska Audio File
688 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mod"), ED2KFT_AUDIO)); // Amiga Music Module File
689 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mol"), ED2KFT_AUDIO));
690 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mp1"), ED2KFT_AUDIO)); // MPEG-1 Audio File
691 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mp2"), ED2KFT_AUDIO)); // MPEG-2 Audio File
692 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mp3"), ED2KFT_AUDIO)); // MPEG-3 Audio File
693 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mpa"), ED2KFT_AUDIO)); // MPEG Audio File
694 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mpc"), ED2KFT_AUDIO)); // Musepack Compressed Audio File
695 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mpp"), ED2KFT_AUDIO));
696 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mtm"), ED2KFT_AUDIO)); // MultiTracker Module
697 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".nst"), ED2KFT_AUDIO)); // NoiseTracker
698 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ogg"), ED2KFT_AUDIO)); // Ogg Vorbis Compressed Audio File
699 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".okt"), ED2KFT_AUDIO)); // Oktalyzer Module (Amiga)
700 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".psm"), ED2KFT_AUDIO)); // Protracker Studio Module
701 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ptm"), ED2KFT_AUDIO)); // PolyTracker Module
702 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ra"), ED2KFT_AUDIO)); // Real Audio File
703 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".rmi"), ED2KFT_AUDIO)); // MIDI File
704 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".s3m"), ED2KFT_AUDIO)); // Scream Tracker 3 Module
705 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".snd"), ED2KFT_AUDIO)); // Audio File (Sun, Unix)
706 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".stm"), ED2KFT_AUDIO)); // Scream Tracker 2 Module
707 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ult"), ED2KFT_AUDIO)); // UltraTracker
708 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".umx"), ED2KFT_AUDIO)); // Unreal Music Package
709 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".wav"), ED2KFT_AUDIO)); // WAVE Audio File
710 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".wma"), ED2KFT_AUDIO)); // Windows Media Audio File
711 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".wow"), ED2KFT_AUDIO)); // Grave Composer audio tracker
712 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".xm"), ED2KFT_AUDIO)); // Fasttracker 2 Extended Module
713
714 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".3g2"), ED2KFT_VIDEO)); // 3GPP Multimedia File
715 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".3gp"), ED2KFT_VIDEO)); // 3GPP Multimedia File
716 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".3gp2"), ED2KFT_VIDEO)); // 3GPP Multimedia File
717 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".3gpp"), ED2KFT_VIDEO)); // 3GPP Multimedia File
718 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".asf"), ED2KFT_VIDEO)); // Advanced Systems Format (MS)
719 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".amv"), ED2KFT_VIDEO)); // Anime Music Video File
720 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".asf"), ED2KFT_VIDEO)); // Advanced Systems Format File
721 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".avi"), ED2KFT_VIDEO)); // Audio Video Interleave File
722 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".bik"), ED2KFT_VIDEO)); // BINK Video File
723 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".divx"), ED2KFT_VIDEO)); // DivX-Encoded Movie File
724 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".dvr-ms"),ED2KFT_VIDEO)); // Microsoft Digital Video Recording
725 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".flc"), ED2KFT_VIDEO)); // FLIC Video File
726 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".fli"), ED2KFT_VIDEO)); // FLIC Video File
727 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".flic"), ED2KFT_VIDEO)); // FLIC Video File
728 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".flv"), ED2KFT_VIDEO)); // Flash Video File
729 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".hdmov"), ED2KFT_VIDEO)); // High-Definition QuickTime Movie
730 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ifo"), ED2KFT_VIDEO)); // DVD-Video Disc Information File
731 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".m1v"), ED2KFT_VIDEO)); // MPEG-1 Video File
732 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".m2t"), ED2KFT_VIDEO)); // MPEG-2 Video Transport Stream
733 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".m2ts"), ED2KFT_VIDEO)); // MPEG-2 Video Transport Stream
734 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".m2v"), ED2KFT_VIDEO)); // MPEG-2 Video File
735 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".m4b"), ED2KFT_VIDEO)); // MPEG-4 Video File
736 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".m4v"), ED2KFT_VIDEO)); // MPEG-4 Video File
737 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mkv"), ED2KFT_VIDEO)); // Matroska Video File
738 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mov"), ED2KFT_VIDEO)); // QuickTime Movie File
739 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".movie"), ED2KFT_VIDEO)); // QuickTime Movie File
740 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mp1v"), ED2KFT_VIDEO)); // QuickTime Movie File
741 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mp2v"), ED2KFT_VIDEO)); // MPEG-1 Video File
742 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mp4"), ED2KFT_VIDEO)); // MPEG-2 Video File
743 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mpe"), ED2KFT_VIDEO)); // MPEG-4 Video File
744 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mpeg"), ED2KFT_VIDEO)); // MPEG Video File
745 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mpg"), ED2KFT_VIDEO)); // MPEG Video File
746 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mps"), ED2KFT_VIDEO)); // MPEG Video File
747 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mpv"), ED2KFT_VIDEO)); // MPEG Video File
748 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mpv1"), ED2KFT_VIDEO)); // MPEG-1 Video File
749 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mpv2"), ED2KFT_VIDEO)); // MPEG-2 Video File
750 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ogm"), ED2KFT_VIDEO)); // Ogg Media File
751 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ogv"), ED2KFT_VIDEO)); // Ogg Theora Video File
752 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".pva"), ED2KFT_VIDEO)); // MPEG Video File
753 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".qt"), ED2KFT_VIDEO)); // QuickTime Movie
754 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ram"), ED2KFT_VIDEO)); // Real Audio Media
755 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ratdvd"),ED2KFT_VIDEO)); // RatDVD Disk Image
756 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".rm"), ED2KFT_VIDEO)); // Real Media File
757 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".rmm"), ED2KFT_VIDEO)); // Real Media File
758 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".rmvb"), ED2KFT_VIDEO)); // Real Video Variable Bit Rate File
759 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".rv"), ED2KFT_VIDEO)); // Real Video File
760 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".rv9"), ED2KFT_VIDEO));
761 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".smil"), ED2KFT_VIDEO)); // SMIL Presentation File
762 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".smk"), ED2KFT_VIDEO)); // Smacker Compressed Movie File
763 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".swf"), ED2KFT_VIDEO)); // Macromedia Flash Movie
764 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".tp"), ED2KFT_VIDEO)); // Video Transport Stream File
765 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ts"), ED2KFT_VIDEO)); // Video Transport Stream File
766 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".vid"), ED2KFT_VIDEO)); // General Video File
767 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".video"), ED2KFT_VIDEO)); // General Video File
768 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".vivo"), ED2KFT_VIDEO)); // VivoActive Video File
769 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".vob"), ED2KFT_VIDEO)); // DVD Video Object File
770 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".vp6"), ED2KFT_VIDEO)); // TrueMotion VP6 Video File
771 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".webm"), ED2KFT_VIDEO)); // WebM Video File
772 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".wm"), ED2KFT_VIDEO)); // Windows Media Video File
773 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".wmv"), ED2KFT_VIDEO)); // Windows Media Video File
774 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".xvid"), ED2KFT_VIDEO)); // Xvid-Encoded Video File
775
776 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".bmp"), ED2KFT_IMAGE)); // Bitmap Image File
777 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".dcx"), ED2KFT_IMAGE)); // FAXserve Fax Document
778 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".emf"), ED2KFT_IMAGE)); // Enhanced Windows Metafile
779 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".gif"), ED2KFT_IMAGE)); // Graphical Interchange Format File
780 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ico"), ED2KFT_IMAGE)); // Icon File
781 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".jfif"), ED2KFT_IMAGE)); // JPEG File Interchange Format
782 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".jpe"), ED2KFT_IMAGE)); // JPEG Image File
783 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".jpeg"), ED2KFT_IMAGE)); // JPEG Image File
784 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".jpg"), ED2KFT_IMAGE)); // JPEG Image File
785 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".pct"), ED2KFT_IMAGE)); // PICT Picture File
786 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".pcx"), ED2KFT_IMAGE)); // Paintbrush Bitmap Image File
787 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".pic"), ED2KFT_IMAGE)); // PICT Picture File
788 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".pict"), ED2KFT_IMAGE)); // PICT Picture File
789 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".png"), ED2KFT_IMAGE)); // Portable Network Graphic
790 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".psd"), ED2KFT_IMAGE)); // Photoshop Document
791 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".psp"), ED2KFT_IMAGE)); // Paint Shop Pro Image File
792 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".tga"), ED2KFT_IMAGE)); // Targa Graphic
793 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".tif"), ED2KFT_IMAGE)); // Tagged Image File
794 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".tiff"), ED2KFT_IMAGE)); // Tagged Image File
795 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".wbmp"), ED2KFT_IMAGE)); // Wireless Application Protocol Bitmap Format
796 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".webp"), ED2KFT_IMAGE)); // Weppy Photo File
797 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".wmf"), ED2KFT_IMAGE)); // Windows Metafile
798 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".wmp"), ED2KFT_IMAGE)); // Windows Media Photo File
799 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".xif"), ED2KFT_IMAGE)); // ScanSoft Pagis Extended Image Format File
800 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".xpm"), ED2KFT_IMAGE)); // X-Windows Pixmap
801
802 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".7z"), ED2KFT_ARCHIVE)); // 7-Zip Compressed File
803 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ace"), ED2KFT_ARCHIVE)); // WinAce Compressed File
804 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".alz"), ED2KFT_ARCHIVE)); // ALZip Archive
805 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".arc"), ED2KFT_ARCHIVE)); // Compressed File Archive
806 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".arj"), ED2KFT_ARCHIVE)); // ARJ Compressed File Archive
807 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".bz2"), ED2KFT_ARCHIVE)); // Bzip Compressed File
808 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".cab"), ED2KFT_ARCHIVE)); // Cabinet File
809 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".cbr"), ED2KFT_ARCHIVE)); // Comic Book RAR Archive
810 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".cbt"), ED2KFT_ARCHIVE)); // Comic Book Tarball
811 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".cbz"), ED2KFT_ARCHIVE)); // Comic Book ZIP Archive
812 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".gz"), ED2KFT_ARCHIVE)); // Gnu Zipped File
813 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".hqx"), ED2KFT_ARCHIVE)); // BinHex 4.0 Encoded File
814 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".lha"), ED2KFT_ARCHIVE)); // LHARC Compressed Archive
815 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".lzh"), ED2KFT_ARCHIVE)); // LZH Compressed File
816 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".msi"), ED2KFT_ARCHIVE)); // Microsoft Installer File
817 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".pak"), ED2KFT_ARCHIVE)); // PAK (Packed) File
818 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".par"), ED2KFT_ARCHIVE)); // Parchive Index File
819 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".par2"), ED2KFT_ARCHIVE)); // Parchive 2 Index File
820 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".rar"), ED2KFT_ARCHIVE)); // WinRAR Compressed Archive
821 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".sea"), ED2KFT_ARCHIVE)); // Self-Extracting Archive (Mac)
822 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".sit"), ED2KFT_ARCHIVE)); // Stuffit Archive
823 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".sitx"), ED2KFT_ARCHIVE)); // Stuffit X Archive
824 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".tar"), ED2KFT_ARCHIVE)); // Consolidated Unix File Archive
825 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".tbz2"), ED2KFT_ARCHIVE)); // Tar BZip 2 Compressed File
826 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".tgz"), ED2KFT_ARCHIVE)); // Gzipped Tar File
827 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".uc2"), ED2KFT_ARCHIVE)); // UltraCompressor 2 Archive
828 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".xpi"), ED2KFT_ARCHIVE)); // Mozilla Installer Package
829 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".z"), ED2KFT_ARCHIVE)); // Unix Compressed File
830 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".zip"), ED2KFT_ARCHIVE)); // Zipped File
831 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".zoo"), ED2KFT_ARCHIVE)); // Zoo Archive
832
833 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".bat"), ED2KFT_PROGRAM)); // Batch File
834 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".cmd"), ED2KFT_PROGRAM)); // Command File
835 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".com"), ED2KFT_PROGRAM)); // COM File
836 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".exe"), ED2KFT_PROGRAM)); // Executable File
837 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".hta"), ED2KFT_PROGRAM)); // HTML Application
838 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".js"), ED2KFT_PROGRAM)); // Java Script
839 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".jse"), ED2KFT_PROGRAM)); // Encoded Java Script
840 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".msc"), ED2KFT_PROGRAM)); // Microsoft Common Console File
841 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".vbe"), ED2KFT_PROGRAM)); // Encoded Visual Basic Script File
842 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".vbs"), ED2KFT_PROGRAM)); // Visual Basic Script File
843 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".wsf"), ED2KFT_PROGRAM)); // Windows Script File
844 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".wsh"), ED2KFT_PROGRAM)); // Windows Scripting Host File
845
846 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".bin"), ED2KFT_CDIMAGE)); // CD Image
847 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".bwa"), ED2KFT_CDIMAGE)); // BlindWrite Disk Information File
848 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".bwi"), ED2KFT_CDIMAGE)); // BlindWrite CD/DVD Disc Image
849 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".bws"), ED2KFT_CDIMAGE)); // BlindWrite Sub Code File
850 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".bwt"), ED2KFT_CDIMAGE)); // BlindWrite 4 Disk Image
851 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ccd"), ED2KFT_CDIMAGE)); // CloneCD Disk Image
852 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".cue"), ED2KFT_CDIMAGE)); // Cue Sheet File
853 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".dmg"), ED2KFT_CDIMAGE)); // Mac OS X Disk Image
854 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".dmz"), ED2KFT_CDIMAGE));
855 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".img"), ED2KFT_CDIMAGE)); // Disk Image Data File
856 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".iso"), ED2KFT_CDIMAGE)); // Disc Image File
857 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mdf"), ED2KFT_CDIMAGE)); // Media Disc Image File
858 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mds"), ED2KFT_CDIMAGE)); // Media Descriptor File
859 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".nrg"), ED2KFT_CDIMAGE)); // Nero CD/DVD Image File
860 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".sub"), ED2KFT_CDIMAGE)); // Subtitle File
861 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".toast"), ED2KFT_CDIMAGE)); // Toast Disc Image
862
863 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".azw"), ED2KFT_DOCUMENT)); // EBook File
864 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".chm"), ED2KFT_DOCUMENT)); // Compiled HTML Help File
865 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".css"), ED2KFT_DOCUMENT)); // Cascading Style Sheet
866 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".diz"), ED2KFT_DOCUMENT)); // Description in Zip File
867 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".doc"), ED2KFT_DOCUMENT)); // Document File
868 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".dot"), ED2KFT_DOCUMENT)); // Document Template File
869 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".epub"), ED2KFT_DOCUMENT)); // EBook File
870 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".hlp"), ED2KFT_DOCUMENT)); // Help File
871 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".htm"), ED2KFT_DOCUMENT)); // HTML File
872 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".html"), ED2KFT_DOCUMENT)); // HTML File
873 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".mobi"), ED2KFT_DOCUMENT)); // EBook File
874 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".nfo"), ED2KFT_DOCUMENT)); // Warez Information File
875 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".odp"), ED2KFT_DOCUMENT)); // OpenDocument Presentation
876 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ods"), ED2KFT_DOCUMENT)); // OpenDocument Spreadsheet
877 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".odt"), ED2KFT_DOCUMENT)); // OpenDocument File
878 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".otp"), ED2KFT_DOCUMENT)); // OpenDocument Presentation Template
879 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ott"), ED2KFT_DOCUMENT)); // OpenDocument Template File
880 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ots"), ED2KFT_DOCUMENT)); // OpenDocument Spreadsheet Template
881 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".pdf"), ED2KFT_DOCUMENT)); // Portable Document Format File
882 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".pps"), ED2KFT_DOCUMENT)); // PowerPoint Slide Show
883 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ppt"), ED2KFT_DOCUMENT)); // PowerPoint Presentation
884 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".ps"), ED2KFT_DOCUMENT)); // PostScript File
885 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".rtf"), ED2KFT_DOCUMENT)); // Rich Text Format File
886 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".stc"), ED2KFT_DOCUMENT)); // OpenOffice.org 1.0 Spreadsheet Template
887 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".sti"), ED2KFT_DOCUMENT)); // OpenOffice.org 1.0 Presentation Template
888 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".stw"), ED2KFT_DOCUMENT)); // OpenOffice.org 1.0 Document Template File
889 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".sxc"), ED2KFT_DOCUMENT)); // OpenOffice.org 1.0 Spreadsheet
890 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".sxi"), ED2KFT_DOCUMENT)); // OpenOffice.org 1.0 Presentation
891 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".sxw"), ED2KFT_DOCUMENT)); // OpenOffice.org 1.0 Document File
892 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".text"), ED2KFT_DOCUMENT)); // General Text File
893 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".txt"), ED2KFT_DOCUMENT)); // Text File
894 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".wri"), ED2KFT_DOCUMENT)); // Windows Write Document
895 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".xls"), ED2KFT_DOCUMENT)); // Microsoft Excel Spreadsheet
896 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".xlt"), ED2KFT_DOCUMENT)); // Microsoft Excel Template
897 ED2KFileTypesMap.insert(SED2KFileTypeMapElement(wxT(".xml"), ED2KFT_DOCUMENT)); // XML File
898 }
899 };
900
901
902 // get the list initialized *before* any code is accessing it
903 CED2KFileTypes theED2KFileTypes;
904
GetED2KFileTypeID(const CPath & fileName)905 EED2KFileType GetED2KFileTypeID(const CPath& fileName)
906 {
907 const wxString ext = fileName.GetExt().Lower();
908 if (ext.IsEmpty()) {
909 return ED2KFT_ANY;
910 }
911
912 SED2KFileTypeMap::iterator it = ED2KFileTypesMap.find(wxT(".") + ext);
913 if (it != ED2KFileTypesMap.end()) {
914 return it->second.GetType();
915 } else {
916 return ED2KFT_ANY;
917 }
918 }
919
920
921 // Retuns the ed2k file type term which is to be used in server searches
GetED2KFileTypeSearchTerm(EED2KFileType iFileID)922 wxString GetED2KFileTypeSearchTerm(EED2KFileType iFileID)
923 {
924 if (iFileID == ED2KFT_AUDIO) return ED2KFTSTR_AUDIO;
925 if (iFileID == ED2KFT_VIDEO) return ED2KFTSTR_VIDEO;
926 if (iFileID == ED2KFT_IMAGE) return ED2KFTSTR_IMAGE;
927 if (iFileID == ED2KFT_DOCUMENT) return ED2KFTSTR_DOCUMENT;
928 if (iFileID == ED2KFT_PROGRAM) return ED2KFTSTR_PROGRAM;
929 // NOTE: Archives and CD-Images are published with file type "Pro"
930 if (iFileID == ED2KFT_ARCHIVE) return ED2KFTSTR_PROGRAM;
931 if (iFileID == ED2KFT_CDIMAGE) return ED2KFTSTR_PROGRAM;
932
933 return wxEmptyString;
934 }
935
936
937 // Returns a file type which is used eMule internally only, examining the extention of the given filename
GetFileTypeByName(const CPath & fileName)938 wxString GetFileTypeByName(const CPath& fileName)
939 {
940 EED2KFileType iFileType = GetED2KFileTypeID(fileName);
941 switch (iFileType) {
942 case ED2KFT_AUDIO: return ED2KFTSTR_AUDIO;
943 case ED2KFT_VIDEO: return ED2KFTSTR_VIDEO;
944 case ED2KFT_IMAGE: return ED2KFTSTR_IMAGE;
945 case ED2KFT_DOCUMENT: return ED2KFTSTR_DOCUMENT;
946 case ED2KFT_PROGRAM: return ED2KFTSTR_PROGRAM;
947 case ED2KFT_ARCHIVE: return ED2KFTSTR_ARCHIVE;
948 case ED2KFT_CDIMAGE: return ED2KFTSTR_CDIMAGE;
949 default: return wxEmptyString;
950 }
951 }
952
953
954 // Retuns the ed2k file type integer ID which is to be used for publishing+searching
GetED2KFileTypeSearchID(EED2KFileType iFileID)955 EED2KFileType GetED2KFileTypeSearchID(EED2KFileType iFileID)
956 {
957 switch (iFileID) {
958 case ED2KFT_AUDIO: return ED2KFT_AUDIO;
959 case ED2KFT_VIDEO: return ED2KFT_VIDEO;
960 case ED2KFT_IMAGE: return ED2KFT_IMAGE;
961 case ED2KFT_DOCUMENT: return ED2KFT_DOCUMENT;
962 case ED2KFT_PROGRAM: return ED2KFT_PROGRAM;
963 // NOTE: Archives and CD-Images are published+searched with file type "Pro"
964 // NOTE: If this gets changed, the function 'GetED2KFileTypeSearchTerm' also needs to get updated!
965 case ED2KFT_ARCHIVE: return ED2KFT_PROGRAM;
966 case ED2KFT_CDIMAGE: return ED2KFT_PROGRAM;
967 default: return ED2KFT_ANY;
968 }
969 }
970
971
972 /**
973 * Dumps a buffer to a wxString
974 */
DumpMemToStr(const void * buff,int n,const wxString & msg,bool ok)975 wxString DumpMemToStr(const void *buff, int n, const wxString& msg, bool ok)
976 {
977 const unsigned char *p = (const unsigned char *)buff;
978 int lines = (n + 15)/ 16;
979
980 wxString result;
981 // Allocate aproximetly what is needed
982 result.Alloc( ( lines + 1 ) * 80 );
983 if ( !msg.IsEmpty() ) {
984 result += msg + wxT(" - ok=") + ( ok ? wxT("true, ") : wxT("false, ") );
985 }
986
987 result += CFormat(wxT("%d bytes\n")) % n;
988 for ( int i = 0; i < lines; ++i) {
989 // Show address
990 result += CFormat(wxT("%08x ")) % (i * 16);
991
992 // Show two columns of hex-values
993 for ( int j = 0; j < 2; ++j) {
994 for ( int k = 0; k < 8; ++k) {
995 int pos = 16 * i + 8 * j + k;
996
997 if ( pos < n ) {
998 result += CFormat(wxT("%02x ")) % p[pos];
999 } else {
1000 result += wxT(" ");
1001 }
1002 }
1003 result += wxT(" ");
1004 }
1005 result += wxT("|");
1006 // Show a column of ascii-values
1007 for ( int k = 0; k < 16; ++k) {
1008 int pos = 16 * i + k;
1009
1010 if ( pos < n ) {
1011 if ( isspace( p[pos] ) ) {
1012 result += wxT(" ");
1013 } else if ( !isgraph( p[pos] ) ) {
1014 result += wxT(".");
1015 } else {
1016 result += (wxChar)p[pos];
1017 }
1018 } else {
1019 result += wxT(" ");
1020 }
1021 }
1022 result += wxT("|\n");
1023 }
1024 result.Shrink();
1025
1026 return result;
1027 }
1028
1029
1030 /**
1031 * Dumps a buffer to stdout
1032 */
DumpMem(const void * buff,int n,const wxString & msg,bool ok)1033 void DumpMem(const void *buff, int n, const wxString& msg, bool ok)
1034 {
1035 printf("%s\n", (const char*)unicode2char(DumpMemToStr( buff, n, msg, ok )) );
1036 }
1037
1038
1039 //
1040 // Dump mem in dword format
DumpMem_DW(const uint32 * ptr,int count)1041 void DumpMem_DW(const uint32 *ptr, int count)
1042 {
1043 for(int i = 0; i < count; i++) {
1044 printf("%08x ", ptr[i]);
1045 if ( (i % 4) == 3) printf("\n");
1046 }
1047 printf("\n");
1048 }
1049
1050
GetConfigDir(const wxString & configFileBase)1051 wxString GetConfigDir(const wxString &configFileBase)
1052 {
1053 wxString configPath;
1054
1055 // "Portable aMule" - Use aMule from an external USB drive
1056 // Check for ./config/amule.conf (or whatever gets passed as configFile)
1057 // and use this configuration if found
1058 const wxString configDir = JoinPaths(wxFileName::GetCwd(), wxT("config"));
1059 const wxString configFile = JoinPaths(configDir, configFileBase);
1060
1061 if (CPath::DirExists(configDir) && CPath::FileExists(configFile)) {
1062 AddLogLineN(CFormat(_("Using config dir: %s")) % configDir);
1063
1064 configPath = configDir;
1065 } else {
1066 configPath = wxStandardPaths::Get().GetUserDataDir();
1067 }
1068
1069 configPath += wxFileName::GetPathSeparator();
1070
1071 return configPath;
1072 }
1073
1074
1075 /*************************** Locale specific stuff ***************************/
1076
1077 #ifndef __WINDOWS__
1078 # define SETWINLANG(LANG, SUBLANG)
1079 #else
1080 # define SETWINLANG(LANG, SUBLANG) \
1081 info.WinLang = LANG; \
1082 info.WinSublang = SUBLANG;
1083 #endif
1084
1085 #define CUSTOMLANGUAGE(wxid, iso, winlang, winsublang, dir, desc) \
1086 info.Language = wxid; \
1087 info.CanonicalName = wxT(iso); \
1088 info.LayoutDirection = dir; \
1089 info.Description = wxT(desc); \
1090 SETWINLANG(winlang, winsublang) \
1091 wxLocale::AddLanguage(info);
1092
InitCustomLanguages()1093 void InitCustomLanguages()
1094 {
1095 wxLanguageInfo info;
1096
1097 #if !wxCHECK_VERSION(2, 9, 0)
1098 CUSTOMLANGUAGE(wxLANGUAGE_ASTURIAN, "ast", 0, 0, wxLayout_LeftToRight, "Asturian");
1099 #endif
1100 }
1101
1102
InitLocale(wxLocale & locale,int language)1103 void InitLocale(wxLocale& locale, int language)
1104 {
1105 locale.Init(language, wxLOCALE_LOAD_DEFAULT);
1106
1107 #if defined(__WXMAC__) || defined(__WINDOWS__)
1108 locale.AddCatalogLookupPathPrefix(JoinPaths(wxStandardPaths::Get().GetDataDir(), wxT("locale")));
1109 #else
1110 #if (wxCHECK_VERSION(2,9,5) && !wxCHECK_VERSION(3,0,3)) || (wxCHECK_VERSION(3,1,0) && !wxCHECK_VERSION(3,1,1))
1111 // Add correct place to look for catalog files if we're using a wxWidgets version where it's broken
1112 // See also http://trac.wxwidgets.org/ticket/17740
1113 locale.AddCatalogLookupPathPrefix(JoinPaths(JoinPaths(wxStandardPaths::Get().GetInstallPrefix(), wxT("share")), wxT("locale")));
1114 #endif /* wxCHECK_VERSION(2,9,5)... */
1115 #endif /* (!)(defined(__WXMAC__) || defined(__WINDOWS__)) */
1116
1117 locale.AddCatalog(wxT(PACKAGE));
1118 }
1119
1120
StrLang2wx(const wxString & language)1121 int StrLang2wx(const wxString& language)
1122 {
1123 // get rid of possible encoding and modifier
1124 wxString lang(language.BeforeFirst('.').BeforeFirst('@'));
1125
1126 if (!lang.IsEmpty()) {
1127 const wxLanguageInfo *lng = wxLocale::FindLanguageInfo(lang);
1128 if (lng) {
1129 int langID = lng->Language;
1130 // Traditional Chinese: original Chinese, used in Taiwan, Hong Kong and Macau.
1131 // Simplified Chinese: simplified Chinese characters used in Mainland China since 1950s, and in some other places such as Singapore and Malaysia.
1132 //
1133 // Chinese (Traditional) contains zh_TW, zh_HK and zh_MO (but there are differences in some words).
1134 // Because of most Traditional Chinese user are in Taiwan, zh_TW becomes the representation of Traditional Chinese.
1135 // Chinese (Simplified) contains zh_CN, zh_SG and zh_MY. In the same reason, zh_CN becomes the representation of Simplified Chinese.
1136 // (see http://forum.amule.org/index.php?topic=13208.msg98043#msg98043 )
1137 //
1138 // wx maps "Traditional Chinese" to "Chinese" however. This must me corrected:
1139 if (langID == wxLANGUAGE_CHINESE) {
1140 langID = wxLANGUAGE_CHINESE_TRADITIONAL;
1141 }
1142 return langID;
1143 } else {
1144 return wxLANGUAGE_DEFAULT;
1145 }
1146 } else {
1147 return wxLANGUAGE_DEFAULT;
1148 }
1149 }
1150
1151
wxLang2Str(const int lang)1152 wxString wxLang2Str(const int lang)
1153 {
1154 if (lang != wxLANGUAGE_DEFAULT) {
1155 const wxLanguageInfo *lng = wxLocale::GetLanguageInfo(lang);
1156 if (lng) {
1157 return lng->CanonicalName;
1158 } else {
1159 return wxEmptyString;
1160 }
1161 } else {
1162 return wxEmptyString;
1163 }
1164 }
1165
1166 /*****************************************************************************/
1167
GetPassword(bool allowEmptyPassword)1168 CMD4Hash GetPassword(bool allowEmptyPassword)
1169 {
1170 wxString pass_plain;
1171 CMD4Hash password;
1172 #ifndef __WINDOWS__
1173 pass_plain = char2unicode(getpass("Enter password for mule connection: "));
1174 #else
1175 //#warning This way, pass enter is not hidden on windows. Bad thing.
1176 char temp_str[512];
1177 // Though fflush() on an input stream is undefined behaviour by the standard,
1178 // the MSVCRT version does seem to clear the input buffers.
1179 // cppcheck-suppress fflushOnInputStream
1180 fflush(stdin);
1181 printf("Enter password for mule connection: \n");
1182 fflush(stdout);
1183 fgets(temp_str, 512, stdin);
1184 temp_str[strlen(temp_str)-1] = '\0';
1185 pass_plain = char2unicode(temp_str);
1186 #endif
1187 wxCHECK2(password.Decode(MD5Sum(pass_plain).GetHash()), /* Do nothing. */ );
1188 if (!allowEmptyPassword) {
1189 // MD5 hash for an empty string, according to rfc1321.
1190 if (password.Encode() == wxT("D41D8CD98F00B204E9800998ECF8427E")) {
1191 printf("No empty password allowed.\n");
1192 return GetPassword(false);
1193 }
1194 }
1195
1196 return password;
1197 }
1198
1199
1200 const uint8 BitVector::s_posMask[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
1201 const uint8 BitVector::s_negMask[] = {0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xBF, 0x7F};
1202
1203 // File_checked_for_headers
1204