--- a/Win32OperatingSystem.st Fri Mar 03 13:22:22 2006 +0100
+++ b/Win32OperatingSystem.st Fri Mar 03 14:29:53 2006 +0100
@@ -8917,19 +8917,65 @@
"
!
+commandTemplateToOpenMimeType:mimeType
+ "given a mimeType, retrieve the command-template of an application for opening the document.
+ Return nil, if no such application is known.
+ Do nor use directly - this is a helper for MIMEType"
+
+ ^ self commandTemplateToOpenSuffix:(self extensionForMimeType:mimeType)
+
+ "
+ Win32OperatingSystem::RegistryEntry commandTemplateToOpenMimeType:'application/pdf'
+ Win32OperatingSystem::RegistryEntry commandTemplateToOpenMimeType:'audio/mp3'
+ Win32OperatingSystem::RegistryEntry commandTemplateToOpenMimeType:'video/avi'
+ Win32OperatingSystem::RegistryEntry commandTemplateToOpenMimeType:'application/x-zip-compressed'
+ "
+!
+
+commandTemplateToOpenSuffix:suffixArg
+ "given a suffix, retrieve the command template for an application to print the document.
+ Do nor use directly - this is a helper for MIMEType"
+
+ ^ self shellCommandTemplateFor:'open' onSuffix:suffixArg
+
+ "
+ self commandTemplateToOpenSuffix:'pdf'
+ self commandTemplateToOpenSuffix:'zip'
+ "
+!
+
+commandTemplateToPrintMimeType:mimeType
+ "given a mimeType, retrieve the command-template of an application for printing the document.
+ Return nil, if no such application is known.
+ Do nor use directly - this is a helper for MIMEType"
+
+ ^ self commandTemplateToPrintSuffix:(self extensionForMimeType:mimeType)
+
+ "
+ Win32OperatingSystem::RegistryEntry commandTemplateToPrintMimeType:'application/pdf'
+ Win32OperatingSystem::RegistryEntry commandTemplateToPrintMimeType:'audio/mp3'
+ "
+!
+
+commandTemplateToPrintSuffix:suffixArg
+ "given a suffix, retrieve the command template for an application to open the document.
+ Do nor use directly - this is a helper for MIMEType"
+
+ ^ self shellCommandTemplateFor:'print' onSuffix:suffixArg
+
+ "
+ self commandTemplateToPrintSuffix:'pdf'
+ self commandTemplateToPrintSuffix:'zip'
+ "
+!
+
executableForMimeType:mimeType
"given a mimeType, retrieve the path to an application from the registry"
- |k suffix|
-
- k := self key:'HKEY_CLASSES_ROOT\MIME\Database\Content Type\',mimeType.
- k notNil ifTrue:[
- suffix := k valueNamed:'extension'.
- suffix notNil ifTrue:[
- ^ self executableForSuffix:suffix
- ].
- ].
- ^ nil
+ <resource: #obsolete>
+
+ self obsoleteMethodWarning:'use commandTemplateToOpenMimeType:'.
+ ^ self commandTemplateToOpenMimeType:mimeType
"
Win32OperatingSystem::RegistryEntry executableForMimeType:'application/pdf'
@@ -8942,33 +8988,56 @@
executableForSuffix:suffixArg
"given a suffix, retrieve the path to an application from the registry"
+ <resource: #obsolete>
+
+ self obsoleteMethodWarning:'use commandTemplateToOpenSuffix:'.
+ ^ self commandTemplateToOpenSuffix:suffixArg.
+
+ "
+ self executableForSuffix:'pdf'
+ self executableForSuffix:'zip'
+ "
+!
+
+extensionForMimeType:mimeType
+ "HELPER: given a mimeType, retrieve the file extension or nil (if unknown)"
+
+ |k suffix|
+
+ k := self key:'HKEY_CLASSES_ROOT\MIME\Database\Content Type\',mimeType.
+ k notNil ifTrue:[
+ suffix := k valueNamed:'extension'.
+ ].
+ ^ suffix
+!
+
+shellCommandTemplateFor:operation onSuffix:suffixArg
+ "HELPER: given a suffix, and an operation, retrieve a command template for an application"
+
|k fkey cmd suffix|
suffix := suffixArg.
+ suffix isNil ifTrue:[^ nil].
+
(suffix startsWith:'.') ifTrue:[
- suffix := suffix copyFrom:2
+ suffix := suffix copyFrom:2
].
k := self key:'HKEY_CLASSES_ROOT\.',suffix.
k notNil ifTrue:[
- fkey := (k valueNamed:'').
+ fkey := (k valueNamed:'').
].
fkey isNil ifTrue:[
- fkey := suffix,'_auto_file'
+ fkey := suffix,'_auto_file'
].
fkey notEmptyOrNil ifTrue:[
- k := Win32OperatingSystem::RegistryEntry key:('HKEY_CLASSES_ROOT\' , fkey , '\shell\open\command').
- k notNil ifTrue:[
- cmd := k valueNamed:''
- ].
+ k := Win32OperatingSystem::RegistryEntry key:('HKEY_CLASSES_ROOT\' , fkey , '\shell\',operation,'\command').
+ k notNil ifTrue:[
+ cmd := k valueNamed:''
+ ].
].
^ cmd
-
- "
- self executableForSuffix:'pdf'
- self executableForSuffix:'zip'
- "
! !
!Win32OperatingSystem::RegistryEntry class methodsFor:'registry access'!
@@ -11119,7 +11188,7 @@
!Win32OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.223 2006-03-03 12:03:15 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.224 2006-03-03 13:29:53 cg Exp $'
! !
Win32OperatingSystem initialize!