MIMETypes.st
author Claus Gittinger <cg@exept.de>
Mon, 03 Feb 2003 11:01:30 +0100
changeset 1693 4055b361abe9
parent 1691 6ee1100ba672
child 1716 0dab062f4be4
permissions -rw-r--r--
isArchiv -> isArchive
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG 
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
     3
	      All Rights Reserved
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
1410
faf04ef6892b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1364
diff changeset
    15
"{ Package: 'stx:libview2' }"
faf04ef6892b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1364
diff changeset
    16
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
Object subclass:#MIMETypes
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    18
	instanceVariableNames:''
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    19
	classVariableNames:'TypeToImageReaderClassMapping FileSuffixToTypeMapping
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    20
		FilenameToTypeMapping FileSuffixToImageReaderClassMapping
1691
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
    21
		CharSetToFontMapping LastSuffix LastType
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
    22
		DefaultCommandPerMIMEPerOS'
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    23
	poolDictionaries:''
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    24
	category:'System-Documentation'
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    25
!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    26
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    27
String variableByteSubclass:#MIMEType
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    28
	instanceVariableNames:''
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    29
	classVariableNames:'CachedTypes'
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    30
	poolDictionaries:''
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    31
	privateIn:MIMETypes
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
!MIMETypes class methodsFor:'documentation'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
copyright
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
 COPYRIGHT (c) 1997 by eXept Software AG 
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
    39
	      All Rights Reserved
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
 This software is furnished under a license and may be used
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
 only in accordance with the terms of that license and with the
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
 inclusion of the above copyright notice.   This software may not
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
 be provided or otherwise made available to, or used by, any
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
 other person.  No title to or ownership of the software is
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
 hereby transferred.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
documentation
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    just a place to keep MIME information
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    (avoid spreading things at many places)
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    57
    MIMETypes is abstract and functional.
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    58
    Actually, in some OperatingSystems, this information may
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    59
    be found in some config files (or registries).
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    60
    Therefore, this class may have to be extended to support this
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    61
    and fetch the information from there eventually.
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    62
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    [author:]
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
        Claus Gittinger
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
"
1311
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    66
!
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    67
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    68
knownTypes
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    69
"
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    70
    simply a reminder for me ...
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    71
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    72
    application         mime                            file extentsions
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    73
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    74
        powerpoint      application/ms-powerpoint       .pot, .ppz, .ppt, .pps, 
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    75
                        application/mspowerpoint        
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    76
                        application/vnd.ms-powerpoint   
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    77
                        application/x-mspowerpoint
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    78
1312
Claus Gittinger <cg@exept.de>
parents: 1311
diff changeset
    79
        shockwave       application/x-shockwave-flash   .swf     
1311
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    80
1312
Claus Gittinger <cg@exept.de>
parents: 1311
diff changeset
    81
        futuresplash    application/futuresplash        .spl
1311
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    82
"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
! !
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
!MIMETypes class methodsFor:'initialization'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    87
applicationComprAndArchiveTypeList
1606
158c10a36736 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
    88
    "compressors and archivers"
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    89
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    90
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    91
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    92
        'tar'                   'application/x-tar'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    93
        'gtar'                  'application/x-gtar'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    94
        'tgz'                   'application/x-tar-compressed'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    95
        'zip'                   'application/x-zip-compressed'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    96
        ('gz' 'z')              'application/x-gzip-compressed'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    97
        'cpio'                  'application/x-cpio'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    98
        'shar'                  'application/x-shar'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    99
        'jar'                   'application/java-archive'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   100
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   101
!
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   102
1609
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   103
applicationMiscTypeList
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   104
    "misc applications"
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   105
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   106
    ^ #(
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   107
        ('a' 'o' 'obj' )                        'application/binary'
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   108
        'a'                                     'application/library'
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   109
        ('dll' 'so')                            'application/shared-library'
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   110
    )
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   111
!
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   112
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   113
applicationProgLangTypeList
1606
158c10a36736 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   114
    "applications for programm languages"
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
   115
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   116
    ^ #(
1609
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   117
        ('st' 'cls' 'rc')            'application/x-smalltalk-source'
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   118
        'sif'                        'application/x-smalltalk-source-sif'
1668
070264d3a087 added dolphin package
Claus Gittinger <cg@exept.de>
parents: 1666
diff changeset
   119
        'pac'                        'application/x-smalltalk-dolphin-package'
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   120
        'c'                          'application/x-c-source'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   121
        ('cc' 'cpp')                 'application/x-cpp-source'
1609
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   122
        ('h' 'hi')                   'application/x-c-header'
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   123
        ('js' 'mocha')               'application/x-javascript'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   124
        ('java' 'jav')               'application/x-java-source'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   125
        'sh'                         'application/x-sh'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   126
        'csh'                        'application/x-csh'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   127
        'tcl'                        'application/x-tcl'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   128
        'pl'                         'application/x-perl'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   129
        'mak'                        'application/x-make'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   130
        'bat'                        'application/x-batch-script'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   131
        ('asn1' 'x409' 'gdmo' 'gdm') 'application/x-asn1-source'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   132
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   133
!
1561
942de18a3e3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   134
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   135
applicationTextTypeList
1606
158c10a36736 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   136
    "text applications"
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   137
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   138
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   139
        ('ps' 'eps')                 'application/postscript'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   140
        'pdf'                        'application/pdf'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   141
        'rtf'                        'application/rtf'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   142
        'doc'                        'application/winword'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   143
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   144
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   145
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   146
applicationTypeList
1606
158c10a36736 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   147
    "applications"
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   148
1611
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   149
    |typeStrings|                            
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   150
1611
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   151
    typeStrings := OrderedCollection new.
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   152
    typeStrings addAll:self applicationProgLangTypeList.
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   153
    typeStrings addAll:self applicationTextTypeList.
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   154
    typeStrings addAll:self applicationComprAndArchiveTypeList.
1616
f07466809515 add binary file extensions
penk
parents: 1612
diff changeset
   155
    typeStrings addAll:self applicationMiscTypeList.
f07466809515 add binary file extensions
penk
parents: 1612
diff changeset
   156
1611
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   157
    ^ typeStrings
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   158
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   159
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   160
audioTypeList
1606
158c10a36736 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   161
    "audio formats ..."
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   162
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   163
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   164
        ('ra' 'ram')            'audio/x-pn-realaudio'
1680
d34932ed0e86 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   165
        'rpm'                   'audio/x-pn-realaudio-plugin'
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   166
        ('mpa' 'mpega')         'audio/x-mpeg'
1680
d34932ed0e86 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   167
        'mp3'                   'audio/x-mp3'
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   168
        'wav'                   'audio/x-wav'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   169
        ('aif' 'aiff' 'aifc')   'audio/x-aiff'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   170
        ('au' 'snd')            'audio/basic'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   171
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   172
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   173
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   174
imageTypeList
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   175
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   176
    ^ #(
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   177
        "/ image formats ...
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   178
1216
26fe79e724d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1188
diff changeset
   179
        ('jpg' 'jpeg')  'image/jpeg'
1188
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   180
        'gif'           'image/gif'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   181
        ('tif' 'tiff')  'image/tiff'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   182
        'xbm'           'image/x-xbitmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   183
        'xpm'           'image/x-xpixmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   184
        'png'           'image/x-png'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   185
        'pcd'           'image/x-photo-cd'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   186
        'bmp'           'image/x-MS-bmp'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   187
        'rgb'           'image/x-rgb'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   188
        'ppm'           'image/x-portable-pixmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   189
        'pgm'           'image/x-portable-graymap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   190
        'pbm'           'image/x-portable-bitmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   191
        'pnm'           'image/x-portable-anymap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   192
        'xwd'           'image/x-xwindowdump'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   193
        'ras'           'image/x-cmu-raster'
1216
26fe79e724d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1188
diff changeset
   194
        'tga'           'image/x-targa'
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   195
    ) 
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   196
!
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   197
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   198
initialize
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   199
    "initialize wellKnown facts"
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   200
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   201
    |typeToImageReaderClassMapping fileSuffixToTypeMapping
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   202
     fileSuffixToImageReaderClassMapping charSetToFontMapping types|
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   203
1610
34bb3a9f1379 Fix everything, so that stx can be started
Stefan Vogel <sv@exept.de>
parents: 1609
diff changeset
   204
    MIMEType initialize.   "must be initialized first"
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   205
    LastSuffix := LastType := nil.
1411
d72f09a436d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1410
diff changeset
   206
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   207
    (fileSuffixToImageReaderClassMapping := FileSuffixToImageReaderClassMapping) isNil ifTrue:[
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   208
        FileSuffixToImageReaderClassMapping := fileSuffixToImageReaderClassMapping := Dictionary new
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   209
    ].
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   210
    (typeToImageReaderClassMapping := TypeToImageReaderClassMapping) isNil ifTrue:[
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   211
        TypeToImageReaderClassMapping := typeToImageReaderClassMapping := Dictionary new
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   212
    ].
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   213
    (fileSuffixToTypeMapping := FileSuffixToTypeMapping) isNil ifTrue:[
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   214
        FileSuffixToTypeMapping := fileSuffixToTypeMapping := Dictionary new
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   215
    ].
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   216
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   217
    "/ setup file-suffix to mimeType mapping ...
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   218
1606
158c10a36736 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1604
diff changeset
   219
    types := OrderedCollection new.
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   220
    types addAll:self textTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   221
    types addAll:self imageTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   222
    types addAll:self videoTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   223
    types addAll:self audioTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   224
    types addAll:self applicationTypeList.
1609
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   225
    types pairWiseDo:[:suff :typeString|
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   226
        |type|
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   227
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   228
        type := MIMEType fromString:typeString.
1188
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   229
        suff isArray ifTrue:[
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   230
            suff do:[:s | fileSuffixToTypeMapping at:s put:type]
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   231
        ] ifFalse:[
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   232
            fileSuffixToTypeMapping at:suff put:type
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   233
        ]
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   234
    ].
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   235
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   236
    FilenameToTypeMapping := Dictionary new.
1616
f07466809515 add binary file extensions
penk
parents: 1612
diff changeset
   237
    self miscFilenameList pairWiseDo:[:nm :typeString|
1609
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   238
        |type|
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   239
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   240
        type := MIMEType fromString:typeString.
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   241
        nm isArray ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   242
            nm do:[:s | FilenameToTypeMapping at:s put:type]
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   243
        ] ifFalse:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   244
            FilenameToTypeMapping at:nm put:type
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   245
        ]
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   246
    ].
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   247
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   248
    "/ setup mimeType to image reader class mapping ...
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   249
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   250
    typeToImageReaderClassMapping at:'image/jpeg' put:JPEGReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   251
    typeToImageReaderClassMapping at:'image/gif'  put:GIFReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   252
    typeToImageReaderClassMapping at:'image/tiff' put:TIFFReader.
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   253
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   254
    "/ setup suffix to image reader class mapping ...
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   255
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   256
    fileSuffixToImageReaderClassMapping at:'jpg'  put:JPEGReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   257
    fileSuffixToImageReaderClassMapping at:'gif'  put:GIFReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   258
    fileSuffixToImageReaderClassMapping at:'tif'  put:TIFFReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   259
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   260
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   261
    "/ character sets (not really mime stuff, but also placed here)
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   262
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   263
    (charSetToFontMapping := CharSetToFontMapping) isNil ifTrue:[
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   264
        CharSetToFontMapping := charSetToFontMapping := Dictionary new
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   265
    ].
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   266
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   267
    #(
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   268
        'iso2022-jp'   'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   269
        'x-iso2022-jp' 'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   270
        'x-euc-jp'     'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   271
        'x-shift-jis'  'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   272
        'x-sjis'       'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   273
        'x-jis7'       'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   274
        'jis7'         'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   275
        'euc'          'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   276
        'euc-jp'       'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   277
        'sjis'         'jis*0208*'
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
   278
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   279
        'big5'         'big5*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   280
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   281
        'gb2312'       'gb*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   282
        'hz-gb-2312'   'gb*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   283
        'x-gbk'        'gb*'
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   284
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   285
        'iso2022-kr'   'ksc*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   286
        'x-euc-kr'     'ksc*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   287
    ) pairWiseDo:[:charSet :fontEncoding|
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   288
         charSetToFontMapping at:charSet put:fontEncoding
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   289
    ].
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    "
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
     self initialize
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
    "
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
1269
4362ec6dd5c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
   295
    "Modified: / 19.11.1999 / 15:01:53 / cg"
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   296
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   297
1691
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   298
initializeDefaultCommands
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   299
    "TODO: move this to OS"
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   300
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   301
    |unixCommands win32Commands|
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   302
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   303
    DefaultCommandPerMIMEPerOS := Dictionary new.
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   304
    DefaultCommandPerMIMEPerOS at:#unix  put:(unixCommands := Dictionary new).
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   305
    DefaultCommandPerMIMEPerOS at:#win32 put:(win32Commands := Dictionary new).
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   306
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   307
    unixCommands at:'application/x-tar-compressed' put:'gunzip < %1 | tar tvf -'.
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   308
    unixCommands at:'application/pdf'              put:'acroread -display %2 %1'.
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   309
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   310
    "
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   311
     self initializeDefaultCommands
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   312
    "
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   313
!
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   314
1609
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   315
miscFilenameList
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   316
    "other formats (not by suffix, but by fileName isnstead) ..."
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   317
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   318
    ^ #(
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   319
        ('makefile' 'make.proto')  'application/x-make'
1681
2ba809d67f16 shockwave mime fixed
Claus Gittinger <cg@exept.de>
parents: 1680
diff changeset
   320
        'swf'                      'application/x-shockwave-flash'
1609
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   321
    )
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   322
!
090ee7aa4cab *** empty log message ***
penk
parents: 1606
diff changeset
   323
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   324
textTypeList
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   325
   "/ misc text ...
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   326
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   327
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   328
        ('htm' 'html')          'text/html'
1680
d34932ed0e86 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   329
        'shtml'                 'text/html'
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   330
        ('txt' 'text')          'text/plain'
1680
d34932ed0e86 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   331
        'xml'                   'text/xml'
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   332
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   333
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   334
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   335
videoTypeList
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   336
    "/ video formats ...
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   337
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   338
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   339
        'movie'                            'video/x-sgi-movie'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   340
        'avi'                              'video/x-msvideo'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   341
        ('qt' 'mov' 'moov')                'video/quicktime'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   342
        ('mpv2' 'mp2v' 'mp2' 'mpeg2')      'video/x-mpeg2'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   343
        ('mpv' 'mpegv' 'mpg' 'mpeg' 'mpe') 'video/mpeg'
1680
d34932ed0e86 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   344
        'rm'                               'application/vnd.rn-realmedia'
d34932ed0e86 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   345
        'rv'                               'video/x-pn-realvideo'
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   346
    )
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
! !
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
!MIMETypes class methodsFor:'accessing'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
1472
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   351
commentStringsForFilename:aFilename
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   352
    "return a useful comment definition; heuristics for now.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   353
     The returned value is an array of 2 elements;
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   354
     the first is the end-of-line comment string (or nil);
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   355
     the second an array of opening/closing delimiters (or an array of nils)"
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   356
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   357
     |mime|
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   358
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   359
     mime := MIMETypes mimeTypeForFilename:aFilename.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   360
     ^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix)
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   361
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   362
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   363
     MIMETypes commentStringsForFilename:'Makefile'.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   364
     MIMETypes commentStringsForFilename:'Object.st'. 
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   365
     MIMETypes commentStringsForFilename:'Foo.java'. 
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   366
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   367
!
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   368
1489
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   369
commentStringsForFilename:aFilename ifUnknown:alternativeBlockReturningCommentString
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   370
    "return a useful comment definition; heuristics for now.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   371
     The returned value is an array of 2 elements;
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   372
     the first is the end-of-line comment string (or nil);
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   373
     the second an array of opening/closing delimiters (or an array of nils)"
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   374
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   375
     |mime|
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   376
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   377
     mime := MIMETypes mimeTypeForFilename:aFilename.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   378
     ^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternativeBlockReturningCommentString
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   379
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   380
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   381
     MIMETypes commentStringsForFilename:'Makefile'.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   382
     MIMETypes commentStringsForFilename:'Object.st'. 
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   383
     MIMETypes commentStringsForFilename:'Foo.java'. 
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   384
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   385
!
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   386
1472
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   387
commentStringsForMimeType:mime suffix:suff
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   388
    "return a useful comment definition; heuristics for now.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   389
     The returned value is an array of 2 elements;
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   390
     the first is the end-of-line comment string (or nil);
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   391
     the second an array of opening/closing delimiters (or an array of nils)"
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   392
1489
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   393
    ^ self
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   394
        commentStringsForMimeType:mime suffix:suff 
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   395
        ifUnknown: #(';' (nil nil))  
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   396
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   397
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   398
     |mime|
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   399
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   400
     mime := MIMETypes mimeTypeForFilename:'Makefile'.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   401
     MIMETypes commentStringsForMimeType:mime suffix:nil.     
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   402
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   403
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   404
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   405
     |mime|
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   406
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   407
     mime := MIMETypes mimeTypeForFilename:'Object.st'.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   408
     MIMETypes commentStringsForMimeType:mime suffix:nil.    
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   409
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   410
!
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   411
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   412
commentStringsForMimeType:mime suffix:suff ifUnknown:alternativeBlockReturningCommentString
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   413
    "return a useful comment definition; heuristics for now.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   414
     The returned value is an array of 2 elements;
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   415
     the first is the end-of-line comment string (or nil);
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   416
     the second an array of opening/closing delimiters (or an array of nils)"
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   417
1472
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   418
    (mime = 'application/x-make') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   419
        "/ makefile
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   420
        ^ #('#' (nil nil)).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   421
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   422
    (mime = 'application/x-sh') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   423
        "/ shell script
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   424
        ^ #('#' (nil nil)).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   425
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   426
    ((mime = 'text/html') 
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   427
    or:[(mime = 'text/xml')
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   428
    or:[(mime = 'application/xml')]]) ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   429
        ^ #(nil ('<!!-- ' ' -->')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   430
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   431
    (mime = 'application/x-batch-script') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   432
        ^ #('rem ' (nil nil)).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   433
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   434
    (mime = 'application/x-smalltalk-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   435
        ^ #('"/' ('"' '"')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   436
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   437
    (mime = 'application/x-pascal-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   438
        ^ #(nil ('{' '}')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   439
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   440
    (mime = 'application/x-c-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   441
        ^ #(nil ('/*' '*/')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   442
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   443
    (mime = 'application/x-cpp-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   444
        ^ #('//' ('/*' '*/')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   445
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   446
    (mime = 'application/x-java-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   447
        ^ #('//' ('/*' '*/')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   448
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   449
    (mime = 'application/x-asn1-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   450
        ^ #('--' ('--' '--')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   451
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   452
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   453
    "/ st/x support files
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   454
    (suff = 'style') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   455
        ^ #(';' (nil nil)).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   456
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   457
    (suff = 'rs') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   458
        ^ #(';' (nil nil)).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   459
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   460
1489
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   461
    ^ alternativeBlockReturningCommentString value
1472
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   462
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   463
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   464
     |mime|
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   465
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   466
     mime := MIMETypes mimeTypeForFilename:'Makefile'.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   467
     MIMETypes commentStringsForMimeType:mime suffix:nil.     
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   468
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   469
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   470
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   471
     |mime|
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   472
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   473
     mime := MIMETypes mimeTypeForFilename:'Object.st'.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   474
     MIMETypes commentStringsForMimeType:mime suffix:nil.    
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   475
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   476
!
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   477
1691
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   478
defaultCommandPerMIME
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   479
    "TODO: move this to OS"
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   480
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   481
    DefaultCommandPerMIMEPerOS isNil ifTrue:[
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   482
        self initializeDefaultCommands
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   483
    ].
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   484
    OperatingSystem isUNIXlike ifTrue:[
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   485
        ^ DefaultCommandPerMIMEPerOS at:#unix
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   486
    ].
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   487
    ^ DefaultCommandPerMIMEPerOS at:#win32
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   488
!
6ee1100ba672 defaultCommandPerMIME moved from FileBrowser
Claus Gittinger <cg@exept.de>
parents: 1681
diff changeset
   489
647
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   490
defineImageType:mimeType suffix:aSuffix reader:aReaderClass
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   491
    "register an image reader."
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   492
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   493
    aSuffix notNil ifTrue:[
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   494
        self imageReaderForSuffix:aSuffix put:aReaderClass.
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   495
    ].
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   496
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   497
    mimeType notNil ifTrue:[
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   498
        self imageReaderForType:mimeType put:aReaderClass
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   499
    ].
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   500
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   501
    (aSuffix notNil and:[mimeType notNil]) ifTrue:[
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   502
        self mimeTypeForSuffix:aSuffix put:mimeType
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   503
    ].
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   504
!
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   505
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
fileSuffixToImageReaderMapping
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   507
    "return the suffix-to-imageReader mapping"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   508
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
    ^ FileSuffixToImageReaderClassMapping ? #()
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   511
    "Modified: / 1.8.1998 / 17:00:11 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   513
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   514
fontForCharset:aCharSet
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   515
    "return the font-encoding for an iso-charset"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   516
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   517
    ^ CharSetToFontMapping at:aCharSet ifAbsent:nil
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   518
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   519
    "
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   520
     MIMETypes fontForCharset:'iso2022-jp'       
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   521
     MIMETypes fontForCharset:'euc-jp'     
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   522
    "
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   523
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   524
    "Modified: / 1.8.1998 / 17:00:57 / cg"
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   525
!
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   526
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
imageFileSuffixes
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   528
    "return a collection with known file suffixes"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   529
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
    FileSuffixToImageReaderClassMapping isNil ifTrue:[^ #()].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
    ^ FileSuffixToImageReaderClassMapping keys
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   533
    "Created: / 30.6.1997 / 22:04:48 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   534
    "Modified: / 1.8.1998 / 17:01:26 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
imageReaderClasses
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   538
    "return a collection of registered image reader classes"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   539
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   540
    |setOfClasses|
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   541
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   542
    setOfClasses := IdentitySet new.
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   543
    FileSuffixToImageReaderClassMapping notNil ifTrue:[
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   544
        FileSuffixToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   545
            setOfClasses add:cls
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   546
        ].
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   547
    ].
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   548
    TypeToImageReaderClassMapping notNil ifTrue:[
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   549
        TypeToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   550
            setOfClasses add:cls
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   551
        ].
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   552
    ].
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   553
    ^ setOfClasses
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   554
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   555
    "Created: / 30.6.1997 / 22:03:42 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   556
    "Modified: / 1.8.1998 / 16:59:52 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
imageReaderForSuffix:aSuffix
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   560
    "given a file suffix, return an approriate image reader class"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   561
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
    FileSuffixToImageReaderClassMapping isNil ifTrue:[^ nil].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
    ^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   565
    "Created: / 30.6.1997 / 21:59:11 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   566
    "Modified: / 1.8.1998 / 17:01:58 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
imageReaderForSuffix:aSuffix put:aReaderClass
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   570
    "register an image reader for a file suffix"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   571
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
    FileSuffixToImageReaderClassMapping isNil ifTrue:[
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
        FileSuffixToImageReaderClassMapping := Dictionary new.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
    ].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
    FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   577
    "Created: / 30.6.1997 / 21:59:43 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   578
    "Modified: / 1.8.1998 / 17:02:14 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
imageReaderForType:mimeTypeString
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   582
    "given a mime-type, return an approriate image reader class"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   583
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
    TypeToImageReaderClassMapping isNil ifTrue:[^ nil].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
    ^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   587
    "Created: / 30.6.1997 / 21:56:01 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   588
    "Modified: / 1.8.1998 / 17:02:28 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
imageReaderForType:mimeTypeString put:aReaderClass
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   592
    "register an image reader for a mime-type"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   593
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
    TypeToImageReaderClassMapping isNil ifTrue:[
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
        TypeToImageReaderClassMapping := Dictionary new.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   596
    ].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
    TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   599
    "Created: / 30.6.1997 / 21:56:11 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   600
    "Modified: / 1.8.1998 / 17:02:40 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
1473
876caa979b7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
   603
mimeTypeForFilename:filenameArg
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   604
    "given a filename, return the mime-type or nil, if unknown"
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   605
1473
876caa979b7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
   606
    |type filename lcFilename suff|
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   607
1473
876caa979b7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
   608
    filename := filenameArg asFilename.
1474
bd86cf0c1a84 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1473
diff changeset
   609
bd86cf0c1a84 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1473
diff changeset
   610
    lcFilename := filename baseName asLowercase.
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   611
    type := FilenameToTypeMapping at:lcFilename ifAbsent:nil.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   612
    type isNil ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   613
        "/ allow for fallback ...
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   614
        type := OperatingSystem mimeTypeForFilename:lcFilename.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   615
        "/ the special value #unknown is returned as nil;
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   616
        "/ this avoids constant retry if a mimeType is not known in
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   617
        "/ the OS.
1275
cf421c7dfeec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
   618
"/        type isNil ifTrue:[
cf421c7dfeec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
   619
"/            FilenameToTypeMapping at:lcFilename put:#unknown
cf421c7dfeec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
   620
"/        ].
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   621
    ].
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   622
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   623
    type == #unknown ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   624
        type := nil.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   625
    ].
1273
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   626
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   627
    type isNil ifTrue:[
1473
876caa979b7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
   628
        suff := filename suffix.
1273
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   629
        suff size ~~ 0 ifTrue:[
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   630
            ^ self mimeTypeForSuffix:suff
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   631
        ]
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   632
    ].
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   633
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   634
    ^ type
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   635
!
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   636
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   637
mimeTypeForFilename:filename put:mimeType
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   638
    "register a mime type for a filename"
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   639
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   640
    FilenameToTypeMapping isNil ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   641
        FilenameToTypeMapping := Dictionary new
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   642
    ].
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   643
    FilenameToTypeMapping at:filename put:(MIMEType fromString:mimeType asLowercase)
1611
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   644
!
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   645
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
mimeTypeForSuffix:suffix
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   647
    "given a file suffix, return the mime-type"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   648
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   649
    |type lcSuffix|
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   650
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   651
    lcSuffix := suffix asLowercase.
1300
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   652
    lcSuffix = LastSuffix ifTrue:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   653
        type := LastType
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   654
    ] ifFalse:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   655
        type := FileSuffixToTypeMapping at:lcSuffix ifAbsent:nil.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   656
        type isNil ifTrue:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   657
            "/ allow for fallback ...
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   658
            type := OperatingSystem mimeTypeForSuffix:lcSuffix.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   659
            "/ the special value #unknown is returned as nil;
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   660
            "/ this avoids constant retry if a mimeType is not known in
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   661
            "/ the OS.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   662
    "/        type isNil ifTrue:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   663
    "/            FileSuffixToTypeMapping at:lcSuffix put:#unknown
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   664
    "/        ].
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   665
        ].
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   666
        LastSuffix := lcSuffix.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   667
        LastType := type.
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   668
    ].
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   669
    type == #unknown ifTrue:[
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   670
        type := nil
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   671
    ].
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   672
    type notNil ifTrue:[
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   673
        ^ MIMEType fromString:type
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   674
    ].
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   675
    ^ type
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
1666
2fe4fb7be12c added xml type
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   677
    "
2fe4fb7be12c added xml type
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   678
     self mimeTypeForSuffix:'xml'
2fe4fb7be12c added xml type
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   679
    "
2fe4fb7be12c added xml type
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   680
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   681
    "Created: / 30.6.1997 / 21:55:51 / cg"
1300
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   682
    "Modified: / 23.12.1999 / 22:30:55 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   684
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   685
mimeTypeForSuffix:suffix put:mimeType
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   686
    "register a mime type for a file suffix"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   687
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   688
    FileSuffixToTypeMapping isNil ifTrue:[
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
        FileSuffixToTypeMapping := Dictionary new
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
    ].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   691
    FileSuffixToTypeMapping at:suffix put:mimeType asLowercase
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   692
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   693
    "Created: / 30.6.1997 / 21:56:20 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   694
    "Modified: / 1.8.1998 / 17:03:18 / cg"
1593
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   695
!
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   696
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   697
mimeTypeForSuffixMapping
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   698
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   699
    ^ FileSuffixToTypeMapping
1611
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   700
!
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   701
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   702
mimeTypeOfContents:filename
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   703
    "given a filename, scan the contents, return the mime-type or nil, if unknown"
5804b7d63ee8 checkin from browser
penk
parents: 1610
diff changeset
   704
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   705
    |typeString|
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   706
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   707
    typeString := filename mimeTypeOfContents.
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   708
    typeString isNil ifTrue:[^ nil].
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   709
    ^ MIMEType fromString:typeString.
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   710
! !
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   711
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   712
!MIMETypes::MIMEType class methodsFor:'documentation'!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   713
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   714
documentation
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   715
"
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   716
    like a string, but knows that it represents a mimeType
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   717
"
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   718
! !
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   719
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   720
!MIMETypes::MIMEType class methodsFor:'initialization'!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   721
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   722
initialize
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   723
    CachedTypes := CacheDictionary new:30.
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   724
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   725
    "
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   726
     self initialize
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   727
    "
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   728
! !
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   729
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   730
!MIMETypes::MIMEType class methodsFor:'instance creation'!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   731
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   732
fromString:aString
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   733
    |cachedType newType|
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   734
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   735
    aString class == self ifTrue:[^ aString].
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   736
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   737
    cachedType := CachedTypes at:aString ifAbsent:nil.
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   738
    cachedType notNil ifTrue:[^ cachedType].
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   739
    newType := aString copy changeClassTo:self.
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   740
    CachedTypes at:aString put:newType.
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   741
    ^ newType
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   742
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   743
    "
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   744
     self fromString:'text/html'
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   745
    "
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   746
! !
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   747
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   748
!MIMETypes::MIMEType methodsFor:'queries'!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   749
1693
4055b361abe9 isArchiv -> isArchive
Claus Gittinger <cg@exept.de>
parents: 1691
diff changeset
   750
isArchive
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   751
    |archivTypes|
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   752
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   753
    archivTypes := MIMETypes applicationComprAndArchiveTypeList.
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   754
    archivTypes pairWiseDo:[: ext : type |
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   755
        self = type ifTrue:[ ^ true].
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   756
    ].
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   757
    ^ false
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   758
!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   759
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   760
isHtml
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   761
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   762
    ^ (self = 'text/html')
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   763
!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   764
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   765
isImage
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   766
1693
4055b361abe9 isArchiv -> isArchive
Claus Gittinger <cg@exept.de>
parents: 1691
diff changeset
   767
    ^ (self startsWith:'image/')
1612
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   768
!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   769
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   770
isPdf
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   771
    ^ (self = 'application/pdf')
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   772
!
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   773
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   774
isSmalltalkSource
4c7893f943a8 *** empty log message ***
penk
parents: 1611
diff changeset
   775
    ^ (self = 'application/x-smalltalk-source')
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
! !
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
!MIMETypes class methodsFor:'documentation'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   779
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
version
1693
4055b361abe9 isArchiv -> isArchive
Claus Gittinger <cg@exept.de>
parents: 1691
diff changeset
   781
    ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.49 2003-02-03 10:01:30 cg Exp $'
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
! !
1666
2fe4fb7be12c added xml type
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   783
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
MIMETypes initialize!
1666
2fe4fb7be12c added xml type
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   785
MIMETypes::MIMEType initialize!