2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002-2008 Merkur ( devs@emule-project.net / http://www.emule-project.net )
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
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.
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.
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
26 // The backtrace functions contain modified code from libYaMa, (c) Venkatesha Murthy G.
27 // You can check libYaMa at http://personal.pavanashree.org/libyama/
29 #include <tags/FileTags.h>
31 #include <wx/filename.h> // Needed for wxFileName
32 #include <wx/log.h> // Needed for wxLogNull
35 #include "config.h" // Needed for a number of defines
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>
46 #include "OtherFunctions.h" // Interface declarations
57 wxString
GetMuleVersion()
59 wxString
ver(wxT(VERSION
));
61 ver
+= wxT(" using ");
64 // Figure out the wx build-type
71 #elif defined(__WXMAC__)
73 #elif defined(__WXMSW__)
75 #elif defined(__WXCOCOA__)
76 ver
+= wxT("wxCocoa");
79 ver
+= wxString::Format(wxT(" v%d.%d.%d"), wxMAJOR_VERSION
, wxMINOR_VERSION
, wxRELEASE_NUMBER
);
81 #if defined(__WXDEBUG__)
82 ver
+= wxT(" (Debugging)");
86 ver
+= wxString::Format( wxT(" (Snapshot: %s)"), wxT(SVNDATE
));
93 // Formats a filesize in bytes to make it suitable for displaying
94 wxString
CastItoXBytes( uint64 count
)
98 return wxString::Format( wxT("%u "), (unsigned)count
) + wxPLURAL("byte", "bytes", count
) ;
99 else if (count
< 1048576)
100 return wxString::Format( wxT("%u "), (unsigned)count
>> 10) + _("kB") ;
101 else if (count
< 1073741824)
102 return wxString::Format( wxT("%.2f "), (float)(uint32
)count
/1048576) + _("MB") ;
103 else if (count
< 1099511627776LL)
104 return wxString::Format( wxT("%.3f "), (float)((uint32
)(count
/1024))/1048576) + _("GB") ;
106 return wxString::Format( wxT("%.3f "), (float)count
/1099511627776LL) + _("TB") ;
110 wxString
CastItoIShort(uint64 count
)
114 return wxString::Format(wxT("%u"), (uint32
)count
);
115 else if (count
< 1000000)
116 return wxString::Format(wxT("%.0f"),(float)(uint32
)count
/1000) + _("k") ;
117 else if (count
< 1000000000)
118 return wxString::Format(wxT("%.2f"),(float)(uint32
)count
/1000000) + _("M") ;
119 else if (count
< 1000000000000LL)
120 return wxString::Format(wxT("%.2f"),(float)((uint32
)(count
/1000))/1000000) + _("G") ;
122 return wxString::Format(wxT("%.2f"),(float)count
/1000000000000LL) + _("T");
126 wxString
CastItoSpeed(uint32 bytes
)
129 return wxString::Format(wxT("%u "), bytes
) + wxPLURAL("byte/sec", "bytes/sec", bytes
);
130 else if (bytes
< 1048576)
131 return wxString::Format(wxT("%.2f "), bytes
/ 1024.0) + _("kB/s");
133 return wxString::Format(wxT("%.2f "), bytes
/ 1048576.0) + _("MB/s");
137 // Make a time value in seconds suitable for displaying
138 wxString
CastSecondsToHM(uint32 count
, uint16 msecs
)
142 return wxString::Format(
143 wxT("%02u %s"), count
, _("secs"));
145 return wxString::Format(
147 (count
+ ((float)msecs
/1000)), _("secs"));
149 } else if (count
< 3600) {
150 return wxString::Format(
155 } else if (count
< 86400) {
156 return wxString::Format(
162 return wxString::Format(
163 wxT("%u %s %02u:%02u %s"),
166 (count
% 86400)/3600,
173 // Examines a filename and determines the filetype
174 FileType
GetFiletype(const CPath
& filename
)
176 // FIXME: WTF do we have two such functions in the first place?
177 switch (GetED2KFileTypeID(filename
)) {
178 case ED2KFT_AUDIO
: return ftAudio
;
179 case ED2KFT_VIDEO
: return ftVideo
;
180 case ED2KFT_IMAGE
: return ftPicture
;
181 case ED2KFT_PROGRAM
: return ftProgram
;
182 case ED2KFT_DOCUMENT
: return ftText
;
183 case ED2KFT_ARCHIVE
: return ftArchive
;
184 case ED2KFT_CDIMAGE
: return ftCDImage
;
185 default: return ftAny
;
190 // Returns the (translated) description assosiated with a FileType
191 wxString
GetFiletypeDesc(FileType type
, bool translated
)
198 return wxT("Videos");
210 return _("Archives");
212 return wxT("Archives");
217 return _("CD-Images");
219 return wxT("CD-Images");
224 return _("Pictures");
226 return wxT("Pictures");
238 return _("Programs");
240 return wxT("Programs");
253 // Returns the Typename, examining the extention of the given filename
255 wxString
GetFiletypeByName(const CPath
& filename
, bool translated
)
257 return GetFiletypeDesc(GetFiletype(filename
), translated
);
261 // Return the text associated with a rating of a file
262 wxString
GetRateString(uint16 rate
)
265 case 0: return _("Not rated");
266 case 1: return _("Invalid / Corrupt / Fake");
267 case 2: return _("Poor");
268 case 3: return _("Fair");
269 case 4: return _("Good");
270 case 5: return _("Excellent");
271 default: return _("Not rated");
277 * Return the size in bytes of the given size-type
279 * @param type The type (as an int) where: 0 = Byte, 1 = KB, 2 = MB, 3 = GB
281 * @return The amount of Bytes the provided size-type represents
283 * Values over GB aren't handled since the amount of Bytes 1TB represents
284 * is over the uint32 capacity
286 uint32
GetTypeSize(uint8 type
)
288 enum {Bytes
, KB
, MB
, GB
};
292 case Bytes
: size
= 1; break;
293 case KB
: size
= 1024; break;
294 case MB
: size
= 1048576; break;
295 case GB
: size
= 1073741824; break;
296 default: size
= -1; break;
302 // Base16 chars for encode an decode functions
303 static wxChar base16Chars
[17] = wxT("0123456789ABCDEF");
304 static wxChar base32Chars
[33] = wxT("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");
305 #define BASE16_LOOKUP_MAX 23
306 static wxChar base16Lookup
[BASE16_LOOKUP_MAX
][2] = {
333 // Returns a BASE16 encoded byte array
336 // buffer: Pointer to byte array
337 // bufLen: Lenght of buffer array
340 // wxString object with BASE16 encoded byte array
341 wxString
EncodeBase16(const unsigned char* buffer
, unsigned int bufLen
)
345 for(unsigned int i
= 0; i
< bufLen
; ++i
) {
346 Base16Buff
+= base16Chars
[buffer
[i
] >> 4];
347 Base16Buff
+= base16Chars
[buffer
[i
] & 0xf];
354 // Decodes a BASE16 string into a byte array
357 // base16Buffer: String containing BASE16
358 // base16BufLen: Lenght BASE16 coded string's length
361 // buffer: byte array containing decoded string
362 unsigned int DecodeBase16(const wxString
&base16Buffer
, unsigned int base16BufLen
, byte
*buffer
)
364 if (base16BufLen
& 1) {
367 unsigned int ret
= base16BufLen
>> 1;
368 memset( buffer
, 0, ret
);
369 for(unsigned int i
= 0; i
< base16BufLen
; ++i
) {
370 int lookup
= toupper(base16Buffer
[i
]) - wxT('0');
371 // Check to make sure that the given word falls inside a valid range
372 byte word
= (lookup
< 0 || lookup
>= BASE16_LOOKUP_MAX
) ?
373 0xFF : base16Lookup
[lookup
][1];
374 unsigned idx
= i
>> 1;
375 buffer
[idx
] = (i
& 1) ? // odd or even?
376 (buffer
[idx
] | word
) : (word
<< 4);
383 // Returns a BASE32 encoded byte array
386 // buffer: Pointer to byte array
387 // bufLen: Lenght of buffer array
390 // wxString object with BASE32 encoded byte array
391 wxString
EncodeBase32(const unsigned char* buffer
, unsigned int bufLen
)
394 unsigned int i
, index
;
397 for(i
= 0, index
= 0; i
< bufLen
;) {
398 // Is the current word going to span a byte boundary?
400 word
= (buffer
[i
] & (0xFF >> index
));
401 index
= (index
+ 5) % 8;
403 if (i
< bufLen
- 1) {
404 word
|= buffer
[i
+ 1] >> (8 - index
);
408 word
= (buffer
[i
] >> (8 - (index
+ 5))) & 0x1F;
409 index
= (index
+ 5) % 8;
414 Base32Buff
+= (char) base32Chars
[word
];
421 // Decodes a BASE32 string into a byte array
424 // base32Buffer: String containing BASE32
425 // base32BufLen: Lenght BASE32 coded string's length
428 // buffer: byte array containing decoded string
431 unsigned int DecodeBase32(const wxString
&base32Buffer
, unsigned int base32BufLen
, unsigned char *buffer
)
433 size_t nInputLen
= base32Buffer
.Length();
434 uint32 nDecodeLen
= (nInputLen
* 5) / 8;
435 if ((nInputLen
* 5) % 8 > 0) {
438 if (base32BufLen
== 0) {
441 if (nDecodeLen
> base32BufLen
) {
447 for (size_t i
= 0; i
< nInputLen
; ++i
)
449 if (base32Buffer
[i
] >= wxT('A') && base32Buffer
[i
] <= wxT('Z')) {
450 nBits
|= ( base32Buffer
[i
] - wxT('A') );
452 else if (base32Buffer
[i
] >= wxT('a') && base32Buffer
[i
] <= wxT('z')) {
453 nBits
|= ( base32Buffer
[i
] - wxT('a') );
455 else if (base32Buffer
[i
] >= wxT('2') && base32Buffer
[i
] <= wxT('7')) {
456 nBits
|= ( base32Buffer
[i
] - wxT('2') + 26 );
463 *buffer
++ = (byte
)( nBits
>> (nCount
- 8) );
476 * Base64 encoding/decoding command line filter
478 * Copyright (c) 2002-2008 Matthias Gaertner
479 * Adapted to use wxWidgets by
480 * Copyright (c) 2005-2008 Marcelo Roberto Jimenez ( phoenix@amule.org )
483 static const wxString
to_b64(
484 /* 0000000000111111111122222222223333333333444444444455555555556666 */
485 /* 0123456789012345678901234567890123456789012345678901234567890123 */
486 wxT("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"));
489 /* Option variables */
490 static bool g_fUseCRLF
= false;
491 static unsigned int g_nCharsPerLine
= 72;
492 static wxString strHeaderLine
;
495 wxString
EncodeBase64(const char *pbBufferIn
, unsigned int bufLen
)
497 wxString pbBufferOut
;
500 if( !strHeaderLine
.IsEmpty() ) {
501 strHeader
= wxT("-----BEGIN ") + strHeaderLine
+ wxT("-----");
503 strHeader
+= wxT("\r");
505 strHeader
+= wxT("\n");
508 unsigned long nDiv
= ((unsigned long)bufLen
) / 3;
509 unsigned long nRem
= ((unsigned long)bufLen
) % 3;
510 unsigned int NewLineSize
= g_fUseCRLF
? 2 : 1;
512 // Allocate enough space in the output buffer to speed up things
514 strHeader
.Len() * 2 + // header/footer
515 (bufLen
* 4) / 3 + 1 + // Number of codes
516 nDiv
* NewLineSize
+ // Number of new lines
517 (nRem
? 1 : 0) * NewLineSize
); // Last line
518 pbBufferOut
= strHeader
;
520 unsigned long nChars
= 0;
521 const unsigned char *pIn
= (unsigned char*)pbBufferIn
;
523 pbBufferOut
+= to_b64
[ (pIn
[0] >> 2) & 0x3f];
524 pbBufferOut
+= to_b64
[((pIn
[0] << 4) & 0x30) | ((pIn
[1] >> 4) & 0xf)];
525 pbBufferOut
+= to_b64
[((pIn
[1] << 2) & 0x3c) | ((pIn
[2] >> 6) & 0x3)];
526 pbBufferOut
+= to_b64
[ pIn
[2] & 0x3f];
530 if( nChars
>= g_nCharsPerLine
&& g_nCharsPerLine
!= 0 ) {
533 pbBufferOut
+= wxT("\r");
535 pbBufferOut
+= wxT("\n");
540 pbBufferOut
+= to_b64
[ (pIn
[0] >> 2) & 0x3f];
541 pbBufferOut
+= to_b64
[((pIn
[0] << 4) & 0x30) | ((pIn
[1] >> 4) & 0xf)];
542 pbBufferOut
+= to_b64
[ (pIn
[1] << 2) & 0x3c];
543 pbBufferOut
+= wxT("=");
545 if( nChars
>= g_nCharsPerLine
&& g_nCharsPerLine
!= 0 ) {
548 pbBufferOut
+= wxT("\r");
550 pbBufferOut
+= wxT("\n");
554 pbBufferOut
+= to_b64
[ (pIn
[0] >> 2) & 0x3f];
555 pbBufferOut
+= to_b64
[ (pIn
[0] << 4) & 0x30];
556 pbBufferOut
+= wxT("=");
557 pbBufferOut
+= wxT("=");
559 if( nChars
>= g_nCharsPerLine
&& g_nCharsPerLine
!= 0 ) {
562 pbBufferOut
+= wxT("\r");
564 pbBufferOut
+= wxT("\n");
572 pbBufferOut
+= wxT("\r");
574 pbBufferOut
+= wxT("\n");
578 if( !strHeaderLine
.IsEmpty() ) {
579 pbBufferOut
= wxT("-----END ") + strHeaderLine
+ wxT("-----");
581 pbBufferOut
+= wxT("\r");
583 pbBufferOut
+= wxT("\n");
590 unsigned int DecodeBase64(const wxString
&base64Buffer
, unsigned int base64BufLen
, unsigned char *buffer
)
592 int z
= 0; // 0 Normal, 1 skip MIME separator (---) to end of line
593 unsigned int nData
= 0;
596 if (base64BufLen
== 0) {
601 for(unsigned int j
= 0; j
< base64BufLen
; ++j
) {
602 wxChar c
= base64Buffer
[j
];
603 wxChar bits
= wxT('z');
609 else if(c
>= wxT('A') && c
<= wxT('Z')) {
612 else if(c
>= wxT('a') && c
<= wxT('z')) {
613 bits
= c
- wxT('a') + (wxChar
)26;
615 else if(c
>= wxT('0') && c
<= wxT('9')) {
616 bits
= c
- wxT('0') + (wxChar
)52;
618 else if(c
== wxT('+')) {
621 else if(c
== wxT('/')) {
624 else if(c
== wxT('-')) {
627 else if(c
== wxT('=')) {
633 // Skips anything that was not recognized
634 // as a base64 valid char ('y' or 'z')
635 if (bits
< (wxChar
)64) {
638 buffer
[i
+0] = (bits
<< 2) & 0xfc;
641 buffer
[i
+0] |= (bits
>> 4) & 0x03;
642 buffer
[i
+1] = (bits
<< 4) & 0xf0;
645 buffer
[i
+1] |= (bits
>> 2) & 0x0f;
646 buffer
[i
+2] = (bits
<< 6) & 0xc0;
649 buffer
[i
+2] |= bits
& 0x3f;
659 // Syntax error or buffer was empty
671 // Returns the text assosiated with a category type
672 wxString
GetCatTitle(int catid
)
675 case 0: return _("all");
676 case 1: return _("all others");
677 case 2: return _("Incomplete");
678 case 3: return _("Completed");
679 case 4: return _("Waiting");
680 case 5: return _("Downloading");
681 case 6: return _("Erroneous");
682 case 7: return _("Paused");
683 case 8: return _("Stopped");
684 case 9: return _("Video");
685 case 10: return _("Audio");
686 case 11: return _("Archive");
687 case 12: return _("CD-Images");
688 case 13: return _("Pictures");
689 case 14: return _("Text");
690 case 15: return _("Active");
691 default: return wxT("?");
696 typedef std::map
<wxString
, EED2KFileTypeClass
> SED2KFileTypeMap
;
697 typedef SED2KFileTypeMap::value_type SED2KFileTypeMapElement
;
698 static SED2KFileTypeMap ED2KFileTypesMap
;
701 class CED2KFileTypes
{
705 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".669"), ED2KFT_AUDIO
)); // 8 channel tracker module
706 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".aac"), ED2KFT_AUDIO
)); // Advanced Audio Coding File
707 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ac3"), ED2KFT_AUDIO
)); // Audio Codec 3 File
708 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".aif"), ED2KFT_AUDIO
)); // Audio Interchange File Format
709 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".aifc"), ED2KFT_AUDIO
)); // Audio Interchange File Format
710 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".aiff"), ED2KFT_AUDIO
)); // Audio Interchange File Format
711 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".amf"), ED2KFT_AUDIO
)); // DSMI Advanced Module Format
712 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".amr"), ED2KFT_AUDIO
)); // Adaptive Multi-Rate Codec File
713 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ams"), ED2KFT_AUDIO
)); // Extreme Tracker Module
714 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ape"), ED2KFT_AUDIO
)); // Monkey's Audio Lossless Audio File
715 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".au"), ED2KFT_AUDIO
)); // Audio File (Sun, Unix)
716 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".aud"), ED2KFT_AUDIO
)); // General Audio File
717 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".audio"), ED2KFT_AUDIO
)); // General Audio File
718 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".cda"), ED2KFT_AUDIO
)); // CD Audio Track
719 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".dbm"), ED2KFT_AUDIO
));
720 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".dmf"), ED2KFT_AUDIO
)); // Delusion Digital Music File
721 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".dsm"), ED2KFT_AUDIO
)); // Digital Sound Module
722 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".dts"), ED2KFT_AUDIO
)); // DTS Encoded Audio File
723 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".far"), ED2KFT_AUDIO
)); // Farandole Composer Module
724 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".flac"), ED2KFT_AUDIO
)); // Free Lossless Audio Codec File
725 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".it"), ED2KFT_AUDIO
)); // Impulse Tracker Module
726 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".m1a"), ED2KFT_AUDIO
)); // MPEG-1 Audio File
727 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".m2a"), ED2KFT_AUDIO
)); // MPEG-2 Audio File
728 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".m4a"), ED2KFT_AUDIO
)); // MPEG-4 Audio File
729 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mdl"), ED2KFT_AUDIO
)); // DigiTrakker Module
730 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".med"), ED2KFT_AUDIO
)); // Amiga MED Sound File
731 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mid"), ED2KFT_AUDIO
)); // MIDI File
732 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".midi"), ED2KFT_AUDIO
)); // MIDI File
733 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mka"), ED2KFT_AUDIO
)); // Matroska Audio File
734 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mod"), ED2KFT_AUDIO
)); // Amiga Music Module File
735 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mol"), ED2KFT_AUDIO
));
736 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mp1"), ED2KFT_AUDIO
)); // MPEG-1 Audio File
737 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mp2"), ED2KFT_AUDIO
)); // MPEG-2 Audio File
738 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mp3"), ED2KFT_AUDIO
)); // MPEG-3 Audio File
739 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mpa"), ED2KFT_AUDIO
)); // MPEG Audio File
740 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mpc"), ED2KFT_AUDIO
)); // Musepack Compressed Audio File
741 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mpp"), ED2KFT_AUDIO
));
742 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mtm"), ED2KFT_AUDIO
)); // MultiTracker Module
743 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".nst"), ED2KFT_AUDIO
)); // NoiseTracker
744 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ogg"), ED2KFT_AUDIO
)); // Ogg Vorbis Compressed Audio File
745 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".okt"), ED2KFT_AUDIO
)); // Oktalyzer Module (Amiga)
746 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".psm"), ED2KFT_AUDIO
)); // Protracker Studio Module
747 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ptm"), ED2KFT_AUDIO
)); // PolyTracker Module
748 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ra"), ED2KFT_AUDIO
)); // Real Audio File
749 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".rmi"), ED2KFT_AUDIO
)); // MIDI File
750 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".s3m"), ED2KFT_AUDIO
)); // Scream Tracker 3 Module
751 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".snd"), ED2KFT_AUDIO
)); // Audio File (Sun, Unix)
752 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".stm"), ED2KFT_AUDIO
)); // Scream Tracker 2 Module
753 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ult"), ED2KFT_AUDIO
)); // UltraTracker
754 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".umx"), ED2KFT_AUDIO
)); // Unreal Music Package
755 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".wav"), ED2KFT_AUDIO
)); // WAVE Audio File
756 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".wma"), ED2KFT_AUDIO
)); // Windows Media Audio File
757 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".wow"), ED2KFT_AUDIO
)); // Grave Composer audio tracker
758 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".xm"), ED2KFT_AUDIO
)); // Fasttracker 2 Extended Module
760 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".3g2"), ED2KFT_VIDEO
)); // 3GPP Multimedia File
761 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".3gp"), ED2KFT_VIDEO
)); // 3GPP Multimedia File
762 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".3gp2"), ED2KFT_VIDEO
)); // 3GPP Multimedia File
763 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".3gpp"), ED2KFT_VIDEO
)); // 3GPP Multimedia File
764 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".asf"), ED2KFT_VIDEO
)); // Advanced Systems Format (MS)
765 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".amv"), ED2KFT_VIDEO
)); // Anime Music Video File
766 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".asf"), ED2KFT_VIDEO
)); // Advanced Systems Format File
767 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".avi"), ED2KFT_VIDEO
)); // Audio Video Interleave File
768 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".bik"), ED2KFT_VIDEO
)); // BINK Video File
769 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".divx"), ED2KFT_VIDEO
)); // DivX-Encoded Movie File
770 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".dvr-ms"),ED2KFT_VIDEO
)); // Microsoft Digital Video Recording
771 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".flc"), ED2KFT_VIDEO
)); // FLIC Video File
772 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".fli"), ED2KFT_VIDEO
)); // FLIC Video File
773 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".flic"), ED2KFT_VIDEO
)); // FLIC Video File
774 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".flv"), ED2KFT_VIDEO
)); // Flash Video File
775 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".hdmov"), ED2KFT_VIDEO
)); // High-Definition QuickTime Movie
776 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ifo"), ED2KFT_VIDEO
)); // DVD-Video Disc Information File
777 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".m1v"), ED2KFT_VIDEO
)); // MPEG-1 Video File
778 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".m2t"), ED2KFT_VIDEO
)); // MPEG-2 Video Transport Stream
779 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".m2ts"), ED2KFT_VIDEO
)); // MPEG-2 Video Transport Stream
780 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".m2v"), ED2KFT_VIDEO
)); // MPEG-2 Video File
781 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".m4b"), ED2KFT_VIDEO
)); // MPEG-4 Video File
782 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".m4v"), ED2KFT_VIDEO
)); // MPEG-4 Video File
783 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mkv"), ED2KFT_VIDEO
)); // Matroska Video File
784 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mov"), ED2KFT_VIDEO
)); // QuickTime Movie File
785 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".movie"), ED2KFT_VIDEO
)); // QuickTime Movie File
786 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mp1v"), ED2KFT_VIDEO
)); // QuickTime Movie File
787 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mp2v"), ED2KFT_VIDEO
)); // MPEG-1 Video File
788 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mp4"), ED2KFT_VIDEO
)); // MPEG-2 Video File
789 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mpe"), ED2KFT_VIDEO
)); // MPEG-4 Video File
790 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mpeg"), ED2KFT_VIDEO
)); // MPEG Video File
791 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mpg"), ED2KFT_VIDEO
)); // MPEG Video File
792 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mps"), ED2KFT_VIDEO
)); // MPEG Video File
793 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mpv"), ED2KFT_VIDEO
)); // MPEG Video File
794 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mpv1"), ED2KFT_VIDEO
)); // MPEG-1 Video File
795 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mpv2"), ED2KFT_VIDEO
)); // MPEG-2 Video File
796 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ogm"), ED2KFT_VIDEO
)); // Ogg Media File
797 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".pva"), ED2KFT_VIDEO
)); // MPEG Video File
798 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".qt"), ED2KFT_VIDEO
)); // QuickTime Movie
799 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ram"), ED2KFT_VIDEO
)); // Real Audio Media
800 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ratdvd"),ED2KFT_VIDEO
)); // RatDVD Disk Image
801 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".rm"), ED2KFT_VIDEO
)); // Real Media File
802 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".rmm"), ED2KFT_VIDEO
)); // Real Media File
803 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".rmvb"), ED2KFT_VIDEO
)); // Real Video Variable Bit Rate File
804 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".rv"), ED2KFT_VIDEO
)); // Real Video File
805 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".rv9"), ED2KFT_VIDEO
));
806 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".smil"), ED2KFT_VIDEO
)); // SMIL Presentation File
807 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".smk"), ED2KFT_VIDEO
)); // Smacker Compressed Movie File
808 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".swf"), ED2KFT_VIDEO
)); // Macromedia Flash Movie
809 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".tp"), ED2KFT_VIDEO
)); // Video Transport Stream File
810 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ts"), ED2KFT_VIDEO
)); // Video Transport Stream File
811 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".vid"), ED2KFT_VIDEO
)); // General Video File
812 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".video"), ED2KFT_VIDEO
)); // General Video File
813 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".vivo"), ED2KFT_VIDEO
)); // VivoActive Video File
814 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".vob"), ED2KFT_VIDEO
)); // DVD Video Object File
815 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".vp6"), ED2KFT_VIDEO
)); // TrueMotion VP6 Video File
816 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".wm"), ED2KFT_VIDEO
)); // Windows Media Video File
817 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".wmv"), ED2KFT_VIDEO
)); // Windows Media Video File
818 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".xvid"), ED2KFT_VIDEO
)); // Xvid-Encoded Video File
820 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".bmp"), ED2KFT_IMAGE
)); // Bitmap Image File
821 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".dcx"), ED2KFT_IMAGE
)); // FAXserve Fax Document
822 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".emf"), ED2KFT_IMAGE
)); // Enhanced Windows Metafile
823 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".gif"), ED2KFT_IMAGE
)); // Graphical Interchange Format File
824 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ico"), ED2KFT_IMAGE
)); // Icon File
825 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".jfif"), ED2KFT_IMAGE
)); // JPEG File Interchange Format
826 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".jpe"), ED2KFT_IMAGE
)); // JPEG Image File
827 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".jpeg"), ED2KFT_IMAGE
)); // JPEG Image File
828 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".jpg"), ED2KFT_IMAGE
)); // JPEG Image File
829 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".pct"), ED2KFT_IMAGE
)); // PICT Picture File
830 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".pcx"), ED2KFT_IMAGE
)); // Paintbrush Bitmap Image File
831 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".pic"), ED2KFT_IMAGE
)); // PICT Picture File
832 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".pict"), ED2KFT_IMAGE
)); // PICT Picture File
833 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".png"), ED2KFT_IMAGE
)); // Portable Network Graphic
834 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".psd"), ED2KFT_IMAGE
)); // Photoshop Document
835 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".psp"), ED2KFT_IMAGE
)); // Paint Shop Pro Image File
836 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".tga"), ED2KFT_IMAGE
)); // Targa Graphic
837 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".tif"), ED2KFT_IMAGE
)); // Tagged Image File
838 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".tiff"), ED2KFT_IMAGE
)); // Tagged Image File
839 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".wmf"), ED2KFT_IMAGE
)); // Windows Metafile
840 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".wmp"), ED2KFT_IMAGE
)); // Windows Media Photo File
841 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".xif"), ED2KFT_IMAGE
)); // ScanSoft Pagis Extended Image Format File
842 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".xpm"), ED2KFT_IMAGE
)); // X-Windows Pixmap
844 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".7z"), ED2KFT_ARCHIVE
)); // 7-Zip Compressed File
845 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ace"), ED2KFT_ARCHIVE
)); // WinAce Compressed File
846 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".alz"), ED2KFT_ARCHIVE
)); // ALZip Archive
847 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".arc"), ED2KFT_ARCHIVE
)); // Compressed File Archive
848 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".arj"), ED2KFT_ARCHIVE
)); // ARJ Compressed File Archive
849 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".bz2"), ED2KFT_ARCHIVE
)); // Bzip Compressed File
850 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".cab"), ED2KFT_ARCHIVE
)); // Cabinet File
851 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".cbr"), ED2KFT_ARCHIVE
)); // Comic Book RAR Archive
852 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".cbz"), ED2KFT_ARCHIVE
)); // Comic Book ZIP Archive
853 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".gz"), ED2KFT_ARCHIVE
)); // Gnu Zipped File
854 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".hqx"), ED2KFT_ARCHIVE
)); // BinHex 4.0 Encoded File
855 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".lha"), ED2KFT_ARCHIVE
)); // LHARC Compressed Archive
856 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".lzh"), ED2KFT_ARCHIVE
)); // LZH Compressed File
857 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".msi"), ED2KFT_ARCHIVE
)); // Microsoft Installer File
858 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".pak"), ED2KFT_ARCHIVE
)); // PAK (Packed) File
859 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".par"), ED2KFT_ARCHIVE
)); // Parchive Index File
860 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".par2"), ED2KFT_ARCHIVE
)); // Parchive 2 Index File
861 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".rar"), ED2KFT_ARCHIVE
)); // WinRAR Compressed Archive
862 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".sea"), ED2KFT_ARCHIVE
)); // Self-Extracting Archive (Mac)
863 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".sit"), ED2KFT_ARCHIVE
)); // Stuffit Archive
864 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".sitx"), ED2KFT_ARCHIVE
)); // Stuffit X Archive
865 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".tar"), ED2KFT_ARCHIVE
)); // Consolidated Unix File Archive
866 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".tbz2"), ED2KFT_ARCHIVE
)); // Tar BZip 2 Compressed File
867 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".tgz"), ED2KFT_ARCHIVE
)); // Gzipped Tar File
868 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".uc2"), ED2KFT_ARCHIVE
)); // UltraCompressor 2 Archive
869 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".xpi"), ED2KFT_ARCHIVE
)); // Mozilla Installer Package
870 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".z"), ED2KFT_ARCHIVE
)); // Unix Compressed File
871 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".zip"), ED2KFT_ARCHIVE
)); // Zipped File
873 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".bat"), ED2KFT_PROGRAM
)); // Batch File
874 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".cmd"), ED2KFT_PROGRAM
)); // Command File
875 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".com"), ED2KFT_PROGRAM
)); // COM File
876 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".exe"), ED2KFT_PROGRAM
)); // Executable File
877 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".hta"), ED2KFT_PROGRAM
)); // HTML Application
878 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".js"), ED2KFT_PROGRAM
)); // Java Script
879 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".jse"), ED2KFT_PROGRAM
)); // Encoded Java Script
880 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".msc"), ED2KFT_PROGRAM
)); // Microsoft Common Console File
881 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".vbe"), ED2KFT_PROGRAM
)); // Encoded Visual Basic Script File
882 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".vbs"), ED2KFT_PROGRAM
)); // Visual Basic Script File
883 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".wsf"), ED2KFT_PROGRAM
)); // Windows Script File
884 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".wsh"), ED2KFT_PROGRAM
)); // Windows Scripting Host File
886 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".bin"), ED2KFT_CDIMAGE
)); // CD Image
887 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".bwa"), ED2KFT_CDIMAGE
)); // BlindWrite Disk Information File
888 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".bwi"), ED2KFT_CDIMAGE
)); // BlindWrite CD/DVD Disc Image
889 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".bws"), ED2KFT_CDIMAGE
)); // BlindWrite Sub Code File
890 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".bwt"), ED2KFT_CDIMAGE
)); // BlindWrite 4 Disk Image
891 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ccd"), ED2KFT_CDIMAGE
)); // CloneCD Disk Image
892 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".cue"), ED2KFT_CDIMAGE
)); // Cue Sheet File
893 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".dmg"), ED2KFT_CDIMAGE
)); // Mac OS X Disk Image
894 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".dmz"), ED2KFT_CDIMAGE
));
895 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".img"), ED2KFT_CDIMAGE
)); // Disk Image Data File
896 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".iso"), ED2KFT_CDIMAGE
)); // Disc Image File
897 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mdf"), ED2KFT_CDIMAGE
)); // Media Disc Image File
898 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".mds"), ED2KFT_CDIMAGE
)); // Media Descriptor File
899 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".nrg"), ED2KFT_CDIMAGE
)); // Nero CD/DVD Image File
900 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".sub"), ED2KFT_CDIMAGE
)); // Subtitle File
901 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".toast"), ED2KFT_CDIMAGE
)); // Toast Disc Image
903 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".chm"), ED2KFT_DOCUMENT
)); // Compiled HTML Help File
904 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".css"), ED2KFT_DOCUMENT
)); // Cascading Style Sheet
905 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".diz"), ED2KFT_DOCUMENT
)); // Description in Zip File
906 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".doc"), ED2KFT_DOCUMENT
)); // Document File
907 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".dot"), ED2KFT_DOCUMENT
)); // Document Template File
908 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".hlp"), ED2KFT_DOCUMENT
)); // Help File
909 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".htm"), ED2KFT_DOCUMENT
)); // HTML File
910 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".html"), ED2KFT_DOCUMENT
)); // HTML File
911 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".nfo"), ED2KFT_DOCUMENT
)); // Warez Information File
912 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".pdf"), ED2KFT_DOCUMENT
)); // Portable Document Format File
913 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".pps"), ED2KFT_DOCUMENT
)); // PowerPoint Slide Show
914 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ppt"), ED2KFT_DOCUMENT
)); // PowerPoint Presentation
915 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".ps"), ED2KFT_DOCUMENT
)); // PostScript File
916 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".rtf"), ED2KFT_DOCUMENT
)); // Rich Text Format File
917 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".text"), ED2KFT_DOCUMENT
)); // General Text File
918 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".txt"), ED2KFT_DOCUMENT
)); // Text File
919 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".wri"), ED2KFT_DOCUMENT
)); // Windows Write Document
920 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".xls"), ED2KFT_DOCUMENT
)); // Microsoft Excel Spreadsheet
921 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".xlt"), ED2KFT_DOCUMENT
)); // Microsoft Excel Template
922 ED2KFileTypesMap
.insert(SED2KFileTypeMapElement(wxT(".xml"), ED2KFT_DOCUMENT
)); // XML File
927 // get the list initialized *before* any code is accessing it
928 CED2KFileTypes theED2KFileTypes
;
930 EED2KFileType
GetED2KFileTypeID(const CPath
& fileName
)
932 const wxString ext
= fileName
.GetExt().Lower();
937 SED2KFileTypeMap::iterator it
= ED2KFileTypesMap
.find(wxT(".") + ext
);
938 if (it
!= ED2KFileTypesMap
.end()) {
939 return it
->second
.GetType();
946 // Retuns the ed2k file type term which is to be used in server searches
947 wxString
GetED2KFileTypeSearchTerm(EED2KFileType iFileID
)
949 if (iFileID
== ED2KFT_AUDIO
) return ED2KFTSTR_AUDIO
;
950 if (iFileID
== ED2KFT_VIDEO
) return ED2KFTSTR_VIDEO
;
951 if (iFileID
== ED2KFT_IMAGE
) return ED2KFTSTR_IMAGE
;
952 if (iFileID
== ED2KFT_DOCUMENT
) return ED2KFTSTR_DOCUMENT
;
953 if (iFileID
== ED2KFT_PROGRAM
) return ED2KFTSTR_PROGRAM
;
954 // NOTE: Archives and CD-Images are published with file type "Pro"
955 if (iFileID
== ED2KFT_ARCHIVE
) return ED2KFTSTR_PROGRAM
;
956 if (iFileID
== ED2KFT_CDIMAGE
) return ED2KFTSTR_PROGRAM
;
958 return wxEmptyString
;
962 // Returns a file type which is used eMule internally only, examining the extention of the given filename
963 wxString
GetFileTypeByName(const CPath
& fileName
)
965 EED2KFileType iFileType
= GetED2KFileTypeID(fileName
);
967 case ED2KFT_AUDIO
: return ED2KFTSTR_AUDIO
;
968 case ED2KFT_VIDEO
: return ED2KFTSTR_VIDEO
;
969 case ED2KFT_IMAGE
: return ED2KFTSTR_IMAGE
;
970 case ED2KFT_DOCUMENT
: return ED2KFTSTR_DOCUMENT
;
971 case ED2KFT_PROGRAM
: return ED2KFTSTR_PROGRAM
;
972 case ED2KFT_ARCHIVE
: return ED2KFTSTR_ARCHIVE
;
973 case ED2KFT_CDIMAGE
: return ED2KFTSTR_CDIMAGE
;
974 default: return wxEmptyString
;
979 // Retuns the ed2k file type integer ID which is to be used for publishing+searching
980 EED2KFileType
GetED2KFileTypeSearchID(EED2KFileType iFileID
)
983 case ED2KFT_AUDIO
: return ED2KFT_AUDIO
;
984 case ED2KFT_VIDEO
: return ED2KFT_VIDEO
;
985 case ED2KFT_IMAGE
: return ED2KFT_IMAGE
;
986 case ED2KFT_DOCUMENT
: return ED2KFT_DOCUMENT
;
987 case ED2KFT_PROGRAM
: return ED2KFT_PROGRAM
;
988 // NOTE: Archives and CD-Images are published+searched with file type "Pro"
989 // NOTE: If this gets changed, the function 'GetED2KFileTypeSearchTerm' also needs to get updated!
990 case ED2KFT_ARCHIVE
: return ED2KFT_PROGRAM
;
991 case ED2KFT_CDIMAGE
: return ED2KFT_PROGRAM
;
992 default: return ED2KFT_ANY
;
998 * Dumps a buffer to a wxString
1000 wxString
DumpMemToStr(const void *buff
, int n
, const wxString
& msg
, bool ok
)
1002 const unsigned char *p
= (const unsigned char *)buff
;
1003 int lines
= (n
+ 15)/ 16;
1006 // Allocate aproximetly what is needed
1007 result
.Alloc( ( lines
+ 1 ) * 80 );
1008 if ( !msg
.IsEmpty() ) {
1009 result
+= msg
+ wxT(" - ok=") + ( ok
? wxT("true, ") : wxT("false, ") );
1012 result
+= wxString::Format( wxT("%d bytes\n"), n
);
1013 for ( int i
= 0; i
< lines
; ++i
) {
1015 result
+= wxString::Format( wxT("%08x "), i
* 16 );
1017 // Show two columns of hex-values
1018 for ( int j
= 0; j
< 2; ++j
) {
1019 for ( int k
= 0; k
< 8; ++k
) {
1020 int pos
= 16 * i
+ 8 * j
+ k
;
1023 result
+= wxString::Format( wxT("%02x "), p
[pos
] );
1031 // Show a column of ascii-values
1032 for ( int k
= 0; k
< 16; ++k
) {
1033 int pos
= 16 * i
+ k
;
1036 if ( isspace( p
[pos
] ) ) {
1038 } else if ( !isgraph( p
[pos
] ) ) {
1041 result
+= (wxChar
)p
[pos
];
1047 result
+= wxT("|\n");
1056 * Dumps a buffer to stdout
1058 void DumpMem(const void *buff
, int n
, const wxString
& msg
, bool ok
)
1060 printf("%s\n", (const char*)unicode2char(DumpMemToStr( buff
, n
, msg
, ok
)) );
1065 // Dump mem in dword format
1066 void DumpMem_DW(const uint32
*ptr
, int count
)
1068 for(int i
= 0; i
< count
; i
++) {
1069 printf("%08x ", ptr
[i
]);
1070 if ( (i
% 4) == 3) printf("\n");
1076 wxString
GetConfigDir(const wxString
&configFileBase
)
1079 static wxString configPath
;
1081 if (configPath
.IsEmpty()) {
1082 // "Portable aMule" - Use aMule from an external USB drive
1083 // Check for ./config/amule.conf (or whatever gets passed as configFile)
1084 // and use this configuration if found
1085 const wxString configDir
= JoinPaths(wxFileName::GetCwd(), wxT("config"));
1086 const wxString configFile
= JoinPaths(configDir
, configFileBase
);
1088 if (CPath::DirExists(configDir
) && CPath::FileExists(configFile
)) {
1089 AddLogLineN(CFormat(wxT("Using configDir: %s")) % configDir
);
1091 configPath
= configDir
;
1093 configPath
= wxStandardPaths::Get().GetUserDataDir();
1096 configPath
+= wxFileName::GetPathSeparator();
1103 /*************************** Locale specific stuff ***************************/
1106 # define SETWINLANG(LANG, SUBLANG)
1108 # define SETWINLANG(LANG, SUBLANG) \
1109 info.WinLang = LANG; \
1110 info.WinSublang = SUBLANG;
1113 #define CUSTOMLANGUAGE(wxid, iso, winlang, winsublang, dir, desc) \
1114 info.Language = wxid; \
1115 info.CanonicalName = wxT(iso); \
1116 info.LayoutDirection = dir; \
1117 info.Description = wxT(desc); \
1118 SETWINLANG(winlang, winsublang) \
1119 wxLocale::AddLanguage(info);
1121 void InitCustomLanguages()
1123 wxLanguageInfo info
;
1125 #if !wxCHECK_VERSION(2, 9, 0)
1126 CUSTOMLANGUAGE(wxLANGUAGE_ASTURIAN
, "ast", 0, 0, wxLayout_LeftToRight
, "Asturian");
1131 void InitLocale(wxLocale
& locale
, int language
)
1133 locale
.Init(language
, wxLOCALE_LOAD_DEFAULT
);
1135 #if defined(__WXMAC__) || defined(__WXMSW__)
1136 locale
.AddCatalogLookupPathPrefix(JoinPaths(wxStandardPaths::Get().GetDataDir(), wxT("locale")));
1138 locale
.AddCatalog(wxT(PACKAGE
));
1142 int StrLang2wx(const wxString
& language
)
1144 // get rid of possible encoding and modifier
1145 wxString
lang(language
.BeforeFirst('.').BeforeFirst('@'));
1147 if (!lang
.IsEmpty()) {
1148 const wxLanguageInfo
*lng
= wxLocale::FindLanguageInfo(lang
);
1150 return lng
->Language
;
1152 return wxLANGUAGE_DEFAULT
;
1155 return wxLANGUAGE_DEFAULT
;
1160 wxString
wxLang2Str(const int lang
)
1162 if (lang
!= wxLANGUAGE_DEFAULT
) {
1163 const wxLanguageInfo
*lng
= wxLocale::GetLanguageInfo(lang
);
1165 return lng
->CanonicalName
;
1167 return wxEmptyString
;
1170 return wxEmptyString
;
1174 /*****************************************************************************/
1176 wxString
GetPassword() {
1177 wxString pass_plain
;
1180 pass_plain
= char2unicode(getpass("Enter password for mule connection: "));
1182 //#warning This way, pass enter is not hidden on windows. Bad thing.
1185 printf("Enter password for mule connection: \n");
1187 fgets(temp_str
, 512, stdin
);
1188 temp_str
[strlen(temp_str
)-1] = '\0';
1189 pass_plain
= char2unicode(temp_str
);
1191 wxCHECK2(password
.Decode(MD5Sum(pass_plain
).GetHash()), /* Do nothing. */ );
1192 // MD5 hash for an empty string, according to rfc1321.
1193 if (password
.Encode() == wxT("D41D8CD98F00B204E9800998ECF8427E")) {
1194 printf("No empty password allowed.\n");
1195 return GetPassword();
1199 return password
.Encode();
1202 // File_checked_for_headers