MIMETypes.st
author penk
Tue, 10 Sep 2002 15:50:49 +0200
changeset 1604 0c678133dc4b
parent 1593 4bf2544435a9
child 1606 158c10a36736
permissions -rw-r--r--
new class for mimeType instances
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 
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	      All Rights Reserved
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
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	instanceVariableNames:''
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	classVariableNames:'TypeToImageReaderClassMapping FileSuffixToTypeMapping
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
    20
		FilenameToTypeMapping FileSuffixToImageReaderClassMapping
1300
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
    21
		CharSetToFontMapping LastSuffix LastType'
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	poolDictionaries:''
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
	category:'System-Documentation'
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
!MIMETypes class methodsFor:'documentation'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
copyright
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 COPYRIGHT (c) 1997 by eXept Software AG 
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
	      All Rights Reserved
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 This software is furnished under a license and may be used
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 only in accordance with the terms of that license and with the
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 inclusion of the above copyright notice.   This software may not
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 be provided or otherwise made available to, or used by, any
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 other person.  No title to or ownership of the software is
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
 hereby transferred.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
documentation
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
"
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    just a place to keep MIME information
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    (avoid spreading things at many places)
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    49
    MIMETypes is abstract and functional.
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    50
    Actually, in some OperatingSystems, this information may
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    51
    be found in some config files (or registries).
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    52
    Therefore, this class may have to be extended to support this
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    53
    and fetch the information from there eventually.
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    54
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    [author:]
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
        Claus Gittinger
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
"
1311
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    58
!
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    59
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    60
knownTypes
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    61
"
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    62
    simply a reminder for me ...
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    63
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    64
    application         mime                            file extentsions
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    65
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    66
        powerpoint      application/ms-powerpoint       .pot, .ppz, .ppt, .pps, 
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    67
                        application/mspowerpoint        
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    68
                        application/vnd.ms-powerpoint   
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    69
                        application/x-mspowerpoint
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    70
1312
Claus Gittinger <cg@exept.de>
parents: 1311
diff changeset
    71
        shockwave       application/x-shockwave-flash   .swf     
1311
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    72
1312
Claus Gittinger <cg@exept.de>
parents: 1311
diff changeset
    73
        futuresplash    application/futuresplash        .spl
1311
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
    74
"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
! !
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
!MIMETypes class methodsFor:'initialization'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    79
applicationComprAndArchiveTypeList
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    80
    "/ compressors and archivers
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    81
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    82
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    83
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    84
        'tar'                   'application/x-tar'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    85
        'gtar'                  'application/x-gtar'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    86
        'tgz'                   'application/x-tar-compressed'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    87
        'zip'                   'application/x-zip-compressed'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    88
        ('gz' 'z')              'application/x-gzip-compressed'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    89
        'cpio'                  'application/x-cpio'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    90
        'shar'                  'application/x-shar'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    91
        'jar'                   'application/java-archive'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    92
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    93
!
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
    94
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    95
applicationProgLangTypeList
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    96
    "/ applications for programm languages
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
    97
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    98
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
    99
        ('st' 'cls')                 'application/x-smalltalk-source'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   100
        'sif'                        'application/x-smalltalk-source-sif'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   101
        'c'                          'application/x-c-source'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   102
        ('cc' 'cpp')                 'application/x-cpp-source'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   103
        ('js' 'mocha')               'application/x-javascript'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   104
        ('java' 'jav')               'application/x-java-source'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   105
        'sh'                         'application/x-sh'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   106
        'csh'                        'application/x-csh'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   107
        'tcl'                        'application/x-tcl'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   108
        'pl'                         'application/x-perl'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   109
        'mak'                        'application/x-make'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   110
        'bat'                        'application/x-batch-script'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   111
        ('asn1' 'x409' 'gdmo' 'gdm') 'application/x-asn1-source'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   112
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   113
!
1561
942de18a3e3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   114
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   115
applicationTextTypeList
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   116
    "/ text applications
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   117
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   118
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   119
        ('ps' 'eps')                 'application/postscript'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   120
        'pdf'                        'application/pdf'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   121
        'rtf'                        'application/rtf'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   122
        'doc'                        'application/winword'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   123
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   124
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   125
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   126
applicationTypeList
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   127
    "/ applications
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   128
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   129
    |types|                            
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   130
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   131
    types := Array new.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   132
    types addAll:self applicationProgLangTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   133
    types addAll:self applicationTextTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   134
    types addAll:self applicationComprAndArchiveTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   135
    ^ types
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   136
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   137
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   138
audioTypeList
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   139
    "/ audio formats ...
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   140
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   141
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   142
        ('ra' 'ram')            'audio/x-pn-realaudio'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   143
        ('mpa' 'mpega')         'audio/x-mpeg'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   144
        ('mp3' )                'audio/x-mp3'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   145
        'wav'                   'audio/x-wav'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   146
        ('aif' 'aiff' 'aifc')   'audio/x-aiff'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   147
        ('au' 'snd')            'audio/basic'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   148
        ('swf')                 'audio/x-shockwave-flash'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   149
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   150
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   151
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   152
imageTypeList
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   153
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   154
    ^ #(
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   155
        "/ image formats ...
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   156
1216
26fe79e724d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1188
diff changeset
   157
        ('jpg' 'jpeg')  'image/jpeg'
1188
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   158
        'gif'           'image/gif'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   159
        ('tif' 'tiff')  'image/tiff'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   160
        'xbm'           'image/x-xbitmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   161
        'xpm'           'image/x-xpixmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   162
        'png'           'image/x-png'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   163
        'pcd'           'image/x-photo-cd'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   164
        'bmp'           'image/x-MS-bmp'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   165
        'rgb'           'image/x-rgb'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   166
        'ppm'           'image/x-portable-pixmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   167
        'pgm'           'image/x-portable-graymap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   168
        'pbm'           'image/x-portable-bitmap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   169
        'pnm'           'image/x-portable-anymap'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   170
        'xwd'           'image/x-xwindowdump'
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   171
        'ras'           'image/x-cmu-raster'
1216
26fe79e724d0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1188
diff changeset
   172
        'tga'           'image/x-targa'
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   173
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   174
    ) 
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   175
!
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   176
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   177
initialize
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   178
    "initialize wellKnown facts"
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   179
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   180
    |typeToImageReaderClassMapping fileSuffixToTypeMapping
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   181
     fileSuffixToImageReaderClassMapping charSetToFontMapping types|
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   182
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   183
    LastSuffix := LastType := nil.
1411
d72f09a436d3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1410
diff changeset
   184
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   185
    (fileSuffixToImageReaderClassMapping := FileSuffixToImageReaderClassMapping) isNil ifTrue:[
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   186
        FileSuffixToImageReaderClassMapping := fileSuffixToImageReaderClassMapping := Dictionary new
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   187
    ].
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   188
    (typeToImageReaderClassMapping := TypeToImageReaderClassMapping) isNil ifTrue:[
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   189
        TypeToImageReaderClassMapping := typeToImageReaderClassMapping := Dictionary new
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   190
    ].
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   191
    (fileSuffixToTypeMapping := FileSuffixToTypeMapping) isNil ifTrue:[
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   192
        FileSuffixToTypeMapping := fileSuffixToTypeMapping := Dictionary new
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   193
    ].
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   194
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   195
    "/ 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
   196
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   197
    types := Array new.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   198
    types addAll:self textTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   199
    types addAll:self imageTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   200
    types addAll:self videoTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   201
    types addAll:self audioTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   202
    types addAll:self applicationTypeList.
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   203
    types pairWiseDo:[:suff :type|
1188
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   204
        suff isArray ifTrue:[
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   205
            suff do:[:s | fileSuffixToTypeMapping at:s put:type]
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   206
        ] ifFalse:[
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   207
            fileSuffixToTypeMapping at:suff put:type
bea6424548e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1180
diff changeset
   208
        ]
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   209
    ].
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   210
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   211
    FilenameToTypeMapping := Dictionary new.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   212
    #(
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   213
        ('makefile' 'make.proto')  'application/x-make'
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   214
    ) pairWiseDo:[:nm :type|
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   215
        nm isArray ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   216
            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
   217
        ] ifFalse:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   218
            FilenameToTypeMapping at:nm put:type
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   219
        ]
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   220
    ].
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   221
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   222
    "/ 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
   223
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   224
    typeToImageReaderClassMapping at:'image/jpeg' put:JPEGReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   225
    typeToImageReaderClassMapping at:'image/gif'  put:GIFReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   226
    typeToImageReaderClassMapping at:'image/tiff' put:TIFFReader.
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   227
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   228
    "/ setup suffix to image reader class mapping ...
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   229
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   230
    fileSuffixToImageReaderClassMapping at:'jpg'  put:JPEGReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   231
    fileSuffixToImageReaderClassMapping at:'gif'  put:GIFReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   232
    fileSuffixToImageReaderClassMapping at:'tif'  put:TIFFReader.
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   233
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   234
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   235
    "/ character sets (not really mime stuff, but also placed here)
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   236
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   237
    (charSetToFontMapping := CharSetToFontMapping) isNil ifTrue:[
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   238
        CharSetToFontMapping := charSetToFontMapping := Dictionary new
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   239
    ].
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   240
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   241
    #(
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   242
        'iso2022-jp'   'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   243
        'x-iso2022-jp' 'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   244
        'x-euc-jp'     'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   245
        'x-shift-jis'  'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   246
        'x-sjis'       'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   247
        'x-jis7'       'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   248
        'jis7'         'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   249
        'euc'          'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   250
        'euc-jp'       'jis*0208*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   251
        'sjis'         'jis*0208*'
713
548898fdd1dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 663
diff changeset
   252
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   253
        'big5'         'big5*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   254
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   255
        'gb2312'       'gb*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   256
        'hz-gb-2312'   'gb*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   257
        'x-gbk'        'gb*'
1022
bd0b1d58acba more types
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   258
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   259
        'iso2022-kr'   'ksc*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   260
        'x-euc-kr'     'ksc*'
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   261
    ) pairWiseDo:[:charSet :fontEncoding|
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   262
         charSetToFontMapping at:charSet put:fontEncoding
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   263
    ].
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    "
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
     self initialize
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
    "
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
1269
4362ec6dd5c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1221
diff changeset
   269
    "Modified: / 19.11.1999 / 15:01:53 / cg"
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   270
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   271
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   272
textTypeList
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   273
   "/ misc text ...
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   274
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   275
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   276
        ('htm' 'html')          'text/html'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   277
        ('shtml')               'text/html'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   278
        ('txt' 'text')          'text/plain'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   279
    )
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   280
!
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   281
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   282
videoTypeList
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   283
    "/ video formats ...
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   284
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   285
    ^ #(
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   286
        'movie'                            'video/x-sgi-movie'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   287
        'avi'                              'video/x-msvideo'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   288
        ('qt' 'mov' 'moov')                'video/quicktime'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   289
        ('mpv2' 'mp2v' 'mp2' 'mpeg2')      'video/x-mpeg2'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   290
        ('mpv' 'mpegv' 'mpg' 'mpeg' 'mpe') 'video/mpeg'
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   291
    )
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
! !
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
!MIMETypes class methodsFor:'accessing'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
1472
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   296
commentStringsForFilename:aFilename
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   297
    "return a useful comment definition; heuristics for now.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   298
     The returned value is an array of 2 elements;
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   299
     the first is the end-of-line comment string (or nil);
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   300
     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
   301
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   302
     |mime|
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   303
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   304
     mime := MIMETypes mimeTypeForFilename:aFilename.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   305
     ^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix)
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   306
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   307
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   308
     MIMETypes commentStringsForFilename:'Makefile'.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   309
     MIMETypes commentStringsForFilename:'Object.st'. 
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   310
     MIMETypes commentStringsForFilename:'Foo.java'. 
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   311
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   312
!
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   313
1489
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   314
commentStringsForFilename:aFilename ifUnknown:alternativeBlockReturningCommentString
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   315
    "return a useful comment definition; heuristics for now.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   316
     The returned value is an array of 2 elements;
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   317
     the first is the end-of-line comment string (or nil);
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   318
     the second an array of opening/closing delimiters (or an array of nils)"
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   319
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   320
     |mime|
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   321
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   322
     mime := MIMETypes mimeTypeForFilename:aFilename.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   323
     ^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix) ifUnknown:alternativeBlockReturningCommentString
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   324
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   325
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   326
     MIMETypes commentStringsForFilename:'Makefile'.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   327
     MIMETypes commentStringsForFilename:'Object.st'. 
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   328
     MIMETypes commentStringsForFilename:'Foo.java'. 
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   329
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   330
!
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   331
1472
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   332
commentStringsForMimeType:mime suffix:suff
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   333
    "return a useful comment definition; heuristics for now.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   334
     The returned value is an array of 2 elements;
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   335
     the first is the end-of-line comment string (or nil);
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   336
     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
   337
1489
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   338
    ^ self
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   339
        commentStringsForMimeType:mime suffix:suff 
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   340
        ifUnknown: #(';' (nil nil))  
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   341
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   342
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   343
     |mime|
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   344
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   345
     mime := MIMETypes mimeTypeForFilename:'Makefile'.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   346
     MIMETypes commentStringsForMimeType:mime suffix:nil.     
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   347
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   348
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   349
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   350
     |mime|
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   351
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   352
     mime := MIMETypes mimeTypeForFilename:'Object.st'.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   353
     MIMETypes commentStringsForMimeType:mime suffix:nil.    
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   354
    "
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   355
!
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   356
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   357
commentStringsForMimeType:mime suffix:suff ifUnknown:alternativeBlockReturningCommentString
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   358
    "return a useful comment definition; heuristics for now.
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   359
     The returned value is an array of 2 elements;
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   360
     the first is the end-of-line comment string (or nil);
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   361
     the second an array of opening/closing delimiters (or an array of nils)"
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   362
1472
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   363
    (mime = 'application/x-make') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   364
        "/ makefile
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   365
        ^ #('#' (nil nil)).
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
    (mime = 'application/x-sh') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   368
        "/ shell script
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   369
        ^ #('#' (nil nil)).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   370
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   371
    ((mime = 'text/html') 
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   372
    or:[(mime = 'text/xml')
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   373
    or:[(mime = 'application/xml')]]) ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   374
        ^ #(nil ('<!!-- ' ' -->')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   375
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   376
    (mime = 'application/x-batch-script') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   377
        ^ #('rem ' (nil nil)).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   378
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   379
    (mime = 'application/x-smalltalk-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   380
        ^ #('"/' ('"' '"')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   381
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   382
    (mime = 'application/x-pascal-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   383
        ^ #(nil ('{' '}')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   384
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   385
    (mime = 'application/x-c-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   386
        ^ #(nil ('/*' '*/')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   387
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   388
    (mime = 'application/x-cpp-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   389
        ^ #('//' ('/*' '*/')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   390
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   391
    (mime = 'application/x-java-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   392
        ^ #('//' ('/*' '*/')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   393
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   394
    (mime = 'application/x-asn1-source') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   395
        ^ #('--' ('--' '--')).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   396
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   397
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   398
    "/ st/x support files
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   399
    (suff = 'style') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   400
        ^ #(';' (nil nil)).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   401
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   402
    (suff = 'rs') ifTrue:[
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   403
        ^ #(';' (nil nil)).
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   404
    ].
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   405
1489
9e339e123bfa commentStrings: added ifUnknown-argument
tm
parents: 1475
diff changeset
   406
    ^ alternativeBlockReturningCommentString value
1472
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   407
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   408
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   409
     |mime|
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   410
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   411
     mime := MIMETypes mimeTypeForFilename:'Makefile'.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   412
     MIMETypes commentStringsForMimeType:mime suffix:nil.     
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   413
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   414
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   415
    "
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   416
     |mime|
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   417
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   418
     mime := MIMETypes mimeTypeForFilename:'Object.st'.
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   419
     MIMETypes commentStringsForMimeType:mime suffix:nil.    
bef5798d367d comment strings
Claus Gittinger <cg@exept.de>
parents: 1411
diff changeset
   420
    "
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
647
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   423
defineImageType:mimeType suffix:aSuffix reader:aReaderClass
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   424
    "register an image reader."
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   425
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   426
    aSuffix notNil ifTrue:[
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   427
        self imageReaderForSuffix:aSuffix put:aReaderClass.
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   428
    ].
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   429
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   430
    mimeType notNil ifTrue:[
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   431
        self imageReaderForType:mimeType put:aReaderClass
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   432
    ].
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   433
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   434
    (aSuffix notNil and:[mimeType notNil]) ifTrue:[
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   435
        self mimeTypeForSuffix:aSuffix put:mimeType
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   436
    ].
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   437
!
6f26c76aa0c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 646
diff changeset
   438
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
fileSuffixToImageReaderMapping
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   440
    "return the suffix-to-imageReader mapping"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   441
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
    ^ FileSuffixToImageReaderClassMapping ? #()
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   444
    "Modified: / 1.8.1998 / 17:00:11 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   447
fontForCharset:aCharSet
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   448
    "return the font-encoding for an iso-charset"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   449
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   450
    ^ CharSetToFontMapping at:aCharSet ifAbsent:nil
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   451
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   452
    "
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   453
     MIMETypes fontForCharset:'iso2022-jp'       
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   454
     MIMETypes fontForCharset:'euc-jp'     
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   455
    "
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   456
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   457
    "Modified: / 1.8.1998 / 17:00:57 / cg"
648
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   458
!
ed834e41dcd4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   459
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
imageFileSuffixes
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   461
    "return a collection with known file suffixes"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   462
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
    FileSuffixToImageReaderClassMapping isNil ifTrue:[^ #()].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
    ^ FileSuffixToImageReaderClassMapping keys
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   466
    "Created: / 30.6.1997 / 22:04:48 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   467
    "Modified: / 1.8.1998 / 17:01:26 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
imageReaderClasses
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   471
    "return a collection of registered image reader classes"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   472
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   473
    |setOfClasses|
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   474
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   475
    setOfClasses := IdentitySet new.
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   476
    FileSuffixToImageReaderClassMapping notNil ifTrue:[
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   477
        FileSuffixToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   478
            setOfClasses add:cls
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   479
        ].
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   480
    ].
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   481
    TypeToImageReaderClassMapping notNil ifTrue:[
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   482
        TypeToImageReaderClassMapping keysAndValuesDo:[:suff :cls |
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   483
            setOfClasses add:cls
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   484
        ].
645
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   485
    ].
97e83ab4d246 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 643
diff changeset
   486
    ^ setOfClasses
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   488
    "Created: / 30.6.1997 / 22:03:42 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   489
    "Modified: / 1.8.1998 / 16:59:52 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
imageReaderForSuffix:aSuffix
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   493
    "given a file suffix, return an approriate image reader class"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   494
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
    FileSuffixToImageReaderClassMapping isNil ifTrue:[^ nil].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
    ^ FileSuffixToImageReaderClassMapping at:aSuffix asLowercase ifAbsent:nil
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   498
    "Created: / 30.6.1997 / 21:59:11 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   499
    "Modified: / 1.8.1998 / 17:01:58 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
imageReaderForSuffix:aSuffix put:aReaderClass
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   503
    "register an image reader for a file suffix"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   504
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   505
    FileSuffixToImageReaderClassMapping isNil ifTrue:[
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
        FileSuffixToImageReaderClassMapping := Dictionary new.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
    ].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
    FileSuffixToImageReaderClassMapping at:aSuffix asLowercase put:aReaderClass
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   510
    "Created: / 30.6.1997 / 21:59:43 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   511
    "Modified: / 1.8.1998 / 17:02:14 / 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
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
imageReaderForType:mimeTypeString
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   515
    "given a mime-type, return an approriate image reader class"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   516
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
    TypeToImageReaderClassMapping isNil ifTrue:[^ nil].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
    ^ TypeToImageReaderClassMapping at:mimeTypeString asLowercase ifAbsent:nil
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   520
    "Created: / 30.6.1997 / 21:56:01 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   521
    "Modified: / 1.8.1998 / 17:02:28 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
imageReaderForType:mimeTypeString put:aReaderClass
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   525
    "register an image reader for a mime-type"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   526
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
    TypeToImageReaderClassMapping isNil ifTrue:[
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
        TypeToImageReaderClassMapping := Dictionary new.
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
    ].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
    TypeToImageReaderClassMapping at:mimeTypeString asLowercase put:aReaderClass
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   532
    "Created: / 30.6.1997 / 21:56:11 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   533
    "Modified: / 1.8.1998 / 17:02:40 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
1473
876caa979b7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
   536
mimeTypeForFilename:filenameArg
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   537
    "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
   538
1473
876caa979b7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
   539
    |type filename lcFilename suff|
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   540
1473
876caa979b7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
   541
    filename := filenameArg asFilename.
1474
bd86cf0c1a84 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1473
diff changeset
   542
bd86cf0c1a84 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1473
diff changeset
   543
    lcFilename := filename baseName asLowercase.
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   544
    type := FilenameToTypeMapping at:lcFilename ifAbsent:nil.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   545
    type isNil ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   546
        "/ allow for fallback ...
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   547
        type := OperatingSystem mimeTypeForFilename:lcFilename.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   548
        "/ 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
   549
        "/ 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
   550
        "/ the OS.
1275
cf421c7dfeec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
   551
"/        type isNil ifTrue:[
cf421c7dfeec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
   552
"/            FilenameToTypeMapping at:lcFilename put:#unknown
cf421c7dfeec *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1274
diff changeset
   553
"/        ].
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   554
    ].
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   555
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   556
    type == #unknown ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   557
        type := nil.
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   558
    ].
1273
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   559
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   560
    type isNil ifTrue:[
1473
876caa979b7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1472
diff changeset
   561
        suff := filename suffix.
1273
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   562
        suff size ~~ 0 ifTrue:[
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   563
            ^ self mimeTypeForSuffix:suff
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   564
        ]
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   565
    ].
7a52d4bcdb10 filenames mime query falls back to suffix query.
Claus Gittinger <cg@exept.de>
parents: 1272
diff changeset
   566
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   567
    ^ type
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   568
!
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   569
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   570
mimeTypeForFilename:filename put:mimeType
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   571
    "register a mime type for a filename"
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   572
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   573
    FilenameToTypeMapping isNil ifTrue:[
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   574
        FilenameToTypeMapping := Dictionary new
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   575
    ].
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   576
    FilenameToTypeMapping at:filename put:mimeType asLowercase
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   577
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   578
!
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   579
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
mimeTypeForSuffix:suffix
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   581
    "given a file suffix, return the mime-type"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   582
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   583
    |type lcSuffix|
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   584
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   585
    lcSuffix := suffix asLowercase.
1300
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   586
    lcSuffix = LastSuffix ifTrue:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   587
        type := LastType
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   588
    ] ifFalse:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   589
        type := FileSuffixToTypeMapping at:lcSuffix ifAbsent:nil.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   590
        type isNil ifTrue:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   591
            "/ allow for fallback ...
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   592
            type := OperatingSystem mimeTypeForSuffix:lcSuffix.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   593
            "/ the special value #unknown is returned as nil;
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   594
            "/ this avoids constant retry if a mimeType is not known in
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   595
            "/ the OS.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   596
    "/        type isNil ifTrue:[
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   597
    "/            FileSuffixToTypeMapping at:lcSuffix put:#unknown
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   598
    "/        ].
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   599
        ].
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   600
        LastSuffix := lcSuffix.
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   601
        LastType := type.
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   602
    ].
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   603
    type == #unknown ifTrue:[
1272
91ba4078b690 additional mime table for filenames without suffix.
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   604
        type := nil
1180
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   605
    ].
c3309b30d14f code cleanup & added mimeType aquire fallBack via OS
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   606
    ^ type
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   608
    "Created: / 30.6.1997 / 21:55:51 / cg"
1300
09ff1f28470c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
   609
    "Modified: / 23.12.1999 / 22:30:55 / cg"
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
mimeTypeForSuffix:suffix put:mimeType
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   613
    "register a mime type for a file suffix"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   614
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
    FileSuffixToTypeMapping isNil ifTrue:[
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
        FileSuffixToTypeMapping := Dictionary new
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
    ].
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
    FileSuffixToTypeMapping at:suffix put:mimeType asLowercase
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
1021
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   620
    "Created: / 30.6.1997 / 21:56:20 / cg"
004c324dc31a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   621
    "Modified: / 1.8.1998 / 17:03:18 / cg"
1593
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   622
!
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   623
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   624
mimeTypeForSuffixMapping
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   625
4bf2544435a9 add class getter method for FileSuffixToTypemapping
penk
parents: 1561
diff changeset
   626
    ^ FileSuffixToTypeMapping
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
! !
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
!MIMETypes class methodsFor:'documentation'!
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
version
1604
0c678133dc4b new class for mimeType instances
penk
parents: 1593
diff changeset
   632
    ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.37 2002-09-10 13:50:49 penk Exp $'
643
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
! !
f3bd12eb1008 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
MIMETypes initialize!