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